use of org.jowidgets.api.widgets.ISlider in project jo-client-platform by jo-source.
the class GraphSettingsDialog method createSliderComponent.
private void createSliderComponent(final IScrollComposite content, final double defaultValue, final int forceNumber, final GraphLayout layout) {
int max = 0;
int min = 0;
String description = null;
switch(layout) {
case RADIAL_TREE_LAYOUT:
max = RADIAL_RADIUS_MAX;
min = RADIAL_RADIUS_MIN;
description = RADIAL_RADIUS_DISTANCES[forceNumber];
break;
case NODE_TREE_LINK_LAYOUT:
max = NODE_LINK_DISTANCE_MAX;
min = NODE_LINK_DISTANCE_MIN;
description = NODE_LINK_DISTANCES[forceNumber];
break;
default:
break;
}
final ITextLabelBluePrint labelBp = BPF.textLabel().alignRight();
content.add(labelBp.setText(description), "sg lg");
final ISliderBluePrint sliderBp = BPF.slider();
final ISlider slider;
final int defaultVal = (int) defaultValue;
final int step = (max - min) / 100;
sliderBp.setMaximum(max).setMinimum(min).setTickSpacing((max - min) / 20);
slider = content.add(sliderBp, "growx, w 0::");
slider.setValue(defaultVal);
final IInputField<Integer> inputField;
inputField = content.add(BPF.inputFieldIntegerNumber(), "growx, w 0::, wrap");
inputField.setValue((int) (slider.getValue()));
DEFAULT_SLIDER_SETTINGS.put(slider, defaultVal);
inputField.addInputListener(new ParameterListener(slider, inputField, null, forceNumber, step, min, false, Listener.INPUTFIELD, layout));
slider.addInputListener(new ParameterListener(slider, inputField, null, forceNumber, step, min, false, Listener.SLIDER, layout));
}
use of org.jowidgets.api.widgets.ISlider in project jo-client-platform by jo-source.
the class GraphSettingsDialog method createDefaultSetterButton.
private void createDefaultSetterButton(final IScrollComposite content) {
final IButton btn = content.add(BPF.button("Reset", "Set settings to default"), "growx, w 0::75, alignx left");
btn.addActionListener(new IActionListener() {
@Override
public void actionPerformed() {
final Set<ISlider> sliders = DEFAULT_SLIDER_SETTINGS.keySet();
for (final ISlider slider : sliders) {
slider.setValue(DEFAULT_SLIDER_SETTINGS.get(slider));
}
}
});
final IButton btnCancel = content.add(BPF.buttonCancel(), " w 0:75:, span 2, alignx right");
btnCancel.addActionListener(new IActionListener() {
@Override
public void actionPerformed() {
closeDialog();
}
});
}
use of org.jowidgets.api.widgets.ISlider in project jo-client-platform by jo-source.
the class GraphSettingsDialog method createSliderComponent.
private void createSliderComponent(final IScrollComposite content, final Force force, final int param, final String description) {
final String forceParameter = force.getParameterName(param);
final double value = MODIFIED_VALUES.containsKey(forceParameter + "_DEFAULT") ? MODIFIED_VALUES.get(forceParameter + "_DEFAULT") : force.getParameter(param);
final double min = MODIFIED_VALUES.containsKey(forceParameter + "_MIN") ? MODIFIED_VALUES.get(forceParameter + "_MIN") : force.getMinValue(param);
final double max = MODIFIED_VALUES.containsKey(forceParameter + "_MAX") ? MODIFIED_VALUES.get(forceParameter + "_MAX") : force.getMaxValue(param);
final boolean displayPercent;
final double step = (max - min) / 100;
final ITextLabelBluePrint labelBp = BPF.textLabel().alignRight();
content.add(labelBp.setText(description), "sg lg");
final ISliderBluePrint sliderBp = BPF.slider();
final ISlider slider;
final int defaultValue;
final IInputField<Integer> inputField;
if (Arrays.asList(DISPLAY_PERCENT_PARAMETER).contains(forceParameter)) {
sliderBp.setMaximum(100).setMinimum(0).setTickSpacing(5);
slider = content.add(sliderBp, "growx, w 0::");
defaultValue = (int) (100 / max * value);
slider.setValue(defaultValue);
inputField = content.add(BPF.inputFieldIntegerNumber(), "growx, w 0::, split2");
content.add(BPF.label().setText("%"), "wrap");
inputField.setValue((int) (slider.getValue()));
displayPercent = true;
useForce(displayPercent, param, force, min, slider, step);
} else {
sliderBp.setMaximum((int) max).setMinimum((int) min).setTickSpacing((int) (max - min) / 20);
slider = content.add(sliderBp, "growx, w 0::");
defaultValue = (int) value;
slider.setValue(defaultValue);
inputField = content.add(BPF.inputFieldIntegerNumber(), "growx, w 0::, wrap");
inputField.setValue((int) value);
displayPercent = false;
useForce(displayPercent, param, force, min, slider, step);
}
DEFAULT_SLIDER_SETTINGS.put(slider, defaultValue);
inputField.addInputListener(new ParameterListener(slider, inputField, force, param, step, min, displayPercent, Listener.INPUTFIELD, GraphLayout.FORCE_DIRECTED_LAYOUT));
slider.addInputListener(new ParameterListener(slider, inputField, force, param, step, min, displayPercent, Listener.SLIDER, GraphLayout.FORCE_DIRECTED_LAYOUT));
}
Aggregations