IButton button1 = new IButton(I18nProvider.getSampleMessages().renderingDrawCircle());
button1.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
map.getVectorContext().drawGroup(map.getGroup(RenderGroup.SCREEN), group1);
ShapeStyle style = new ShapeStyle("#66CC22", 0.5f, "#66AA22", 1, 2);
map.getVectorContext().drawCircle(group1, "circle", new Coordinate(200, 100), 30, style);
}
});
button1.setWidth100();
column1.addMember(button1);
// Button2: Draw LineString
IButton button2 = new IButton(I18nProvider.getSampleMessages().renderingDrawLineString());
button2.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
map.getVectorContext().drawGroup(map.getGroup(RenderGroup.SCREEN), group2);
LineString geometry = map.getMapModel().getGeometryFactory().createLineString(
new Coordinate[] { new Coordinate(60, 20), new Coordinate(120, 80), new Coordinate(80, 100) });
ShapeStyle style = new ShapeStyle("#994488", 0.0f, "#993388", 1, 2);
map.getVectorContext().drawLine(group2, "LineString", geometry, style);
}
});
button2.setWidth100();
column1.addMember(button2);
// Button3: Draw Polygon
IButton button3 = new IButton(I18nProvider.getSampleMessages().renderingDrawPolygon());
button3.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
map.getVectorContext().drawGroup(map.getGroup(RenderGroup.SCREEN), group2);
GeometryFactory factory = map.getMapModel().getGeometryFactory();
LinearRing shell = factory.createLinearRing(new Coordinate[] { new Coordinate(110, 10),
new Coordinate(210, 10), new Coordinate(210, 110), new Coordinate(110, 110),
new Coordinate(110, 10) });
LinearRing hole = factory.createLinearRing(new Coordinate[] { new Coordinate(140, 40),
new Coordinate(170, 40), new Coordinate(170, 70), new Coordinate(140, 70),
new Coordinate(140, 40) });
Polygon polygon = factory.createPolygon(shell, new LinearRing[] { hole });
ShapeStyle style = new ShapeStyle("#9933EE", 0.5f, "#9900FF", 1, 2);
map.getVectorContext().drawPolygon(group2, "Polygon", polygon, style);
}
});
button3.setWidth100();
column1.addMember(button3);
// Button4: Draw Text
IButton button4 = new IButton(I18nProvider.getSampleMessages().renderingDrawText());
button4.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
map.getVectorContext().drawGroup(map.getGroup(RenderGroup.SCREEN), group1);
FontStyle style = new FontStyle("#FF0000", 12, "Verdana", "normal", "normal");
map.getVectorContext()
.drawText(group1, "text", "This is some text...", new Coordinate(100, 120), style);
}
});
button4.setWidth100();
column2.addMember(button4);
// Button5: Draw Rectangle
IButton button5 = new IButton(I18nProvider.getSampleMessages().renderingDrawRectangle());
button5.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
map.getVectorContext().drawGroup(map.getGroup(RenderGroup.SCREEN), group2);
ShapeStyle style = new ShapeStyle("#337788", 0.5f, "#337766", 1, 2);
map.getVectorContext().drawRectangle(group2, "rectangle", new Bbox(50, 200, 200, 50), style);
}
});
button5.setWidth100();
column2.addMember(button5);