boolean adjusting = false;
- private float min;
+ final private float min;
- private float max;
+ final private float max;
+
+ final private float scaleFactor;
String type = null;
this.fr = frender;
this.type = type;
ap = fr.ap;
- initDialogFrame(this, true, block, "Graduated Feature Colour for "
- + type, 480, 185);
+ String title = MessageManager.formatMessage(
+ "label.graduated_color_for_params", new String[] { type });
+ initDialogFrame(this, true, block, title, 480, 185);
// frame.setLayer(JLayeredPane.PALETTE_LAYER);
// Desktop.addInternalFrame(frame, "Graduated Feature Colour for "+type,
// 480, 145);
slider.addChangeListener(new ChangeListener()
{
+ @Override
public void stateChanged(ChangeEvent evt)
{
if (!adjusting)
{
- thresholdValue.setText(((float) slider.getValue() / 1000f) + "");
+ thresholdValue.setText((slider.getValue() / scaleFactor) + "");
valueChanged();
}
}
});
slider.addMouseListener(new MouseAdapter()
{
+ @Override
public void mouseReleased(MouseEvent evt)
{
if (ap != null)
float mm[] = ((float[][]) fr.getMinMax().get(type))[0];
min = mm[0];
max = mm[1];
+
+ /*
+ * ensure scale factor allows a scaled range with
+ * 10 integer divisions ('ticks'); if we have got here,
+ * we should expect that max != min
+ */
+ scaleFactor = (max == min) ? 1f : 100f / (max - min);
+
oldcs = fr.getFeatureColours().get(type);
if (oldcs instanceof GraduatedColor)
{
waitForInput();
}
- public FeatureColourChooser()
- {
- try
- {
- jbInit();
- } catch (Exception ex)
- {
- ex.printStackTrace();
- }
- }
-
private void jbInit() throws Exception
{
minColour.setToolTipText(MessageManager.getString("label.min_colour"));
minColour.addMouseListener(new MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent e)
{
if (minColour.isEnabled())
maxColour.setToolTipText(MessageManager.getString("label.max_colour"));
maxColour.addMouseListener(new MouseAdapter()
{
+ @Override
public void mousePressed(MouseEvent e)
{
if (maxColour.isEnabled())
jPanel2.setBackground(Color.white);
threshold.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
threshold_actionPerformed(e);
jPanel3.setLayout(flowLayout2);
thresholdValue.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent e)
{
thresholdValue_actionPerformed(e);
.getString("label.toggle_absolute_relative_display_threshold"));
thresholdIsMin.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent actionEvent)
{
thresholdIsMin_actionPerformed(actionEvent);
.getString("label.display_features_same_type_different_label_using_different_colour"));
colourByLabel.addActionListener(new ActionListener()
{
+ @Override
public void actionPerformed(ActionEvent actionEvent)
{
colourByLabel_actionPerformed(actionEvent);
adjusting = true;
acg.setThresh(threshline.value);
- float range = max * 1000f - min * 1000f;
+ float range = (max - min) * scaleFactor;
- slider.setMinimum((int) (min * 1000));
- slider.setMaximum((int) (max * 1000));
- slider.setValue((int) (threshline.value * 1000));
+ slider.setMinimum((int) (min * scaleFactor));
+ slider.setMaximum((int) (max * scaleFactor));
+ slider.setValue((int) (threshline.value * scaleFactor));
thresholdValue.setText(threshline.value + "");
slider.setMajorTickSpacing((int) (range / 10f));
slider.setEnabled(true);
ap.paintAlignment(false);
}
+ @Override
protected void raiseClosed()
{
if (this.colourEditor != null)
}
}
+ @Override
public void okPressed()
{
changeColour();
}
+ @Override
public void cancelPressed()
{
reset();
try
{
float f = Float.parseFloat(thresholdValue.getText());
- slider.setValue((int) (f * 1000));
+ slider.setValue((int) (f * scaleFactor));
threshline.value = f;
} catch (NumberFormatException ex)
{
public void valueChanged()
{
- threshline.value = (float) slider.getValue() / 1000f;
+ threshline.value = slider.getValue() / scaleFactor;
cs.setThresh(threshline.value);
changeColour();
ap.paintAlignment(false);