X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureTypeSettings.java;h=f59aa59cccf26e217ecdc2cbb8277dd60899a5f6;hb=2bd87d696f010a6364fca99c3137d6a06b9af23b;hp=5169dfbd8d3bb7dd112a7c14a2df854fd616109c;hpb=217274a8e9ea2ae20d5a6d21989b8b16840ca6f0;p=jalview.git diff --git a/src/jalview/gui/FeatureTypeSettings.java b/src/jalview/gui/FeatureTypeSettings.java index 5169dfb..f59aa59 100644 --- a/src/jalview/gui/FeatureTypeSettings.java +++ b/src/jalview/gui/FeatureTypeSettings.java @@ -62,7 +62,6 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JRadioButton; import javax.swing.JSlider; -import javax.swing.JTabbedPane; import javax.swing.JTextField; import javax.swing.border.LineBorder; import javax.swing.event.ChangeEvent; @@ -105,14 +104,15 @@ public class FeatureTypeSettings extends JalviewDialog /* * FeatureRenderer holds colour scheme and filters for feature types */ - private final FeatureRenderer fr; // todo refactor to allow interface type here + private final FeatureRenderer fr; // todo refactor to allow interface type + // here /* * the view panel to update when settings change */ final AlignmentViewPanel ap; - private final String featureType; + final String featureType; /* * the colour and filters to reset to on Cancel @@ -153,6 +153,10 @@ public class FeatureTypeSettings extends JalviewDialog JRadioButton graduatedColour = new JRadioButton(); + JPanel coloursPanel; + + JPanel filtersPanel; + JPanel singleColour = new JPanel(); JPanel minColour = new JPanel(); @@ -197,13 +201,8 @@ public class FeatureTypeSettings extends JalviewDialog */ List filters; - // set white normally, black to debug layout - private Color debugBorderColour = Color.white; - private JPanel chooseFiltersPanel; - private JTabbedPane tabbedPane; - /** * Constructor * @@ -212,28 +211,14 @@ public class FeatureTypeSettings extends JalviewDialog */ public FeatureTypeSettings(FeatureRenderer frender, String theType) { - this(frender, false, theType); - } - - /** - * Constructor, with option to make a blocking dialog (has to complete in the - * AWT event queue thread). Currently this option is always set to false. - * - * @param frender - * @param blocking - * @param theType - */ - FeatureTypeSettings(FeatureRenderer frender, boolean blocking, - String theType) - { this.fr = frender; this.featureType = theType; ap = fr.ap; originalFilter = fr.getFeatureFilter(theType); originalColour = fr.getFeatureColours().get(theType); - + adjusting = true; - + try { initialise(); @@ -242,28 +227,27 @@ public class FeatureTypeSettings extends JalviewDialog ex.printStackTrace(); return; } - - updateColoursTab(); - - updateFiltersTab(); - + + updateColoursPanel(); + + updateFiltersPanel(); + adjusting = false; - + colourChanged(false); - + String title = MessageManager .formatMessage("label.display_settings_for", new String[] { theType }); - initDialogFrame(this, true, blocking, title, 600, 360); - + initDialogFrame(this, true, false, title, 580, 500); waitForInput(); } /** - * Configures the widgets on the Colours tab according to the current feature + * Configures the widgets on the Colours panel according to the current feature * colour scheme */ - private void updateColoursTab() + private void updateColoursPanel() { FeatureColourI fc = fr.getFeatureColours().get(featureType); @@ -278,9 +262,9 @@ public class FeatureTypeSettings extends JalviewDialog */ if (fc.isSimpleColour()) { - simpleColour.setSelected(true); singleColour.setBackground(fc.getColour()); singleColour.setForeground(fc.getColour()); + simpleColour.setSelected(true); } /* @@ -401,8 +385,6 @@ public class FeatureTypeSettings extends JalviewDialog private void initialise() { this.setLayout(new BorderLayout()); - tabbedPane = new JTabbedPane(); - this.add(tabbedPane, BorderLayout.CENTER); /* * an ActionListener that applies colour changes @@ -417,18 +399,16 @@ public class FeatureTypeSettings extends JalviewDialog }; /* - * first tab: colour options + * first panel: colour options */ JPanel coloursPanel = initialiseColoursPanel(); - tabbedPane.addTab(MessageManager.getString("action.colour"), - coloursPanel); + this.add(coloursPanel, BorderLayout.NORTH); /* - * second tab: filter options + * second panel: filter options */ JPanel filtersPanel = initialiseFiltersPanel(); - tabbedPane.addTab(MessageManager.getString("label.filters"), - filtersPanel); + this.add(filtersPanel, BorderLayout.CENTER); JPanel okCancelPanel = initialiseOkCancelPanel(); @@ -556,7 +536,8 @@ public class FeatureTypeSettings extends JalviewDialog { if (minColour.isEnabled()) { - showColourChooser(minColour, "label.select_colour_minimum_value"); + String ttl = MessageManager.getString("label.select_colour_minimum_value"); + showColourChooser(minColour, ttl); } } }); @@ -572,19 +553,19 @@ public class FeatureTypeSettings extends JalviewDialog { if (maxColour.isEnabled()) { - showColourChooser(maxColour, "label.select_colour_maximum_value"); + String ttl = MessageManager.getString("label.select_colour_maximum_value"); + showColourChooser(maxColour, ttl); } } }); maxColour.setBorder(new LineBorder(Color.black)); /* - * default max colour to current colour (if a plain colour), - * or to Black if colour by label; make min colour a pale - * version of max colour + * default max colour to last plain colour; + * make min colour a pale version of max colour */ FeatureColourI fc = fr.getFeatureColours().get(featureType); - Color bg = fc.isSimpleColour() ? fc.getColour() : Color.BLACK; + Color bg = fc.getColour() == null ? Color.BLACK : fc.getColour(); maxColour.setBackground(bg); minColour.setBackground(ColorUtils.bleachColour(bg, 0.9f)); @@ -734,15 +715,16 @@ public class FeatureTypeSettings extends JalviewDialog private JPanel initialiseColoursPanel() { JPanel colourByPanel = new JPanel(); + colourByPanel.setBackground(Color.white); colourByPanel.setLayout(new BoxLayout(colourByPanel, BoxLayout.Y_AXIS)); + JvSwingUtils.createTitledBorder(colourByPanel, + MessageManager.getString("action.colour"), true); /* * simple colour radio button and colour picker */ JPanel simpleColourPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); simpleColourPanel.setBackground(Color.white); - JvSwingUtils.createTitledBorder(simpleColourPanel, - MessageManager.getString("label.simple"), true); colourByPanel.add(simpleColourPanel); simpleColour = new JRadioButton( @@ -755,14 +737,24 @@ public class FeatureTypeSettings extends JalviewDialog { if (simpleColour.isSelected() && !adjusting) { - showColourChooser(singleColour, "label.select_colour"); + colourChanged(true); } } }); - + singleColour.setFont(JvSwingUtils.getLabelFont()); singleColour.setBorder(BorderFactory.createLineBorder(Color.black)); singleColour.setPreferredSize(new Dimension(40, 20)); + if (originalColour.isGraduatedColour()) + { + singleColour.setBackground(originalColour.getMaxColour()); + singleColour.setForeground(originalColour.getMaxColour()); + } + else + { + singleColour.setBackground(originalColour.getColour()); + singleColour.setForeground(originalColour.getColour()); + } singleColour.addMouseListener(new MouseAdapter() { @Override @@ -770,7 +762,8 @@ public class FeatureTypeSettings extends JalviewDialog { if (simpleColour.isSelected()) { - showColourChooser(singleColour, "label.select_colour"); + String ttl = MessageManager.formatMessage("label.select_colour_for", featureType); + showColourChooser(singleColour, ttl); } } }); @@ -838,10 +831,9 @@ public class FeatureTypeSettings extends JalviewDialog * * @param colourPanel * the panel whose background colour is being picked - * @param key - * message bundle key for the dialog title + * @param title */ - void showColourChooser(JPanel colourPanel, String key) + void showColourChooser(JPanel colourPanel, String title) { ColourChooserListener listener = new ColourChooserListener() { @@ -854,14 +846,14 @@ public class FeatureTypeSettings extends JalviewDialog colourChanged(true); } }; - JalviewColourChooser.showColourChooser(this, MessageManager.getString(key), - colourPanel.getBackground(), listener); + JalviewColourChooser.showColourChooser(this, title, + colourPanel.getBackground(), listener); } /** - * Constructs and sets the selected colour options as the colour for the feature - * type, and repaints the alignment, and optionally the Overview and/or - * structure viewer if open + * Constructs and sets the selected colour options as the colour for the + * feature type, and repaints the alignment, and optionally the Overview + * and/or structure viewer if open * * @param updateStructsAndOverview */ @@ -889,7 +881,7 @@ public class FeatureTypeSettings extends JalviewDialog fr.setColour(featureType, acg); ap.paintAlignment(updateStructsAndOverview, updateStructsAndOverview); - updateColoursTab(); + updateColoursPanel(); } /** @@ -912,8 +904,8 @@ public class FeatureTypeSettings extends JalviewDialog */ if (byCategory.isSelected()) { - Color c = this.getBackground(); - FeatureColourI fc = new FeatureColour(c, c, null, 0f, 0f); + Color c = singleColour.getBackground(); + FeatureColourI fc = new FeatureColour(c); fc.setColourByLabel(true); String byWhat = (String) colourByTextCombo.getSelectedItem(); if (!LABEL_18N.equals(byWhat)) @@ -1075,8 +1067,8 @@ public class FeatureTypeSettings extends JalviewDialog /** * Converts the slider value to its absolute value by dividing by the - * scaleFactor. Rounding errors are squashed by forcing min/max of slider range - * to the actual min/max of feature score range + * scaleFactor. Rounding errors are squashed by forcing min/max of slider + * range to the actual min/max of feature score range * * @return */ @@ -1099,11 +1091,11 @@ public class FeatureTypeSettings extends JalviewDialog } /** - * A helper method to build the drop-down choice of attributes for a feature. If - * 'withRange' is true, then Score, and any attributes with a min-max range, are - * added. If 'withText' is true, Label and any known attributes are added. This - * allows 'categorical numerical' attributes e.g. codon position to be coloured - * by text. + * A helper method to build the drop-down choice of attributes for a feature. + * If 'withRange' is true, then Score, and any attributes with a min-max + * range, are added. If 'withText' is true, Label and any known attributes are + * added. This allows 'categorical numerical' attributes e.g. codon position + * to be coloured by text. *

* Where metadata is available with a description for an attribute, that is * added as a tooltip. @@ -1198,7 +1190,6 @@ public class FeatureTypeSettings extends JalviewDialog { JPanel andOrPanel = new JPanel(new FlowLayout(FlowLayout.LEFT)); andOrPanel.setBackground(Color.white); - andOrPanel.setBorder(BorderFactory.createLineBorder(debugBorderColour)); andFilters = new JRadioButton(MessageManager.getString("label.and")); orFilters = new JRadioButton(MessageManager.getString("label.or")); ActionListener actionListener = new ActionListener() @@ -1228,7 +1219,7 @@ public class FeatureTypeSettings extends JalviewDialog * for adding a condition. This should be called after a filter has been * removed, added or amended. */ - private void updateFiltersTab() + private void updateFiltersPanel() { /* * clear the panel and list of filter conditions @@ -1286,7 +1277,6 @@ public class FeatureTypeSettings extends JalviewDialog for (FeatureMatcherI filter : filters) { JPanel row = addFilter(filter, attNames, filterIndex); - row.setBorder(BorderFactory.createLineBorder(debugBorderColour)); chooseFiltersPanel.add(row); filterIndex++; } @@ -1298,7 +1288,8 @@ public class FeatureTypeSettings extends JalviewDialog /** * A helper method that constructs a row (panel) with one filter condition: *