// thresholdPanel.setFont(JvSwingUtils.getLabelFont());
// thresholdPanel.setLayout(new MigLayout("", "[left][right]", "[][]"));
+ percentThreshold.setLabel("As percentage");
+ percentThreshold.addItemListener(this);
+
actionPanel.setBackground(Color.white);
// actionPanel.setFont(JvSwingUtils.getLabelFont());
ngStructureFilterPanel = new StructureFilterPanel(this);
thresholdPanel.setTitle("Threshold Filter");
+ thresholdPanel.add(percentThreshold);
thresholdPanel.add(getThreshold());
thresholdPanel.add(slider);
thresholdPanel.add(thresholdValue);
slider.setMinimum((int) (getCurrentAnnotation().graphMin * 1000));
slider.setMaximum((int) (getCurrentAnnotation().graphMax * 1000));
slider.setValue((int) (getCurrentAnnotation().threshold.value * 1000));
- thresholdValue.setText(getCurrentAnnotation().threshold.value + "");
+ setThresholdValueText();
// slider.setMajorTickSpacing((int) (range / 10f));
slider.setEnabled(true);
thresholdValue.setEnabled(true);
{
threshold_actionPerformed(null);
}
+ else if (e.getSource() == percentThreshold)
+ {
+ if (!adjusting)
+ {
+ percentageValue_actionPerformed();
+ }
+
+ }
}
public void selectedAnnotationChanged()
protected Scrollbar slider = new Scrollbar(Scrollbar.HORIZONTAL);
+ protected Checkbox percentThreshold = new Checkbox();
+
protected TextField thresholdValue = new TextField(20);
protected Frame frame;
updateView();
}
+ protected void setThresholdValueText()
+ {
+ adjusting = true;
+ if (percentThreshold.getState())
+ {
+ double scl = slider.getMaximum() - slider.getMinimum();
+ scl = (slider.getValue() - slider.getMinimum()) / scl;
+ thresholdValue.setText(100 * scl + "");
+ }
+ else
+ {
+ thresholdValue.setText((slider.getValue() / 1000f) + "");
+ }
+ thresholdValue.setCaretPosition(0);
+ adjusting = false;
+ }
+
public void thresholdValue_actionPerformed(ActionEvent e)
{
try
{
float f = Float.parseFloat(thresholdValue.getText());
- slider.setValue((int) (f * 1000));
+ if (percentThreshold.getState())
+ {
+ 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 populateThresholdComboBox(Choice threshold)
{
threshold.addItem(MessageManager