return p;
}
private DialogBox makeAddPolyDialog() {
DialogBox dialog = new DialogBox();
dialog.setTitle("Add Polyline");
Grid grid = new Grid(2, 4);
VerticalPanel vp = new VerticalPanel();
grid.setHTML(0, 0, "<b>Opacity</b>");
// The drop down lists for setting the style
final ListBox opacityBox = new ListBox();
for (int i = 100; i > 0; i -= 10) {
opacityBox.addItem(i + "%");
}
opacityBox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String val = opacityBox.getItemText(opacityBox.getSelectedIndex());
opacity = Double.parseDouble(val.replace("%", "")) / 100.0;
}
});
grid.setWidget(1, 0, opacityBox);
grid.setHTML(0, 1, "<b>Weight</b>");
final ListBox weightBox = new ListBox();
weightBox.addItem("1 pixel");
weightBox.addItem("2 pixels");
weightBox.addItem("3 pixels");
weightBox.addItem("5 pixels");
weightBox.addItem("10 pixels");
weightBox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
String val = weightBox.getItemText(weightBox.getSelectedIndex());
val = val.replace(" pixel", "");
val = val.replace("s", "");
weight = Integer.parseInt(val);
}
});
grid.setWidget(1, 1, weightBox);
grid.setHTML(0, 2, "<b>Color</b>");
final ListBox colorBox = new ListBox();
colorBox.addItem("#FF0000 red");
colorBox.addItem("#FFFF00 yellow");
colorBox.addItem("#00FF00 green");
colorBox.addItem("#00FFFF cyan");
colorBox.addItem("#0000FF blue");
colorBox.addItem("#FF00FF violet");
colorBox.addChangeHandler(new ChangeHandler() {
public void onChange(ChangeEvent event) {
color = colorBox.getItemText(colorBox.getSelectedIndex()).substring(0,
7);
}
});
grid.setWidget(1, 2, colorBox);
grid.setHTML(0, 3, "<b>Fill Polygon</b>");
final CheckBox fillCheckBox = new CheckBox("");
fillCheckBox.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
fillFlag = fillCheckBox.getValue();
}
});
grid.setWidget(1, 3, fillCheckBox);
Button addPolylineButton = new Button("Make Polyline");
addPolylineButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
message1.setText("opacity=" + opacity + " color=" + color + " weight="
+ weight + " polygon=" + makePolygon + " center=" + map.getCenter()
+ " zoom=" + map.getZoomLevel());
addPolyDialog.hide();
createPolyline();
editPolylineButton.setEnabled(true);
}
});
Button addPolygonButton = new Button("Make Polygon");
addPolygonButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
message1.setText("Opacity=" + opacity + " color=" + color + "weight="
+ weight + "polygon = " + makePolygon + "Center=" + map.getCenter()
+ " zoom=" + map.getZoomLevel() + "fill=" + fillFlag);
addPolyDialog.hide();
createPolygon();
editPolygonButton.setEnabled(true);
}
});
Button cancelButton = new Button("Cancel");
cancelButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
addPolyDialog.hide();
}
});
HorizontalPanel buttonPanel = new HorizontalPanel();
buttonPanel.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
buttonPanel.add(addPolylineButton);
buttonPanel.add(addPolygonButton);
buttonPanel.add(cancelButton);
vp.add(grid);
vp.add(buttonPanel);
dialog.add(vp);
return dialog;
}