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.gui.JvSwingUtils;
24 import jalview.gui.StructureViewer.ViewerType;
25 import jalview.util.MessageManager;
27 import java.awt.BorderLayout;
28 import java.awt.Color;
29 import java.awt.Component;
30 import java.awt.Dimension;
31 import java.awt.FlowLayout;
33 import java.awt.GridBagConstraints;
34 import java.awt.GridBagLayout;
35 import java.awt.GridLayout;
36 import java.awt.Insets;
37 import java.awt.Rectangle;
38 import java.awt.event.ActionEvent;
39 import java.awt.event.ActionListener;
40 import java.awt.event.FocusEvent;
41 import java.awt.event.KeyEvent;
42 import java.awt.event.MouseAdapter;
43 import java.awt.event.MouseEvent;
45 import javax.swing.BorderFactory;
46 import javax.swing.DefaultListCellRenderer;
47 import javax.swing.JButton;
48 import javax.swing.JCheckBox;
49 import javax.swing.JComboBox;
50 import javax.swing.JFileChooser;
51 import javax.swing.JLabel;
52 import javax.swing.JList;
53 import javax.swing.JPanel;
54 import javax.swing.JScrollPane;
55 import javax.swing.JTabbedPane;
56 import javax.swing.JTextField;
57 import javax.swing.ListSelectionModel;
58 import javax.swing.SwingConstants;
59 import javax.swing.border.Border;
60 import javax.swing.border.EmptyBorder;
61 import javax.swing.border.TitledBorder;
62 import javax.swing.event.ChangeEvent;
63 import javax.swing.event.ChangeListener;
64 import javax.swing.event.ListSelectionEvent;
65 import javax.swing.event.ListSelectionListener;
68 * Base class for the Preferences panel.
73 public class GPreferences extends JPanel
75 private static final Font verdana11 = JvSwingUtils.getLabelFont();
78 * Visual tab components
80 protected JCheckBox fullScreen = new JCheckBox();
82 protected JCheckBox openoverv = new JCheckBox();
84 protected JCheckBox seqLimit = new JCheckBox();
86 protected JCheckBox rightAlign = new JCheckBox();
88 protected JComboBox<String> fontSizeCB = new JComboBox<String>();
90 protected JComboBox<String> fontStyleCB = new JComboBox<String>();
92 protected JComboBox<String> fontNameCB = new JComboBox<String>();
94 protected JCheckBox showUnconserved = new JCheckBox();
96 protected JCheckBox idItalics = new JCheckBox();
98 protected JCheckBox smoothFont = new JCheckBox();
100 protected JComboBox<String> gapSymbolCB = new JComboBox<String>();
102 protected JCheckBox wrap = new JCheckBox();
104 protected JComboBox<String> sortby = new JComboBox<String>();
106 protected JComboBox<String> sortAnnBy = new JComboBox<String>();
108 protected JComboBox<String> sortAutocalc = new JComboBox<String>();
110 protected JCheckBox startupCheckbox = new JCheckBox();
112 protected JTextField startupFileTextfield = new JTextField();
114 // below are in the 'second column'
115 protected JCheckBox annotations = new JCheckBox();
117 protected JCheckBox quality = new JCheckBox();
119 protected JCheckBox conservation = new JCheckBox();
121 protected JCheckBox identity = new JCheckBox();
123 protected JCheckBox showGroupConsensus = new JCheckBox();
125 protected JCheckBox showGroupConservation = new JCheckBox();
127 protected JCheckBox showConsensHistogram = new JCheckBox();
129 protected JCheckBox showConsensLogo = new JCheckBox();
131 protected JCheckBox showDbRefTooltip = new JCheckBox();
133 protected JCheckBox showNpTooltip = new JCheckBox();
136 * Structure tab and components
138 protected JPanel structureTab;
140 protected JCheckBox structFromPdb = new JCheckBox();
142 protected JCheckBox useRnaView = new JCheckBox();
144 protected JCheckBox addSecondaryStructure = new JCheckBox();
146 protected JCheckBox addTempFactor = new JCheckBox();
148 protected JComboBox<String> structViewer = new JComboBox<String>();
150 protected JTextField chimeraPath = new JTextField();
153 * Colours tab components
155 protected JPanel minColour = new JPanel();
157 protected JPanel maxColour = new JPanel();
159 protected JComboBox<String> protColour = new JComboBox<String>();
161 protected JComboBox<String> nucColour = new JComboBox<String>();
164 * Connections tab components
166 protected JList linkURLList = new JList();
168 protected JTextField proxyServerTB = new JTextField();
170 protected JTextField proxyPortTB = new JTextField();
172 protected JTextField defaultBrowser = new JTextField();
174 protected JList linkNameList = new JList();
176 protected JCheckBox useProxy = new JCheckBox();
178 protected JCheckBox usagestats = new JCheckBox();
180 protected JCheckBox questionnaire = new JCheckBox();
182 protected JCheckBox versioncheck = new JCheckBox();
185 * Output tab components
187 protected JComboBox<String> epsRendering = new JComboBox<String>();
189 protected JLabel userIdWidthlabel = new JLabel();
191 protected JCheckBox autoIdWidth = new JCheckBox();
193 protected JTextField userIdWidth = new JTextField();
195 protected JCheckBox blcjv = new JCheckBox();
197 protected JCheckBox pileupjv = new JCheckBox();
199 protected JCheckBox clustaljv = new JCheckBox();
201 protected JCheckBox msfjv = new JCheckBox();
203 protected JCheckBox fastajv = new JCheckBox();
205 protected JCheckBox pfamjv = new JCheckBox();
207 protected JCheckBox pirjv = new JCheckBox();
209 protected JCheckBox modellerOutput = new JCheckBox();
212 * Editing tab components
214 protected JCheckBox autoCalculateConsCheck = new JCheckBox();
216 protected JCheckBox padGaps = new JCheckBox();
218 protected JCheckBox sortByTree = new JCheckBox();
223 protected JPanel dasTab = new JPanel();
228 protected JPanel wsTab = new JPanel();
231 * Creates a new GPreferences object.
233 public GPreferences()
238 } catch (Exception ex)
240 ex.printStackTrace();
245 * Construct the panel and its tabbed sub-panels.
249 private void jbInit() throws Exception
251 final JTabbedPane tabbedPane = new JTabbedPane();
252 this.setLayout(new BorderLayout());
253 JPanel okCancelPanel = initOkCancelPanel();
254 this.add(tabbedPane, BorderLayout.CENTER);
255 this.add(okCancelPanel, BorderLayout.SOUTH);
257 tabbedPane.add(initVisualTab(),
258 MessageManager.getString("label.visual"));
260 tabbedPane.add(initColoursTab(),
261 MessageManager.getString("label.colours"));
263 tabbedPane.add(initStructureTab(),
264 MessageManager.getString("label.structure"));
266 tabbedPane.add(initConnectionsTab(),
267 MessageManager.getString("label.connections"));
269 tabbedPane.add(initOutputTab(), MessageManager.getString("label.output"));
271 tabbedPane.add(initEditingTab(), MessageManager.getString("label.editing"));
274 * See DasSourceBrowser for the real work of configuring this tab.
276 dasTab.setLayout(new BorderLayout());
278 .add(dasTab, MessageManager.getString("label.das_settings"));
281 * See WsPreferences for the real work of configuring this tab.
283 wsTab.setLayout(new BorderLayout());
284 tabbedPane.add(wsTab, MessageManager.getString("label.web_services"));
287 * Handler to validate a tab before leaving it - currently only for
290 tabbedPane.addChangeListener(new ChangeListener()
292 private Component lastTab;
295 public void stateChanged(ChangeEvent e)
297 if (lastTab == structureTab
298 && tabbedPane.getSelectedComponent() != structureTab)
300 if (!validateStructure())
302 tabbedPane.setSelectedComponent(structureTab);
306 lastTab = tabbedPane.getSelectedComponent();
313 * Initialises the Editing tabbed panel.
317 private JPanel initEditingTab()
319 JPanel editingTab = new JPanel();
320 editingTab.setLayout(null);
321 autoCalculateConsCheck.setFont(verdana11);
322 autoCalculateConsCheck.setText(MessageManager
323 .getString("label.autocalculate_consensus"));
324 autoCalculateConsCheck.setBounds(new Rectangle(21, 52, 209, 23));
325 padGaps.setFont(verdana11);
326 padGaps.setText(MessageManager.getString("label.pad_gaps_when_editing"));
327 padGaps.setBounds(new Rectangle(22, 94, 168, 23));
328 sortByTree.setFont(verdana11);
330 .setText(MessageManager.getString("label.sort_with_new_tree"));
332 .setToolTipText(MessageManager
333 .getString("label.any_trees_calculated_or_loaded_alignment_automatically_sort"));
334 sortByTree.setBounds(new Rectangle(22, 136, 168, 23));
335 editingTab.add(autoCalculateConsCheck);
336 editingTab.add(padGaps);
337 editingTab.add(sortByTree);
342 * Initialises the Output tabbed panel.
346 private JPanel initOutputTab()
348 JPanel outputTab = new JPanel();
349 outputTab.setLayout(null);
350 JLabel epsLabel = new JLabel();
351 epsLabel.setFont(verdana11);
352 epsLabel.setHorizontalAlignment(SwingConstants.RIGHT);
353 epsLabel.setText(MessageManager.getString("label.eps_rendering_style"));
354 epsLabel.setBounds(new Rectangle(9, 31, 140, 24));
355 epsRendering.setFont(verdana11);
356 epsRendering.setBounds(new Rectangle(154, 34, 187, 21));
357 JLabel jLabel1 = new JLabel();
358 jLabel1.setFont(verdana11);
359 jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
360 jLabel1.setText(MessageManager.getString("label.append_start_end"));
361 jLabel1.setFont(verdana11);
362 fastajv.setFont(verdana11);
363 fastajv.setHorizontalAlignment(SwingConstants.LEFT);
364 clustaljv.setText(MessageManager.getString("label.clustal") + " ");
365 blcjv.setText(MessageManager.getString("label.blc") + " ");
366 fastajv.setText(MessageManager.getString("label.fasta") + " ");
367 msfjv.setText(MessageManager.getString("label.msf") + " ");
368 pfamjv.setText(MessageManager.getString("label.pfam") + " ");
369 pileupjv.setText(MessageManager.getString("label.pileup") + " ");
370 msfjv.setFont(verdana11);
371 msfjv.setHorizontalAlignment(SwingConstants.LEFT);
372 pirjv.setText(MessageManager.getString("label.pir") + " ");
373 JPanel jPanel11 = new JPanel();
374 jPanel11.setFont(verdana11);
375 TitledBorder titledBorder2 = new TitledBorder(
376 MessageManager.getString("label.file_output"));
377 jPanel11.setBorder(titledBorder2);
378 jPanel11.setBounds(new Rectangle(30, 72, 196, 182));
379 GridLayout gridLayout3 = new GridLayout();
380 jPanel11.setLayout(gridLayout3);
381 gridLayout3.setRows(8);
382 blcjv.setFont(verdana11);
383 blcjv.setHorizontalAlignment(SwingConstants.LEFT);
384 clustaljv.setFont(verdana11);
385 clustaljv.setHorizontalAlignment(SwingConstants.LEFT);
386 pfamjv.setFont(verdana11);
387 pfamjv.setHorizontalAlignment(SwingConstants.LEFT);
388 pileupjv.setFont(verdana11);
389 pileupjv.setHorizontalAlignment(SwingConstants.LEFT);
390 pirjv.setFont(verdana11);
391 pirjv.setHorizontalAlignment(SwingConstants.LEFT);
392 autoIdWidth.setFont(verdana11);
393 autoIdWidth.setText(MessageManager
394 .getString("label.automatically_set_id_width"));
396 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.adjusts_width_generated_eps_png")));
397 autoIdWidth.setBounds(new Rectangle(228, 96, 188, 23));
398 autoIdWidth.addActionListener(new ActionListener()
402 public void actionPerformed(ActionEvent e)
404 autoIdWidth_actionPerformed();
407 userIdWidthlabel.setFont(verdana11);
408 userIdWidthlabel.setText(MessageManager
409 .getString("label.figure_id_column_width"));
411 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.manually_specify_width_left_column")));
413 .setToolTipText(JvSwingUtils.wrapTooltip(true, MessageManager.getString("label.manually_specify_width_left_column")));
414 userIdWidthlabel.setBounds(new Rectangle(236, 120, 168, 23));
415 userIdWidth.setFont(JvSwingUtils.getTextAreaFont());
416 userIdWidth.setText("");
417 userIdWidth.setBounds(new Rectangle(232, 144, 84, 23));
418 userIdWidth.addActionListener(new ActionListener()
422 public void actionPerformed(ActionEvent e)
424 userIdWidth_actionPerformed();
427 jPanel11.add(jLabel1);
429 jPanel11.add(clustaljv);
430 jPanel11.add(fastajv);
432 jPanel11.add(pfamjv);
433 jPanel11.add(pileupjv);
435 outputTab.add(autoIdWidth);
436 outputTab.add(userIdWidth);
437 outputTab.add(userIdWidthlabel);
438 outputTab.add(modellerOutput);
439 outputTab.add(epsLabel);
440 outputTab.add(epsRendering);
441 outputTab.add(jPanel11);
442 modellerOutput.setFont(verdana11);
443 modellerOutput.setText(MessageManager
444 .getString("label.use_modeller_output"));
445 modellerOutput.setBounds(new Rectangle(228, 226, 168, 23));
450 * Initialises the Connections tabbed panel.
454 private JPanel initConnectionsTab()
456 JPanel connectTab = new JPanel();
457 connectTab.setLayout(new GridBagLayout());
458 JLabel serverLabel = new JLabel();
459 serverLabel.setText(MessageManager.getString("label.address"));
460 serverLabel.setHorizontalAlignment(SwingConstants.RIGHT);
461 serverLabel.setFont(verdana11);
462 proxyServerTB.setFont(verdana11);
463 proxyPortTB.setFont(verdana11);
464 JLabel portLabel = new JLabel();
465 portLabel.setFont(verdana11);
466 portLabel.setHorizontalAlignment(SwingConstants.RIGHT);
467 portLabel.setText(MessageManager.getString("label.port"));
468 JLabel browserLabel = new JLabel();
469 browserLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
470 browserLabel.setHorizontalAlignment(SwingConstants.TRAILING);
471 browserLabel.setText(MessageManager
472 .getString("label.default_browser_unix"));
473 defaultBrowser.setFont(verdana11);
474 defaultBrowser.setText("");
475 usagestats.setText(MessageManager
476 .getString("label.send_usage_statistics"));
477 usagestats.setFont(verdana11);
478 usagestats.setHorizontalAlignment(SwingConstants.RIGHT);
479 usagestats.setHorizontalTextPosition(SwingConstants.LEADING);
480 questionnaire.setText(MessageManager
481 .getString("label.check_for_questionnaires"));
482 questionnaire.setFont(verdana11);
483 questionnaire.setHorizontalAlignment(SwingConstants.RIGHT);
484 questionnaire.setHorizontalTextPosition(SwingConstants.LEADING);
485 versioncheck.setText(MessageManager
486 .getString("label.check_for_latest_version"));
487 versioncheck.setFont(verdana11);
488 versioncheck.setHorizontalAlignment(SwingConstants.RIGHT);
489 versioncheck.setHorizontalTextPosition(SwingConstants.LEADING);
490 JButton newLink = new JButton();
491 newLink.setText(MessageManager.getString("action.new"));
492 newLink.addActionListener(new java.awt.event.ActionListener()
494 public void actionPerformed(ActionEvent e)
496 newLink_actionPerformed(e);
499 JButton editLink = new JButton();
500 editLink.setText(MessageManager.getString("action.edit"));
501 editLink.addActionListener(new java.awt.event.ActionListener()
503 public void actionPerformed(ActionEvent e)
505 editLink_actionPerformed(e);
508 JButton deleteLink = new JButton();
509 deleteLink.setText(MessageManager.getString("action.delete"));
510 deleteLink.addActionListener(new java.awt.event.ActionListener()
512 public void actionPerformed(ActionEvent e)
514 deleteLink_actionPerformed(e);
518 linkURLList.addListSelectionListener(new ListSelectionListener()
520 public void valueChanged(ListSelectionEvent e)
522 int index = linkURLList.getSelectedIndex();
523 linkNameList.setSelectedIndex(index);
527 linkNameList.addListSelectionListener(new ListSelectionListener()
529 public void valueChanged(ListSelectionEvent e)
531 int index = linkNameList.getSelectedIndex();
532 linkURLList.setSelectedIndex(index);
536 JScrollPane linkScrollPane = new JScrollPane();
537 linkScrollPane.setBorder(null);
538 JPanel linkPanel = new JPanel();
539 linkPanel.setBorder(new TitledBorder(MessageManager
540 .getString("label.url_linkfrom_sequence_id")));
541 linkPanel.setLayout(new BorderLayout());
542 GridLayout gridLayout1 = new GridLayout();
543 JPanel editLinkButtons = new JPanel();
544 editLinkButtons.setLayout(gridLayout1);
545 gridLayout1.setRows(3);
546 linkNameList.setFont(verdana11);
547 linkNameList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
548 BorderLayout borderLayout3 = new BorderLayout();
549 JPanel linkPanel2 = new JPanel();
550 linkPanel2.setLayout(borderLayout3);
551 linkURLList.setFont(verdana11);
552 linkURLList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
554 defaultBrowser.addMouseListener(new MouseAdapter()
556 public void mouseClicked(MouseEvent e)
558 if (e.getClickCount() > 1)
560 defaultBrowser_mouseClicked(e);
564 useProxy.setFont(verdana11);
565 useProxy.setHorizontalAlignment(SwingConstants.RIGHT);
566 useProxy.setHorizontalTextPosition(SwingConstants.LEADING);
567 useProxy.setText(MessageManager.getString("label.use_proxy_server"));
568 useProxy.addActionListener(new ActionListener()
570 public void actionPerformed(ActionEvent e)
572 useProxy_actionPerformed();
575 linkPanel.add(editLinkButtons, BorderLayout.EAST);
576 editLinkButtons.add(newLink, null);
577 editLinkButtons.add(editLink, null);
578 editLinkButtons.add(deleteLink, null);
579 linkPanel.add(linkScrollPane, BorderLayout.CENTER);
580 linkScrollPane.getViewport().add(linkPanel2, null);
581 linkPanel2.add(linkURLList, BorderLayout.CENTER);
582 linkPanel2.add(linkNameList, BorderLayout.WEST);
583 JPanel jPanel1 = new JPanel();
584 TitledBorder titledBorder1 = new TitledBorder(
585 MessageManager.getString("label.proxy_server"));
586 jPanel1.setBorder(titledBorder1);
587 jPanel1.setLayout(new GridBagLayout());
588 jPanel1.add(serverLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0,
589 GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
591 jPanel1.add(portLabel, new GridBagConstraints(2, 1, 1, 1, 0.0, 0.0,
592 GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
594 connectTab.add(linkPanel, new GridBagConstraints(0, 0, 2, 1, 1.0, 1.0,
595 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
596 16, 0, 0, 12), 359, -17));
597 connectTab.add(jPanel1, new GridBagConstraints(0, 2, 2, 1, 1.0, 1.0,
598 GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(
599 21, 0, 35, 12), 4, 6));
600 connectTab.add(browserLabel, new GridBagConstraints(0, 1, 1, 1, 0.0,
601 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE,
602 new Insets(16, 0, 0, 0), 5, 1));
603 jPanel1.add(useProxy, new GridBagConstraints(0, 0, 2, 1, 0.0, 0.0,
604 GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0,
606 jPanel1.add(proxyPortTB, new GridBagConstraints(3, 1, 1, 1, 1.0, 0.0,
607 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
608 new Insets(0, 2, 4, 2), 54, 1));
609 jPanel1.add(proxyServerTB, new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0,
610 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
611 new Insets(0, 2, 4, 0), 263, 1));
612 connectTab.add(defaultBrowser, new GridBagConstraints(1, 1, 1, 1, 1.0,
613 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
614 new Insets(15, 0, 0, 15), 307, 1));
615 connectTab.add(usagestats, new GridBagConstraints(0, 4, 1, 1, 1.0, 0.0,
616 GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
617 new Insets(0, 2, 4, 2), 70, 1));
618 connectTab.add(questionnaire, new GridBagConstraints(1, 4, 1, 1, 1.0,
619 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
620 new Insets(0, 2, 4, 2), 70, 1));
621 connectTab.add(versioncheck, new GridBagConstraints(0, 5, 1, 1, 1.0,
622 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
623 new Insets(0, 2, 4, 2), 70, 1));
628 * Initialises the parent panel which contains the tabbed sections.
632 private JPanel initOkCancelPanel()
634 JButton ok = new JButton();
635 ok.setText(MessageManager.getString("action.ok"));
636 ok.addActionListener(new ActionListener()
638 public void actionPerformed(ActionEvent e)
640 ok_actionPerformed(e);
643 JButton cancel = new JButton();
644 cancel.setText(MessageManager.getString("action.cancel"));
645 cancel.addActionListener(new ActionListener()
647 public void actionPerformed(ActionEvent e)
649 cancel_actionPerformed(e);
652 JPanel okCancelPanel = new JPanel();
653 okCancelPanel.add(ok);
654 okCancelPanel.add(cancel);
655 return okCancelPanel;
659 * Initialises the Colours tabbed panel.
663 private JPanel initColoursTab()
665 JPanel coloursTab = new JPanel();
666 coloursTab.setBorder(new TitledBorder(MessageManager
667 .getString("action.open_new_alignment")));
668 coloursTab.setLayout(new FlowLayout());
669 JLabel mincolourLabel = new JLabel();
670 mincolourLabel.setFont(verdana11);
671 mincolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
672 mincolourLabel.setText(MessageManager.getString("label.min_colour"));
673 minColour.setFont(verdana11);
674 minColour.setBorder(BorderFactory.createEtchedBorder());
675 minColour.setPreferredSize(new Dimension(40, 20));
676 minColour.addMouseListener(new MouseAdapter()
678 public void mousePressed(MouseEvent e)
680 minColour_actionPerformed(minColour);
683 JLabel maxcolourLabel = new JLabel();
684 maxcolourLabel.setFont(verdana11);
685 maxcolourLabel.setHorizontalAlignment(SwingConstants.RIGHT);
686 maxcolourLabel.setText(MessageManager.getString("label.max_colour"));
687 maxColour.setFont(verdana11);
688 maxColour.setBorder(BorderFactory.createEtchedBorder());
689 maxColour.setPreferredSize(new Dimension(40, 20));
690 maxColour.addMouseListener(new MouseAdapter()
692 public void mousePressed(MouseEvent e)
694 maxColour_actionPerformed(maxColour);
698 protColour.setFont(verdana11);
699 protColour.setBounds(new Rectangle(172, 225, 155, 21));
700 JLabel protColourLabel = new JLabel();
701 protColourLabel.setFont(verdana11);
702 protColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
703 protColourLabel.setText(MessageManager
704 .getString("label.prot_alignment_colour") + " ");
705 JvSwingUtils.addtoLayout(coloursTab, MessageManager
706 .getString("label.default_colour_scheme_for_alignment"),
707 protColourLabel, protColour);
709 nucColour.setFont(verdana11);
710 nucColour.setBounds(new Rectangle(172, 240, 155, 21));
711 JLabel nucColourLabel = new JLabel();
712 nucColourLabel.setFont(verdana11);
713 nucColourLabel.setHorizontalAlignment(SwingConstants.LEFT);
714 nucColourLabel.setText(MessageManager
715 .getString("label.nuc_alignment_colour")
717 JvSwingUtils.addtoLayout(coloursTab, MessageManager
718 .getString("label.default_colour_scheme_for_alignment"),
719 nucColourLabel, nucColour);
721 JPanel annotationShding = new JPanel();
722 annotationShding.setBorder(new TitledBorder(MessageManager
723 .getString("label.annotation_shading_default")));
724 annotationShding.setLayout(new GridLayout(1, 2));
725 JvSwingUtils.addtoLayout(annotationShding, MessageManager
726 .getString("label.default_minimum_colour_annotation_shading"),
727 mincolourLabel, minColour);
728 JvSwingUtils.addtoLayout(annotationShding, MessageManager
729 .getString("label.default_maximum_colour_annotation_shading"),
730 maxcolourLabel, maxColour);
731 coloursTab.add(annotationShding); // , FlowLayout.LEFT);
736 * Initialises the Structure tabbed panel.
740 private JPanel initStructureTab()
742 structureTab = new JPanel();
744 structureTab.setBorder(new TitledBorder(MessageManager
745 .getString("label.structure_options")));
746 structureTab.setLayout(null);
747 final int width = 400;
748 final int height = 23;
749 final int lineSpacing = 30;
752 structFromPdb.setFont(verdana11);
753 structFromPdb.setText(MessageManager.getString("label.struct_from_pdb"));
754 structFromPdb.setBounds(new Rectangle(5, ypos, width, height));
755 structFromPdb.addActionListener(new ActionListener()
758 public void actionPerformed(ActionEvent e)
760 boolean selected = structFromPdb.isSelected();
761 // enable other options only when the first is checked
762 useRnaView.setEnabled(selected);
763 addSecondaryStructure.setEnabled(selected);
764 addTempFactor.setEnabled(selected);
767 structureTab.add(structFromPdb);
769 // indent checkboxes that are conditional on the first one
771 useRnaView.setFont(verdana11);
772 useRnaView.setText(MessageManager.getString("label.use_rnaview"));
773 useRnaView.setBounds(new Rectangle(25, ypos, width, height));
774 structureTab.add(useRnaView);
777 addSecondaryStructure.setFont(verdana11);
778 addSecondaryStructure.setText(MessageManager
779 .getString("label.autoadd_secstr"));
780 addSecondaryStructure.setBounds(new Rectangle(25, ypos, width, height));
781 structureTab.add(addSecondaryStructure);
784 addTempFactor.setFont(verdana11);
785 addTempFactor.setText(MessageManager.getString("label.autoadd_temp"));
786 addTempFactor.setBounds(new Rectangle(25, ypos, width, height));
787 structureTab.add(addTempFactor);
790 JLabel viewerLabel = new JLabel();
791 viewerLabel.setFont(verdana11);
792 viewerLabel.setHorizontalAlignment(SwingConstants.LEFT);
793 viewerLabel.setText(MessageManager.getString("label.structure_viewer"));
794 viewerLabel.setBounds(new Rectangle(10, ypos, 200, height));
795 structureTab.add(viewerLabel);
797 structViewer.setFont(verdana11);
798 structViewer.setBounds(new Rectangle(160, ypos, 120, height));
799 structViewer.addItem(ViewerType.JMOL.name());
800 structViewer.addItem(ViewerType.CHIMERA.name());
801 structViewer.addActionListener(new ActionListener()
804 public void actionPerformed(ActionEvent e)
806 structureViewer_actionPerformed((String) structViewer
810 structureTab.add(structViewer);
813 JLabel pathLabel = new JLabel();
814 pathLabel.setFont(new java.awt.Font("SansSerif", 0, 11));
815 pathLabel.setHorizontalAlignment(SwingConstants.LEFT);
816 pathLabel.setText(MessageManager.getString("label.chimera_path"));
817 final String tooltip = JvSwingUtils.wrapTooltip(true,
818 MessageManager.getString("label.chimera_path_tip"));
819 pathLabel.setToolTipText(tooltip);
820 pathLabel.setBounds(new Rectangle(10, ypos, 140, height));
821 structureTab.add(pathLabel);
823 chimeraPath.setFont(verdana11);
824 chimeraPath.setText("");
825 chimeraPath.setBounds(new Rectangle(160, ypos, 300, height));
826 chimeraPath.addMouseListener(new MouseAdapter()
829 public void mouseClicked(MouseEvent e)
831 if (e.getClickCount() == 2)
833 String chosen = openFileChooser();
836 chimeraPath.setText(chosen);
841 structureTab.add(chimeraPath);
847 * Action on choosing a structure viewer from combobox options.
849 * @param selectedItem
851 protected void structureViewer_actionPerformed(String selectedItem)
856 * Show a dialog for the user to choose a file. Returns the chosen path, or
861 protected String openFileChooser()
863 String choice = null;
864 JFileChooser chooser = new JFileChooser();
866 // chooser.setFileView(new JalviewFileView());
867 chooser.setDialogTitle(MessageManager
868 .getString("label.open_local_file"));
869 chooser.setToolTipText(MessageManager.getString("action.open"));
871 int value = chooser.showOpenDialog(this);
873 if (value == JFileChooser.APPROVE_OPTION)
875 choice = chooser.getSelectedFile().getPath();
881 * Validate the structure tab preferences; if invalid, set focus on this tab.
885 protected boolean validateStructure(FocusEvent e)
887 if (!validateStructure())
889 e.getComponent().requestFocusInWindow();
895 protected boolean validateStructure()
901 * Initialises the Visual tabbed panel.
905 private JPanel initVisualTab()
907 JPanel visualTab = new JPanel();
908 visualTab.setBorder(new TitledBorder(MessageManager
909 .getString("action.open_new_alignment")));
910 visualTab.setLayout(null);
911 fullScreen.setFont(verdana11);
912 fullScreen.setHorizontalAlignment(SwingConstants.RIGHT);
913 fullScreen.setHorizontalTextPosition(SwingConstants.LEFT);
914 fullScreen.setText(MessageManager.getString("label.maximize_window"));
915 quality.setEnabled(false);
916 quality.setFont(verdana11);
917 quality.setHorizontalAlignment(SwingConstants.RIGHT);
918 quality.setHorizontalTextPosition(SwingConstants.LEFT);
919 quality.setSelected(true);
920 quality.setText(MessageManager.getString("label.quality"));
921 conservation.setEnabled(false);
922 conservation.setFont(verdana11);
923 conservation.setHorizontalAlignment(SwingConstants.RIGHT);
924 conservation.setHorizontalTextPosition(SwingConstants.LEFT);
925 conservation.setSelected(true);
926 conservation.setText(MessageManager.getString("label.conservation"));
927 identity.setEnabled(false);
928 identity.setFont(verdana11);
929 identity.setHorizontalAlignment(SwingConstants.RIGHT);
930 identity.setHorizontalTextPosition(SwingConstants.LEFT);
931 identity.setSelected(true);
932 identity.setText(MessageManager.getString("label.consensus"));
933 JLabel showGroupbits = new JLabel();
934 showGroupbits.setFont(verdana11);
935 showGroupbits.setHorizontalAlignment(SwingConstants.RIGHT);
936 showGroupbits.setHorizontalTextPosition(SwingConstants.LEFT);
937 showGroupbits.setText(MessageManager.getString("action.show_group")
939 JLabel showConsensbits = new JLabel();
940 showConsensbits.setFont(verdana11);
941 showConsensbits.setHorizontalAlignment(SwingConstants.RIGHT);
942 showConsensbits.setHorizontalTextPosition(SwingConstants.LEFT);
943 showConsensbits.setText(MessageManager.getString("label.consensus")
945 showConsensHistogram.setEnabled(false);
946 showConsensHistogram.setFont(verdana11);
947 showConsensHistogram.setHorizontalAlignment(SwingConstants.RIGHT);
948 showConsensHistogram.setHorizontalTextPosition(SwingConstants.LEFT);
949 showConsensHistogram.setSelected(true);
950 showConsensHistogram.setText(MessageManager
951 .getString("label.histogram"));
952 showConsensLogo.setEnabled(false);
953 showConsensLogo.setFont(verdana11);
954 showConsensLogo.setHorizontalAlignment(SwingConstants.RIGHT);
955 showConsensLogo.setHorizontalTextPosition(SwingConstants.LEFT);
956 showConsensLogo.setSelected(true);
957 showConsensLogo.setText(MessageManager.getString("label.logo"));
958 showGroupConsensus.setEnabled(false);
959 showGroupConsensus.setFont(verdana11);
960 showGroupConsensus.setHorizontalAlignment(SwingConstants.RIGHT);
961 showGroupConsensus.setHorizontalTextPosition(SwingConstants.LEFT);
962 showGroupConsensus.setSelected(true);
963 showGroupConsensus.setText(MessageManager.getString("label.consensus"));
964 showGroupConservation.setEnabled(false);
965 showGroupConservation.setFont(verdana11);
966 showGroupConservation.setHorizontalAlignment(SwingConstants.RIGHT);
967 showGroupConservation.setHorizontalTextPosition(SwingConstants.LEFT);
968 showGroupConservation.setSelected(true);
969 showGroupConservation.setText(MessageManager
970 .getString("label.conservation"));
971 showNpTooltip.setEnabled(true);
972 showNpTooltip.setFont(verdana11);
973 showNpTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
974 showNpTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
975 showNpTooltip.setSelected(true);
976 showNpTooltip.setText(MessageManager
977 .getString("label.non_positional_features"));
978 showDbRefTooltip.setEnabled(true);
979 showDbRefTooltip.setFont(verdana11);
980 showDbRefTooltip.setHorizontalAlignment(SwingConstants.RIGHT);
981 showDbRefTooltip.setHorizontalTextPosition(SwingConstants.LEFT);
982 showDbRefTooltip.setSelected(true);
983 showDbRefTooltip.setText(MessageManager
984 .getString("label.database_references"));
985 annotations.setFont(verdana11);
986 annotations.setHorizontalAlignment(SwingConstants.RIGHT);
987 annotations.setHorizontalTextPosition(SwingConstants.LEADING);
988 annotations.setSelected(true);
989 annotations.setText(MessageManager.getString("label.show_annotations"));
990 annotations.setBounds(new Rectangle(169, 12, 200, 23));
991 annotations.addActionListener(new ActionListener()
993 public void actionPerformed(ActionEvent e)
995 annotations_actionPerformed(e);
998 identity.addActionListener(new ActionListener()
1000 public void actionPerformed(ActionEvent e)
1002 annotations_actionPerformed(e);
1005 showGroupConsensus.addActionListener(new ActionListener()
1007 public void actionPerformed(ActionEvent e)
1009 annotations_actionPerformed(e);
1012 showUnconserved.setFont(verdana11);
1013 showUnconserved.setHorizontalAlignment(SwingConstants.RIGHT);
1014 showUnconserved.setHorizontalTextPosition(SwingConstants.LEFT);
1015 showUnconserved.setSelected(true);
1016 showUnconserved.setText(MessageManager
1017 .getString("action.show_unconserved"));
1018 showUnconserved.addActionListener(new ActionListener()
1020 public void actionPerformed(ActionEvent e)
1022 showunconserved_actionPerformed(e);
1026 // TODO these are not yet added to / action from Preferences
1027 // JCheckBox shareSelections = new JCheckBox();
1028 // shareSelections.setFont(verdana11);
1029 // shareSelections.setHorizontalAlignment(SwingConstants.RIGHT);
1030 // shareSelections.setHorizontalTextPosition(SwingConstants.LEFT);
1031 // shareSelections.setSelected(true);
1032 // shareSelections.setText(MessageManager
1033 // .getString("label.share_selection_across_views"));
1034 // JCheckBox followHighlight = new JCheckBox();
1035 // followHighlight.setFont(verdana11);
1036 // followHighlight.setHorizontalAlignment(SwingConstants.RIGHT);
1037 // followHighlight.setHorizontalTextPosition(SwingConstants.LEFT);
1038 // // showUnconserved.setBounds(new Rectangle(169, 40, 200, 23));
1039 // followHighlight.setSelected(true);
1040 // followHighlight.setText(MessageManager
1041 // .getString("label.scroll_highlighted_regions"));
1043 seqLimit.setFont(verdana11);
1044 seqLimit.setHorizontalAlignment(SwingConstants.RIGHT);
1045 seqLimit.setHorizontalTextPosition(SwingConstants.LEFT);
1046 seqLimit.setText(MessageManager.getString("label.full_sequence_id"));
1047 smoothFont.setFont(verdana11);
1048 smoothFont.setHorizontalAlignment(SwingConstants.RIGHT);
1049 smoothFont.setHorizontalTextPosition(SwingConstants.LEADING);
1050 smoothFont.setText(MessageManager.getString("label.smooth_font"));
1051 JLabel gapLabel = new JLabel();
1052 gapLabel.setFont(verdana11);
1053 gapLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1054 gapLabel.setText(MessageManager.getString("label.gap_symbol") + " ");
1055 JLabel fontLabel = new JLabel();
1056 fontLabel.setFont(verdana11);
1057 fontLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1058 fontLabel.setText(MessageManager.getString("label.font"));
1059 fontSizeCB.setFont(verdana11);
1060 fontSizeCB.setBounds(new Rectangle(320, 104, 65, 23));
1061 fontStyleCB.setFont(verdana11);
1062 fontStyleCB.setBounds(new Rectangle(382, 104, 80, 23));
1063 fontNameCB.setFont(verdana11);
1064 fontNameCB.setBounds(new Rectangle(172, 104, 147, 23));
1065 gapSymbolCB.setFont(verdana11);
1066 gapSymbolCB.setBounds(new Rectangle(172, 196, 69, 23));
1067 DefaultListCellRenderer dlcr = new DefaultListCellRenderer();
1068 dlcr.setHorizontalAlignment(DefaultListCellRenderer.CENTER);
1069 gapSymbolCB.setRenderer(dlcr);
1071 startupCheckbox.setText(MessageManager.getString("action.open_file"));
1072 startupCheckbox.setFont(verdana11);
1073 startupCheckbox.setHorizontalAlignment(SwingConstants.RIGHT);
1074 startupCheckbox.setHorizontalTextPosition(SwingConstants.LEFT);
1075 startupCheckbox.setSelected(true);
1076 startupFileTextfield.setFont(verdana11);
1077 startupFileTextfield.setBounds(new Rectangle(172, 290, 270, 20));
1078 startupFileTextfield.addMouseListener(new MouseAdapter()
1080 public void mouseClicked(MouseEvent e)
1082 if (e.getClickCount() > 1)
1084 startupFileTextfield_mouseClicked();
1089 sortby.setFont(verdana11);
1090 sortby.setBounds(new Rectangle(172, 240, 155, 21));
1091 JLabel sortLabel = new JLabel();
1092 sortLabel.setFont(verdana11);
1093 sortLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1094 sortLabel.setText(MessageManager.getString("label.sort_by"));
1095 sortAnnBy.setFont(verdana11);
1096 sortAnnBy.setBounds(new Rectangle(172, 265, 110, 21));
1097 JLabel sortAnnLabel = new JLabel();
1098 sortAnnLabel.setFont(verdana11);
1099 sortAnnLabel.setHorizontalAlignment(SwingConstants.RIGHT);
1100 sortAnnLabel.setText(MessageManager.getString("label.sort_ann_by"));
1101 sortAutocalc.setFont(verdana11);
1102 sortAutocalc.setBounds(new Rectangle(290, 265, 165, 21));
1103 JPanel annsettingsPanel = new JPanel();
1104 annsettingsPanel.setBounds(new Rectangle(173, 34, 300, 61));
1105 annsettingsPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0));
1106 JPanel autoAnnotSettings1 = new JPanel();
1107 autoAnnotSettings1.setLayout(new GridLayout(3, 1, 0, 0));
1108 annsettingsPanel.add(autoAnnotSettings1);
1109 JPanel autoAnnotSettings2 = new JPanel();
1110 autoAnnotSettings2.setLayout(new GridLayout(3, 1, 0, 0));
1111 annsettingsPanel.add(autoAnnotSettings2);
1112 JPanel autoAnnotSettings3 = new JPanel();
1113 autoAnnotSettings3.setLayout(new GridLayout(3, 1, 0, 0));
1114 annsettingsPanel.add(autoAnnotSettings3);
1115 visualTab.add(annsettingsPanel);
1116 Border jb = new EmptyBorder(1, 1, 4, 5);
1117 quality.setBorder(jb);
1118 conservation.setBorder(jb);
1119 identity.setBorder(jb);
1120 showConsensbits.setBorder(jb);
1121 showGroupbits.setBorder(jb);
1122 showGroupConsensus.setBorder(jb);
1123 showGroupConservation.setBorder(jb);
1124 showConsensHistogram.setBorder(jb);
1125 showConsensLogo.setBorder(jb);
1127 autoAnnotSettings2.add(conservation);
1128 autoAnnotSettings1.add(quality);
1129 autoAnnotSettings3.add(identity);
1130 autoAnnotSettings1.add(showGroupbits);
1131 autoAnnotSettings3.add(showGroupConsensus);
1132 autoAnnotSettings2.add(showGroupConservation);
1133 autoAnnotSettings1.add(showConsensbits);
1134 autoAnnotSettings2.add(showConsensHistogram);
1135 autoAnnotSettings3.add(showConsensLogo);
1137 JPanel tooltipSettings = new JPanel();
1138 tooltipSettings.setBorder(new TitledBorder(MessageManager
1139 .getString("label.sequence_id_tooltip")));
1140 tooltipSettings.setBounds(173, 130, 200, 62);
1141 tooltipSettings.setLayout(new GridLayout(2, 1));
1142 tooltipSettings.add(showDbRefTooltip);
1143 tooltipSettings.add(showNpTooltip);
1144 visualTab.add(tooltipSettings);
1146 wrap.setFont(verdana11);
1147 wrap.setHorizontalAlignment(SwingConstants.TRAILING);
1148 wrap.setHorizontalTextPosition(SwingConstants.LEADING);
1149 wrap.setText(MessageManager.getString("label.wrap_alignment"));
1150 rightAlign.setFont(verdana11);
1151 rightAlign.setForeground(Color.black);
1152 rightAlign.setHorizontalAlignment(SwingConstants.RIGHT);
1153 rightAlign.setHorizontalTextPosition(SwingConstants.LEFT);
1154 rightAlign.setText(MessageManager.getString("label.right_align_ids"));
1155 idItalics.setFont(verdana11);
1156 idItalics.setHorizontalAlignment(SwingConstants.RIGHT);
1157 idItalics.setHorizontalTextPosition(SwingConstants.LEADING);
1158 idItalics.setText(MessageManager
1159 .getString("label.sequence_name_italics"));
1160 openoverv.setFont(verdana11);
1161 openoverv.setActionCommand(MessageManager
1162 .getString("label.open_overview"));
1163 openoverv.setHorizontalAlignment(SwingConstants.RIGHT);
1164 openoverv.setHorizontalTextPosition(SwingConstants.LEFT);
1165 openoverv.setText(MessageManager.getString(("label.open_overview")));
1166 JPanel jPanel2 = new JPanel();
1167 jPanel2.setBounds(new Rectangle(7, 17, 158, 297));
1168 GridLayout gridLayout2 = new GridLayout();
1169 jPanel2.setLayout(gridLayout2);
1170 gridLayout2.setRows(13);
1171 jPanel2.add(fullScreen);
1172 jPanel2.add(openoverv);
1173 jPanel2.add(seqLimit);
1174 jPanel2.add(rightAlign);
1175 jPanel2.add(fontLabel);
1176 jPanel2.add(showUnconserved);
1177 jPanel2.add(idItalics);
1178 jPanel2.add(smoothFont);
1179 jPanel2.add(gapLabel);
1181 jPanel2.add(sortLabel);
1182 jPanel2.add(sortAnnLabel);
1183 jPanel2.add(startupCheckbox);
1184 visualTab.add(jPanel2);
1185 visualTab.add(annotations);
1186 visualTab.add(startupFileTextfield);
1187 visualTab.add(sortby);
1188 visualTab.add(sortAnnBy);
1189 visualTab.add(sortAutocalc);
1190 visualTab.add(gapSymbolCB);
1191 visualTab.add(fontNameCB);
1192 visualTab.add(fontSizeCB);
1193 visualTab.add(fontStyleCB);
1197 protected void autoIdWidth_actionPerformed()
1199 // TODO Auto-generated method stub
1203 protected void userIdWidth_actionPerformed()
1205 // TODO Auto-generated method stub
1209 protected void maxColour_actionPerformed(JPanel panel)
1213 protected void minColour_actionPerformed(JPanel panel)
1217 protected void showunconserved_actionPerformed(ActionEvent e)
1219 // TODO Auto-generated method stub
1229 public void ok_actionPerformed(ActionEvent e)
1239 public void cancel_actionPerformed(ActionEvent e)
1249 public void annotations_actionPerformed(ActionEvent e)
1256 public void startupFileTextfield_mouseClicked()
1260 public void newLink_actionPerformed(ActionEvent e)
1265 public void editLink_actionPerformed(ActionEvent e)
1270 public void deleteLink_actionPerformed(ActionEvent e)
1275 public void defaultBrowser_mouseClicked(MouseEvent e)
1280 public void linkURLList_keyTyped(KeyEvent e)
1285 public void useProxy_actionPerformed()
1287 proxyServerTB.setEnabled(useProxy.isSelected());
1288 proxyPortTB.setEnabled(useProxy.isSelected());