X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureTypeSettings.java;h=c5727989006a100a4ff3c7179a47e83f8e23115a;hb=5b126eb259ecff2dce5c024066ced2528d87d39a;hp=c3567315ab2564ad590d06ae805777f972a527a4;hpb=761ad3f4f8408cee61c932d926532e186d71b95d;p=jalview.git diff --git a/src/jalview/gui/FeatureTypeSettings.java b/src/jalview/gui/FeatureTypeSettings.java index c356731..c572798 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.SwingConstants; import javax.swing.border.LineBorder; @@ -107,7 +106,8 @@ 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 @@ -155,7 +155,12 @@ public class FeatureTypeSettings extends JalviewDialog private JRadioButton graduatedColour = new JRadioButton(); - private JPanel singleColour = new JPanel(); + /** + * colours and filters are shown in tabbed view or single content pane + */ + JPanel coloursPanel, filtersPanel; + + JPanel singleColour = new JPanel(); private JPanel minColour = new JPanel(); @@ -199,13 +204,8 @@ public class FeatureTypeSettings extends JalviewDialog */ private List filters; - // set white normally, black to debug layout - private Color debugBorderColour = Color.white; - private JPanel chooseFiltersPanel; - private JTabbedPane tabbedPane; - /** * Constructor * @@ -256,7 +256,7 @@ public class FeatureTypeSettings extends JalviewDialog String title = MessageManager .formatMessage("label.display_settings_for", new String[] { theType }); - initDialogFrame(this, true, blocking, title, 600, 360); + initDialogFrame(this, true, blocking, title, 500, 500); waitForInput(); } @@ -295,8 +295,8 @@ public class FeatureTypeSettings extends JalviewDialog if (fc.isColourByAttribute()) { String[] attributeName = fc.getAttributeName(); - colourByTextCombo - .setSelectedItem(toAttributeDisplayName(attributeName)); + colourByTextCombo.setSelectedItem( + FeatureMatcher.toAttributeDisplayName(attributeName)); } else { @@ -325,6 +325,7 @@ public class FeatureTypeSettings extends JalviewDialog * Graduated colour, by score or attribute value range */ graduatedColour.setSelected(true); + updateColourMinMax(); // ensure min, max are set colourByRangeCombo.setEnabled(colourByRangeCombo.getItemCount() > 1); minColour.setEnabled(true); maxColour.setEnabled(true); @@ -336,8 +337,8 @@ public class FeatureTypeSettings extends JalviewDialog if (fc.isColourByAttribute()) { String[] attributeName = fc.getAttributeName(); - colourByRangeCombo - .setSelectedItem(toAttributeDisplayName(attributeName)); + colourByRangeCombo.setSelectedItem( + FeatureMatcher.toAttributeDisplayName(attributeName)); } else { @@ -402,8 +403,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 @@ -418,18 +417,16 @@ public class FeatureTypeSettings extends JalviewDialog }; /* - * first tab: colour options + * first panel/tab: colour options */ JPanel coloursPanel = initialiseColoursPanel(); - tabbedPane.addTab(MessageManager.getString("action.colour"), - coloursPanel); + this.add(coloursPanel, BorderLayout.NORTH); /* - * second tab: filter options + * second panel/tab: filter options */ JPanel filtersPanel = initialiseFiltersPanel(); - tabbedPane.addTab(MessageManager.getString("label.filters"), - filtersPanel); + this.add(filtersPanel, BorderLayout.CENTER); JPanel okCancelPanel = initialiseOkCancelPanel(); @@ -478,7 +475,7 @@ public class FeatureTypeSettings extends JalviewDialog { // colour by attribute range minMax = FeatureAttributes.getInstance().getMinMax(featureType, - fromAttributeDisplayName(attName)); + FeatureMatcher.fromAttributeDisplayName(attName)); } return minMax; } @@ -735,15 +732,18 @@ 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); +// JvSwingUtils.createTitledBorder(simpleColourPanel, +// MessageManager.getString("label.simple"), true); colourByPanel.add(simpleColourPanel); simpleColour = new JRadioButton( @@ -761,7 +761,7 @@ public class FeatureTypeSettings extends JalviewDialog } }); - + singleColour.setFont(JvSwingUtils.getLabelFont()); singleColour.setBorder(BorderFactory.createLineBorder(Color.black)); singleColour.setPreferredSize(new Dimension(40, 20)); @@ -848,9 +848,9 @@ public class FeatureTypeSettings extends JalviewDialog } /** - * 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 */ @@ -907,7 +907,8 @@ public class FeatureTypeSettings extends JalviewDialog String byWhat = (String) colourByTextCombo.getSelectedItem(); if (!LABEL_18N.equals(byWhat)) { - fc.setAttributeName(fromAttributeDisplayName(byWhat)); + fc.setAttributeName( + FeatureMatcher.fromAttributeDisplayName(byWhat)); } return fc; } @@ -964,7 +965,7 @@ public class FeatureTypeSettings extends JalviewDialog String byWhat = (String) colourByRangeCombo.getSelectedItem(); if (!SCORE_18N.equals(byWhat)) { - fc.setAttributeName(fromAttributeDisplayName(byWhat)); + fc.setAttributeName(FeatureMatcher.fromAttributeDisplayName(byWhat)); } /* @@ -989,30 +990,6 @@ public class FeatureTypeSettings extends JalviewDialog return fc; } - /** - * A helper method that converts a 'compound' attribute name from its display - * form, e.g. CSQ:PolyPhen to array form, e.g. { "CSQ", "PolyPhen" } - * - * @param attribute - * @return - */ - private String[] fromAttributeDisplayName(String attribute) - { - return attribute == null ? null : attribute.split(COLON); - } - - /** - * A helper method that converts a 'compound' attribute name to its display - * form, e.g. CSQ:PolyPhen from its array form, e.g. { "CSQ", "PolyPhen" } - * - * @param attName - * @return - */ - private String toAttributeDisplayName(String[] attName) - { - return attName == null ? "" : String.join(COLON, attName); - } - @Override protected void raiseClosed() { @@ -1087,8 +1064,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 */ @@ -1111,11 +1088,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. @@ -1159,7 +1136,7 @@ public class FeatureTypeSettings extends JalviewDialog { continue; } - displayAtts.add(toAttributeDisplayName(attName)); + displayAtts.add(FeatureMatcher.toAttributeDisplayName(attName)); String desc = fa.getDescription(featureType, attName); if (desc != null && desc.length() > MAX_TOOLTIP_LENGTH) { @@ -1210,7 +1187,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() @@ -1293,7 +1269,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++; } @@ -1305,7 +1280,8 @@ public class FeatureTypeSettings extends JalviewDialog /** * A helper method that constructs a row (panel) with one filter condition: *