use of org.cytoscape.work.internal.tunables.utils.TunableSlider in project cytoscape-impl by cytoscape.
the class BoundedHandler method initPanel.
private void initPanel(T bounded) {
double min = ((Number) bounded.getLowerBound()).doubleValue();
double max = ((Number) bounded.getUpperBound()).doubleValue();
double range = max - min;
final DecimalFormat format = getDecimalFormat(range);
final JLabel label = new JLabel();
if (useSlider) {
label.setText(title);
slider = new TunableSlider(title, (Number) bounded.getLowerBound(), (Number) bounded.getUpperBound(), (Number) bounded.getValue(), bounded.isLowerBoundStrict(), bounded.isUpperBoundStrict(), format);
slider.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
if (!isUpdating)
handle();
}
});
updateFieldPanel(panel, label, slider, horizontal);
panel.validate();
setTooltip(getTooltip(), label, slider);
} else {
// Do something reasonable for max and min...
// At some point, we should use superscripts for scientific notation...
label.setText(title + " (max: " + format.format((Number) bounded.getLowerBound()) + " min: " + format.format((Number) bounded.getUpperBound()) + ")");
boundedField = new TunableBoundedField((Number) bounded.getValue(), (Number) bounded.getLowerBound(), (Number) bounded.getUpperBound(), bounded.isLowerBoundStrict(), bounded.isUpperBoundStrict());
boundedField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (!isUpdating)
handle();
}
});
boundedField.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
if (!isUpdating)
handle();
}
});
updateFieldPanel(panel, label, boundedField, horizontal);
panel.validate();
setTooltip(getTooltip(), label, boundedField);
}
}
Aggregations