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("");
686 final String tooltip = JvSwingUtils.wrapTooltip(true,
687 MessageManager.getString("label.double_click_to_browse"));
688 defaultBrowser.setToolTipText(tooltip);
689 defaultBrowser.addMouseListener(new MouseAdapter()
692 public void mouseClicked(MouseEvent e)
694 if (e.getClickCount() > 1)
696 defaultBrowser_mouseClicked(e);
701 JPanel proxyPanel = initConnTabProxyPanel();
702 initConnTabCheckboxes();
704 // Add default Browser text box
705 connectTab.add(browserLabel,
706 new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0,
707 GridBagConstraints.WEST, GridBagConstraints.NONE,
708 new Insets(10, 0, 5, 5), 5, 1));
709 defaultBrowser.setFont(LABEL_FONT);
710 defaultBrowser.setText("");
712 connectTab.add(defaultBrowser, new GridBagConstraints(1, 0, 1, 1, 1.0,
713 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
714 new Insets(10, 0, 5, 10), 30, 1));
716 // Add proxy server panel
717 connectTab.add(proxyPanel, new GridBagConstraints(0, 1, 2, 1, 1.0, 0.0,
718 GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL,
719 new Insets(10, 0, 5, 12), 4, 10));
721 // Add usage stats, version check and questionnaire checkboxes
722 connectTab.add(usagestats,
723 new GridBagConstraints(0, 2, 1, 1, 1.0, 0.0,
724 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
725 new Insets(0, 2, 5, 5), 70, 1));
726 connectTab.add(questionnaire,
727 new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0,
728 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
729 new Insets(0, 2, 5, 10), 70, 1));
730 connectTab.add(versioncheck,
731 new GridBagConstraints(0, 3, 1, 1, 1.0, 0.0,
732 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
733 new Insets(0, 2, 5, 5), 70, 1));
735 // Add padding so the panel doesn't look ridiculous
736 JPanel spacePanel = new JPanel();
737 connectTab.add(spacePanel,
738 new GridBagConstraints(0, 4, 1, 1, 1.0, 1.0,
739 GridBagConstraints.WEST, GridBagConstraints.BOTH,
740 new Insets(0, 0, 0, 5), 70, 1));
746 * Initialises the Links tabbed panel.
750 private JPanel initLinksTab()
752 JPanel linkTab = new JPanel();
753 linkTab.setLayout(new GridBagLayout());
755 // Set up table for Url links
756 linkUrlTable.setFillsViewportHeight(true);
757 linkUrlTable.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
758 linkUrlTable.setAutoCreateRowSorter(true);
759 linkUrlTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
761 // adjust row height so radio buttons actually fit
762 // don't do this in the renderer, it causes the awt thread to activate
764 JRadioButton temp = new JRadioButton();
765 linkUrlTable.setRowHeight(temp.getMinimumSize().height);
767 // Table in scrollpane so that the table is given a scrollbar
768 JScrollPane linkScrollPane = new JScrollPane(linkUrlTable);
769 linkScrollPane.setBorder(null);
771 // Panel for links functionality
772 JPanel linkPanel = new JPanel(new GridBagLayout());
773 linkPanel.setBorder(new TitledBorder(
774 MessageManager.getString("label.url_linkfrom_sequence_id")));
776 // Put the Url links panel together
778 // Buttons go at top right, resizing only resizes the blank space vertically
779 JPanel buttonPanel = initLinkTabUrlButtons();
780 GridBagConstraints linkConstraints1 = new GridBagConstraints();
781 linkConstraints1.insets = new Insets(0, 0, 5, 0);
782 linkConstraints1.gridx = 0;
783 linkConstraints1.gridy = 0;
784 linkConstraints1.weightx = 1.0;
785 linkConstraints1.fill = GridBagConstraints.HORIZONTAL;
786 linkTab.add(buttonPanel, linkConstraints1);
788 // Links table goes at top left, resizing resizes the table
789 GridBagConstraints linkConstraints2 = new GridBagConstraints();
790 linkConstraints2.insets = new Insets(0, 0, 5, 5);
791 linkConstraints2.gridx = 0;
792 linkConstraints2.gridy = 1;
793 linkConstraints2.weightx = 1.0;
794 linkConstraints2.weighty = 1.0;
795 linkConstraints2.fill = GridBagConstraints.BOTH;
796 linkTab.add(linkScrollPane, linkConstraints2);
798 // Filter box and buttons goes at bottom left, resizing resizes the text box
799 JPanel filterPanel = initLinkTabFilterPanel();
800 GridBagConstraints linkConstraints3 = new GridBagConstraints();
801 linkConstraints3.insets = new Insets(0, 0, 0, 5);
802 linkConstraints3.gridx = 0;
803 linkConstraints3.gridy = 2;
804 linkConstraints3.weightx = 1.0;
805 linkConstraints3.fill = GridBagConstraints.HORIZONTAL;
806 linkTab.add(filterPanel, linkConstraints3);
811 private JPanel initLinkTabFilterPanel()
813 // Filter textbox and reset button
814 JLabel filterLabel = new JLabel(
815 MessageManager.getString("label.filter"));
816 filterLabel.setFont(LABEL_FONT);
817 filterLabel.setHorizontalAlignment(SwingConstants.RIGHT);
818 filterLabel.setHorizontalTextPosition(SwingConstants.LEADING);
820 filterTB.setFont(LABEL_FONT);
821 filterTB.setText("");
823 doReset.setText(MessageManager.getString("action.showall"));
824 userOnly.setText(MessageManager.getString("action.customfilter"));
826 // Panel for filter functionality
827 JPanel filterPanel = new JPanel(new GridBagLayout());
828 filterPanel.setBorder(new TitledBorder("Filter"));
829 GridBagConstraints gbc = new GridBagConstraints();
832 gbc.fill = GridBagConstraints.NONE;
833 gbc.anchor = GridBagConstraints.WEST;
835 filterPanel.add(filterLabel, gbc);
837 GridBagConstraints gbc1 = new GridBagConstraints();
840 gbc1.fill = GridBagConstraints.HORIZONTAL;
841 gbc1.anchor = GridBagConstraints.WEST;
843 filterPanel.add(filterTB, gbc1);
845 GridBagConstraints gbc2 = new GridBagConstraints();
847 gbc2.fill = GridBagConstraints.NONE;
848 gbc2.anchor = GridBagConstraints.WEST;
849 filterPanel.add(doReset, gbc2);
851 GridBagConstraints gbc3 = new GridBagConstraints();
853 gbc3.fill = GridBagConstraints.NONE;
854 gbc3.anchor = GridBagConstraints.WEST;
855 filterPanel.add(userOnly, gbc3);
860 private JPanel initLinkTabUrlButtons()
862 // Buttons for new / edit / delete Url links
863 JButton newLink = new JButton();
864 newLink.setText(MessageManager.getString("action.new"));
866 editLink.setText(MessageManager.getString("action.edit"));
868 deleteLink.setText(MessageManager.getString("action.delete"));
870 // no current selection, so initially disable delete/edit buttons
871 editLink.setEnabled(false);
872 deleteLink.setEnabled(false);
874 newLink.addActionListener(new java.awt.event.ActionListener()
877 public void actionPerformed(ActionEvent e)
879 newLink_actionPerformed(e);
883 editLink.setText(MessageManager.getString("action.edit"));
884 editLink.addActionListener(new java.awt.event.ActionListener()
887 public void actionPerformed(ActionEvent e)
889 editLink_actionPerformed(e);
893 deleteLink.setText(MessageManager.getString("action.delete"));
894 deleteLink.addActionListener(new java.awt.event.ActionListener()
897 public void actionPerformed(ActionEvent e)
899 deleteLink_actionPerformed(e);
903 JPanel buttonPanel = new JPanel(new GridBagLayout());
904 buttonPanel.setBorder(new TitledBorder("Edit links"));
905 GridBagConstraints gbc = new GridBagConstraints();
908 gbc.fill = GridBagConstraints.NONE;
909 buttonPanel.add(newLink, gbc);
911 GridBagConstraints gbc1 = new GridBagConstraints();
914 gbc1.fill = GridBagConstraints.NONE;
915 buttonPanel.add(editLink, gbc1);
917 GridBagConstraints gbc2 = new GridBagConstraints();
920 gbc2.fill = GridBagConstraints.NONE;
921 buttonPanel.add(deleteLink, gbc2);
923 GridBagConstraints gbc3 = new GridBagConstraints();
926 gbc3.fill = GridBagConstraints.HORIZONTAL;
928 JPanel spacePanel = new JPanel();
929 spacePanel.setBorder(null);
930 buttonPanel.add(spacePanel, gbc3);
936 * Initialises the proxy server panel in the Connections tab
938 * @return the proxy server panel
940 private JPanel initConnTabProxyPanel()
942 // Label for server text box
943 serverLabel.setText(MessageManager.getString("label.address"));
944 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
945 serverLabel.setFont(LABEL_FONT);
947 // Proxy server and port text boxes
948 proxyServerTB.setFont(LABEL_FONT);
949 proxyPortTB.setFont(LABEL_FONT);
951 // Label for Port text box
952 portLabel.setFont(LABEL_FONT);
953 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
954 portLabel.setText(MessageManager.getString("label.port"));
956 // Use proxy server checkbox
957 useProxy.setFont(LABEL_FONT);
958 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
959 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
960 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
961 useProxy.addActionListener(new ActionListener()
964 public void actionPerformed(ActionEvent e)
966 useProxy_actionPerformed();
970 // Make proxy server panel
971 JPanel proxyPanel = new JPanel();
972 TitledBorder titledBorder1 = new TitledBorder(
973 MessageManager.getString("label.proxy_server"));
974 proxyPanel.setBorder(titledBorder1);
975 proxyPanel.setLayout(new GridBagLayout());
976 proxyPanel.add(serverLabel,
977 new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
978 GridBagConstraints.WEST, GridBagConstraints.NONE,
979 new Insets(0, 2, 2, 0), 5, 0));
980 proxyPanel.add(portLabel,
981 new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
982 GridBagConstraints.WEST, GridBagConstraints.NONE,
983 new Insets(0, 0, 2, 0), 11, 0));
984 proxyPanel.add(useProxy,
985 new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
986 GridBagConstraints.WEST, GridBagConstraints.NONE,
987 new Insets(0, 2, 5, 185), 2, -4));
988 proxyPanel.add(proxyPortTB,
989 new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
990 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
991 new Insets(0, 2, 2, 2), 54, 1));
992 proxyPanel.add(proxyServerTB,
993 new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
994 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
995 new Insets(0, 2, 2, 0), 263, 1));
1001 * Initialises the checkboxes in the Connections tab
1003 private void initConnTabCheckboxes()
1005 // Usage stats checkbox label
1007 MessageManager.getString("label.send_usage_statistics"));
1008 usagestats.setFont(LABEL_FONT);
1009 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
1010 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
1012 // Questionnaire checkbox label
1013 questionnaire.setText(
1014 MessageManager.getString("label.check_for_questionnaires"));
1015 questionnaire.setFont(LABEL_FONT);
1016 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
1017 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
1019 // Check for latest version checkbox label
1020 versioncheck.setText(
1021 MessageManager.getString("label.check_for_latest_version"));
1022 versioncheck.setFont(LABEL_FONT);
1023 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
1024 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
1028 * Initialises the parent panel which contains the tabbed sections.
1032 private JPanel initOkCancelPanel()
1034 JButton ok = new JButton();
1035 ok.setText(MessageManager.getString("action.ok"));
1036 ok.addActionListener(new ActionListener()
1039 public void actionPerformed(ActionEvent e)
1041 ok_actionPerformed(e);
1044 JButton cancel = new JButton();
1045 cancel.setText(MessageManager.getString("action.cancel"));
1046 cancel.addActionListener(new ActionListener()
1049 public void actionPerformed(ActionEvent e)
1051 cancel_actionPerformed(e);
1054 JPanel okCancelPanel = new JPanel();
1055 okCancelPanel.add(ok);
1056 okCancelPanel.add(cancel);
1057 return okCancelPanel;
1061 * Initialises the Colours tabbed panel.
1065 private JPanel initColoursTab()
1067 JPanel coloursTab = new JPanel();
1068 coloursTab.setBorder(new TitledBorder(
1069 MessageManager.getString("action.open_new_alignment")));
1070 coloursTab.setLayout(new FlowLayout());
1071 JLabel mincolourLabel = new JLabel();
1072 mincolourLabel.setFont(LABEL_FONT);
1073 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1074 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
1075 minColour.setFont(LABEL_FONT);
1076 minColour.setBorder(BorderFactory.createEtchedBorder());
1077 minColour.setPreferredSize(new Dimension(40, 20));
1078 minColour.addMouseListener(new MouseAdapter()
1081 public void mousePressed(MouseEvent e)
1083 minColour_actionPerformed(minColour);
1086 JLabel maxcolourLabel = new JLabel();
1087 maxcolourLabel.setFont(LABEL_FONT);
1088 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1089 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
1090 maxColour.setFont(LABEL_FONT);
1091 maxColour.setBorder(BorderFactory.createEtchedBorder());
1092 maxColour.setPreferredSize(new Dimension(40, 20));
1093 maxColour.addMouseListener(new MouseAdapter()
1096 public void mousePressed(MouseEvent e)
1098 maxColour_actionPerformed(maxColour);
1102 protColour.setFont(LABEL_FONT);
1103 protColour.setBounds(new Rectangle(172, 225, 155, 21));
1104 JLabel protColourLabel = new JLabel();
1105 protColourLabel.setFont(LABEL_FONT);
1106 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1107 protColourLabel.setText(
1108 MessageManager.getString("label.prot_alignment_colour") + " ");
1109 GPreferences.addtoLayout(coloursTab,
1111 .getString("label.default_colour_scheme_for_alignment"),
1112 protColourLabel, protColour);
1114 nucColour.setFont(LABEL_FONT);
1115 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
1116 JLabel nucColourLabel = new JLabel();
1117 nucColourLabel.setFont(LABEL_FONT);
1118 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
1119 nucColourLabel.setText(
1120 MessageManager.getString("label.nuc_alignment_colour") + " ");
1121 GPreferences.addtoLayout(coloursTab,
1123 .getString("label.default_colour_scheme_for_alignment"),
1124 nucColourLabel, nucColour);
1126 JPanel annotationShding = new JPanel();
1127 annotationShding.setBorder(new TitledBorder(
1128 MessageManager.getString("label.annotation_shading_default")));
1129 annotationShding.setLayout(new GridLayout(1, 2));
1130 GPreferences.addtoLayout(annotationShding,
1131 MessageManager.getString(
1132 "label.default_minimum_colour_annotation_shading"),
1133 mincolourLabel, minColour);
1134 GPreferences.addtoLayout(annotationShding,
1135 MessageManager.getString(
1136 "label.default_maximum_colour_annotation_shading"),
1137 maxcolourLabel, maxColour);
1138 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
1143 * Initialises the Overview tabbed panel.
1147 private JPanel initOverviewTab()
1149 JPanel overviewPanel = new JPanel();
1150 overviewPanel.setBorder(new TitledBorder(
1151 MessageManager.getString("label.overview_settings")));
1153 gapColour.setFont(LABEL_FONT);
1154 // fixing the border colours stops apparent colour bleed from the panel
1155 gapColour.setBorder(
1156 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1157 gapColour.setPreferredSize(new Dimension(40, 20));
1158 gapColour.addMouseListener(new MouseAdapter()
1161 public void mousePressed(MouseEvent e)
1163 gapColour_actionPerformed(gapColour);
1167 hiddenColour.setFont(LABEL_FONT);
1168 // fixing the border colours stops apparent colour bleed from the panel
1169 hiddenColour.setBorder(
1170 BorderFactory.createEtchedBorder(Color.white, Color.lightGray));
1171 hiddenColour.setPreferredSize(new Dimension(40, 20));
1172 hiddenColour.addMouseListener(new MouseAdapter()
1175 public void mousePressed(MouseEvent e)
1177 hiddenColour_actionPerformed(hiddenColour);
1181 useLegacyGap = new JCheckBox(
1182 MessageManager.getString("label.ov_legacy_gap"));
1183 useLegacyGap.setFont(LABEL_FONT);
1184 useLegacyGap.setHorizontalAlignment(SwingConstants.LEFT);
1185 useLegacyGap.setVerticalTextPosition(SwingConstants.TOP);
1186 gapLabel = new JLabel(
1187 MessageManager.getString("label.gap_colour"));
1188 gapLabel.setFont(LABEL_FONT);
1189 gapLabel.setHorizontalAlignment(SwingConstants.LEFT);
1190 gapLabel.setVerticalTextPosition(SwingConstants.TOP);
1191 showHiddenAtStart = new JCheckBox(
1192 MessageManager.getString("label.ov_show_hide_default"));
1193 showHiddenAtStart.setFont(LABEL_FONT);
1194 showHiddenAtStart.setHorizontalAlignment(SwingConstants.LEFT);
1195 showHiddenAtStart.setVerticalTextPosition(SwingConstants.TOP);
1196 JLabel hiddenLabel = new JLabel(
1197 MessageManager.getString("label.hidden_colour"));
1198 hiddenLabel.setFont(LABEL_FONT);
1199 hiddenLabel.setHorizontalAlignment(SwingConstants.LEFT);
1200 hiddenLabel.setVerticalTextPosition(SwingConstants.TOP);
1202 useLegacyGap.addActionListener(new ActionListener()
1205 public void actionPerformed(ActionEvent e)
1207 useLegacyGaps_actionPerformed(e);
1211 overviewPanel.setLayout(new GridBagLayout());
1212 GridBagConstraints c1 = new GridBagConstraints();
1214 c1.fill = GridBagConstraints.HORIZONTAL;
1219 c1.anchor = GridBagConstraints.FIRST_LINE_START;
1220 overviewPanel.add(useLegacyGap, c1);
1222 GridBagConstraints c2 = new GridBagConstraints();
1223 c2.fill = GridBagConstraints.HORIZONTAL;
1226 c2.insets = new Insets(0, 15, 0, 10);
1227 overviewPanel.add(gapLabel, c2);
1229 GridBagConstraints c3 = new GridBagConstraints();
1230 c3.fill = GridBagConstraints.HORIZONTAL;
1233 c3.insets = new Insets(0, 0, 0, 15);
1234 overviewPanel.add(gapColour, c3);
1236 GridBagConstraints c4 = new GridBagConstraints();
1237 c4.fill = GridBagConstraints.HORIZONTAL;
1241 overviewPanel.add(showHiddenAtStart, c4);
1243 GridBagConstraints c5 = new GridBagConstraints();
1244 c5.fill = GridBagConstraints.HORIZONTAL;
1247 c5.insets = new Insets(0, 15, 0, 10);
1248 overviewPanel.add(hiddenLabel, c5);
1250 GridBagConstraints c6 = new GridBagConstraints();
1251 c6.fill = GridBagConstraints.HORIZONTAL;
1254 c6.insets = new Insets(0, 0, 0, 15);
1255 overviewPanel.add(hiddenColour, c6);
1257 JButton resetButton = new JButton(
1258 MessageManager.getString("label.reset_to_defaults"));
1260 resetButton.addActionListener(new ActionListener()
1263 public void actionPerformed(ActionEvent e)
1265 resetOvDefaults_actionPerformed(e);
1269 GridBagConstraints c7 = new GridBagConstraints();
1270 c7.fill = GridBagConstraints.NONE;
1273 c7.insets = new Insets(10, 0, 0, 0);
1274 c7.anchor = GridBagConstraints.WEST;
1275 overviewPanel.add(resetButton, c7);
1277 // Add padding so the panel doesn't look ridiculous
1278 JPanel spacePanel = new JPanel();
1279 overviewPanel.add(spacePanel,
1280 new GridBagConstraints(0, 3, 1, 1, 1.0, 1.0,
1281 GridBagConstraints.WEST, GridBagConstraints.BOTH,
1282 new Insets(0, 0, 0, 5), 0, 0));
1284 return overviewPanel;
1288 * Initialises the Structure tabbed panel.
1292 private JPanel initStructureTab()
1294 structureTab = new JPanel();
1296 structureTab.setBorder(new TitledBorder(
1297 MessageManager.getString("label.structure_options")));
1298 structureTab.setLayout(null);
1299 final int width = 400;
1300 final int height = 22;
1301 final int lineSpacing = 25;
1304 structFromPdb.setFont(LABEL_FONT);
1306 .setText(MessageManager.getString("label.struct_from_pdb"));
1307 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
1308 structFromPdb.addActionListener(new ActionListener()
1311 public void actionPerformed(ActionEvent e)
1313 boolean selected = structFromPdb.isSelected();
1314 // enable other options only when the first is checked
1315 useRnaView.setEnabled(selected);
1316 addSecondaryStructure.setEnabled(selected);
1317 addTempFactor.setEnabled(selected);
1320 structureTab.add(structFromPdb);
1322 // indent checkboxes that are conditional on the first one
1323 ypos += lineSpacing;
1324 useRnaView.setFont(LABEL_FONT);
1325 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
1326 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
1327 structureTab.add(useRnaView);
1329 ypos += lineSpacing;
1330 addSecondaryStructure.setFont(LABEL_FONT);
1331 addSecondaryStructure
1332 .setText(MessageManager.getString("label.autoadd_secstr"));
1333 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
1334 structureTab.add(addSecondaryStructure);
1336 ypos += lineSpacing;
1337 addTempFactor.setFont(LABEL_FONT);
1338 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
1339 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
1340 structureTab.add(addTempFactor);
1342 ypos += lineSpacing;
1343 JLabel viewerLabel = new JLabel();
1344 viewerLabel.setFont(LABEL_FONT);
1345 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
1346 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
1347 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
1348 structureTab.add(viewerLabel);
1350 structViewer.setFont(LABEL_FONT);
1351 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
1352 structViewer.addItem(ViewerType.JMOL.name());
1353 structViewer.addItem(ViewerType.CHIMERA.name());
1354 structViewer.addActionListener(new ActionListener()
1357 public void actionPerformed(ActionEvent e)
1359 structureViewer_actionPerformed(
1360 (String) structViewer.getSelectedItem());
1363 structureTab.add(structViewer);
1365 ypos += lineSpacing;
1366 JLabel pathLabel = new JLabel();
1367 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
1368 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
1369 pathLabel.setText(MessageManager.getString("label.chimera_path"));
1370 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
1371 structureTab.add(pathLabel);
1373 chimeraPath.setFont(LABEL_FONT);
1374 chimeraPath.setText("");
1375 final String tooltip = JvSwingUtils.wrapTooltip(true,
1376 MessageManager.getString("label.chimera_path_tip"));
1377 chimeraPath.setToolTipText(tooltip);
1378 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
1379 chimeraPath.addMouseListener(new MouseAdapter()
1382 public void mouseClicked(MouseEvent e)
1384 if (e.getClickCount() == 2)
1386 String chosen = openFileChooser(false);
1389 chimeraPath.setText(chosen);
1394 structureTab.add(chimeraPath);
1396 ypos += lineSpacing;
1397 nwMapping.setFont(LABEL_FONT);
1398 nwMapping.setText(MessageManager.getString("label.nw_mapping"));
1399 siftsMapping.setFont(LABEL_FONT);
1400 siftsMapping.setText(MessageManager.getString("label.sifts_mapping"));
1401 mappingMethod.add(nwMapping);
1402 mappingMethod.add(siftsMapping);
1403 JPanel mappingPanel = new JPanel();
1404 mappingPanel.setFont(LABEL_FONT);
1405 TitledBorder mmTitledBorder = new TitledBorder(
1406 MessageManager.getString("label.mapping_method"));
1407 mmTitledBorder.setTitleFont(LABEL_FONT);
1408 mappingPanel.setBorder(mmTitledBorder);
1409 mappingPanel.setBounds(new Rectangle(10, ypos, 452, 45));
1410 // GridLayout mappingLayout = new GridLayout();
1411 mappingPanel.setLayout(new GridLayout());
1412 mappingPanel.add(nwMapping);
1413 mappingPanel.add(siftsMapping);
1414 structureTab.add(mappingPanel);
1416 ypos += lineSpacing;
1417 ypos += lineSpacing;
1418 FTSDataColumnPreferences docFieldPref = new FTSDataColumnPreferences(
1419 PreferenceSource.PREFERENCES, PDBFTSRestClient.getInstance());
1420 docFieldPref.setBounds(new Rectangle(10, ypos, 450, 120));
1421 structureTab.add(docFieldPref);
1423 return structureTab;
1427 * Action on choosing a structure viewer from combobox options.
1429 * @param selectedItem
1431 protected void structureViewer_actionPerformed(String selectedItem)
1436 * Show a dialog for the user to choose a file. Returns the chosen path, or
1441 protected String openFileChooser(boolean forFolder)
1443 String choice = null;
1444 JFileChooser chooser = new JFileChooser();
1447 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
1450 // chooser.setFileView(new JalviewFileView());
1451 chooser.setDialogTitle(
1452 MessageManager.getString("label.open_local_file"));
1453 chooser.setToolTipText(MessageManager.getString("action.open"));
1455 int value = chooser.showOpenDialog(this);
1457 if (value == JFileChooser.APPROVE_OPTION)
1459 choice = chooser.getSelectedFile().getPath();
1464 protected boolean validateStructure()
1470 * Initialises the Visual tabbed panel.
1474 private JPanel initVisualTab()
1476 JPanel visualTab = new JPanel();
1477 visualTab.setBorder(new TitledBorder(
1478 MessageManager.getString("action.open_new_alignment")));
1479 visualTab.setLayout(null);
1480 fullScreen.setFont(LABEL_FONT);
1481 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
1482 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
1483 fullScreen.setText(MessageManager.getString("label.maximize_window"));
1484 quality.setEnabled(false);
1485 quality.setFont(LABEL_FONT);
1486 quality.setHorizontalAlignment(SwingConstants.RIGHT);
1487 quality.setHorizontalTextPosition(SwingConstants.LEFT);
1488 quality.setSelected(true);
1489 quality.setText(MessageManager.getString("label.quality"));
1490 conservation.setEnabled(false);
1491 conservation.setFont(LABEL_FONT);
1492 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
1493 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
1494 conservation.setSelected(true);
1495 conservation.setText(MessageManager.getString("label.conservation"));
1496 identity.setEnabled(false);
1497 identity.setFont(LABEL_FONT);
1498 identity.setHorizontalAlignment(SwingConstants.RIGHT);
1499 identity.setHorizontalTextPosition(SwingConstants.LEFT);
1500 identity.setSelected(true);
1501 identity.setText(MessageManager.getString("label.consensus"));
1502 showOccupancy.setFont(LABEL_FONT);
1503 showOccupancy.setEnabled(false);
1504 showOccupancy.setHorizontalAlignment(SwingConstants.RIGHT);
1505 showOccupancy.setHorizontalTextPosition(SwingConstants.LEFT);
1506 showOccupancy.setSelected(true);
1507 showOccupancy.setText(MessageManager.getString("label.occupancy"));
1509 JLabel showGroupbits = new JLabel();
1510 showGroupbits.setFont(LABEL_FONT);
1511 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
1512 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
1514 .setText(MessageManager.getString("action.show_group") + ":");
1515 JLabel showConsensbits = new JLabel();
1516 showConsensbits.setFont(LABEL_FONT);
1517 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
1518 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
1520 .setText(MessageManager.getString("label.consensus") + ":");
1521 showConsensHistogram.setEnabled(false);
1522 showConsensHistogram.setFont(LABEL_FONT);
1523 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
1524 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
1525 showConsensHistogram.setSelected(true);
1526 showConsensHistogram
1527 .setText(MessageManager.getString("label.histogram"));
1528 showConsensLogo.setEnabled(false);
1529 showConsensLogo.setFont(LABEL_FONT);
1530 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
1531 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
1532 showConsensLogo.setSelected(true);
1533 showConsensLogo.setText(MessageManager.getString("label.logo"));
1534 showGroupConsensus.setEnabled(false);
1535 showGroupConsensus.setFont(LABEL_FONT);
1536 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
1537 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
1538 showGroupConsensus.setSelected(true);
1539 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
1540 showGroupConservation.setEnabled(false);
1541 showGroupConservation.setFont(LABEL_FONT);
1542 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
1543 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
1544 showGroupConservation.setSelected(true);
1545 showGroupConservation
1546 .setText(MessageManager.getString("label.conservation"));
1547 showNpTooltip.setEnabled(true);
1548 showNpTooltip.setFont(LABEL_FONT);
1549 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1550 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1551 showNpTooltip.setSelected(true);
1552 showNpTooltip.setText(
1553 MessageManager.getString("label.non_positional_features"));
1554 showDbRefTooltip.setEnabled(true);
1555 showDbRefTooltip.setFont(LABEL_FONT);
1556 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
1557 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
1558 showDbRefTooltip.setSelected(true);
1560 .setText(MessageManager.getString("label.database_references"));
1561 annotations.setFont(LABEL_FONT);
1562 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
1563 annotations.setHorizontalTextPosition(SwingConstants.LEFT);
1564 annotations.setSelected(true);
1565 annotations.setText(MessageManager.getString("label.show_annotations"));
1566 // annotations.setBounds(new Rectangle(169, 12, 200, 23));
1567 annotations.addActionListener(new ActionListener()
1570 public void actionPerformed(ActionEvent e)
1572 annotations_actionPerformed(e);
1575 identity.addActionListener(new ActionListener()
1578 public void actionPerformed(ActionEvent e)
1580 annotations_actionPerformed(e);
1583 showGroupConsensus.addActionListener(new ActionListener()
1586 public void actionPerformed(ActionEvent e)
1588 annotations_actionPerformed(e);
1591 showUnconserved.setFont(LABEL_FONT);
1592 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1593 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1594 showUnconserved.setSelected(true);
1596 .setText(MessageManager.getString("action.show_unconserved"));
1597 showUnconserved.addActionListener(new ActionListener()
1600 public void actionPerformed(ActionEvent e)
1602 showunconserved_actionPerformed(e);
1606 // TODO these are not yet added to / action from Preferences
1607 // JCheckBox shareSelections = new JCheckBox();
1608 // shareSelections.setFont(verdana11);
1609 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1610 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1611 // shareSelections.setSelected(true);
1612 // shareSelections.setText(MessageManager
1613 // .getString("label.share_selection_across_views"));
1614 // JCheckBox followHighlight = new JCheckBox();
1615 // followHighlight.setFont(verdana11);
1616 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1617 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1618 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1619 // followHighlight.setSelected(true);
1620 // followHighlight.setText(MessageManager
1621 // .getString("label.scroll_highlighted_regions"));
1623 seqLimit.setFont(LABEL_FONT);
1624 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1625 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1626 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1627 smoothFont.setFont(LABEL_FONT);
1628 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1629 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1630 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1631 scaleProteinToCdna.setFont(LABEL_FONT);
1632 scaleProteinToCdna.setHorizontalAlignment(SwingConstants.RIGHT);
1633 scaleProteinToCdna.setHorizontalTextPosition(SwingConstants.LEADING);
1634 scaleProteinToCdna.setText(
1635 MessageManager.getString("label.scale_protein_to_cdna"));
1636 scaleProteinToCdna.setToolTipText(
1637 MessageManager.getString("label.scale_protein_to_cdna_tip"));
1638 JLabel gapLabel = new JLabel();
1639 gapLabel.setFont(LABEL_FONT);
1640 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1641 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1642 JLabel fontLabel = new JLabel();
1643 fontLabel.setFont(LABEL_FONT);
1644 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1645 fontLabel.setText(MessageManager.getString("label.font"));
1646 fontSizeCB.setFont(LABEL_FONT);
1647 fontSizeCB.setBounds(new Rectangle(320, 112, 65, 23));
1648 fontStyleCB.setFont(LABEL_FONT);
1649 fontStyleCB.setBounds(new Rectangle(382, 112, 80, 23));
1650 fontNameCB.setFont(LABEL_FONT);
1651 fontNameCB.setBounds(new Rectangle(172, 112, 147, 23));
1652 gapSymbolCB.setFont(LABEL_FONT);
1653 gapSymbolCB.setBounds(new Rectangle(172, 215, 69, 23));
1654 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1655 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1656 gapSymbolCB.setRenderer(dlcr);
1658 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1659 startupCheckbox.setFont(LABEL_FONT);
1660 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1661 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1662 startupCheckbox.setSelected(true);
1663 startupFileTextfield.setFont(LABEL_FONT);
1664 startupFileTextfield.setBounds(new Rectangle(172, 310, 330, 20));
1665 final String tooltip = JvSwingUtils.wrapTooltip(true,
1666 MessageManager.getString("label.double_click_to_browse"));
1667 startupFileTextfield.setToolTipText(tooltip);
1668 startupFileTextfield.addMouseListener(new MouseAdapter()
1671 public void mouseClicked(MouseEvent e)
1673 if (e.getClickCount() > 1)
1675 startupFileTextfield_mouseClicked();
1680 sortby.setFont(LABEL_FONT);
1681 sortby.setBounds(new Rectangle(172, 260, 155, 21));
1682 JLabel sortLabel = new JLabel();
1683 sortLabel.setFont(LABEL_FONT);
1684 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1685 sortLabel.setText(MessageManager.getString("label.sort_by"));
1686 sortAnnBy.setFont(LABEL_FONT);
1687 sortAnnBy.setBounds(new Rectangle(172, 285, 110, 21));
1688 JLabel sortAnnLabel = new JLabel();
1689 sortAnnLabel.setFont(LABEL_FONT);
1690 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1691 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1692 sortAutocalc.setFont(LABEL_FONT);
1693 sortAutocalc.setBounds(new Rectangle(290, 285, 165, 21));
1695 JPanel annsettingsPanel = new JPanel();
1696 annsettingsPanel.setBounds(new Rectangle(173, 13, 320, 96));
1697 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1698 annsettingsPanel.setBorder(new EtchedBorder());
1699 visualTab.add(annsettingsPanel);
1700 Border jb = new EmptyBorder(1, 1, 4, 5);
1701 annotations.setBorder(jb);
1702 showOccupancy.setBorder(jb);
1703 quality.setBorder(jb);
1704 conservation.setBorder(jb);
1705 identity.setBorder(jb);
1706 showConsensbits.setBorder(jb);
1707 showGroupbits.setBorder(jb);
1708 showGroupConsensus.setBorder(jb);
1709 showGroupConservation.setBorder(jb);
1710 showConsensHistogram.setBorder(jb);
1711 showConsensLogo.setBorder(jb);
1713 JPanel autoAnnotSettings = new JPanel();
1714 annsettingsPanel.add(autoAnnotSettings);
1715 autoAnnotSettings.setLayout(new GridLayout(0, 2));
1716 autoAnnotSettings.add(annotations);
1717 autoAnnotSettings.add(quality);
1718 // second row of autoannotation box
1719 autoAnnotSettings = new JPanel();
1720 annsettingsPanel.add(autoAnnotSettings);
1722 autoAnnotSettings.setLayout(new GridLayout(0, 3));
1723 autoAnnotSettings.add(conservation);
1724 autoAnnotSettings.add(identity);
1725 autoAnnotSettings.add(showOccupancy);
1726 autoAnnotSettings.add(showGroupbits);
1727 autoAnnotSettings.add(showGroupConservation);
1728 autoAnnotSettings.add(showGroupConsensus);
1729 autoAnnotSettings.add(showConsensbits);
1730 autoAnnotSettings.add(showConsensHistogram);
1731 autoAnnotSettings.add(showConsensLogo);
1733 JPanel tooltipSettings = new JPanel();
1734 tooltipSettings.setBorder(new TitledBorder(
1735 MessageManager.getString("label.sequence_id_tooltip")));
1736 tooltipSettings.setBounds(173, 140, 220, 62);
1737 tooltipSettings.setLayout(new GridLayout(2, 1));
1738 tooltipSettings.add(showDbRefTooltip);
1739 tooltipSettings.add(showNpTooltip);
1740 visualTab.add(tooltipSettings);
1742 wrap.setFont(LABEL_FONT);
1743 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1744 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1745 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1746 rightAlign.setFont(LABEL_FONT);
1747 rightAlign.setForeground(Color.black);
1748 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1749 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1750 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1751 idItalics.setFont(LABEL_FONT_ITALIC);
1752 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1753 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1755 MessageManager.getString("label.sequence_name_italics"));
1756 openoverv.setFont(LABEL_FONT);
1757 openoverv.setActionCommand(
1758 MessageManager.getString("label.open_overview"));
1759 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1760 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1761 openoverv.setText(MessageManager.getString("label.open_overview"));
1762 JPanel jPanel2 = new JPanel();
1763 jPanel2.setBounds(new Rectangle(7, 17, 158, 310));
1764 jPanel2.setLayout(new GridLayout(14, 1));
1765 jPanel2.add(fullScreen);
1766 jPanel2.add(openoverv);
1767 jPanel2.add(seqLimit);
1768 jPanel2.add(rightAlign);
1769 jPanel2.add(fontLabel);
1770 jPanel2.add(showUnconserved);
1771 jPanel2.add(idItalics);
1772 jPanel2.add(smoothFont);
1773 jPanel2.add(scaleProteinToCdna);
1774 jPanel2.add(gapLabel);
1776 jPanel2.add(sortLabel);
1777 jPanel2.add(sortAnnLabel);
1778 jPanel2.add(startupCheckbox);
1779 visualTab.add(jPanel2);
1780 visualTab.add(startupFileTextfield);
1781 visualTab.add(sortby);
1782 visualTab.add(sortAnnBy);
1783 visualTab.add(sortAutocalc);
1784 visualTab.add(gapSymbolCB);
1785 visualTab.add(fontNameCB);
1786 visualTab.add(fontSizeCB);
1787 visualTab.add(fontStyleCB);
1791 protected void autoIdWidth_actionPerformed()
1793 // TODO Auto-generated method stub
1797 protected void userIdWidth_actionPerformed()
1799 // TODO Auto-generated method stub
1803 protected void maxColour_actionPerformed(JPanel panel)
1807 protected void minColour_actionPerformed(JPanel panel)
1811 protected void gapColour_actionPerformed(JPanel panel)
1815 protected void hiddenColour_actionPerformed(JPanel panel)
1819 protected void showunconserved_actionPerformed(ActionEvent e)
1821 // TODO Auto-generated method stub
1825 protected void useLegacyGaps_actionPerformed(ActionEvent e)
1829 protected void resetOvDefaults_actionPerformed(ActionEvent e)
1839 public void ok_actionPerformed(ActionEvent e)
1849 public void cancel_actionPerformed(ActionEvent e)
1859 public void annotations_actionPerformed(ActionEvent e)
1866 public void startupFileTextfield_mouseClicked()
1870 public void newLink_actionPerformed(ActionEvent e)
1875 public void editLink_actionPerformed(ActionEvent e)
1880 public void deleteLink_actionPerformed(ActionEvent e)
1885 public void defaultBrowser_mouseClicked(MouseEvent e)
1890 public void linkURLList_keyTyped(KeyEvent e)
1895 public void useProxy_actionPerformed()
1897 boolean enabled = useProxy.isSelected();
1898 portLabel.setEnabled(enabled);
1899 serverLabel.setEnabled(enabled);
1900 proxyServerTB.setEnabled(enabled);
1901 proxyPortTB.setEnabled(enabled);
1905 * Customer renderer for JTable: supports column of radio buttons
1907 public class RadioButtonRenderer extends JRadioButton
1908 implements TableCellRenderer
1910 public RadioButtonRenderer()
1912 setHorizontalAlignment(CENTER);
1913 setToolTipText(MessageManager.getString("label.urltooltip"));
1917 public Component getTableCellRendererComponent(JTable table,
1918 Object value, boolean isSelected, boolean hasFocus, int row,
1921 setSelected((boolean) value);
1923 // set colours to match rest of table
1926 setBackground(table.getSelectionBackground());
1927 setForeground(table.getSelectionForeground());
1931 setBackground(table.getBackground());
1932 setForeground(table.getForeground());
1939 * Customer cell editor for JTable: supports column of radio buttons in
1940 * conjunction with renderer
1942 public class RadioButtonEditor extends AbstractCellEditor
1943 implements TableCellEditor
1945 private JRadioButton button = new JRadioButton();
1947 public RadioButtonEditor()
1949 button.setHorizontalAlignment(SwingConstants.CENTER);
1950 this.button.addActionListener(new ActionListener()
1953 public void actionPerformed(ActionEvent e)
1955 fireEditingStopped();
1961 public Component getTableCellEditorComponent(JTable table, Object value,
1962 boolean isSelected, int row, int column)
1964 button.setSelected((boolean) value);
1969 public Object getCellEditorValue()
1971 return button.isSelected();
1976 protected void validateHmmerPath()
1980 protected void validateCygwinPath()
1985 * A helper method to add a panel containing a label and a component to a
1993 protected static void addtoLayout(JPanel panel, String tooltip,
1994 JComponent label, JComponent valBox)
1996 JPanel laypanel = new JPanel(new GridLayout(1, 2));
1997 JPanel labPanel = new JPanel(new BorderLayout());
1998 JPanel valPanel = new JPanel();
1999 labPanel.setBounds(new Rectangle(7, 7, 158, 23));
2000 valPanel.setBounds(new Rectangle(172, 7, 270, 23));
2001 labPanel.add(label, BorderLayout.WEST);
2002 valPanel.add(valBox);
2003 laypanel.add(labPanel);
2004 laypanel.add(valPanel);
2005 valPanel.setToolTipText(tooltip);
2006 labPanel.setToolTipText(tooltip);
2007 valBox.setToolTipText(tooltip);
2008 panel.add(laypanel);