JButton button = new JButton("Create Containing Rectangle Filter");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
DrawingTool dt = getDrawingTool();
if (dt != null) {
GraphicAttributes fga = getFilterGA();
OMRect rect = (OMRect) getDrawingTool().create("com.bbn.openmap.omGraphics.OMRect",
fga,
layer,
false);
if (rect != null) {
rect.setAppObject(internalKey);
} else {
Debug.error("DemoLayer: Drawing tool can't create OMRect");
}
} else {
Debug.output("DemoLayer can't find a drawing tool");
}
}
});
box.add(button);
button = new JButton("Create Containing Polygon Filter");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
DrawingTool dt = getDrawingTool();
if (dt != null) {
GraphicAttributes fga = getFilterGA();
fga.setFillPaint(OMColor.clear);
EditableOMPoly eomp = new EditableOMPoly(fga);
eomp.setEnclosed(true);
eomp.setShowGUI(false);
dt.setBehaviorMask(OMDrawingTool.QUICK_CHANGE_BEHAVIOR_MASK);
OMPoly poly = (OMPoly) getDrawingTool().edit(eomp, layer);
if (poly != null) {
poly.setIsPolygon(true);
poly.setAppObject(internalKey);
} else {
Debug.error("DemoLayer: Drawing tool can't create OMPoly");
}
} else {
Debug.output("DemoLayer can't find a drawing tool");
}
}
});
box.add(button);
button = new JButton("Create Excluding Rectangle Filter");
button.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent event) {
DrawingTool dt = getDrawingTool();
if (dt != null) {
GraphicAttributes fga = getFilterGA();
fga.setFillPaint(OMColor.clear);
OMRect rect = (OMRect) getDrawingTool().create("com.bbn.openmap.omGraphics.OMRect",
fga,
layer,
false);