use of com.vaadin.ui.ColorPicker in project charts by vaadin.
the class ModifyOnePoint method setup.
@Override
protected void setup() {
super.setup();
FormLayout formLayout = new FormLayout();
formLayout.setCaption("Special point settings, only updated point state is sent to client.");
formLayout.setMargin(true);
final Slider sliderX = new Slider();
sliderX.setMin(3);
sliderX.setMax(8);
sliderX.setResolution(1);
sliderX.setValue(4d);
sliderX.setCaption("X");
sliderX.addValueChangeListener(event -> {
dataSeriesItem.setX(sliderX.getValue());
series.update(dataSeriesItem);
});
sliderX.setWidth("200px");
formLayout.addComponent(sliderX);
final Slider sliderY = new Slider();
sliderY.setMin(0);
sliderY.setMax(10);
sliderY.setResolution(1);
sliderY.setValue(4d);
sliderY.setCaption("Y");
sliderY.addValueChangeListener(event -> {
dataSeriesItem.setY(sliderY.getValue());
updateItemInChart();
});
sliderY.setWidth("200px");
formLayout.addComponent(sliderY);
final ColorPicker colorPicker = new ColorPicker();
colorPicker.setValue(new com.vaadin.shared.ui.colorpicker.Color(255, 0, 0));
colorPicker.setCaption("Marker color");
colorPicker.addValueChangeListener(event -> {
dataSeriesItem.getMarker().setFillColor(new SolidColor(event.getValue().getCSS()));
updateItemInChart();
});
formLayout.addComponent(colorPicker);
Button c = new Button("Pseudorandom", new Button.ClickListener() {
Random r = new Random(0);
@Override
public void buttonClick(ClickEvent event) {
sliderX.setValue(r.nextDouble() * 5 + 3);
sliderY.setValue(r.nextDouble() * 10);
colorPicker.setValue(new com.vaadin.shared.ui.colorpicker.Color(r.nextInt(255), r.nextInt(255), r.nextInt(255)));
}
});
c.setId("random");
formLayout.addComponent(c);
addComponentAsFirst(formLayout);
}
Aggregations