*/
private List<FeatureMatcherI> 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
*
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();
}
if (fc.isColourByAttribute())
{
String[] attributeName = fc.getAttributeName();
- colourByTextCombo
- .setSelectedItem(toAttributeDisplayName(attributeName));
+ colourByTextCombo.setSelectedItem(
+ FeatureMatcher.toAttributeDisplayName(attributeName));
}
else
{
* 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);
if (fc.isColourByAttribute())
{
String[] attributeName = fc.getAttributeName();
- colourByRangeCombo
- .setSelectedItem(toAttributeDisplayName(attributeName));
+ colourByRangeCombo.setSelectedItem(
+ FeatureMatcher.toAttributeDisplayName(attributeName));
}
else
{
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
};
/*
- * 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();
{
// colour by attribute range
minMax = FeatureAttributes.getInstance().getMinMax(featureType,
- fromAttributeDisplayName(attName));
+ FeatureMatcher.fromAttributeDisplayName(attName));
}
return minMax;
}
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(
String byWhat = (String) colourByTextCombo.getSelectedItem();
if (!LABEL_18N.equals(byWhat))
{
- fc.setAttributeName(fromAttributeDisplayName(byWhat));
+ fc.setAttributeName(
+ FeatureMatcher.fromAttributeDisplayName(byWhat));
}
return fc;
}
String byWhat = (String) colourByRangeCombo.getSelectedItem();
if (!SCORE_18N.equals(byWhat))
{
- fc.setAttributeName(fromAttributeDisplayName(byWhat));
+ fc.setAttributeName(FeatureMatcher.fromAttributeDisplayName(byWhat));
}
/*
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()
{
{
continue;
}
- displayAtts.add(toAttributeDisplayName(attName));
+ displayAtts.add(FeatureMatcher.toAttributeDisplayName(attName));
String desc = fa.getDescription(featureType, attName);
if (desc != null && desc.length() > MAX_TOOLTIP_LENGTH)
{
{
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()
for (FeatureMatcherI filter : filters)
{
JPanel row = addFilter(filter, attNames, filterIndex);
- row.setBorder(BorderFactory.createLineBorder(debugBorderColour));
chooseFiltersPanel.add(row);
filterIndex++;
}
}
else
{
- attCombo.setSelectedItem(toAttributeDisplayName(attName));
+ attCombo.setSelectedItem(
+ FeatureMatcher.toAttributeDisplayName(attName));
}
attCombo.addItemListener(new ItemListener()
{
* disable pattern field for condition 'Present / NotPresent'
*/
Condition selectedCondition = (Condition) condCombo.getSelectedItem();
- if (!selectedCondition.needsAPattern())
- {
- patternField.setEnabled(false);
- }
+ patternField.setEnabled(selectedCondition.needsAPattern());
/*
* 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)
}
else
{
- item = toAttributeDisplayName(filter.getAttribute());
+ item = FeatureMatcher.toAttributeDisplayName(filter.getAttribute());
}
attCombo.setSelectedItem(item);
return item;
}
/**
- * 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
+ * <ul>
+ * <li>the minimum value, if condition is > or >=</li>
+ * <li>the maximum value, if condition is < or <=</li>
+ * </ul>
*
* @param attName
* @param selectedCondition
* @param patternField
*/
- private void setPatternTooltip(String attName,
+ private void setNumericHints(String attName,
Condition selectedCondition, JTextField patternField)
{
patternField.setToolTipText("");
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);
+ }
+ }
+ }
}
}
}
JComboBox<Condition> condCombo, JTextField patternField)
{
Datatype type = FeatureAttributes.getInstance().getDatatype(featureType,
- fromAttributeDisplayName(attName));
+ FeatureMatcher.fromAttributeDisplayName(attName));
if (LABEL_18N.equals(attName))
{
type = Datatype.Character;
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);
condCombo.setSelectedIndex(0);
}
- condCombo.addItemListener(listener);
-
/*
* clear pattern if it is now invalid for condition
*/
patternField.setText("");
}
}
+
+ /*
+ * restore the listener
+ */
+ condCombo.addItemListener(listener);
}
/**
Condition cond = (Condition) condCombo.getSelectedItem();
String pattern = valueField.getText().trim();
- setPatternTooltip(attName, cond, valueField);
+ setNumericHints(attName, cond, valueField);
if (pattern.length() == 0 && cond.needsAPattern())
{
+ valueField.setEnabled(true); // ensure pattern field is enabled!
return false;
}
else
{
km = FeatureMatcher.byAttribute(cond, pattern,
- fromAttributeDisplayName(attName));
+ FeatureMatcher.fromAttributeDisplayName(attName));
}
filters.set(filterIndex, km);
public void showTab(boolean coloursTab)
{
setVisible(true);
- tabbedPane.setSelectedIndex(coloursTab ? 0 : 1);
+// tabbedPane.setSelectedIndex(coloursTab ? 0 : 1);
}
/**