+ this.setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
+ this.setBackground(Color.white);
+
+ changeColourAction = new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ changeColour(true);
+ }
+ };
+
+ changeMinMaxAction = new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ updateMinMax();
+ changeColour(true);
+ }
+ };
+
+ /*
+ * this panel
+ * detailsPanel
+ * colourByTextPanel
+ * colourByScorePanel
+ * okCancelPanel
+ */
+ JPanel detailsPanel = new JPanel();
+ detailsPanel.setLayout(new BoxLayout(detailsPanel, BoxLayout.Y_AXIS));
+
+ JPanel colourByTextPanel = initColourByTextPanel();
+ detailsPanel.add(colourByTextPanel);
+
+ JPanel colourByValuePanel = initColourByValuePanel();
+ detailsPanel.add(colourByValuePanel);
+
+ /*
+ * 4 radio buttons select between colour by description, by
+ * attribute text, by score, or by attribute value
+ */
+ ButtonGroup bg = new ButtonGroup();
+ bg.add(byDescription);
+ bg.add(byAttributeText);
+ bg.add(byScore);
+ bg.add(byAttributeValue);
+
+ JPanel okCancelPanel = initOkCancelPanel();
+
+ this.add(detailsPanel);
+ this.add(okCancelPanel);
+ }
+
+ /**
+ * Updates the min-max range for a change in choice of Colour by Score, or
+ * Colour by Attribute (value)
+ */
+ protected void updateMinMax()
+ {
+ float[] minMax = null;
+ if (byScore.isSelected())
+ {
+ minMax = fr.getMinMax().get(type)[0];
+ }
+ else if (byAttributeValue.isSelected())
+ {
+ String attName = (String) valueAttributeCombo.getSelectedItem();
+ String[] attNames = attName.split(COLON);
+ minMax = FeatureAttributes.getInstance().getMinMax(type, attNames);
+ }
+ if (minMax != null)
+ {
+ min = minMax[0];
+ max = minMax[1];
+ scaleFactor = (max == min) ? 1f : 100f / (max - min);
+ slider.setValue((int) (min * scaleFactor));
+ }
+ }
+
+ /**
+ * Lay out fields for graduated colour by value
+ *
+ * @return
+ */
+ protected JPanel initColourByValuePanel()
+ {
+ JPanel byValuePanel = new JPanel();
+ byValuePanel.setLayout(new BoxLayout(byValuePanel, BoxLayout.Y_AXIS));
+ JvSwingUtils.createItalicTitledBorder(byValuePanel,
+ MessageManager.getString("label.colour_by_value"), true);
+ byValuePanel.setBackground(Color.white);
+
+ /*
+ * first row - choose colour by score or by attribute, choose attribute
+ */
+ JPanel byWhatPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ byWhatPanel.setBackground(Color.white);
+ byValuePanel.add(byWhatPanel);
+
+ byScore.setText(MessageManager.getString("label.score"));
+ byWhatPanel.add(byScore);
+ byScore.addActionListener(changeMinMaxAction);
+
+ byAttributeValue.setText(MessageManager.getString("label.attribute"));
+ byAttributeValue.addActionListener(changeMinMaxAction);
+ byWhatPanel.add(byAttributeValue);
+
+ List<String[]> attNames = FeatureAttributes.getInstance()
+ .getAttributes(type);
+ valueAttributeCombo = populateAttributesDropdown(type, attNames, true);
+
+ /*
+ * if no numeric atttibutes found, disable colour by attribute value
+ */
+ if (valueAttributeCombo.getItemCount() == 0)
+ {
+ byAttributeValue.setEnabled(false);
+ }
+
+ byWhatPanel.add(valueAttributeCombo);
+
+ /*
+ * second row - min/max/no colours
+ */
+ JPanel colourRangePanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
+ colourRangePanel.setBackground(Color.white);
+ byValuePanel.add(colourRangePanel);