return getPolyGUI(true, true, true);
}
public JToolBar getPolyGUI(boolean includeEnclose, boolean includeAdd,
boolean includeDelete) {
JToolBar buttonBox = new GridBagToolBar();
URL url;
ImageIcon imageIcon;
if (polygonButton == null) {
url = getImageURL("enclosepoly.gif");
imageIcon = new ImageIcon(url);
polygonButton = new JToggleButton(imageIcon);
polygonButton.setToolTipText(i18n.get(EditableOMPoly.class,
"polygonButton.tooltip",
"Automatically link first and last nodes"));
}
polygonButton.setSelected(isEnclosed());
polygonButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (getStateMachine().getState() instanceof GraphicSelectedState) {
enclose(((JToggleButton) e.getSource()).isSelected());
} else {
setEnclosed(((JToggleButton) e.getSource()).isSelected());
}
}
});
if (includeEnclose) {
buttonBox.add(polygonButton);
}
if (addButton == null) {
url = getImageURL("addpoint.gif");
imageIcon = new ImageIcon(url);
addButton = new JButton(imageIcon);
addButton.setToolTipText(i18n.get(EditableOMPoly.class,
"addButton.tooltip",
"Add a node to the polygon"));
}
addButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
((PolyStateMachine) stateMachine).setAddNode();
enablePolygonEditButtons(false);
}
});
addButton.setEnabled(false);
if (includeAdd) {
buttonBox.add(addButton);
}
if (deleteButton == null) {
url = getImageURL("deletepoint.gif");
imageIcon = new ImageIcon(url);
deleteButton = new JButton(imageIcon);
deleteButton.setToolTipText(i18n.get(EditableOMPoly.class,
"deleteButton.tooltip",
"Delete a node from the polygon"));
}
deleteButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
((PolyStateMachine) stateMachine).setDeleteNode();
enablePolygonEditButtons(false);
}
});
deleteButton.setEnabled(false);
if (includeDelete) {
buttonBox.add(deleteButton);
}
return buttonBox;
}