protected JCheckBox seqAssociated = new JCheckBox();
+ protected JCheckBox percentThreshold = new JCheckBox();
+
protected JSlider slider = new JSlider();
protected JTextField thresholdValue = new JTextField(20);
{
if (!adjusting)
{
- thresholdValue.setText((slider.getValue() / 1000f) + "");
+ setThresholdValueText();
valueChanged(!sliderDragging);
}
}
});
}
+ /**
+ * update the text field from the threshold slider. preserves state of
+ * 'adjusting' so safe to call in init.
+ */
+ protected void setThresholdValueText()
+ {
+ boolean oldadj = adjusting;
+ adjusting = true;
+ if (percentThreshold.isSelected())
+ {
+ thresholdValue.setText("" + (slider.getValue() - slider.getMinimum())
+ * 100f / (slider.getMaximum() - slider.getMinimum()));
+ }
+ else
+ {
+ thresholdValue.setText((slider.getValue() / 1000f) + "");
+ }
+ adjusting = oldadj;
+ }
protected void addSliderMouseListeners()
{
try
{
float f = Float.parseFloat(thresholdValue.getText());
- slider.setValue((int) (f * 1000));
+ if (percentThreshold.isSelected())
+ {
+ slider.setValue(slider.getMinimum()
+ + ((int) ((f / 100f) * (slider.getMaximum() - slider
+ .getMinimum()))));
+ }
+ else
+ {
+ slider.setValue((int) (f * 1000));
+ }
updateView();
} catch (NumberFormatException ex)
{
}
}
+ protected void percentageValue_actionPerformed()
+ {
+ setThresholdValueText();
+ }
+
protected void thresholdIsMin_actionPerformed()
{
updateView();
}
});
+ percentThreshold.setText(MessageManager.getString("label.as_percentage"));
+ percentThreshold.addActionListener(new ActionListener()
+ {
+ @Override
+ public void actionPerformed(ActionEvent e)
+ {
+ if (!adjusting)
+ {
+ percentageValue_actionPerformed();
+ }
+ }
+ });
slider.setPaintLabels(false);
slider.setPaintTicks(true);
slider.setBackground(Color.white);