public TaskSliderField() { progressLbl = new Label(); progressLbl.setWidthUndefined(); slider = new Slider(); slider.setOrientation(SliderOrientation.HORIZONTAL); slider.setImmediate(true); slider.setWidth("150px"); slider.addValueChangeListener(valueChangeEvent -> { Double value = (Double) valueChangeEvent.getProperty().getValue(); if (value != null) { double roundValue = Math.ceil(value / 10) * 10; slider.setValue(roundValue); progressLbl.setValue(roundValue + "%"); setInternalValue(roundValue); } else { slider.setValue(0d); progressLbl.setValue("0%"); setInternalValue(0d); } }); body = new MHorizontalLayout(slider, progressLbl); }
@Override protected Slider buildInternalField(Class<? extends T> type) { Slider slider = new Slider(); if (TypeUtils.isIntegerNumber(getType())) { slider.setResolution(0); } slider.setConverter(new NumberToNumberConverter<>(Double.class, type)); return slider; }
private void updatePoundingCaption(Slider poundingSlider, int poundingIntensity) { if (poundingIntensity == 0) { poundingSlider.setCaption("NOT POUNDING"); } else if (poundingIntensity > 0 && poundingIntensity < 11) { poundingSlider.setCaption("POUNDING"); } else { poundingSlider.setCaption("POUNDING HARD"); } }
private Slider createDividerRatioSlider() { Slider slider = new Slider("Divider ratio", 0, 5); slider.setWidth(100, Unit.PERCENTAGE); slider.setResolution(2); slider.setValue(0.75); slider.addValueChangeListener(event -> updateDividerExpandRatio()); return slider; }
@Override protected Slider buildInternalField(Class<? extends T> type) { Slider slider = new Slider(); if (TypeUtils.isIntegerNumber(getType())) { slider.setResolution(0); } return slider; }
private Slider createRGBSlider(final String caption, final String styleName) { final Slider slider = new Slider(caption, 0, 255); slider.setImmediate(true); slider.setWidth("150px"); slider.addStyleName(styleName); return slider; }
public EvaluationilterEditor(Localizer localizer) { this.localizer = localizer; min = new Slider(); max = new Slider(); min.setMin(0.0); min.setMax(1.0); max.setMin(0.0); max.setMax(1.0); min.setResolution(2); max.setResolution(2); min.setWidth("50%"); max.setWidth("50%"); }
public PercentageSliderField() { slider = new Slider(); slider.setMin(0); slider.setMax(100); slider.setSizeFull(); slider.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { setPercentageValue((Double) event.getProperty().getValue()); } }); }
public Slider bindSliderField(String fieldLabel, SingularAttribute<E, ? extends Number> fieldName, int min, int max) { Slider field = new Slider(fieldLabel, min, max); field.setWidth("100%"); field.setImmediate(true); field.setId(fieldLabel.replace(" ", "")); addValueChangeListeners(field); doBinding(group, fieldName.getName(), field); form.addComponent(field); return field; }
/** * Internal function to build differently parameterized Sliders for * {@link RContainer#getSlider(String, double, double, int)} and * {@link RContainer#getSlider(String, int, int)}. * * @param parName * @param slider */ private void buildSlider(final String parName, Slider slider) { Double parValue = getDouble(parName); try { slider.setValue(parValue); assign(parName, parValue); } catch (ValueOutOfBoundsException e) { /* * The value must be between the min and max, and we indicate that * by disabling the slider */ slider.setEnabled(false); } ValueChangeListener sliderChanged = new ValueChangeListener() { private static final long serialVersionUID = 1L; @Override public void valueChange(ValueChangeEvent event) { Double val = (Double) event.getProperty().getValue(); assign(parName, val); } }; slider.addValueChangeListener(sliderChanged); slider.setImmediate(true); }
@Test(expected = RuntimeException.class) public void testBindNoConverterUnrelatedNonStringPresentation() { when(converterRegistry.getConverter(Double.class, int.class)).thenReturn(null); binder.bind(new Slider(), "testInt"); }
public Slider getStepsSlider() { return stepsSlider; }
public Slider getRedSlider() { return redSlider; }
public void setRedSlider(final Slider redSlider) { this.redSlider = redSlider; }
public Slider getGreenSlider() { return greenSlider; }
public void setGreenSlider(final Slider greenSlider) { this.greenSlider = greenSlider; }
public Slider getBlueSlider() { return blueSlider; }
public void setBlueSlider(final Slider blueSlider) { this.blueSlider = blueSlider; }
@Override public VerticalLayout drawSettings() { VerticalLayout view = new VerticalLayout(); numberOfExercises = new Slider( localizer.getUIText(UIConstants.NUMBER_OF_QUESTIONS), 1, 20); numberOfExercises.setResolution(0); numberOfExercises.setValue(5.0); numberOfExercises.setWidth("200px"); view.addComponent(numberOfExercises); return view; }
@Override protected void init(VaadinRequest request) { VerticalLayout center = new VerticalLayout(); setContent(center); center.setSizeFull(); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSizeUndefined(); center.addComponent(layout); center.setComponentAlignment(layout, Alignment.MIDDLE_CENTER); EywaProperty<String> p = new EywaProperty<String>("shared-textfield", String.class); if (p.getValue() == null) { p.setValue("Share text area"); } final TextArea ta = new TextArea(p); ta.setWidth("300px"); ta.setHeight("200px"); layout.addComponent(ta); ta.setTextChangeEventMode(TextChangeEventMode.EAGER); ta.addTextChangeListener(new TextChangeListener() { public void textChange(TextChangeEvent event) { ta.setValue(event.getText()); } }); final Slider slider = new Slider(0.0, 100.0, 1); slider.setPropertyDataSource(new EywaProperty<Double>("shared-slider", Double.class)); layout.addComponent(slider); slider.setImmediate(true); layout.addComponent(slider); slider.setWidth("300px"); layout.addComponent(new Link("Open this in new window", new ExternalResource(getPage().getLocation().toString()), "" + System.currentTimeMillis(), 400, 300, BorderStyle.MINIMAL)); }
/** * The function returns a slider as defined in {@link com.vaadin.ui.Slider} * * @param parName * The R parameter name to bind the slider with * @param min * The minimum value of the slider * @param max * The maximum value of the slider * @param resolution * The number of digits after the decimal point * @return Vaadin {@link com.vaadin.ui.Slider} element */ public Slider getSlider(final String parName, double min, double max, int resolution) { Slider slider = new Slider(min, max, resolution); buildSlider(parName, slider); return slider; }
/** * The function returns a slider as defined in {@link com.vaadin.ui.Slider} * * @param caption * The slider caption * @param parName * The R parameter name to bind the slider with * @param min * The minimum value of the slider * @param max * The maximum value of the slider * @param resolution * The number of digits after the decimal point * @return Vaadin {@link com.vaadin.ui.Slider} element */ public Slider getSlider(String caption, final String parName, double min, double max, int resolution) { Slider slider = new Slider(min, max, resolution); buildSlider(parName, slider); slider.setCaption(caption); return slider; }
/** * The function returns a slider as defined in {@link com.vaadin.ui.Slider} * * @param parName * The R parameter name to bind the slider with * @param min * The minimum value of the slider * @param max * The maximum value of the slider * @return Vaadin {@link com.vaadin.ui.Slider} element */ public Slider getSlider(final String parName, int min, int max) { Slider slider = new Slider(min, max); buildSlider(parName, slider); return slider; }
/** * The function returns a slider as defined in {@link com.vaadin.ui.Slider} * * @param caption * The slider caption * @param parName * The R parameter name to bind the slider with * @param min * The minimum value of the slider * @param max * The maximum value of the slider * @return Vaadin {@link com.vaadin.ui.Slider} element */ public Slider getSlider(String caption, final String parName, int min, int max) { Slider slider = new Slider(min, max); buildSlider(parName, slider); slider.setCaption(caption); return slider; }
/** * Sets the minimum slider value. If the current value of the slider is * smaller than this, the value is set to the new minimum. * * @param min * The new minimum slider value * @return this for method chaining * @see Slider#setMin(double) */ @SuppressWarnings("unchecked") public default THIS withMin(double min) { ((Slider) this).setMin(min); return (THIS) this; }
/** * Sets the maximum slider value. If the current value of the slider is * larger than this, the value is set to the new maximum. * * @param max * The new maximum slider value * @return this for method chaining * @see Slider#setMax(double) */ @SuppressWarnings("unchecked") public default THIS withMax(double max) { ((Slider) this).setMax(max); return (THIS) this; }
/** * Sets the orientation of the slider. * * @param orientation * the new orientation, either * {@link SliderOrientation#HORIZONTAL} or * {@link SliderOrientation#VERTICAL} * @return this for method chaining * @see Slider#setOrientation(SliderOrientation) */ @SuppressWarnings("unchecked") public default THIS withOrientation(SliderOrientation orientation) { ((Slider) this).setOrientation(orientation); return (THIS) this; }
/** * Set a new resolution for the slider. The resolution is the number of * digits after the decimal point. * * @throws IllegalArgumentException * if resolution is negative. * * @param resolution * the number of digits after the decimal point * @return this for method chaining * @see Slider#setResolution(int) */ @SuppressWarnings("unchecked") public default THIS withResolution(int resolution) { ((Slider) this).setResolution(resolution); return (THIS) this; }