Search in sources :

Example 1 with ISliderBluePrint

use of org.jowidgets.api.widgets.blueprint.ISliderBluePrint 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));
}
Also used : ISlider(org.jowidgets.api.widgets.ISlider) ITextLabelBluePrint(org.jowidgets.api.widgets.blueprint.ITextLabelBluePrint) ISliderBluePrint(org.jowidgets.api.widgets.blueprint.ISliderBluePrint) ISliderBluePrint(org.jowidgets.api.widgets.blueprint.ISliderBluePrint) ITextLabelBluePrint(org.jowidgets.api.widgets.blueprint.ITextLabelBluePrint)

Example 2 with ISliderBluePrint

use of org.jowidgets.api.widgets.blueprint.ISliderBluePrint 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));
}
Also used : ISlider(org.jowidgets.api.widgets.ISlider) ITextLabelBluePrint(org.jowidgets.api.widgets.blueprint.ITextLabelBluePrint) ISliderBluePrint(org.jowidgets.api.widgets.blueprint.ISliderBluePrint) ISliderBluePrint(org.jowidgets.api.widgets.blueprint.ISliderBluePrint) ITextLabelBluePrint(org.jowidgets.api.widgets.blueprint.ITextLabelBluePrint)

Aggregations

ISlider (org.jowidgets.api.widgets.ISlider)2 ISliderBluePrint (org.jowidgets.api.widgets.blueprint.ISliderBluePrint)2 ITextLabelBluePrint (org.jowidgets.api.widgets.blueprint.ITextLabelBluePrint)2