Re: [OpenMap Users] Edit many OMGraphics simultaneously

From: Don Dietrick <dfdietrick_at_gmail.com>
Date: Mon, 9 Aug 2010 10:36:20 -0400

Hi Fede,

The EditableOMGraphicList wasn't designed to allow you to modify just
one OMGraphic when several are selected. It behaves like PowerPoint
in that situation (if I remember PowerPoint correctly).

The EditableOMGraphicList attaches all of the GrabPoints from all of
the child EditableOMGraphics to its own moving GrabPoint. That
GrabPoint is the only one that actually gets moved when any of the
EditableOMGraphics get touched, and all of the other GrabPoints move
in relation to the one.

You should be able to extend EditableOMGraphicList to change this
behavior, by modifying what happens when a GrabPoint of one of the
EditableOMPoly gets selected, and allowing the natural behavior of the
selected GrabPoint receive events from the DrawingTool.

The tricky part will be maintaining the original behavior of all of
the EditableOMGraphics moving when an edge is selected for movement. I
don't have a quick answer for that, you'll just have to test if one of
the child GrabPoints is selected.

The com.bbn.openmap.omGraphics.editable.List*State objects have a lot
to do with how the GrabPoints are handled. So if they need to change,
you'll probably need your EditableOMGraphicList extension to define a
new state machine for you that contains your new states.


Hope this helps,
- Don




On Thu, Aug 5, 2010 at 10:44 AM, fede jeanne <fedejeanne_at_gmail.com> wrote:
> Hi all:
> I'm using OpenMap 4.6.4 and i'm trying to edit several EsriPolygons
> simultaneously. So far I've extended the AbstractToolLoader class to provide
> my own EditableGGGraphicList (I've tried using the existing
> EditableOMGraphicList but i think this class wasn't intended for what i'm
> trying to do). This "EditableGGGraphicList" class has an internal graphic
> list to hold the original graphics and pass events to them (it is kind of a
> "wrapper")... but the edition does not work: i'm able to select several
> polygons together and move them, but i can't edit them (i mean: i can't grab
> ONE point and move it in order to change the "shape" of the polygon).
>
> I attach some code in case it can be useful:
>
> //OMGraphicListLoader.java
> --------------------------------------------------------------------------------------------------------------------------
> package openmap.tools.drawing;
>
> import openmap.omGraphics.EditableGGGraphicList;
>
> import com.bbn.openmap.omGraphics.EditableOMGraphic;
> import com.bbn.openmap.omGraphics.GraphicAttributes;
> import com.bbn.openmap.omGraphics.OMGraphic;
> import com.bbn.openmap.omGraphics.OMGraphicList;
> import com.bbn.openmap.tools.drawing.AbstractToolLoader;
> import com.bbn.openmap.tools.drawing.EditClassWrapper;
>
> public class OMGraphicListLoader extends AbstractToolLoader {
>     protected String graphicClassName =
> "com.bbn.openmap.omGraphics.OMGraphicList";
>
>     public OMGraphicListLoader() {
>         super();
>         init();
>     }
>
>     public EditableOMGraphic getEditableGraphic(OMGraphic graphic) {
>         if (graphic instanceof OMGraphicList) {
>             return new EditableGGGraphicList((OMGraphicList) graphic);
>         }
>         return null;
>     }
>
>     public EditableOMGraphic getEditableGraphic(String classname,
>             GraphicAttributes ga) {
>         if (classname.intern() == graphicClassName) {
>             return new EditableGGGraphicList(ga);
>         }
>         return null;
>     }
>
>     public void init() {
>         EditClassWrapper ecw = new EditClassWrapper(graphicClassName,
>                 "com.bbn.openmap.omGraphics.EditableOMGraphicList",
>                 "editablepoint.gif", "OMGraphicList");
>
>         addEditClassWrapper(ecw);
>     }
>
> //-----------------------------------------------------------------------------------------------------------------------------------------------------------------
> //EditableGGGraphicList.java
> ------------------------------------------------------------------------------------------------------------------------
> package openmap.omGraphics;
>
> import java.awt.Graphics;
> import java.awt.event.MouseEvent;
> import java.util.ArrayList;
> import java.util.List;
>
> import openmap.omGraphics.factory.EditableOMGraphicFactory;
>
> import com.bbn.openmap.omGraphics.EditableOMGraphic;
> import com.bbn.openmap.omGraphics.GraphicAttributes;
> import com.bbn.openmap.omGraphics.OMGraphic;
> import com.bbn.openmap.omGraphics.OMGraphicList;
> import com.bbn.openmap.omGraphics.editable.GGListStateMachine;
> import com.bbn.openmap.proj.Projection;
> import com.bbn.openmap.util.Debug;
>
> public class EditableGGGraphicList extends EditableOMGraphic {
>
>     private OMGraphicList list;
>     private List<EditableOMGraphic> editableList;
>
>     public EditableGGGraphicList(OMGraphicList graphic) {
>         setGraphic(graphic);
>     }
>
>     public EditableGGGraphicList(GraphicAttributes ga) {
>         createGraphic(ga);
>     }
>
>     public void createGraphic(GraphicAttributes ga) {
>         System.out.println("EditableGGGraphicList.createGraphic()");
>         list = new OMGraphicList();
>         editableList = new ArrayList<EditableOMGraphic>();
>     }
>
>     public boolean generate(Projection proj) {
>         boolean ret = true;
>         for (int i = 0; i < editableList.size(); ++i) {
>             ret &= editableList.get(i).generate(proj);
>         }
>         return ret;
>     }
>
>     public OMGraphic getGraphic() {
>         // FIXME this could be the method inside which the edition fails.
> Maybe
>         // what's happening is that, being the edited polygons inside the
>         // "editableList" and not inside the "list", the editor is receiving
> old
>         // (not modified) polygons.
>         return list;
>     }
>
>     public void regenerate(Projection proj) {
>         System.out.println("EditableGGGraphicList.regenerate()");
>         if (list != null) {
>             for (int i = 0; i < editableList.size(); ++i) {
>                 editableList.get(i).regenerate(proj);
>             }
>         }
>
>         setGrabPoints();
>         generate(proj);
>     }
>
>     public void render(Graphics g) {
>         System.out.println("EditableGGGraphicList.render()");
>         if (list != null) {
>             for (int i = 0; i < editableList.size(); ++i) {
>                 editableList.get(i).render(g);
>             }
>         }
>     }
>
>     public void setGrabPoints() {
>         System.out.println("EditableGGGraphicList.setGrabPoints()");
>         if (list != null) {
>             for (int i = 0; i < editableList.size(); ++i) {
>                 editableList.get(i).setGrabPoints();
>             }
>         }
>
>     }
>
>     public void setGraphic(OMGraphic graphic) {
>
>         System.out.println("EditableGGGraphicList.setGraphic()");
>         init();
>         if (graphic instanceof OMGraphicList) {
>             list = (OMGraphicList) graphic;
>             for (int i = 0; i < list.size(); ++i) {
>                 OMGraphic gr = list.getOMGraphicAt(i);
>
>                 // next line is used to get an instance of en EditableOMPoly
>                 // from an OMPoly (remember that EsriPolygon extends OMPoly)
>                 EditableOMGraphic egr = EditableOMGraphicFactory
>                         .createEditableOMGraphic(gr);
>                 editableList.add(egr);
>             }
>             stateMachine.setSelected();
>             setGrabPoints();
>         } else {
>             createGraphic(null);
>         }
>     }
>
>     /**
>      * Create and initialize the state machine that interprets the modifying
>      * gestures/commands, as well as initialize the grab points. Also
> allocates
>      * the grab point array needed by the EditableOMPoint.
>      */
>     public void init() {
>         Debug.message("eomg", "EditableOMPoint.init()");
>         setCanGrabGraphic(false);
>         setStateMachine(new GGListStateMachine(this));
>         editableList = new ArrayList<EditableOMGraphic>();
>     }
>
>     public void move(MouseEvent e) {
>         if (list != null) {
>             for (int i = 0; i < editableList.size(); ++i) {
>                 editableList.get(i).move(e);
>             }
>         }
>     }
> }
> //-----------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Any help or hint on this will be much appreciated!
> thanks in advance
>
> --
> Fede
>

--
[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 Mon Aug 09 2010 - 10:37:47 EDT

This archive was generated by hypermail 2.3.0 : Tue Mar 28 2017 - 23:25:09 EDT