X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fgui%2FFeatureTypeSettings.java;h=01ef48c0ed8bdd3b79ba58f8c25fd872929652f5;hb=d5888333a51923fe86a35262e11be07c22e2798b;hp=6eb583c5ba046f110e6364a271d148ef4f7f984e;hpb=4507753620a54ccb8eb3ce11df9f149e7a2d8a64;p=jalview.git diff --git a/src/jalview/gui/FeatureTypeSettings.java b/src/jalview/gui/FeatureTypeSettings.java index 6eb583c..01ef48c 100644 --- a/src/jalview/gui/FeatureTypeSettings.java +++ b/src/jalview/gui/FeatureTypeSettings.java @@ -199,13 +199,11 @@ 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; - + // for alternative 2 tabs layout (Colour, Filters) +// private JTabbedPane tabbedPane; + /** * Constructor * @@ -256,7 +254,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(); } @@ -403,8 +401,8 @@ public class FeatureTypeSettings extends JalviewDialog private void initialise() { this.setLayout(new BorderLayout()); - tabbedPane = new JTabbedPane(); - this.add(tabbedPane, BorderLayout.CENTER); +// tabbedPane = new JTabbedPane(); +// this.add(tabbedPane, BorderLayout.CENTER); /* * an ActionListener that applies colour changes @@ -419,18 +417,20 @@ public class FeatureTypeSettings extends JalviewDialog }; /* - * first tab: colour options + * first panel/tab: colour options */ JPanel coloursPanel = initialiseColoursPanel(); - tabbedPane.addTab(MessageManager.getString("action.colour"), - coloursPanel); +// 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); +// tabbedPane.addTab(MessageManager.getString("label.filters"), +// filtersPanel); + this.add(filtersPanel, BorderLayout.CENTER); JPanel okCancelPanel = initialiseOkCancelPanel(); @@ -736,15 +736,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( @@ -1188,7 +1191,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() @@ -1271,7 +1273,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++; } @@ -1414,7 +1415,7 @@ public class FeatureTypeSettings extends JalviewDialog * if a numeric condition is selected, show the value range * as a tooltip on the value input field */ - setPatternTooltip(filterBy, selectedCondition, patternField); + setNumericHints(filterBy, selectedCondition, patternField); /* * add remove button if filter is populated (non-empty pattern) @@ -1469,14 +1470,19 @@ public class FeatureTypeSettings extends JalviewDialog } /** - * If a numeric comparison condition is selected, retrieve the min-max range for - * the value (score or attribute), and set it as a tooltip on the value file + * If a numeric comparison condition is selected, retrieves the min-max range + * for the value (score or attribute), and sets it as a tooltip on the value + * field. If the field is currently empty, then pre-populates it with + * * * @param attName * @param selectedCondition * @param patternField */ - private void setPatternTooltip(String attName, + private void setNumericHints(String attName, Condition selectedCondition, JTextField patternField) { patternField.setToolTipText(""); @@ -1486,9 +1492,26 @@ public class FeatureTypeSettings extends JalviewDialog float[] minMax = getMinMax(attName); if (minMax != null) { - String tip = String.format("(%s - %s)", - DECFMT_2_2.format(minMax[0]), DECFMT_2_2.format(minMax[1])); + String minFormatted = DECFMT_2_2.format(minMax[0]); + String maxFormatted = DECFMT_2_2.format(minMax[1]); + String tip = String.format("(%s - %s)", minFormatted, maxFormatted); patternField.setToolTipText(tip); + if (patternField.getText().isEmpty()) + { + if (selectedCondition == Condition.GE + || selectedCondition == Condition.GT) + { + patternField.setText(minFormatted); + } + else + { + if (selectedCondition == Condition.LE + || selectedCondition == Condition.LT) + { + patternField.setText(maxFormatted); + } + } + } } } } @@ -1525,10 +1548,11 @@ public class FeatureTypeSettings extends JalviewDialog ItemListener listener = condCombo.getItemListeners()[0]; condCombo.removeItemListener(listener); boolean condIsValid = false; + condCombo.removeAllItems(); for (Condition c : Condition.values()) { - if ((c.isNumeric() && type != Datatype.Character) + if ((c.isNumeric() && type == Datatype.Number) || (!c.isNumeric() && type != Datatype.Number)) { condCombo.addItem(c); @@ -1551,8 +1575,6 @@ public class FeatureTypeSettings extends JalviewDialog condCombo.setSelectedIndex(0); } - condCombo.addItemListener(listener); - /* * clear pattern if it is now invalid for condition */ @@ -1570,6 +1592,11 @@ public class FeatureTypeSettings extends JalviewDialog patternField.setText(""); } } + + /* + * restore the listener + */ + condCombo.addItemListener(listener); } /** @@ -1646,7 +1673,7 @@ public class FeatureTypeSettings extends JalviewDialog Condition cond = (Condition) condCombo.getSelectedItem(); String pattern = valueField.getText().trim(); - setPatternTooltip(attName, cond, valueField); + setNumericHints(attName, cond, valueField); if (pattern.length() == 0 && cond.needsAPattern()) { @@ -1686,7 +1713,7 @@ public class FeatureTypeSettings extends JalviewDialog public void showTab(boolean coloursTab) { setVisible(true); - tabbedPane.setSelectedIndex(coloursTab ? 0 : 1); +// tabbedPane.setSelectedIndex(coloursTab ? 0 : 1); } /**