selected = false;
EventBus.getSystem().addListener(Selection.SelectionChangeEvent.Changed, selectionCallback);
defaultProperties = new HFlexBox().setBoxAlign(Align.Baseline);
add(defaultProperties);
defaultProperties.add(new Label("Name:").setFont(Font.name("OpenSans").size(12).resolve()));
nameBox = new Textbox("").setHintText("unset");
nameBox.setPrefWidth(100);
nameBox.onAction(new Callback<ActionEvent>() {
public void call(ActionEvent actionEvent) throws Exception {
if(manager.propMan.isClassAvailable(SNode.class)) {
PropertyManager.Property prop = manager.propMan.getProperty("id");
prop.setValue(nameBox.getText());
}
}
});
defaultProperties.add(nameBox,1);
shapeProperties = new HFlexBox().setBoxAlign(HFlexBox.Align.Baseline);
add(shapeProperties);
shapeProperties.setVisible(false);
fillButton = new FillPicker(this.manager);
fillButton.setContext(context);
EventBus.getSystem().addListener(fillButton,ChangedEvent.ObjectChanged, fillButtonCallback);
strokeColorButton = new SwatchColorPicker();
EventBus.getSystem().addListener(ChangedEvent.ColorChanged, colorChangeCallback);
shapeProperties.add(fillButton);
shapeProperties.add(strokeColorButton);
setupShadowProperties();
strokeWidthSlider = new Slider(false);
strokeWidthSlider.setMin(0);
strokeWidthSlider.setMax(20);
strokeWidthSlider.setValue(3);
EventBus.getSystem().addListener(strokeWidthSlider, ChangedEvent.DoubleChanged, strokeWidthCallback);
strokeWidthLabel = new Label(getString("toolbar.stroke")+": " + 3);
shapeProperties.add(strokeWidthLabel);
shapeProperties.add(strokeWidthSlider);
fillOpacitySlider = new Slider(false).setMin(0).setMax(100).setValue(100);
EventBus.getSystem().addListener(fillOpacitySlider, ChangedEvent.DoubleChanged, fillOpacityCallback);
fillOpacityLabel = new Label(getString("toolbar.opacity")+": "+df.format(0));
shapeProperties.add(fillOpacityLabel);
shapeProperties.add(fillOpacitySlider);
fontProperties = new HFlexBox().setBoxAlign(HFlexBox.Align.Baseline);
add(fontProperties);
fontSizeLabel = new Label(getString("toolbar.fontSize")+":");
fontProperties.add(fontSizeLabel);
fontSizeSlider = new Slider(false);
fontSizeSlider.setMin(8);
fontSizeSlider.setMax(500);
fontSizeSlider.setValue(24);
EventBus.getSystem().addListener(fontSizeSlider, ChangedEvent.DoubleChanged, fontSizeCallback);
fontProperties.add(fontSizeSlider);
fontPicker = new PopupMenuButton<String>();
fontPicker.setModel(new ListModel<String>() {
public String get(int i) {
return Main.getDatabase().getAllFonts().get(i).getName();
}
public int size() {
return Main.getDatabase().getAllFonts().size();
}
});
EventBus.getSystem().addListener(fontPicker, SelectionEvent.Changed, new Callback<SelectionEvent>(){
public void call(SelectionEvent event) {
if(manager.propMan.isClassAvailable(SText.class)) {
int index = event.getView().getSelectedIndex();
String fontname = Main.getDatabase().getAllFonts().get(index).getName();
manager.propMan.getProperty("fontName").setValue(fontname);
context.redraw();
}
}
});
fontProperties.add(fontPicker);
fontBoldButton = new Togglebutton("B");
fontBoldButton.onClicked(fontBoldCallback);
fontProperties.add(fontBoldButton);
fontItalicButton = new Togglebutton("I");
fontItalicButton.onClicked(fontItalicCallback);
fontProperties.add(fontItalicButton);
fontAlignLeft = new TIB("cr22-action-text_left.png", new SAction(){
@Override
public void execute() throws Exception {
if(manager.propMan.isClassAvailable(SText.class)) {
manager.propMan.getProperty("halign").setValue(SText.HAlign.Left);
}
}
});
fontAlignHCenter = new TIB("cr22-action-text_center.png", new SAction(){
@Override
public void execute() throws Exception {
if(manager.propMan.isClassAvailable(SText.class)) {
manager.propMan.getProperty("halign").setValue(SText.HAlign.Center);
}
}
});
fontAlignRight = new TIB("cr22-action-text_right.png", new SAction(){
@Override
public void execute() throws Exception {
if(manager.propMan.isClassAvailable(SText.class)) {
manager.propMan.getProperty("halign").setValue(SText.HAlign.Right);
}
}
});
fontProperties.add(fontAlignLeft,fontAlignHCenter,fontAlignRight);
fontAlignGroup = new ToggleGroup();
fontAlignGroup.add(fontAlignLeft).add(fontAlignHCenter).add(fontAlignRight);
fontAlignGroup.setSelectedButton(fontAlignLeft);
EventBus.getSystem().addListener(fontAlignGroup, ActionEvent.Action, new Callback<ActionEvent>(){
public void call(ActionEvent actionEvent) throws Exception {
if(manager.propMan.isClassAvailable(SText.class)) {
if(fontAlignGroup.getSelectedButton() == fontAlignLeft) {
manager.propMan.getProperty("halign").setValue(SText.HAlign.Left);
}
if(fontAlignGroup.getSelectedButton() == fontAlignHCenter) {
manager.propMan.getProperty("halign").setValue(SText.HAlign.Center);
}
if(fontAlignGroup.getSelectedButton() == fontAlignRight) {
manager.propMan.getProperty("halign").setValue(SText.HAlign.Right);
}
context.redraw();
}
}
});
fontWrap = new Checkbox("wrap");
fontWrap.onClicked(new Callback<ActionEvent>() {
public void call(ActionEvent event) throws Exception {
if(manager.propMan.isClassAvailable(SText.class)) {
manager.propMan.getProperty("wrapText").setValue(fontWrap.isSelected());
context.redraw();
}
}
});
fontProperties.add(fontWrap);
arrowHeadEnd = new PopupMenuButton<SArrow.HeadEnd>();
arrowHeadEnd.setModel(ListView.createModel(SArrow.HeadEnd.values()));
add(arrowHeadEnd);
arrowHeadEnd.setVisible(false);
EventBus.getSystem().addListener(arrowHeadEnd, SelectionEvent.Changed, arrowHeadCallback);
groupPropertiesEditor = new HFlexBox()
.add(new IB("align-horizontal-left.png", new NodeActions.AlignLeft(context)))
.add(new IB("align-horizontal-center.png", new NodeActions.AlignCenterH(context)))
.add(new IB("align-horizontal-right.png", new NodeActions.AlignRight(context)))
.add(new IB("align-vertical-bottom.png", new NodeActions.AlignBottom(context)))
.add(new IB("align-vertical-center.png", new NodeActions.AlignCenterV(context)))
.add(new IB("align-vertical-top.png", new NodeActions.AlignTop(context)))
;
add(groupPropertiesEditor);
groupPropertiesEditor.setVisible(false);
booleanPropsEditor = new HFlexBox()
.add(new Button(getString("menus.add")).onClicked(new Callback<ActionEvent>() {
public void call(ActionEvent actionEvent) throws Exception {
new BooleanGeometry.Union(context).execute();
}
}))