All Downloads are FREE. Search and download functionalities are using the official Maven repository.
Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
org.ikasan.designer.menu.ShapeContextMenu Maven / Gradle / Ivy
package org.ikasan.designer.menu;
import com.vaadin.flow.component.AbstractField;
import com.vaadin.flow.component.HasValue;
import com.vaadin.flow.component.UI;
import com.vaadin.flow.component.dialog.Dialog;
import com.vaadin.flow.component.html.Image;
import com.vaadin.flow.component.orderedlayout.FlexLayout;
import com.vaadin.flow.component.select.Select;
import com.vaadin.flow.component.textfield.NumberField;
import com.vaadin.flow.data.renderer.ComponentRenderer;
import org.ikasan.designer.Designer;
import org.ikasan.designer.model.Figure;
public class ShapeContextMenu extends Dialog {
public ShapeContextMenu(Designer designer, Figure figure, int x, int y) {
this.setWidth("200px");
this.getElement().executeJs("this.$.overlay.$.overlay.style[$0]=$1", "align-self", "flex-start");
this.getElement().executeJs("this.$.overlay.$.overlay.style[$0]=$1", "position", "absolute");
this.getElement().executeJs("this.$.overlay.$.overlay.style[$0]=$1", "left", x + "px");
this.getElement().executeJs("this.$.overlay.$.overlay.style[$0]=$1", "top", y + "px");
Select select = new Select<>();
select.setWidth("90%");
select.setItems(new Image("frontend/images/separator.png", "EMPTY"),
new Image("frontend/images/separator.png", "-"),
new Image("frontend/images/separator.png", "."),
new Image("frontend/images/separator.png", "-."),
new Image("frontend/images/separator.png", "-.."),
new Image("frontend/images/separator.png", "- "),
new Image("frontend/images/separator.png", "--"),
new Image("frontend/images/separator.png", "- ."),
new Image("frontend/images/separator.png", "--."),
new Image("frontend/images/separator.png", "--.."));
select.setRenderer(new ComponentRenderer<>(image -> {
FlexLayout wrapper = new FlexLayout();
image.setWidth("5px");
wrapper.add(image);
return wrapper;
}));
select.addValueChangeListener((HasValue.ValueChangeListener, Image>>)
selectImageComponentValueChangeEvent -> designer.setLineType(selectImageComponentValueChangeEvent.getValue().getAlt().get()));
NumberField numberField = new NumberField(getTranslation("label.corner-radius", UI.getCurrent().getLocale()));
numberField.setHasControls(true);
Number size = figure.getAttributeNumberValue("radius");
numberField.setValue(size.doubleValue());
numberField.addValueChangeListener((HasValue.ValueChangeListener>)
numberFieldDoubleComponentValueChangeEvent -> designer.setRadius(numberFieldDoubleComponentValueChangeEvent.getValue()));
NumberField strokeField = new NumberField(getTranslation("label.line-width", UI.getCurrent().getLocale()));
strokeField.setHasControls(true);
strokeField.setValue(0d);
Number stroke = figure.getAttributeNumberValue("stroke");
strokeField.setValue(stroke.doubleValue());
strokeField.addValueChangeListener((HasValue.ValueChangeListener>)
numberFieldDoubleComponentValueChangeEvent -> designer.setStroke(numberFieldDoubleComponentValueChangeEvent.getValue().intValue()));
this.add(select, numberField, strokeField);
}
}