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 jalview.fts.core.FTSDataColumnPreferences;
24 import jalview.fts.core.FTSDataColumnPreferences.PreferenceSource;
25 import jalview.fts.service.pdb.PDBFTSRestClient;
26 import jalview.gui.JvSwingUtils;
27 import jalview.gui.StructureViewer.ViewerType;
28 import jalview.util.MessageManager;
29 import jalview.util.Platform;
31 import java.awt.BorderLayout;
32 import java.awt.Color;
33 import java.awt.Component;
34 import java.awt.Dimension;
35 import java.awt.FlowLayout;
37 import java.awt.GridBagConstraints;
38 import java.awt.GridBagLayout;
39 import java.awt.GridLayout;
40 import java.awt.Insets;
41 import java.awt.Rectangle;
42 import java.awt.event.ActionEvent;
43 import java.awt.event.ActionListener;
44 import java.awt.event.KeyEvent;
45 import java.awt.event.MouseAdapter;
46 import java.awt.event.MouseEvent;
48 import javax.swing.AbstractButton;
49 import javax.swing.AbstractCellEditor;
50 import javax.swing.BorderFactory;
51 import javax.swing.BoxLayout;
52 import javax.swing.ButtonGroup;
53 import javax.swing.DefaultListCellRenderer;
54 import javax.swing.JButton;
55 import javax.swing.JCheckBox;
56 import javax.swing.JComboBox;
57 import javax.swing.JComponent;
58 import javax.swing.JFileChooser;
59 import javax.swing.JLabel;
60 import javax.swing.JPanel;
61 import javax.swing.JRadioButton;
62 import javax.swing.JScrollPane;
63 import javax.swing.JTabbedPane;
64 import javax.swing.JTable;
65 import javax.swing.JTextField;
66 import javax.swing.ListSelectionModel;
67 import javax.swing.SwingConstants;
68 import javax.swing.border.Border;
69 import javax.swing.border.EmptyBorder;
70 import javax.swing.border.EtchedBorder;
71 import javax.swing.border.TitledBorder;
72 import javax.swing.event.ChangeEvent;
73 import javax.swing.event.ChangeListener;
74 import javax.swing.table.TableCellEditor;
75 import javax.swing.table.TableCellRenderer;
77 import net.miginfocom.swing.MigLayout;
80 * Base class for the Preferences panel.
85 public class GPreferences extends JPanel
87 private static final Font LABEL_FONT = JvSwingUtils.getLabelFont();
89 private static final Font LABEL_FONT_ITALIC = JvSwingUtils
90 .getLabelFont(false, true);
93 * Visual tab components
95 protected JCheckBox fullScreen = new JCheckBox();
97 protected JCheckBox openoverv = new JCheckBox();
99 protected JCheckBox seqLimit = new JCheckBox();
101 protected JCheckBox rightAlign = new JCheckBox();
103 protected JComboBox<String> fontSizeCB = new JComboBox<>();
105 protected JComboBox<String> fontStyleCB = new JComboBox<>();
107 protected JComboBox<String> fontNameCB = new JComboBox<>();
109 protected JCheckBox showOccupancy = new JCheckBox();
111 protected JCheckBox showUnconserved = new JCheckBox();
113 protected JCheckBox idItalics = new JCheckBox();
115 protected JCheckBox smoothFont = new JCheckBox();
117 protected JCheckBox scaleProteinToCdna = new JCheckBox();
119 protected JComboBox<String> gapSymbolCB = new JComboBox<>();
121 protected JCheckBox wrap = new JCheckBox();
123 protected JComboBox<String> sortby = new JComboBox<>();
125 protected JComboBox<String> sortAnnBy = new JComboBox<>();
127 protected JComboBox<String> sortAutocalc = new JComboBox<>();
129 protected JCheckBox startupCheckbox = new JCheckBox();
131 protected JTextField startupFileTextfield = new JTextField();
133 // below are in the 'second column'
134 protected JCheckBox annotations = new JCheckBox();
136 protected JCheckBox quality = new JCheckBox();
138 protected JCheckBox conservation = new JCheckBox();
140 protected JCheckBox identity = new JCheckBox();
142 protected JCheckBox showGroupConsensus = new JCheckBox();
144 protected JCheckBox showGroupConservation = new JCheckBox();
146 protected JCheckBox showConsensHistogram = new JCheckBox();
148 protected JCheckBox showConsensLogo = new JCheckBox();
150 protected JCheckBox showInformationHistogram = new JCheckBox();
152 protected JCheckBox showHMMLogo = new JCheckBox();
154 protected JCheckBox showDbRefTooltip = new JCheckBox();
156 protected JCheckBox showNpTooltip = new JCheckBox();
160 * Structure tab and components
162 protected JPanel structureTab;
164 protected JCheckBox structFromPdb = new JCheckBox();
166 protected JCheckBox useRnaView = new JCheckBox();
168 protected JCheckBox addSecondaryStructure = new JCheckBox();
170 protected JCheckBox addTempFactor = new JCheckBox();
172 protected JComboBox<String> structViewer = new JComboBox<>();
174 protected JTextField chimeraPath = new JTextField();
176 protected ButtonGroup mappingMethod = new ButtonGroup();
178 protected JRadioButton siftsMapping = new JRadioButton();
180 protected JRadioButton nwMapping = new JRadioButton();
183 * Colours tab components
185 protected JPanel minColour = new JPanel();
187 protected JPanel maxColour = new JPanel();
189 protected JComboBox<String> protColour = new JComboBox<>();
191 protected JComboBox<String> nucColour = new JComboBox<>();
194 * Overview tab components
196 protected JPanel gapColour = new JPanel();
198 protected JPanel hiddenColour = new JPanel();
200 protected JCheckBox useLegacyGap;
202 protected JCheckBox showHiddenAtStart;
204 protected JLabel gapLabel;
207 * Connections tab components
209 protected JTable linkUrlTable = new JTable();
211 protected JButton editLink = new JButton();
213 protected JButton deleteLink = new JButton();
215 protected JTextField filterTB = new JTextField();
217 protected JButton doReset = new JButton();
219 protected JButton userOnly = new JButton();
221 protected JLabel portLabel = new JLabel();
223 protected JLabel serverLabel = new JLabel();
225 protected JTextField proxyServerTB = new JTextField();
227 protected JTextField proxyPortTB = new JTextField();
229 protected JTextField defaultBrowser = new JTextField();
231 protected JCheckBox useProxy = new JCheckBox();
233 protected JCheckBox usagestats = new JCheckBox();
235 protected JCheckBox questionnaire = new JCheckBox();
237 protected JCheckBox versioncheck = new JCheckBox();
240 * Output tab components
242 protected JComboBox<Object> epsRendering = new JComboBox<>();
244 protected JLabel userIdWidthlabel = new JLabel();
246 protected JCheckBox autoIdWidth = new JCheckBox();
248 protected JTextField userIdWidth = new JTextField();
250 protected JCheckBox blcjv = new JCheckBox();
252 protected JCheckBox pileupjv = new JCheckBox();
254 protected JCheckBox clustaljv = new JCheckBox();
256 protected JCheckBox msfjv = new JCheckBox();
258 protected JCheckBox fastajv = new JCheckBox();
260 protected JCheckBox pfamjv = new JCheckBox();
262 protected JCheckBox pirjv = new JCheckBox();
264 protected JCheckBox modellerOutput = new JCheckBox();
266 protected JCheckBox embbedBioJSON = new JCheckBox();
269 * Editing tab components
271 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
273 protected JCheckBox padGaps = new JCheckBox();
275 protected JCheckBox sortByTree = new JCheckBox();
278 * hmmer tab and components
280 protected JPanel hmmerTab;
282 protected JCheckBox hmmrTrimTermini;
284 protected AbstractButton hmmerBackgroundUniprot;
286 protected AbstractButton hmmerBackgroundAlignment;
288 protected JTextField hmmerSequenceCount;
290 protected JTextField hmmerPath;
292 protected JTextField cygwinPath;
297 protected JPanel dasTab = new JPanel();
302 protected JPanel wsTab = new JPanel();
307 * Creates a new GPreferences object.
309 public GPreferences()
314 } catch (Exception ex)
316 ex.printStackTrace();
321 * Construct the panel and its tabbed sub-panels.
325 private void jbInit() throws Exception
327 final JTabbedPane tabbedPane = new JTabbedPane();
328 this.setLayout(new BorderLayout());
329 JPanel okCancelPanel = initOkCancelPanel();
330 this.add(tabbedPane, BorderLayout.CENTER);
331 this.add(okCancelPanel, BorderLayout.SOUTH);
333 tabbedPane.add(initVisualTab(),
334 MessageManager.getString("label.visual"));
336 tabbedPane.add(initColoursTab(),
337 MessageManager.getString("label.colours"));
339 tabbedPane.add(initOverviewTab(),
340 MessageManager.getString("label.overview"));
342 tabbedPane.add(initStructureTab(),
343 MessageManager.getString("label.structure"));
345 tabbedPane.add(initConnectionsTab(),
346 MessageManager.getString("label.connections"));
348 tabbedPane.add(initLinksTab(),
349 MessageManager.getString("label.urllinks"));
351 tabbedPane.add(initOutputTab(),
352 MessageManager.getString("label.output"));
354 tabbedPane.add(initEditingTab(),
355 MessageManager.getString("label.editing"));
357 tabbedPane.add(initHMMERTab(), MessageManager.getString("label.hmmer"));
360 * See DasSourceBrowser for the real work of configuring this tab.
362 dasTab.setLayout(new BorderLayout());
363 tabbedPane.add(dasTab, MessageManager.getString("label.das_settings"));
366 * See WsPreferences for the real work of configuring this tab.
368 wsTab.setLayout(new BorderLayout());
369 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
372 * Handler to validate a tab before leaving it - currently only for
375 tabbedPane.addChangeListener(new ChangeListener()
377 private Component lastTab;
380 public void stateChanged(ChangeEvent e)
382 if (lastTab == structureTab
383 && tabbedPane.getSelectedComponent() != structureTab)
385 if (!validateStructure())
387 tabbedPane.setSelectedComponent(structureTab);
391 lastTab = tabbedPane.getSelectedComponent();
398 * Initialises the Editing tabbed panel.
402 private JPanel initEditingTab()
404 JPanel editingTab = new JPanel();
405 editingTab.setLayout(null);
406 autoCalculateConsCheck.setFont(LABEL_FONT);
407 autoCalculateConsCheck.setText(
408 MessageManager.getString("label.autocalculate_consensus"));
409 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
410 padGaps.setFont(LABEL_FONT);
412 MessageManager.getString("label.pad_gaps_when_editing"));
413 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
414 sortByTree.setFont(LABEL_FONT);
416 .setText(MessageManager.getString("label.sort_with_new_tree"));
417 sortByTree.setToolTipText(MessageManager.getString(
418 "label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
419 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
420 editingTab.add(autoCalculateConsCheck);
421 editingTab.add(padGaps);
422 editingTab.add(sortByTree);
427 * Initialises the hmmer tabbed panel
431 private JPanel initHMMERTab()
433 hmmerTab = new JPanel();
434 hmmerTab.setLayout(new BoxLayout(hmmerTab, BoxLayout.Y_AXIS));
435 hmmerTab.setLayout(new MigLayout("flowy"));
438 * path to hmmer binaries folder
440 JPanel installationPanel = new JPanel(new MigLayout("flowy"));
441 // new FlowLayout(FlowLayout.LEFT));
442 JvSwingUtils.createTitledBorder(installationPanel,
443 MessageManager.getString("label.installation"), true);
444 hmmerTab.add(installationPanel);
445 JLabel hmmerLocation = new JLabel(
446 MessageManager.getString("label.hmmer_location"));
447 hmmerLocation.setFont(LABEL_FONT);
448 final int pathFieldLength = 40;
449 hmmerPath = new JTextField(pathFieldLength);
450 hmmerPath.addMouseListener(new MouseAdapter()
453 public void mouseClicked(MouseEvent e)
455 if (e.getClickCount() == 2)
457 String chosen = openFileChooser(true);
460 hmmerPath.setText(chosen);
466 installationPanel.add(hmmerLocation);
467 installationPanel.add(hmmerPath);
470 * path to Cygwin binaries folder (for Windows)
472 if (Platform.isWindows())
474 JLabel cygwinLocation = new JLabel(
475 MessageManager.getString("label.cygwin_location"));
476 cygwinLocation.setFont(LABEL_FONT);
477 cygwinPath = new JTextField(pathFieldLength);
478 cygwinPath.addMouseListener(new MouseAdapter()
481 public void mouseClicked(MouseEvent e)
483 if (e.getClickCount() == 2)
485 String chosen = openFileChooser(true);
488 cygwinPath.setText(chosen);
489 validateCygwinPath();
494 installationPanel.add(cygwinLocation);
495 installationPanel.add(cygwinPath);
499 * preferences for hmmalign
501 JPanel alignOptionsPanel = new JPanel(new MigLayout());
502 // new FlowLayout(FlowLayout.LEFT));
503 JvSwingUtils.createTitledBorder(alignOptionsPanel,
504 MessageManager.getString("label.hmmalign_options"), true);
505 hmmerTab.add(alignOptionsPanel);
506 hmmrTrimTermini = new JCheckBox();
507 hmmrTrimTermini.setFont(LABEL_FONT);
508 hmmrTrimTermini.setText(MessageManager.getString("label.trim_termini"));
509 alignOptionsPanel.add(hmmrTrimTermini);
512 * preferences for hmmsearch
514 JPanel searchOptions = new JPanel(new MigLayout());
515 // FlowLayout(FlowLayout.LEFT));
516 JvSwingUtils.createTitledBorder(searchOptions,
517 MessageManager.getString("label.hmmsearch_options"), true);
518 hmmerTab.add(searchOptions);
519 JLabel sequencesToKeep = new JLabel(
520 MessageManager.getString("label.no_of_sequences"));
521 sequencesToKeep.setFont(LABEL_FONT);
522 searchOptions.add(sequencesToKeep);
523 hmmerSequenceCount = new JTextField(5);
524 searchOptions.add(hmmerSequenceCount);
527 * preferences for Information Content annotation
529 // JPanel dummy = new JPanel(new FlowLayout(FlowLayout.LEFT));
530 JPanel annotationOptions = new JPanel(new MigLayout("left"));
531 JvSwingUtils.createTitledBorder(annotationOptions,
532 MessageManager.getString("label.information_annotation"), true);
533 // dummy.add(annotationOptions);
534 hmmerTab.add(annotationOptions);
535 ButtonGroup backgroundOptions = new ButtonGroup();
536 hmmerBackgroundUniprot = new JRadioButton(
537 MessageManager.getString("label.freq_uniprot"));
538 hmmerBackgroundUniprot.setFont(LABEL_FONT);
539 hmmerBackgroundAlignment = new JRadioButton(
540 MessageManager.getString("label.freq_alignment"));
541 hmmerBackgroundAlignment.setFont(LABEL_FONT);
542 backgroundOptions.add(hmmerBackgroundUniprot);
543 backgroundOptions.add(hmmerBackgroundAlignment);
544 backgroundOptions.setSelected(hmmerBackgroundUniprot.getModel(), true);
545 // disable buttons for now as annotation only uses Uniprot background
546 hmmerBackgroundAlignment.setEnabled(false);
547 hmmerBackgroundUniprot.setEnabled(false);
548 annotationOptions.add(hmmerBackgroundUniprot, "wrap");
549 annotationOptions.add(hmmerBackgroundAlignment);
555 * Initialises the Output tabbed panel.
559 private JPanel initOutputTab()
561 JPanel outputTab = new JPanel();
562 outputTab.setLayout(null);
563 JLabel epsLabel = new JLabel();
564 epsLabel.setFont(LABEL_FONT);
565 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
566 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
567 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
568 epsRendering.setFont(LABEL_FONT);
569 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
570 JLabel jLabel1 = new JLabel();
571 jLabel1.setFont(LABEL_FONT);
572 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
573 jLabel1.setText(MessageManager.getString("label.append_start_end"));
574 jLabel1.setFont(LABEL_FONT);
575 fastajv.setFont(LABEL_FONT);
576 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
577 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
578 blcjv.setText(MessageManager.getString("label.blc") + " ");
579 fastajv.setText(MessageManager.getString("label.fasta") + " ");
580 msfjv.setText(MessageManager.getString("label.msf") + " ");
581 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
582 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
583 msfjv.setFont(LABEL_FONT);
584 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
585 pirjv.setText(MessageManager.getString("label.pir") + " ");
586 JPanel jPanel11 = new JPanel();
587 jPanel11.setFont(LABEL_FONT);
588 TitledBorder titledBorder2 = new TitledBorder(
589 MessageManager.getString("label.file_output"));
590 jPanel11.setBorder(titledBorder2);
591 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
592 GridLayout gridLayout3 = new GridLayout();
593 jPanel11.setLayout(gridLayout3);
594 gridLayout3.setRows(8);
595 blcjv.setFont(LABEL_FONT);
596 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
597 clustaljv.setFont(LABEL_FONT);
598 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
599 pfamjv.setFont(LABEL_FONT);
600 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
601 pileupjv.setFont(LABEL_FONT);
602 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
603 pirjv.setFont(LABEL_FONT);
604 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
605 autoIdWidth.setFont(LABEL_FONT);
607 MessageManager.getString("label.automatically_set_id_width"));
608 autoIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
609 .getString("label.adjusts_width_generated_eps_png")));
610 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
611 autoIdWidth.addActionListener(new ActionListener()
615 public void actionPerformed(ActionEvent e)
617 autoIdWidth_actionPerformed();
620 userIdWidthlabel.setFont(LABEL_FONT);
621 userIdWidthlabel.setText(
622 MessageManager.getString("label.figure_id_column_width"));
623 userIdWidth.setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager
624 .getString("label.manually_specify_width_left_column")));
625 userIdWidthlabel.setToolTipText(
626 JvSwingUtils.wrapTooltip(true, MessageManager.getString(
627 "label.manually_specify_width_left_column")));
628 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
629 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
630 userIdWidth.setText("");
631 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
632 userIdWidth.addActionListener(new ActionListener()
636 public void actionPerformed(ActionEvent e)
638 userIdWidth_actionPerformed();
641 modellerOutput.setFont(LABEL_FONT);
643 .setText(MessageManager.getString("label.use_modeller_output"));
644 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
645 embbedBioJSON.setFont(LABEL_FONT);
646 embbedBioJSON.setText(MessageManager.getString("label.embbed_biojson"));
647 embbedBioJSON.setBounds(new Rectangle(228, 200, 250, 23));
649 jPanel11.add(jLabel1);
651 jPanel11.add(clustaljv);
652 jPanel11.add(fastajv);
654 jPanel11.add(pfamjv);
655 jPanel11.add(pileupjv);
657 outputTab.add(autoIdWidth);
658 outputTab.add(userIdWidth);
659 outputTab.add(userIdWidthlabel);
660 outputTab.add(modellerOutput);
661 outputTab.add(embbedBioJSON);
662 outputTab.add(epsLabel);
663 outputTab.add(epsRendering);
664 outputTab.add(jPanel11);
669 * Initialises the Connections tabbed panel.
673 private JPanel initConnectionsTab()
675 JPanel connectTab = new JPanel();
676 connectTab.setLayout(new GridBagLayout());
678 // Label for browser text box
679 JLabel browserLabel = new JLabel();
680 browserLabel.setFont(LABEL_FONT);
681 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
682 browserLabel.setText(
683 MessageManager.getString("label.default_browser_unix"));
684 defaultBrowser.setFont(LABEL_FONT);
685 defaultBrowser.setText("");
687 defaultBrowser.addMouseListener(new MouseAdapter()
690 public void mouseClicked(MouseEvent e)
692 if (e.getClickCount() > 1)
694 defaultBrowser_mouseClicked(e);
699 JPanel proxyPanel = initConnTabProxyPanel();
700 initConnTabCheckboxes();
702 // Add default Browser text box
703 connectTab.add(browserLabel,
704 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
705 GridBagConstraints.WEST, GridBagConstraints.NONE,
706 new Insets(10, 0, 5, 5), 5, 1));
707 defaultBrowser.setFont(LABEL_FONT);
708 defaultBrowser.setText("");
710 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
711 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
712 new Insets(10, 0, 5, 10), 30, 1));
714 // Add proxy server panel
715 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
716 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
717 new Insets(10, 0, 5, 12), 4, 10));
719 // Add usage stats, version check and questionnaire checkboxes
720 connectTab.add(usagestats,
721 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
722 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
723 new Insets(0, 2, 5, 5), 70, 1));
724 connectTab.add(questionnaire,
725 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
726 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
727 new Insets(0, 2, 5, 10), 70, 1));
728 connectTab.add(versioncheck,
729 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
730 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
731 new Insets(0, 2, 5, 5), 70, 1));
733 // Add padding so the panel doesn't look ridiculous
734 JPanel spacePanel = new JPanel();
735 connectTab.add(spacePanel,
736 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
737 GridBagConstraints.WEST, GridBagConstraints.BOTH,
738 new Insets(0, 0, 0, 5), 70, 1));
744 * Initialises the Links tabbed panel.
748 private JPanel initLinksTab()
750 JPanel linkTab = new JPanel();
751 linkTab.setLayout(new GridBagLayout());
753 // Set up table for Url links
754 linkUrlTable.setFillsViewportHeight(true);
755 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
756 linkUrlTable.setAutoCreateRowSorter(true);
757 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
759 // adjust row height so radio buttons actually fit
760 // don't do this in the renderer, it causes the awt thread to activate
762 JRadioButton temp = new JRadioButton();
763 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
765 // Table in scrollpane so that the table is given a scrollbar
766 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
767 linkScrollPane.setBorder(null);
769 // Panel for links functionality
770 JPanel linkPanel = new JPanel(new GridBagLayout());
771 linkPanel.setBorder(new TitledBorder(
772 MessageManager.getString("label.url_linkfrom_sequence_id")));
774 // Put the Url links panel together
776 // Buttons go at top right, resizing only resizes the blank space vertically
777 JPanel buttonPanel = initLinkTabUrlButtons();
778 GridBagConstraints linkConstraints1 = new GridBagConstraints();
779 linkConstraints1.insets = new Insets(0, 0, 5, 0);
780 linkConstraints1.gridx = 0;
781 linkConstraints1.gridy = 0;
782 linkConstraints1.weightx = 1.0;
783 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
784 linkTab.add(buttonPanel, linkConstraints1);
786 // Links table goes at top left, resizing resizes the table
787 GridBagConstraints linkConstraints2 = new GridBagConstraints();
788 linkConstraints2.insets = new Insets(0, 0, 5, 5);
789 linkConstraints2.gridx = 0;
790 linkConstraints2.gridy = 1;
791 linkConstraints2.weightx = 1.0;
792 linkConstraints2.weighty = 1.0;
793 linkConstraints2.fill = GridBagConstraints.BOTH;
794 linkTab.add(linkScrollPane, linkConstraints2);
796 // Filter box and buttons goes at bottom left, resizing resizes the text box
797 JPanel filterPanel = initLinkTabFilterPanel();
798 GridBagConstraints linkConstraints3 = new GridBagConstraints();
799 linkConstraints3.insets = new Insets(0, 0, 0, 5);
800 linkConstraints3.gridx = 0;
801 linkConstraints3.gridy = 2;
802 linkConstraints3.weightx = 1.0;
803 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
804 linkTab.add(filterPanel, linkConstraints3);
809 private JPanel initLinkTabFilterPanel()
811 // Filter textbox and reset button
812 JLabel filterLabel = new JLabel(
813 MessageManager.getString("label.filter"));
814 filterLabel.setFont(LABEL_FONT);
815 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
816 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
818 filterTB.setFont(LABEL_FONT);
819 filterTB.setText("");
821 doReset.setText(MessageManager.getString("action.showall"));
822 userOnly.setText(MessageManager.getString("action.customfilter"));
824 // Panel for filter functionality
825 JPanel filterPanel = new JPanel(new GridBagLayout());
826 filterPanel.setBorder(new TitledBorder("Filter"));
827 GridBagConstraints gbc = new GridBagConstraints();
830 gbc.fill = GridBagConstraints.NONE;
831 gbc.anchor = GridBagConstraints.WEST;
833 filterPanel.add(filterLabel, gbc);
835 GridBagConstraints gbc1 = new GridBagConstraints();
838 gbc1.fill = GridBagConstraints.HORIZONTAL;
839 gbc1.anchor = GridBagConstraints.WEST;
841 filterPanel.add(filterTB, gbc1);
843 GridBagConstraints gbc2 = new GridBagConstraints();
845 gbc2.fill = GridBagConstraints.NONE;
846 gbc2.anchor = GridBagConstraints.WEST;
847 filterPanel.add(doReset, gbc2);
849 GridBagConstraints gbc3 = new GridBagConstraints();
851 gbc3.fill = GridBagConstraints.NONE;
852 gbc3.anchor = GridBagConstraints.WEST;
853 filterPanel.add(userOnly, gbc3);
858 private JPanel initLinkTabUrlButtons()
860 // Buttons for new / edit / delete Url links
861 JButton newLink = new JButton();
862 newLink.setText(MessageManager.getString("action.new"));
864 editLink.setText(MessageManager.getString("action.edit"));
866 deleteLink.setText(MessageManager.getString("action.delete"));
868 // no current selection, so initially disable delete/edit buttons
869 editLink.setEnabled(false);
870 deleteLink.setEnabled(false);
872 newLink.addActionListener(new java.awt.event.ActionListener()
875 public void actionPerformed(ActionEvent e)
877 newLink_actionPerformed(e);
881 editLink.setText(MessageManager.getString("action.edit"));
882 editLink.addActionListener(new java.awt.event.ActionListener()
885 public void actionPerformed(ActionEvent e)
887 editLink_actionPerformed(e);
891 deleteLink.setText(MessageManager.getString("action.delete"));
892 deleteLink.addActionListener(new java.awt.event.ActionListener()
895 public void actionPerformed(ActionEvent e)
897 deleteLink_actionPerformed(e);
901 JPanel buttonPanel = new JPanel(new GridBagLayout());
902 buttonPanel.setBorder(new TitledBorder("Edit links"));
903 GridBagConstraints gbc = new GridBagConstraints();
906 gbc.fill = GridBagConstraints.NONE;
907 buttonPanel.add(newLink, gbc);
909 GridBagConstraints gbc1 = new GridBagConstraints();
912 gbc1.fill = GridBagConstraints.NONE;
913 buttonPanel.add(editLink, gbc1);
915 GridBagConstraints gbc2 = new GridBagConstraints();
918 gbc2.fill = GridBagConstraints.NONE;
919 buttonPanel.add(deleteLink, gbc2);
921 GridBagConstraints gbc3 = new GridBagConstraints();
924 gbc3.fill = GridBagConstraints.HORIZONTAL;
926 JPanel spacePanel = new JPanel();
927 spacePanel.setBorder(null);
928 buttonPanel.add(spacePanel, gbc3);
934 * Initialises the proxy server panel in the Connections tab
936 * @return the proxy server panel
938 private JPanel initConnTabProxyPanel()
940 // Label for server text box
941 serverLabel.setText(MessageManager.getString("label.address"));
942 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
943 serverLabel.setFont(LABEL_FONT);
945 // Proxy server and port text boxes
946 proxyServerTB.setFont(LABEL_FONT);
947 proxyPortTB.setFont(LABEL_FONT);
949 // Label for Port text box
950 portLabel.setFont(LABEL_FONT);
951 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
952 portLabel.setText(MessageManager.getString("label.port"));
954 // Use proxy server checkbox
955 useProxy.setFont(LABEL_FONT);
956 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
957 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
958 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
959 useProxy.addActionListener(new ActionListener()
962 public void actionPerformed(ActionEvent e)
964 useProxy_actionPerformed();
968 // Make proxy server panel
969 JPanel proxyPanel = new JPanel();
970 TitledBorder titledBorder1 = new TitledBorder(
971 MessageManager.getString("label.proxy_server"));
972 proxyPanel.setBorder(titledBorder1);
973 proxyPanel.setLayout(new GridBagLayout());
974 proxyPanel.add(serverLabel,
975 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
976 GridBagConstraints.WEST, GridBagConstraints.NONE,
977 new Insets(0, 2, 2, 0), 5, 0));
978 proxyPanel.add(portLabel,
979 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
980 GridBagConstraints.WEST, GridBagConstraints.NONE,
981 new Insets(0, 0, 2, 0), 11, 0));
982 proxyPanel.add(useProxy,
983 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
984 GridBagConstraints.WEST, GridBagConstraints.NONE,
985 new Insets(0, 2, 5, 185), 2, -4));
986 proxyPanel.add(proxyPortTB,
987 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
988 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
989 new Insets(0, 2, 2, 2), 54, 1));
990 proxyPanel.add(proxyServerTB,
991 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
992 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
993 new Insets(0, 2, 2, 0), 263, 1));
999 * Initialises the checkboxes in the Connections tab
1001 private void initConnTabCheckboxes()
1003 // Usage stats checkbox label
1005 MessageManager.getString("label.send_usage_statistics"));
1006 usagestats.setFont(LABEL_FONT);
1007 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1008 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1010 // Questionnaire checkbox label
1011 questionnaire.setText(
1012 MessageManager.getString("label.check_for_questionnaires"));
1013 questionnaire.setFont(LABEL_FONT);
1014 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1015 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1017 // Check for latest version checkbox label
1018 versioncheck.setText(
1019 MessageManager.getString("label.check_for_latest_version"));
1020 versioncheck.setFont(LABEL_FONT);
1021 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1022 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1026 * Initialises the parent panel which contains the tabbed sections.
1030 private JPanel initOkCancelPanel()
1032 JButton ok = new JButton();
1033 ok.setText(MessageManager.getString("action.ok"));
1034 ok.addActionListener(new ActionListener()
1037 public void actionPerformed(ActionEvent e)
1039 ok_actionPerformed(e);
1042 JButton cancel = new JButton();
1043 cancel.setText(MessageManager.getString("action.cancel"));
1044 cancel.addActionListener(new ActionListener()
1047 public void actionPerformed(ActionEvent e)
1049 cancel_actionPerformed(e);
1052 JPanel okCancelPanel = new JPanel();
1053 okCancelPanel.add(ok);
1054 okCancelPanel.add(cancel);
1055 return okCancelPanel;
1059 * Initialises the Colours tabbed panel.
1063 private JPanel initColoursTab()
1065 JPanel coloursTab = new JPanel();
1066 coloursTab.setBorder(new TitledBorder(
1067 MessageManager.getString("action.open_new_alignment")));
1068 coloursTab.setLayout(new FlowLayout());
1069 JLabel mincolourLabel = new JLabel();
1070 mincolourLabel.setFont(LABEL_FONT);
1071 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1072 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1073 minColour.setFont(LABEL_FONT);
1074 minColour.setBorder(BorderFactory.createEtchedBorder());
1075 minColour.setPreferredSize(new Dimension(40, 20));
1076 minColour.addMouseListener(new MouseAdapter()
1079 public void mousePressed(MouseEvent e)
1081 minColour_actionPerformed(minColour);
1084 JLabel maxcolourLabel = new JLabel();
1085 maxcolourLabel.setFont(LABEL_FONT);
1086 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1087 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1088 maxColour.setFont(LABEL_FONT);
1089 maxColour.setBorder(BorderFactory.createEtchedBorder());
1090 maxColour.setPreferredSize(new Dimension(40, 20));
1091 maxColour.addMouseListener(new MouseAdapter()
1094 public void mousePressed(MouseEvent e)
1096 maxColour_actionPerformed(maxColour);
1100 protColour.setFont(LABEL_FONT);
1101 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1102 JLabel protColourLabel = new JLabel();
1103 protColourLabel.setFont(LABEL_FONT);
1104 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1105 protColourLabel.setText(
1106 MessageManager.getString("label.prot_alignment_colour") + " ");
1107 GPreferences.addtoLayout(coloursTab,
1109 .getString("label.default_colour_scheme_for_alignment"),
1110 protColourLabel, protColour);
1112 nucColour.setFont(LABEL_FONT);
1113 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1114 JLabel nucColourLabel = new JLabel();
1115 nucColourLabel.setFont(LABEL_FONT);
1116 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1117 nucColourLabel.setText(
1118 MessageManager.getString("label.nuc_alignment_colour") + " ");
1119 GPreferences.addtoLayout(coloursTab,
1121 .getString("label.default_colour_scheme_for_alignment"),
1122 nucColourLabel, nucColour);
1124 JPanel annotationShding = new JPanel();
1125 annotationShding.setBorder(new TitledBorder(
1126 MessageManager.getString("label.annotation_shading_default")));
1127 annotationShding.setLayout(new GridLayout(1, 2));
1128 GPreferences.addtoLayout(annotationShding,
1129 MessageManager.getString(
1130 "label.default_minimum_colour_annotation_shading"),
1131 mincolourLabel, minColour);
1132 GPreferences.addtoLayout(annotationShding,
1133 MessageManager.getString(
1134 "label.default_maximum_colour_annotation_shading"),
1135 maxcolourLabel, maxColour);
1136 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1141 * Initialises the Overview tabbed panel.
1145 private JPanel initOverviewTab()
1147 JPanel overviewPanel = new JPanel();
1148 overviewPanel.setBorder(new TitledBorder(
1149 MessageManager.getString("label.overview_settings")));
1151 gapColour.setFont(LABEL_FONT);
1152 // fixing the border colours stops apparent colour bleed from the panel
1153 gapColour.setBorder(
1154 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1155 gapColour.setPreferredSize(new Dimension(40, 20));
1156 gapColour.addMouseListener(new MouseAdapter()
1159 public void mousePressed(MouseEvent e)
1161 gapColour_actionPerformed(gapColour);
1165 hiddenColour.setFont(LABEL_FONT);
1166 // fixing the border colours stops apparent colour bleed from the panel
1167 hiddenColour.setBorder(
1168 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1169 hiddenColour.setPreferredSize(new Dimension(40, 20));
1170 hiddenColour.addMouseListener(new MouseAdapter()
1173 public void mousePressed(MouseEvent e)
1175 hiddenColour_actionPerformed(hiddenColour);
1179 useLegacyGap = new JCheckBox(
1180 MessageManager.getString("label.ov_legacy_gap"));
1181 useLegacyGap.setFont(LABEL_FONT);
1182 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1183 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1184 gapLabel = new JLabel(
1185 MessageManager.getString("label.gap_colour"));
1186 gapLabel.setFont(LABEL_FONT);
1187 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1188 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1189 showHiddenAtStart = new JCheckBox(
1190 MessageManager.getString("label.ov_show_hide_default"));
1191 showHiddenAtStart.setFont(LABEL_FONT);
1192 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1193 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1194 JLabel hiddenLabel = new JLabel(
1195 MessageManager.getString("label.hidden_colour"));
1196 hiddenLabel.setFont(LABEL_FONT);
1197 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1198 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1200 useLegacyGap.addActionListener(new ActionListener()
1203 public void actionPerformed(ActionEvent e)
1205 useLegacyGaps_actionPerformed(e);
1209 overviewPanel.setLayout(new GridBagLayout());
1210 GridBagConstraints c1 = new GridBagConstraints();
1212 c1.fill = GridBagConstraints.HORIZONTAL;
1217 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1218 overviewPanel.add(useLegacyGap, c1);
1220 GridBagConstraints c2 = new GridBagConstraints();
1221 c2.fill = GridBagConstraints.HORIZONTAL;
1224 c2.insets = new Insets(0, 15, 0, 10);
1225 overviewPanel.add(gapLabel, c2);
1227 GridBagConstraints c3 = new GridBagConstraints();
1228 c3.fill = GridBagConstraints.HORIZONTAL;
1231 c3.insets = new Insets(0, 0, 0, 15);
1232 overviewPanel.add(gapColour, c3);
1234 GridBagConstraints c4 = new GridBagConstraints();
1235 c4.fill = GridBagConstraints.HORIZONTAL;
1239 overviewPanel.add(showHiddenAtStart, c4);
1241 GridBagConstraints c5 = new GridBagConstraints();
1242 c5.fill = GridBagConstraints.HORIZONTAL;
1245 c5.insets = new Insets(0, 15, 0, 10);
1246 overviewPanel.add(hiddenLabel, c5);
1248 GridBagConstraints c6 = new GridBagConstraints();
1249 c6.fill = GridBagConstraints.HORIZONTAL;
1252 c6.insets = new Insets(0, 0, 0, 15);
1253 overviewPanel.add(hiddenColour, c6);
1255 JButton resetButton = new JButton(
1256 MessageManager.getString("label.reset_to_defaults"));
1258 resetButton.addActionListener(new ActionListener()
1261 public void actionPerformed(ActionEvent e)
1263 resetOvDefaults_actionPerformed(e);
1267 GridBagConstraints c7 = new GridBagConstraints();
1268 c7.fill = GridBagConstraints.NONE;
1271 c7.insets = new Insets(10, 0, 0, 0);
1272 c7.anchor = GridBagConstraints.WEST;
1273 overviewPanel.add(resetButton, c7);
1275 // Add padding so the panel doesn't look ridiculous
1276 JPanel spacePanel = new JPanel();
1277 overviewPanel.add(spacePanel,
1278 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1279 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1280 new Insets(0, 0, 0, 5), 0, 0));
1282 return overviewPanel;
1286 * Initialises the Structure tabbed panel.
1290 private JPanel initStructureTab()
1292 structureTab = new JPanel();
1294 structureTab.setBorder(new TitledBorder(
1295 MessageManager.getString("label.structure_options")));
1296 structureTab.setLayout(null);
1297 final int width = 400;
1298 final int height = 22;
1299 final int lineSpacing = 25;
1302 structFromPdb.setFont(LABEL_FONT);
1304 .setText(MessageManager.getString("label.struct_from_pdb"));
1305 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1306 structFromPdb.addActionListener(new ActionListener()
1309 public void actionPerformed(ActionEvent e)
1311 boolean selected = structFromPdb.isSelected();
1312 // enable other options only when the first is checked
1313 useRnaView.setEnabled(selected);
1314 addSecondaryStructure.setEnabled(selected);
1315 addTempFactor.setEnabled(selected);
1318 structureTab.add(structFromPdb);
1320 // indent checkboxes that are conditional on the first one
1321 ypos += lineSpacing;
1322 useRnaView.setFont(LABEL_FONT);
1323 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1324 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1325 structureTab.add(useRnaView);
1327 ypos += lineSpacing;
1328 addSecondaryStructure.setFont(LABEL_FONT);
1329 addSecondaryStructure
1330 .setText(MessageManager.getString("label.autoadd_secstr"));
1331 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1332 structureTab.add(addSecondaryStructure);
1334 ypos += lineSpacing;
1335 addTempFactor.setFont(LABEL_FONT);
1336 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1337 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1338 structureTab.add(addTempFactor);
1340 ypos += lineSpacing;
1341 JLabel viewerLabel = new JLabel();
1342 viewerLabel.setFont(LABEL_FONT);
1343 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1344 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1345 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1346 structureTab.add(viewerLabel);
1348 structViewer.setFont(LABEL_FONT);
1349 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1350 structViewer.addItem(ViewerType.JMOL.name());
1351 structViewer.addItem(ViewerType.CHIMERA.name());
1352 structViewer.addActionListener(new ActionListener()
1355 public void actionPerformed(ActionEvent e)
1357 structureViewer_actionPerformed(
1358 (String) structViewer.getSelectedItem());
1361 structureTab.add(structViewer);
1363 ypos += lineSpacing;
1364 JLabel pathLabel = new JLabel();
1365 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1366 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1367 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1368 final String tooltip = JvSwingUtils.wrapTooltip(true,
1369 MessageManager.getString("label.chimera_path_tip"));
1370 pathLabel.setToolTipText(tooltip);
1371 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1372 structureTab.add(pathLabel);
1374 chimeraPath.setFont(LABEL_FONT);
1375 chimeraPath.setText("");
1376 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1377 chimeraPath.addMouseListener(new MouseAdapter()
1380 public void mouseClicked(MouseEvent e)
1382 if (e.getClickCount() == 2)
1384 String chosen = openFileChooser(false);
1387 chimeraPath.setText(chosen);
1392 structureTab.add(chimeraPath);
1394 ypos += lineSpacing;
1395 nwMapping.setFont(LABEL_FONT);
1396 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1397 siftsMapping.setFont(LABEL_FONT);
1398 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1399 mappingMethod.add(nwMapping);
1400 mappingMethod.add(siftsMapping);
1401 JPanel mappingPanel = new JPanel();
1402 mappingPanel.setFont(LABEL_FONT);
1403 TitledBorder mmTitledBorder = new TitledBorder(
1404 MessageManager.getString("label.mapping_method"));
1405 mmTitledBorder.setTitleFont(LABEL_FONT);
1406 mappingPanel.setBorder(mmTitledBorder);
1407 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1408 // GridLayout mappingLayout = new GridLayout();
1409 mappingPanel.setLayout(new GridLayout());
1410 mappingPanel.add(nwMapping);
1411 mappingPanel.add(siftsMapping);
1412 structureTab.add(mappingPanel);
1414 ypos += lineSpacing;
1415 ypos += lineSpacing;
1416 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1417 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1418 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1419 structureTab.add(docFieldPref);
1421 return structureTab;
1425 * Action on choosing a structure viewer from combobox options.
1427 * @param selectedItem
1429 protected void structureViewer_actionPerformed(String selectedItem)
1434 * Show a dialog for the user to choose a file. Returns the chosen path, or
1439 protected String openFileChooser(boolean forFolder)
1441 String choice = null;
1442 JFileChooser chooser = new JFileChooser();
1445 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
1448 // chooser.setFileView(new JalviewFileView());
1449 chooser.setDialogTitle(
1450 MessageManager.getString("label.open_local_file"));
1451 chooser.setToolTipText(MessageManager.getString("action.open"));
1453 int value = chooser.showOpenDialog(this);
1455 if (value == JFileChooser.APPROVE_OPTION)
1457 choice = chooser.getSelectedFile().getPath();
1462 protected boolean validateStructure()
1468 * Initialises the Visual tabbed panel.
1472 private JPanel initVisualTab()
1474 JPanel visualTab = new JPanel();
1475 visualTab.setBorder(new TitledBorder(
1476 MessageManager.getString("action.open_new_alignment")));
1477 visualTab.setLayout(null);
1478 fullScreen.setFont(LABEL_FONT);
1479 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1480 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1481 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1482 quality.setEnabled(false);
1483 quality.setFont(LABEL_FONT);
1484 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1485 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1486 quality.setSelected(true);
1487 quality.setText(MessageManager.getString("label.quality"));
1488 conservation.setEnabled(false);
1489 conservation.setFont(LABEL_FONT);
1490 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1491 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1492 conservation.setSelected(true);
1493 conservation.setText(MessageManager.getString("label.conservation"));
1494 identity.setEnabled(false);
1495 identity.setFont(LABEL_FONT);
1496 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1497 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1498 identity.setSelected(true);
1499 identity.setText(MessageManager.getString("label.consensus"));
1500 showOccupancy.setFont(LABEL_FONT);
1501 showOccupancy.setEnabled(false);
1502 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1503 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1504 showOccupancy.setSelected(true);
1505 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1507 JLabel showGroupbits = new JLabel();
1508 showGroupbits.setFont(LABEL_FONT);
1509 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1510 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1512 .setText(MessageManager.getString("action.show_group") + ":");
1513 JLabel showConsensbits = new JLabel();
1514 showConsensbits.setFont(LABEL_FONT);
1515 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1516 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1518 .setText(MessageManager.getString("label.consensus") + ":");
1519 showConsensHistogram.setEnabled(false);
1520 showConsensHistogram.setFont(LABEL_FONT);
1521 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1522 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1523 showConsensHistogram.setSelected(true);
1524 showConsensHistogram
1525 .setText(MessageManager.getString("label.histogram"));
1526 showConsensLogo.setEnabled(false);
1527 showConsensLogo.setFont(LABEL_FONT);
1528 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1529 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1530 showConsensLogo.setSelected(true);
1531 showConsensLogo.setText(MessageManager.getString("label.logo"));
1532 showGroupConsensus.setEnabled(false);
1533 showGroupConsensus.setFont(LABEL_FONT);
1534 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1535 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1536 showGroupConsensus.setSelected(true);
1537 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1538 showGroupConservation.setEnabled(false);
1539 showGroupConservation.setFont(LABEL_FONT);
1540 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1541 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1542 showGroupConservation.setSelected(true);
1543 showGroupConservation
1544 .setText(MessageManager.getString("label.conservation"));
1545 showNpTooltip.setEnabled(true);
1546 showNpTooltip.setFont(LABEL_FONT);
1547 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1548 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1549 showNpTooltip.setSelected(true);
1550 showNpTooltip.setText(
1551 MessageManager.getString("label.non_positional_features"));
1552 showDbRefTooltip.setEnabled(true);
1553 showDbRefTooltip.setFont(LABEL_FONT);
1554 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1555 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1556 showDbRefTooltip.setSelected(true);
1558 .setText(MessageManager.getString("label.database_references"));
1559 annotations.setFont(LABEL_FONT);
1560 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1561 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1562 annotations.setSelected(true);
1563 annotations.setText(MessageManager.getString("label.show_annotations"));
1564 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1565 annotations.addActionListener(new ActionListener()
1568 public void actionPerformed(ActionEvent e)
1570 annotations_actionPerformed(e);
1573 identity.addActionListener(new ActionListener()
1576 public void actionPerformed(ActionEvent e)
1578 annotations_actionPerformed(e);
1581 showGroupConsensus.addActionListener(new ActionListener()
1584 public void actionPerformed(ActionEvent e)
1586 annotations_actionPerformed(e);
1589 showUnconserved.setFont(LABEL_FONT);
1590 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1591 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1592 showUnconserved.setSelected(true);
1594 .setText(MessageManager.getString("action.show_unconserved"));
1595 showUnconserved.addActionListener(new ActionListener()
1598 public void actionPerformed(ActionEvent e)
1600 showunconserved_actionPerformed(e);
1604 // TODO these are not yet added to / action from Preferences
1605 // JCheckBox shareSelections = new JCheckBox();
1606 // shareSelections.setFont(verdana11);
1607 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1608 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1609 // shareSelections.setSelected(true);
1610 // shareSelections.setText(MessageManager
1611 // .getString("label.share_selection_across_views"));
1612 // JCheckBox followHighlight = new JCheckBox();
1613 // followHighlight.setFont(verdana11);
1614 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1615 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1616 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1617 // followHighlight.setSelected(true);
1618 // followHighlight.setText(MessageManager
1619 // .getString("label.scroll_highlighted_regions"));
1621 seqLimit.setFont(LABEL_FONT);
1622 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1623 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1624 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1625 smoothFont.setFont(LABEL_FONT);
1626 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1627 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1628 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1629 scaleProteinToCdna.setFont(LABEL_FONT);
1630 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1631 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1632 scaleProteinToCdna.setText(
1633 MessageManager.getString("label.scale_protein_to_cdna"));
1634 scaleProteinToCdna.setToolTipText(
1635 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1636 JLabel gapLabel = new JLabel();
1637 gapLabel.setFont(LABEL_FONT);
1638 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1639 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1640 JLabel fontLabel = new JLabel();
1641 fontLabel.setFont(LABEL_FONT);
1642 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1643 fontLabel.setText(MessageManager.getString("label.font"));
1644 fontSizeCB.setFont(LABEL_FONT);
1645 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1646 fontStyleCB.setFont(LABEL_FONT);
1647 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1648 fontNameCB.setFont(LABEL_FONT);
1649 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1650 gapSymbolCB.setFont(LABEL_FONT);
1651 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1652 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1653 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1654 gapSymbolCB.setRenderer(dlcr);
1656 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1657 startupCheckbox.setFont(LABEL_FONT);
1658 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1659 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1660 startupCheckbox.setSelected(true);
1661 startupFileTextfield.setFont(LABEL_FONT);
1662 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1663 startupFileTextfield.addMouseListener(new MouseAdapter()
1666 public void mouseClicked(MouseEvent e)
1668 if (e.getClickCount() > 1)
1670 startupFileTextfield_mouseClicked();
1675 sortby.setFont(LABEL_FONT);
1676 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1677 JLabel sortLabel = new JLabel();
1678 sortLabel.setFont(LABEL_FONT);
1679 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1680 sortLabel.setText(MessageManager.getString("label.sort_by"));
1681 sortAnnBy.setFont(LABEL_FONT);
1682 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1683 JLabel sortAnnLabel = new JLabel();
1684 sortAnnLabel.setFont(LABEL_FONT);
1685 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1686 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1687 sortAutocalc.setFont(LABEL_FONT);
1688 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1690 JPanel annsettingsPanel = new JPanel();
1691 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1692 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1693 annsettingsPanel.setBorder(new EtchedBorder());
1694 visualTab.add(annsettingsPanel);
1695 Border jb = new EmptyBorder(1, 1, 4, 5);
1696 annotations.setBorder(jb);
1697 showOccupancy.setBorder(jb);
1698 quality.setBorder(jb);
1699 conservation.setBorder(jb);
1700 identity.setBorder(jb);
1701 showConsensbits.setBorder(jb);
1702 showGroupbits.setBorder(jb);
1703 showGroupConsensus.setBorder(jb);
1704 showGroupConservation.setBorder(jb);
1705 showConsensHistogram.setBorder(jb);
1706 showConsensLogo.setBorder(jb);
1708 JPanel autoAnnotSettings = new JPanel();
1709 annsettingsPanel.add(autoAnnotSettings);
1710 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1711 autoAnnotSettings.add(annotations);
1712 autoAnnotSettings.add(quality);
1713 // second row of autoannotation box
1714 autoAnnotSettings = new JPanel();
1715 annsettingsPanel.add(autoAnnotSettings);
1717 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1718 autoAnnotSettings.add(conservation);
1719 autoAnnotSettings.add(identity);
1720 autoAnnotSettings.add(showOccupancy);
1721 autoAnnotSettings.add(showGroupbits);
1722 autoAnnotSettings.add(showGroupConservation);
1723 autoAnnotSettings.add(showGroupConsensus);
1724 autoAnnotSettings.add(showConsensbits);
1725 autoAnnotSettings.add(showConsensHistogram);
1726 autoAnnotSettings.add(showConsensLogo);
1728 JPanel tooltipSettings = new JPanel();
1729 tooltipSettings.setBorder(new TitledBorder(
1730 MessageManager.getString("label.sequence_id_tooltip")));
1731 tooltipSettings.setBounds(173, 140, 220, 62);
1732 tooltipSettings.setLayout(new GridLayout(2, 1));
1733 tooltipSettings.add(showDbRefTooltip);
1734 tooltipSettings.add(showNpTooltip);
1735 visualTab.add(tooltipSettings);
1737 wrap.setFont(LABEL_FONT);
1738 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1739 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1740 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1741 rightAlign.setFont(LABEL_FONT);
1742 rightAlign.setForeground(Color.black);
1743 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1744 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1745 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1746 idItalics.setFont(LABEL_FONT_ITALIC);
1747 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1748 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1750 MessageManager.getString("label.sequence_name_italics"));
1751 openoverv.setFont(LABEL_FONT);
1752 openoverv.setActionCommand(
1753 MessageManager.getString("label.open_overview"));
1754 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1755 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1756 openoverv.setText(MessageManager.getString("label.open_overview"));
1757 JPanel jPanel2 = new JPanel();
1758 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1759 jPanel2.setLayout(new GridLayout(14, 1));
1760 jPanel2.add(fullScreen);
1761 jPanel2.add(openoverv);
1762 jPanel2.add(seqLimit);
1763 jPanel2.add(rightAlign);
1764 jPanel2.add(fontLabel);
1765 jPanel2.add(showUnconserved);
1766 jPanel2.add(idItalics);
1767 jPanel2.add(smoothFont);
1768 jPanel2.add(scaleProteinToCdna);
1769 jPanel2.add(gapLabel);
1771 jPanel2.add(sortLabel);
1772 jPanel2.add(sortAnnLabel);
1773 jPanel2.add(startupCheckbox);
1774 visualTab.add(jPanel2);
1775 visualTab.add(startupFileTextfield);
1776 visualTab.add(sortby);
1777 visualTab.add(sortAnnBy);
1778 visualTab.add(sortAutocalc);
1779 visualTab.add(gapSymbolCB);
1780 visualTab.add(fontNameCB);
1781 visualTab.add(fontSizeCB);
1782 visualTab.add(fontStyleCB);
1786 protected void autoIdWidth_actionPerformed()
1788 // TODO Auto-generated method stub
1792 protected void userIdWidth_actionPerformed()
1794 // TODO Auto-generated method stub
1798 protected void maxColour_actionPerformed(JPanel panel)
1802 protected void minColour_actionPerformed(JPanel panel)
1806 protected void gapColour_actionPerformed(JPanel panel)
1810 protected void hiddenColour_actionPerformed(JPanel panel)
1814 protected void showunconserved_actionPerformed(ActionEvent e)
1816 // TODO Auto-generated method stub
1820 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1824 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1834 public void ok_actionPerformed(ActionEvent e)
1844 public void cancel_actionPerformed(ActionEvent e)
1854 public void annotations_actionPerformed(ActionEvent e)
1861 public void startupFileTextfield_mouseClicked()
1865 public void newLink_actionPerformed(ActionEvent e)
1870 public void editLink_actionPerformed(ActionEvent e)
1875 public void deleteLink_actionPerformed(ActionEvent e)
1880 public void defaultBrowser_mouseClicked(MouseEvent e)
1885 public void linkURLList_keyTyped(KeyEvent e)
1890 public void useProxy_actionPerformed()
1892 boolean enabled = useProxy.isSelected();
1893 portLabel.setEnabled(enabled);
1894 serverLabel.setEnabled(enabled);
1895 proxyServerTB.setEnabled(enabled);
1896 proxyPortTB.setEnabled(enabled);
1900 * Customer renderer for JTable: supports column of radio buttons
1902 public class RadioButtonRenderer extends JRadioButton
1903 implements TableCellRenderer
1905 public RadioButtonRenderer()
1907 setHorizontalAlignment(CENTER);
1908 setToolTipText(MessageManager.getString("label.urltooltip"));
1912 public Component getTableCellRendererComponent(JTable table,
1913 Object value, boolean isSelected, boolean hasFocus, int row,
1916 setSelected((boolean) value);
1918 // set colours to match rest of table
1921 setBackground(table.getSelectionBackground());
1922 setForeground(table.getSelectionForeground());
1926 setBackground(table.getBackground());
1927 setForeground(table.getForeground());
1934 * Customer cell editor for JTable: supports column of radio buttons in
1935 * conjunction with renderer
1937 public class RadioButtonEditor extends AbstractCellEditor
1938 implements TableCellEditor
1940 private JRadioButton button = new JRadioButton();
1942 public RadioButtonEditor()
1944 button.setHorizontalAlignment(SwingConstants.CENTER);
1945 this.button.addActionListener(new ActionListener()
1948 public void actionPerformed(ActionEvent e)
1950 fireEditingStopped();
1956 public Component getTableCellEditorComponent(JTable table, Object value,
1957 boolean isSelected, int row, int column)
1959 button.setSelected((boolean) value);
1964 public Object getCellEditorValue()
1966 return button.isSelected();
1971 protected void validateHmmerPath()
1975 protected void validateCygwinPath()
1980 * A helper method to add a panel containing a label and a component to a
1988 protected static void addtoLayout(JPanel panel, String tooltip,
1989 JComponent label, JComponent valBox)
1991 JPanel laypanel = new JPanel(new GridLayout(1, 2));
1992 JPanel labPanel = new JPanel(new BorderLayout());
1993 JPanel valPanel = new JPanel();
1994 labPanel.setBounds(new Rectangle(7, 7, 158, 23));
1995 valPanel.setBounds(new Rectangle(172, 7, 270, 23));
1996 labPanel.add(label, BorderLayout.WEST);
1997 valPanel.add(valBox);
1998 laypanel.add(labPanel);
1999 laypanel.add(valPanel);
2000 valPanel.setToolTipText(tooltip);
2001 labPanel.setToolTipText(tooltip);
2002 valBox.setToolTipText(tooltip);
2003 panel.add(laypanel);