VerticalPanel leftLayout = new VerticalPanel();
leftLayout.setSize("220px", "100%");
leftLayout.add(new HTML("<h3>Drawing options:</h3>"));
Button rectangleBtn = new Button("Draw rectangle");
rectangleBtn.setWidth("200");
rectangleBtn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Rectangle rectangle = new Rectangle(60, 40, 200, 80);
rectangle.setFillColor("#CC9900");
rectangle.setFillOpacity(0.4);
container.add(rectangle);
}
});
leftLayout.add(rectangleBtn);
Button textBtn = new Button("Draw text");
textBtn.setWidth("200");
textBtn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Text text = new Text(70, 60, "Hello World");
text.setFontFamily("Arial");
text.setFontSize(16);
text.setStrokeOpacity(0);
text.setFillColor("#000000");
container.add(text);
}
});
leftLayout.add(textBtn);
Button circleBtn = new Button("Draw circle");
circleBtn.setWidth("200");
circleBtn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Circle circle = new Circle(300, 140, 30);
circle.setFillColor("#0099CC");
circle.setFillOpacity(0.4);
container.add(circle);
}
});
leftLayout.add(circleBtn);
Button pathBtn = new Button("Draw path");
pathBtn.setWidth("200");
pathBtn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Path path = new Path(120, 160);
path.setFillColor("#0066AA");
path.setFillOpacity(0.4);
path.setStrokeColor("#004499");
path.lineRelativelyTo(100, 0);
path.lineRelativelyTo(0, 100);
path.lineRelativelyTo(-100, 0);
path.lineRelativelyTo(0, -100);
path.moveTo(140, 180);
path.lineRelativelyTo(50, 0);
path.lineRelativelyTo(0, 50);
path.lineRelativelyTo(-50, 0);
path.lineRelativelyTo(0, -50);
container.add(path);
}
});
leftLayout.add(pathBtn);
Button deleteBtn = new Button("Delete all drawings");
deleteBtn.setWidth("200");
deleteBtn.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent arg0) {
container.clear();
}
});