Sorry, this was a little tricker than I thought. You need to extend the
DrawingEditorTool and override this method:
/**
* Invoked when a mouse button has been pressed on a component.
*
* _at_param e MouseEvent
* _at_return false
*/
public boolean mousePressed(MouseEvent e) {
if (wantsEvents()) {
if (omdtmm != null) {
// This is the bit that clears out the previous drawn
// graphics so that only one remains at a time:
OMGraphicList omgl = layer.getList();
if (omgl != null && omgl.size() > 0) {
omgl.clear();
layer.repaint();
}
///// end modification
omdtmm.mousePressed(e);
}
return consumeEvents;
} else {
return super.mousePressed(e);
}
}
Then, you can specify your updated DrawingEditorTool in the properties
for that EditorLayer.
Hope this helps,
Don
Adams Tan wrote:
> Well, i try to make changes to the DistanceLayer by using a custom
> DrawingEditorTool...
>
> However, I've encountered a brick wall when I try to remove the old
> line... please advise..
>
> Perhaps there's another way, but the following is what I've experimented...
> Code Snippets...
> //imports....
> public class DistanceDrawingEditorTool extends DrawingEditorTool {
> private List<EditableOMGraphic> drawnLines = new
> ArrayList<EditableOMGraphic>();
>
> public DistanceDrawingEditorTool(EditorLayer layer) {
> super(layer);
> }
>
> _at_Override
> public boolean mouseClicked(MouseEvent e) {
> System.out.println("Total Count: " + drawnLines.size());
> //remove old line if present
> if (drawnLines.size() > 1) {
> EditableOMGraphic oldLine = drawnLines.get(0);
> //remove old line here....
> //BRICK WALL -> How to remove line?
> }
>
> return super.mouseClicked(e);
> }
>
> _at_Override
> protected OMDrawingToolMouseMode activateDrawingTool(String ttc) {
> OMDrawingToolMouseMode mouseMode = super.activateDrawingTool(ttc);
> drawnLines.add(getDrawingTool().getCurrentEditable());
> return mouseMode;
> }
> }
>
> On Wed, Sep 10, 2008 at 3:58 AM, Don Dietrick <dietrick_at_bbn.com
> <mailto:dietrick_at_bbn.com>> wrote:
>
> You might prefer the behavior of the DistanceMouseMode, instead of
> using the distance layer, it only does one measurement at a time.
>
> Of course, you can always adjust the code of the DistanceLayer to
> clear out the OMGraphicList when another distance line is started.
>
> -Don
>
>
>
> On Sep 9, 2008, at 6:26 AM, Adams Tan wrote:
>
> Any hint on this?
>
> Adams
>
> On Tue, Aug 26, 2008 at 9:56 AM, Adams Tan <nikida78_at_gmail.com
> <mailto:nikida78_at_gmail.com>> wrote:
> Hi,
>
> Using the default Distance Layer, a new distance line is created
> everytime.
>
> How can remove the previous line whenever a new line is created?
>
> Adams
>
>
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
> Don Dietrick, dietrick_at_bbn.com <mailto:dietrick_at_bbn.com>
> BBN Technologies, Cambridge MA
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
>
>
>
>
--
[To unsubscribe to this list send an email to "majdart_at_bbn.com"
with the following text in the BODY of the message "unsubscribe openmap-users"]
Received on Wed Sep 10 2008 - 10:02:24 EDT