2 * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3 * Copyright (C) $$Year-Rel$$ The Jalview Authors
5 * This file is part of Jalview.
7 * Jalview is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation, either version 3
10 * of the License, or (at your option) any later version.
12 * Jalview is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty
14 * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19 * The Jalview Authors are detailed in the 'AUTHORS' file.
21 package jalview.jbgui;
23 import java.awt.BorderLayout;
24 import java.awt.Color;
25 import java.awt.Component;
26 import java.awt.Dimension;
27 import java.awt.FlowLayout;
29 import java.awt.GridBagConstraints;
30 import java.awt.GridBagLayout;
31 import java.awt.GridLayout;
32 import java.awt.Insets;
33 import java.awt.Rectangle;
34 import java.awt.event.ActionEvent;
35 import java.awt.event.ActionListener;
36 import java.awt.event.FocusEvent;
37 import java.awt.event.KeyEvent;
38 import java.awt.event.MouseAdapter;
39 import java.awt.event.MouseEvent;
41 import javax.swing.BorderFactory;
42 import javax.swing.DefaultListCellRenderer;
43 import javax.swing.JButton;
44 import javax.swing.JCheckBox;
45 import javax.swing.JComboBox;
46 import javax.swing.JFileChooser;
47 import javax.swing.JLabel;
48 import javax.swing.JList;
49 import javax.swing.JPanel;
50 import javax.swing.JScrollPane;
51 import javax.swing.JTabbedPane;
52 import javax.swing.JTextField;
53 import javax.swing.ListSelectionModel;
54 import javax.swing.SwingConstants;
55 import javax.swing.border.Border;
56 import javax.swing.border.EmptyBorder;
57 import javax.swing.border.EtchedBorder;
58 import javax.swing.border.TitledBorder;
59 import javax.swing.event.ChangeEvent;
60 import javax.swing.event.ChangeListener;
61 import javax.swing.event.ListSelectionEvent;
62 import javax.swing.event.ListSelectionListener;
64 import jalview.gui.JvSwingUtils;
65 import jalview.gui.StructureViewer.ViewerType;
66 import jalview.jbgui.PDBDocFieldPreferences.PreferenceSource;
67 import jalview.util.MessageManager;
70 * Base class for the Preferences panel.
75 public class GPreferences extends JPanel
77 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
79 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
80 .getLabelFont(false, true);
83 * Visual tab components
85 protected JCheckBox fullScreen = new JCheckBox();
87 protected JCheckBox openoverv = new JCheckBox();
89 protected JCheckBox seqLimit = new JCheckBox();
91 protected JCheckBox rightAlign = new JCheckBox();
93 protected JComboBox<String> fontSizeCB = new JComboBox<String>();
95 protected JComboBox<String> fontStyleCB = new JComboBox<String>();
97 protected JComboBox<String> fontNameCB = new JComboBox<String>();
99 protected JCheckBox showUnconserved = new JCheckBox();
101 protected JCheckBox idItalics = new JCheckBox();
103 protected JCheckBox smoothFont = new JCheckBox();
105 protected JCheckBox scaleProteinToCdna = new JCheckBox();
107 protected JComboBox<String> gapSymbolCB = new JComboBox<String>();
109 protected JCheckBox wrap = new JCheckBox();
111 protected JComboBox<String> sortby = new JComboBox<String>();
113 protected JComboBox<String> sortAnnBy = new JComboBox<String>();
115 protected JComboBox<String> sortAutocalc = new JComboBox<String>();
117 protected JCheckBox startupCheckbox = new JCheckBox();
119 protected JTextField startupFileTextfield = new JTextField();
121 // below are in the 'second column'
122 protected JCheckBox annotations = new JCheckBox();
124 protected JCheckBox quality = new JCheckBox();
126 protected JCheckBox conservation = new JCheckBox();
128 protected JCheckBox identity = new JCheckBox();
130 protected JCheckBox showGroupConsensus = new JCheckBox();
132 protected JCheckBox showGroupConservation = new JCheckBox();
134 protected JCheckBox showConsensHistogram = new JCheckBox();
136 protected JCheckBox showConsensLogo = new JCheckBox();
138 protected JCheckBox showDbRefTooltip = new JCheckBox();
140 protected JCheckBox showNpTooltip = new JCheckBox();
143 * Structure tab and components
145 protected JPanel structureTab;
147 protected JCheckBox structFromPdb = new JCheckBox();
149 protected JCheckBox useRnaView = new JCheckBox();
151 protected JCheckBox addSecondaryStructure = new JCheckBox();
153 protected JCheckBox addTempFactor = new JCheckBox();
155 protected JComboBox<String> structViewer = new JComboBox<String>();
157 protected JTextField chimeraPath = new JTextField();
161 * Colours tab components
163 protected JPanel minColour = new JPanel();
165 protected JPanel maxColour = new JPanel();
167 protected JComboBox<String> protColour = new JComboBox<String>();
169 protected JComboBox<String> nucColour = new JComboBox<String>();
172 * Connections tab components
174 protected JList linkURLList = new JList();
176 protected JTextField proxyServerTB = new JTextField();
178 protected JTextField proxyPortTB = new JTextField();
180 protected JTextField defaultBrowser = new JTextField();
182 protected JList linkNameList = new JList();
184 protected JCheckBox useProxy = new JCheckBox();
186 protected JCheckBox usagestats = new JCheckBox();
188 protected JCheckBox questionnaire = new JCheckBox();
190 protected JCheckBox versioncheck = new JCheckBox();
193 * Output tab components
195 protected JComboBox<String> epsRendering = new JComboBox<String>();
197 protected JLabel userIdWidthlabel = new JLabel();
199 protected JCheckBox autoIdWidth = new JCheckBox();
201 protected JTextField userIdWidth = new JTextField();
203 protected JCheckBox blcjv = new JCheckBox();
205 protected JCheckBox pileupjv = new JCheckBox();
207 protected JCheckBox clustaljv = new JCheckBox();
209 protected JCheckBox msfjv = new JCheckBox();
211 protected JCheckBox fastajv = new JCheckBox();
213 protected JCheckBox pfamjv = new JCheckBox();
215 protected JCheckBox pirjv = new JCheckBox();
217 protected JCheckBox modellerOutput = new JCheckBox();
220 * Editing tab components
222 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
224 protected JCheckBox padGaps = new JCheckBox();
226 protected JCheckBox sortByTree = new JCheckBox();
231 protected JPanel dasTab = new JPanel();
236 protected JPanel wsTab = new JPanel();
239 * Creates a new GPreferences object.
241 public GPreferences()
246 } catch (Exception ex)
248 ex.printStackTrace();
253 * Construct the panel and its tabbed sub-panels.
257 private void jbInit() throws Exception
259 final JTabbedPane tabbedPane = new JTabbedPane();
260 this.setLayout(new BorderLayout());
261 JPanel okCancelPanel = initOkCancelPanel();
262 this.add(tabbedPane, BorderLayout.CENTER);
263 this.add(okCancelPanel, BorderLayout.SOUTH);
265 tabbedPane.add(initVisualTab(),
266 MessageManager.getString("label.visual"));
268 tabbedPane.add(initColoursTab(),
269 MessageManager.getString("label.colours"));
271 tabbedPane.add(initStructureTab(),
272 MessageManager.getString("label.structure"));
274 tabbedPane.add(initConnectionsTab(),
275 MessageManager.getString("label.connections"));
277 tabbedPane.add(initOutputTab(), MessageManager.getString("label.output"));
279 tabbedPane.add(initEditingTab(), MessageManager.getString("label.editing"));
282 * See DasSourceBrowser for the real work of configuring this tab.
284 dasTab.setLayout(new BorderLayout());
286 .add(dasTab, MessageManager.getString("label.das_settings"));
289 * See WsPreferences for the real work of configuring this tab.
291 wsTab.setLayout(new BorderLayout());
292 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
295 * Handler to validate a tab before leaving it - currently only for
298 tabbedPane.addChangeListener(new ChangeListener()
300 private Component lastTab;
303 public void stateChanged(ChangeEvent e)
305 if (lastTab == structureTab
306 && tabbedPane.getSelectedComponent() != structureTab)
308 if (!validateStructure())
310 tabbedPane.setSelectedComponent(structureTab);
314 lastTab = tabbedPane.getSelectedComponent();
321 * Initialises the Editing tabbed panel.
325 private JPanel initEditingTab()
327 JPanel editingTab = new JPanel();
328 editingTab.setLayout(null);
329 autoCalculateConsCheck.setFont(LABEL_FONT);
330 autoCalculateConsCheck.setText(MessageManager
331 .getString("label.autocalculate_consensus"));
332 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
333 padGaps.setFont(LABEL_FONT);
334 padGaps.setText(MessageManager.getString("label.pad_gaps_when_editing"));
335 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
336 sortByTree.setFont(LABEL_FONT);
338 .setText(MessageManager.getString("label.sort_with_new_tree"));
340 .setToolTipText(MessageManager
341 .getString("label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
342 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
343 editingTab.add(autoCalculateConsCheck);
344 editingTab.add(padGaps);
345 editingTab.add(sortByTree);
350 * Initialises the Output tabbed panel.
354 private JPanel initOutputTab()
356 JPanel outputTab = new JPanel();
357 outputTab.setLayout(null);
358 JLabel epsLabel = new JLabel();
359 epsLabel.setFont(LABEL_FONT);
360 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
361 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
362 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
363 epsRendering.setFont(LABEL_FONT);
364 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
365 JLabel jLabel1 = new JLabel();
366 jLabel1.setFont(LABEL_FONT);
367 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
368 jLabel1.setText(MessageManager.getString("label.append_start_end"));
369 jLabel1.setFont(LABEL_FONT);
370 fastajv.setFont(LABEL_FONT);
371 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
372 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
373 blcjv.setText(MessageManager.getString("label.blc") + " ");
374 fastajv.setText(MessageManager.getString("label.fasta") + " ");
375 msfjv.setText(MessageManager.getString("label.msf") + " ");
376 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
377 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
378 msfjv.setFont(LABEL_FONT);
379 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
380 pirjv.setText(MessageManager.getString("label.pir") + " ");
381 JPanel jPanel11 = new JPanel();
382 jPanel11.setFont(LABEL_FONT);
383 TitledBorder titledBorder2 = new TitledBorder(
384 MessageManager.getString("label.file_output"));
385 jPanel11.setBorder(titledBorder2);
386 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
387 GridLayout gridLayout3 = new GridLayout();
388 jPanel11.setLayout(gridLayout3);
389 gridLayout3.setRows(8);
390 blcjv.setFont(LABEL_FONT);
391 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
392 clustaljv.setFont(LABEL_FONT);
393 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
394 pfamjv.setFont(LABEL_FONT);
395 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
396 pileupjv.setFont(LABEL_FONT);
397 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
398 pirjv.setFont(LABEL_FONT);
399 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
400 autoIdWidth.setFont(LABEL_FONT);
401 autoIdWidth.setText(MessageManager
402 .getString("label.automatically_set_id_width"));
404 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.adjusts_width_generated_eps_png")));
405 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
406 autoIdWidth.addActionListener(new ActionListener()
410 public void actionPerformed(ActionEvent e)
412 autoIdWidth_actionPerformed();
415 userIdWidthlabel.setFont(LABEL_FONT);
416 userIdWidthlabel.setText(MessageManager
417 .getString("label.figure_id_column_width"));
419 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.manually_specify_width_left_column")));
421 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.manually_specify_width_left_column")));
422 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
423 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
424 userIdWidth.setText("");
425 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
426 userIdWidth.addActionListener(new ActionListener()
430 public void actionPerformed(ActionEvent e)
432 userIdWidth_actionPerformed();
435 jPanel11.add(jLabel1);
437 jPanel11.add(clustaljv);
438 jPanel11.add(fastajv);
440 jPanel11.add(pfamjv);
441 jPanel11.add(pileupjv);
443 outputTab.add(autoIdWidth);
444 outputTab.add(userIdWidth);
445 outputTab.add(userIdWidthlabel);
446 outputTab.add(modellerOutput);
447 outputTab.add(epsLabel);
448 outputTab.add(epsRendering);
449 outputTab.add(jPanel11);
450 modellerOutput.setFont(LABEL_FONT);
451 modellerOutput.setText(MessageManager
452 .getString("label.use_modeller_output"));
453 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
458 * Initialises the Connections tabbed panel.
462 private JPanel initConnectionsTab()
464 JPanel connectTab = new JPanel();
465 connectTab.setLayout(new GridBagLayout());
466 JLabel serverLabel = new JLabel();
467 serverLabel.setText(MessageManager.getString("label.address"));
468 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
469 serverLabel.setFont(LABEL_FONT);
470 proxyServerTB.setFont(LABEL_FONT);
471 proxyPortTB.setFont(LABEL_FONT);
472 JLabel portLabel = new JLabel();
473 portLabel.setFont(LABEL_FONT);
474 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
475 portLabel.setText(MessageManager.getString("label.port"));
476 JLabel browserLabel = new JLabel();
477 browserLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
478 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
479 browserLabel.setText(MessageManager
480 .getString("label.default_browser_unix"));
481 defaultBrowser.setFont(LABEL_FONT);
482 defaultBrowser.setText("");
483 usagestats.setText(MessageManager
484 .getString("label.send_usage_statistics"));
485 usagestats.setFont(LABEL_FONT);
486 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
487 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
488 questionnaire.setText(MessageManager
489 .getString("label.check_for_questionnaires"));
490 questionnaire.setFont(LABEL_FONT);
491 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
492 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
493 versioncheck.setText(MessageManager
494 .getString("label.check_for_latest_version"));
495 versioncheck.setFont(LABEL_FONT);
496 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
497 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
498 JButton newLink = new JButton();
499 newLink.setText(MessageManager.getString("action.new"));
500 newLink.addActionListener(new java.awt.event.ActionListener()
502 public void actionPerformed(ActionEvent e)
504 newLink_actionPerformed(e);
507 JButton editLink = new JButton();
508 editLink.setText(MessageManager.getString("action.edit"));
509 editLink.addActionListener(new java.awt.event.ActionListener()
511 public void actionPerformed(ActionEvent e)
513 editLink_actionPerformed(e);
516 JButton deleteLink = new JButton();
517 deleteLink.setText(MessageManager.getString("action.delete"));
518 deleteLink.addActionListener(new java.awt.event.ActionListener()
520 public void actionPerformed(ActionEvent e)
522 deleteLink_actionPerformed(e);
526 linkURLList.addListSelectionListener(new ListSelectionListener()
528 public void valueChanged(ListSelectionEvent e)
530 int index = linkURLList.getSelectedIndex();
531 linkNameList.setSelectedIndex(index);
535 linkNameList.addListSelectionListener(new ListSelectionListener()
537 public void valueChanged(ListSelectionEvent e)
539 int index = linkNameList.getSelectedIndex();
540 linkURLList.setSelectedIndex(index);
544 JScrollPane linkScrollPane = new JScrollPane();
545 linkScrollPane.setBorder(null);
546 JPanel linkPanel = new JPanel();
547 linkPanel.setBorder(new TitledBorder(MessageManager
548 .getString("label.url_linkfrom_sequence_id")));
549 linkPanel.setLayout(new BorderLayout());
550 GridLayout gridLayout1 = new GridLayout();
551 JPanel editLinkButtons = new JPanel();
552 editLinkButtons.setLayout(gridLayout1);
553 gridLayout1.setRows(3);
554 linkNameList.setFont(LABEL_FONT);
555 linkNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
556 BorderLayout borderLayout3 = new BorderLayout();
557 JPanel linkPanel2 = new JPanel();
558 linkPanel2.setLayout(borderLayout3);
559 linkURLList.setFont(LABEL_FONT);
560 linkURLList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
562 defaultBrowser.addMouseListener(new MouseAdapter()
564 public void mouseClicked(MouseEvent e)
566 if (e.getClickCount() > 1)
568 defaultBrowser_mouseClicked(e);
572 useProxy.setFont(LABEL_FONT);
573 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
574 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
575 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
576 useProxy.addActionListener(new ActionListener()
578 public void actionPerformed(ActionEvent e)
580 useProxy_actionPerformed();
583 linkPanel.add(editLinkButtons, BorderLayout.EAST);
584 editLinkButtons.add(newLink, null);
585 editLinkButtons.add(editLink, null);
586 editLinkButtons.add(deleteLink, null);
587 linkPanel.add(linkScrollPane, BorderLayout.CENTER);
588 linkScrollPane.getViewport().add(linkPanel2, null);
589 linkPanel2.add(linkURLList, BorderLayout.CENTER);
590 linkPanel2.add(linkNameList, BorderLayout.WEST);
591 JPanel jPanel1 = new JPanel();
592 TitledBorder titledBorder1 = new TitledBorder(
593 MessageManager.getString("label.proxy_server"));
594 jPanel1.setBorder(titledBorder1);
595 jPanel1.setLayout(new GridBagLayout());
596 jPanel1.add(serverLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
597 GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
599 jPanel1.add(portLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
600 GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
602 connectTab.add(linkPanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0,
603 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
604 16, 0, 0, 12), 359, -17));
605 connectTab.add(jPanel1, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0,
606 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
607 21, 0, 35, 12), 4, 6));
608 connectTab.add(browserLabel, new GridBagConstraints(0, 1, 1, 1, 0.0,
609 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
610 new Insets(16, 0, 0, 0), 5, 1));
611 jPanel1.add(useProxy, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
612 GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
614 jPanel1.add(proxyPortTB, new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
615 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
616 new Insets(0, 2, 4, 2), 54, 1));
617 jPanel1.add(proxyServerTB, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
618 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
619 new Insets(0, 2, 4, 0), 263, 1));
620 connectTab.add(defaultBrowser, new GridBagConstraints(1, 1, 1, 1, 1.0,
621 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
622 new Insets(15, 0, 0, 15), 307, 1));
623 connectTab.add(usagestats, new GridBagConstraints(0, 4, 1, 1, 1.0, 0.0,
624 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
625 new Insets(0, 2, 4, 2), 70, 1));
626 connectTab.add(questionnaire, new GridBagConstraints(1, 4, 1, 1, 1.0,
627 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
628 new Insets(0, 2, 4, 2), 70, 1));
629 connectTab.add(versioncheck, new GridBagConstraints(0, 5, 1, 1, 1.0,
630 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
631 new Insets(0, 2, 4, 2), 70, 1));
636 * Initialises the parent panel which contains the tabbed sections.
640 private JPanel initOkCancelPanel()
642 JButton ok = new JButton();
643 ok.setText(MessageManager.getString("action.ok"));
644 ok.addActionListener(new ActionListener()
646 public void actionPerformed(ActionEvent e)
648 ok_actionPerformed(e);
651 JButton cancel = new JButton();
652 cancel.setText(MessageManager.getString("action.cancel"));
653 cancel.addActionListener(new ActionListener()
655 public void actionPerformed(ActionEvent e)
657 cancel_actionPerformed(e);
660 JPanel okCancelPanel = new JPanel();
661 okCancelPanel.add(ok);
662 okCancelPanel.add(cancel);
663 return okCancelPanel;
667 * Initialises the Colours tabbed panel.
671 private JPanel initColoursTab()
673 JPanel coloursTab = new JPanel();
674 coloursTab.setBorder(new TitledBorder(MessageManager
675 .getString("action.open_new_alignment")));
676 coloursTab.setLayout(new FlowLayout());
677 JLabel mincolourLabel = new JLabel();
678 mincolourLabel.setFont(LABEL_FONT);
679 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
680 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
681 minColour.setFont(LABEL_FONT);
682 minColour.setBorder(BorderFactory.createEtchedBorder());
683 minColour.setPreferredSize(new Dimension(40, 20));
684 minColour.addMouseListener(new MouseAdapter()
686 public void mousePressed(MouseEvent e)
688 minColour_actionPerformed(minColour);
691 JLabel maxcolourLabel = new JLabel();
692 maxcolourLabel.setFont(LABEL_FONT);
693 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
694 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
695 maxColour.setFont(LABEL_FONT);
696 maxColour.setBorder(BorderFactory.createEtchedBorder());
697 maxColour.setPreferredSize(new Dimension(40, 20));
698 maxColour.addMouseListener(new MouseAdapter()
700 public void mousePressed(MouseEvent e)
702 maxColour_actionPerformed(maxColour);
706 protColour.setFont(LABEL_FONT);
707 protColour.setBounds(new Rectangle(172, 225, 155, 21));
708 JLabel protColourLabel = new JLabel();
709 protColourLabel.setFont(LABEL_FONT);
710 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
711 protColourLabel.setText(MessageManager
712 .getString("label.prot_alignment_colour") + " ");
713 JvSwingUtils.addtoLayout(coloursTab, MessageManager
714 .getString("label.default_colour_scheme_for_alignment"),
715 protColourLabel, protColour);
717 nucColour.setFont(LABEL_FONT);
718 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
719 JLabel nucColourLabel = new JLabel();
720 nucColourLabel.setFont(LABEL_FONT);
721 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
722 nucColourLabel.setText(MessageManager
723 .getString("label.nuc_alignment_colour")
725 JvSwingUtils.addtoLayout(coloursTab, MessageManager
726 .getString("label.default_colour_scheme_for_alignment"),
727 nucColourLabel, nucColour);
729 JPanel annotationShding = new JPanel();
730 annotationShding.setBorder(new TitledBorder(MessageManager
731 .getString("label.annotation_shading_default")));
732 annotationShding.setLayout(new GridLayout(1, 2));
733 JvSwingUtils.addtoLayout(annotationShding, MessageManager
734 .getString("label.default_minimum_colour_annotation_shading"),
735 mincolourLabel, minColour);
736 JvSwingUtils.addtoLayout(annotationShding, MessageManager
737 .getString("label.default_maximum_colour_annotation_shading"),
738 maxcolourLabel, maxColour);
739 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
744 * Initialises the Structure tabbed panel.
748 private JPanel initStructureTab()
750 structureTab = new JPanel();
752 structureTab.setBorder(new TitledBorder(MessageManager
753 .getString("label.structure_options")));
754 structureTab.setLayout(null);
755 final int width = 400;
756 final int height = 22;
757 final int lineSpacing = 25;
760 structFromPdb.setFont(LABEL_FONT);
761 structFromPdb.setText(MessageManager.getString("label.struct_from_pdb"));
762 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
763 structFromPdb.addActionListener(new ActionListener()
766 public void actionPerformed(ActionEvent e)
768 boolean selected = structFromPdb.isSelected();
769 // enable other options only when the first is checked
770 useRnaView.setEnabled(selected);
771 addSecondaryStructure.setEnabled(selected);
772 addTempFactor.setEnabled(selected);
775 structureTab.add(structFromPdb);
777 // indent checkboxes that are conditional on the first one
779 useRnaView.setFont(LABEL_FONT);
780 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
781 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
782 structureTab.add(useRnaView);
785 addSecondaryStructure.setFont(LABEL_FONT);
786 addSecondaryStructure.setText(MessageManager
787 .getString("label.autoadd_secstr"));
788 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
789 structureTab.add(addSecondaryStructure);
792 addTempFactor.setFont(LABEL_FONT);
793 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
794 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
795 structureTab.add(addTempFactor);
798 JLabel viewerLabel = new JLabel();
799 viewerLabel.setFont(LABEL_FONT);
800 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
801 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
802 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
803 structureTab.add(viewerLabel);
805 structViewer.setFont(LABEL_FONT);
806 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
807 structViewer.addItem(ViewerType.JMOL.name());
808 structViewer.addItem(ViewerType.CHIMERA.name());
809 structViewer.addActionListener(new ActionListener()
812 public void actionPerformed(ActionEvent e)
814 structureViewer_actionPerformed((String) structViewer
818 structureTab.add(structViewer);
821 JLabel pathLabel = new JLabel();
822 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
823 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
824 pathLabel.setText(MessageManager.getString("label.chimera_path"));
825 final String tooltip = JvSwingUtils.wrapTooltip(true,
826 MessageManager.getString("label.chimera_path_tip"));
827 pathLabel.setToolTipText(tooltip);
828 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
829 structureTab.add(pathLabel);
831 chimeraPath.setFont(LABEL_FONT);
832 chimeraPath.setText("");
833 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
834 chimeraPath.addMouseListener(new MouseAdapter()
837 public void mouseClicked(MouseEvent e)
839 if (e.getClickCount() == 2)
841 String chosen = openFileChooser();
844 chimeraPath.setText(chosen);
849 structureTab.add(chimeraPath);
852 // scrl_pdbDocFieldConfig.setPreferredSize(new Dimension(450, 100));
853 // scrl_pdbDocFieldConfig
854 // .setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
855 // scrl_pdbDocFieldConfig.setBounds();
856 PDBDocFieldPreferences docFieldPref = new PDBDocFieldPreferences(
857 PreferenceSource.PREFERENCES);
858 docFieldPref.setBounds(new Rectangle(10, ypos + 5, 450, 120));
859 structureTab.add(docFieldPref);
869 * Action on choosing a structure viewer from combobox options.
871 * @param selectedItem
873 protected void structureViewer_actionPerformed(String selectedItem)
878 * Show a dialog for the user to choose a file. Returns the chosen path, or
883 protected String openFileChooser()
885 String choice = null;
886 JFileChooser chooser = new JFileChooser();
888 // chooser.setFileView(new JalviewFileView());
889 chooser.setDialogTitle(MessageManager
890 .getString("label.open_local_file"));
891 chooser.setToolTipText(MessageManager.getString("action.open"));
893 int value = chooser.showOpenDialog(this);
895 if (value == JFileChooser.APPROVE_OPTION)
897 choice = chooser.getSelectedFile().getPath();
903 * Validate the structure tab preferences; if invalid, set focus on this tab.
907 protected boolean validateStructure(FocusEvent e)
909 if (!validateStructure())
911 e.getComponent().requestFocusInWindow();
917 protected boolean validateStructure()
923 * Initialises the Visual tabbed panel.
927 private JPanel initVisualTab()
929 JPanel visualTab = new JPanel();
930 visualTab.setBorder(new TitledBorder(MessageManager
931 .getString("action.open_new_alignment")));
932 visualTab.setLayout(null);
933 fullScreen.setFont(LABEL_FONT);
934 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
935 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
936 fullScreen.setText(MessageManager.getString("label.maximize_window"));
937 quality.setEnabled(false);
938 quality.setFont(LABEL_FONT);
939 quality.setHorizontalAlignment(SwingConstants.RIGHT);
940 quality.setHorizontalTextPosition(SwingConstants.LEFT);
941 quality.setSelected(true);
942 quality.setText(MessageManager.getString("label.quality"));
943 conservation.setEnabled(false);
944 conservation.setFont(LABEL_FONT);
945 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
946 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
947 conservation.setSelected(true);
948 conservation.setText(MessageManager.getString("label.conservation"));
949 identity.setEnabled(false);
950 identity.setFont(LABEL_FONT);
951 identity.setHorizontalAlignment(SwingConstants.RIGHT);
952 identity.setHorizontalTextPosition(SwingConstants.LEFT);
953 identity.setSelected(true);
954 identity.setText(MessageManager.getString("label.consensus"));
955 JLabel showGroupbits = new JLabel();
956 showGroupbits.setFont(LABEL_FONT);
957 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
958 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
959 showGroupbits.setText(MessageManager.getString("action.show_group")
961 JLabel showConsensbits = new JLabel();
962 showConsensbits.setFont(LABEL_FONT);
963 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
964 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
965 showConsensbits.setText(MessageManager.getString("label.consensus")
967 showConsensHistogram.setEnabled(false);
968 showConsensHistogram.setFont(LABEL_FONT);
969 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
970 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
971 showConsensHistogram.setSelected(true);
972 showConsensHistogram.setText(MessageManager
973 .getString("label.histogram"));
974 showConsensLogo.setEnabled(false);
975 showConsensLogo.setFont(LABEL_FONT);
976 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
977 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
978 showConsensLogo.setSelected(true);
979 showConsensLogo.setText(MessageManager.getString("label.logo"));
980 showGroupConsensus.setEnabled(false);
981 showGroupConsensus.setFont(LABEL_FONT);
982 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
983 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
984 showGroupConsensus.setSelected(true);
985 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
986 showGroupConservation.setEnabled(false);
987 showGroupConservation.setFont(LABEL_FONT);
988 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
989 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
990 showGroupConservation.setSelected(true);
991 showGroupConservation.setText(MessageManager
992 .getString("label.conservation"));
993 showNpTooltip.setEnabled(true);
994 showNpTooltip.setFont(LABEL_FONT);
995 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
996 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
997 showNpTooltip.setSelected(true);
998 showNpTooltip.setText(MessageManager
999 .getString("label.non_positional_features"));
1000 showDbRefTooltip.setEnabled(true);
1001 showDbRefTooltip.setFont(LABEL_FONT);
1002 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1003 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1004 showDbRefTooltip.setSelected(true);
1005 showDbRefTooltip.setText(MessageManager
1006 .getString("label.database_references"));
1007 annotations.setFont(LABEL_FONT);
1008 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1009 annotations.setHorizontalTextPosition(SwingConstants.LEADING);
1010 annotations.setSelected(true);
1011 annotations.setText(MessageManager.getString("label.show_annotations"));
1012 annotations.setBounds(new Rectangle(169, 12, 200, 23));
1013 annotations.addActionListener(new ActionListener()
1015 public void actionPerformed(ActionEvent e)
1017 annotations_actionPerformed(e);
1020 identity.addActionListener(new ActionListener()
1022 public void actionPerformed(ActionEvent e)
1024 annotations_actionPerformed(e);
1027 showGroupConsensus.addActionListener(new ActionListener()
1029 public void actionPerformed(ActionEvent e)
1031 annotations_actionPerformed(e);
1034 showUnconserved.setFont(LABEL_FONT);
1035 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1036 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1037 showUnconserved.setSelected(true);
1038 showUnconserved.setText(MessageManager
1039 .getString("action.show_unconserved"));
1040 showUnconserved.addActionListener(new ActionListener()
1042 public void actionPerformed(ActionEvent e)
1044 showunconserved_actionPerformed(e);
1048 // TODO these are not yet added to / action from Preferences
1049 // JCheckBox shareSelections = new JCheckBox();
1050 // shareSelections.setFont(verdana11);
1051 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1052 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1053 // shareSelections.setSelected(true);
1054 // shareSelections.setText(MessageManager
1055 // .getString("label.share_selection_across_views"));
1056 // JCheckBox followHighlight = new JCheckBox();
1057 // followHighlight.setFont(verdana11);
1058 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1059 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1060 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1061 // followHighlight.setSelected(true);
1062 // followHighlight.setText(MessageManager
1063 // .getString("label.scroll_highlighted_regions"));
1065 seqLimit.setFont(LABEL_FONT);
1066 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1067 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1068 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1069 smoothFont.setFont(LABEL_FONT);
1070 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1071 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1072 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1073 scaleProteinToCdna.setFont(LABEL_FONT);
1074 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1075 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1076 scaleProteinToCdna.setText(MessageManager
1077 .getString("label.scale_protein_to_cdna"));
1078 scaleProteinToCdna.setToolTipText(MessageManager
1079 .getString("label.scale_protein_to_cdna_tip"));
1080 JLabel gapLabel = new JLabel();
1081 gapLabel.setFont(LABEL_FONT);
1082 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1083 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1084 JLabel fontLabel = new JLabel();
1085 fontLabel.setFont(LABEL_FONT);
1086 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1087 fontLabel.setText(MessageManager.getString("label.font"));
1088 fontSizeCB.setFont(LABEL_FONT);
1089 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1090 fontStyleCB.setFont(LABEL_FONT);
1091 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1092 fontNameCB.setFont(LABEL_FONT);
1093 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1094 gapSymbolCB.setFont(LABEL_FONT);
1095 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1096 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1097 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1098 gapSymbolCB.setRenderer(dlcr);
1100 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1101 startupCheckbox.setFont(LABEL_FONT);
1102 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1103 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1104 startupCheckbox.setSelected(true);
1105 startupFileTextfield.setFont(LABEL_FONT);
1106 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1107 startupFileTextfield.addMouseListener(new MouseAdapter()
1109 public void mouseClicked(MouseEvent e)
1111 if (e.getClickCount() > 1)
1113 startupFileTextfield_mouseClicked();
1118 sortby.setFont(LABEL_FONT);
1119 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1120 JLabel sortLabel = new JLabel();
1121 sortLabel.setFont(LABEL_FONT);
1122 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1123 sortLabel.setText(MessageManager.getString("label.sort_by"));
1124 sortAnnBy.setFont(LABEL_FONT);
1125 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1126 JLabel sortAnnLabel = new JLabel();
1127 sortAnnLabel.setFont(LABEL_FONT);
1128 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1129 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1130 sortAutocalc.setFont(LABEL_FONT);
1131 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1133 JPanel annsettingsPanel = new JPanel();
1134 annsettingsPanel.setBounds(new Rectangle(173, 34, 320, 75));
1135 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1136 annsettingsPanel.setBorder(new EtchedBorder());
1137 visualTab.add(annsettingsPanel);
1138 Border jb = new EmptyBorder(1, 1, 4, 5);
1139 quality.setBorder(jb);
1140 conservation.setBorder(jb);
1141 identity.setBorder(jb);
1142 showConsensbits.setBorder(jb);
1143 showGroupbits.setBorder(jb);
1144 showGroupConsensus.setBorder(jb);
1145 showGroupConservation.setBorder(jb);
1146 showConsensHistogram.setBorder(jb);
1147 showConsensLogo.setBorder(jb);
1149 JPanel autoAnnotSettings = new JPanel();
1150 autoAnnotSettings.setLayout(new GridLayout(3, 3));
1151 annsettingsPanel.add(autoAnnotSettings);
1152 autoAnnotSettings.add(quality);
1153 autoAnnotSettings.add(conservation);
1154 autoAnnotSettings.add(identity);
1155 autoAnnotSettings.add(showGroupbits);
1156 autoAnnotSettings.add(showGroupConservation);
1157 autoAnnotSettings.add(showGroupConsensus);
1158 autoAnnotSettings.add(showConsensbits);
1159 autoAnnotSettings.add(showConsensHistogram);
1160 autoAnnotSettings.add(showConsensLogo);
1162 JPanel tooltipSettings = new JPanel();
1163 tooltipSettings.setBorder(new TitledBorder(MessageManager
1164 .getString("label.sequence_id_tooltip")));
1165 tooltipSettings.setBounds(173, 140, 220, 62);
1166 tooltipSettings.setLayout(new GridLayout(2, 1));
1167 tooltipSettings.add(showDbRefTooltip);
1168 tooltipSettings.add(showNpTooltip);
1169 visualTab.add(tooltipSettings);
1171 wrap.setFont(LABEL_FONT);
1172 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1173 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1174 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1175 rightAlign.setFont(LABEL_FONT);
1176 rightAlign.setForeground(Color.black);
1177 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1178 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1179 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1180 idItalics.setFont(LABEL_FONT_ITALIC);
1181 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1182 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1183 idItalics.setText(MessageManager
1184 .getString("label.sequence_name_italics"));
1185 openoverv.setFont(LABEL_FONT);
1186 openoverv.setActionCommand(MessageManager
1187 .getString("label.open_overview"));
1188 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1189 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1190 openoverv.setText(MessageManager.getString(("label.open_overview")));
1191 JPanel jPanel2 = new JPanel();
1192 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1193 jPanel2.setLayout(new GridLayout(14, 1));
1194 jPanel2.add(fullScreen);
1195 jPanel2.add(openoverv);
1196 jPanel2.add(seqLimit);
1197 jPanel2.add(rightAlign);
1198 jPanel2.add(fontLabel);
1199 jPanel2.add(showUnconserved);
1200 jPanel2.add(idItalics);
1201 jPanel2.add(smoothFont);
1202 jPanel2.add(scaleProteinToCdna);
1203 jPanel2.add(gapLabel);
1205 jPanel2.add(sortLabel);
1206 jPanel2.add(sortAnnLabel);
1207 jPanel2.add(startupCheckbox);
1208 visualTab.add(jPanel2);
1209 visualTab.add(annotations);
1210 visualTab.add(startupFileTextfield);
1211 visualTab.add(sortby);
1212 visualTab.add(sortAnnBy);
1213 visualTab.add(sortAutocalc);
1214 visualTab.add(gapSymbolCB);
1215 visualTab.add(fontNameCB);
1216 visualTab.add(fontSizeCB);
1217 visualTab.add(fontStyleCB);
1221 protected void autoIdWidth_actionPerformed()
1223 // TODO Auto-generated method stub
1227 protected void userIdWidth_actionPerformed()
1229 // TODO Auto-generated method stub
1233 protected void maxColour_actionPerformed(JPanel panel)
1237 protected void minColour_actionPerformed(JPanel panel)
1241 protected void showunconserved_actionPerformed(ActionEvent e)
1243 // TODO Auto-generated method stub
1253 public void ok_actionPerformed(ActionEvent e)
1263 public void cancel_actionPerformed(ActionEvent e)
1273 public void annotations_actionPerformed(ActionEvent e)
1280 public void startupFileTextfield_mouseClicked()
1284 public void newLink_actionPerformed(ActionEvent e)
1289 public void editLink_actionPerformed(ActionEvent e)
1294 public void deleteLink_actionPerformed(ActionEvent e)
1299 public void defaultBrowser_mouseClicked(MouseEvent e)
1304 public void linkURLList_keyTyped(KeyEvent e)
1309 public void useProxy_actionPerformed()
1311 proxyServerTB.setEnabled(useProxy.isSelected());
1312 proxyPortTB.setEnabled(useProxy.isSelected());