EditableOMPoly (OpenMap API)
Date: 2016-12-09

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bbn.openmap.omGraphics
Class EditableOMPoly

    java.lang.Object
      com.bbn.openmap.event.MapMouseAdapter
          com.bbn.openmap.omGraphics.EditableOMGraphic
              com.bbn.openmap.omGraphics.EditableOMAbstractLine
                  com.bbn.openmap.omGraphics.EditableOMPoly

All Implemented Interfaces:
  MapMouseListener

Direct Known Subclasses:
  EditableLabeledOMPoly, EditableOMDistance, EditableOMSpline

    public class EditableOMPoly

extends EditableOMAbstractLine

The EditableOMPoly encompasses an OMPoly, providing methods for modifying or creating it.

Nested Class Summary
`static class` | `EditableOMPoly.OMPolyUndoEvent` Subclass for undoing edits for OMPoly classes, handles enclose/unenclose events.

Nested classes/interfaces inherited from class com.bbn.openmap.omGraphics.EditableOMGraphic
`EditableOMGraphic.OMGraphicUndoEvent`

Field Summary
`protected OffsetGrabPoint` | `gpm`
`protected OffsetGrabPoint` | `gpo`
`protected boolean` | `manualEnclosed` Whether the poly is a polygon, as opposed to a polyline.
`static int` | `OFFSET_POINT_INDEX`
`protected OMPoly` | `poly`
`protected java.util.List<GrabPoint>` | `polyGrabPoints`
`protected int` | `selectNodeIndex` Set the index of the grab point that should be rendered differently, in order to highlight a specific node.

Fields inherited from class com.bbn.openmap.omGraphics.EditableOMAbstractLine
`arrowheadMenu`

Fields inherited from class com.bbn.openmap.omGraphics.EditableOMGraphic
`actionMask, canGrabGraphic, DEBUG, DEBUG_DETAIL, gPoints, GRAB_POINT_DRAWING_ATTRIBUTES_ATTRIBUTE, holder, i18n, lastMouseEvent, listeners, mouseModeServiceList, movingPoint, popupIsUp, projection, SELECTED_GRAB_POINT_DRAWING_ATTRIBUTES_ATTRIBUTE, showGUI, stateMachine, undoStack, xorRendering`

Constructor Summary
`EditableOMPoly()` Create the EditableOMPoly, setting the state machine to create the poly off of the gestures.
`EditableOMPoly(GraphicAttributes ga)` Create an EditableOMPoly with the polyType and renderType parameters in the GraphicAttributes object.
`EditableOMPoly(OMPoly omp)` Create the EditableOMPoly with an OMPoly already defined, ready for editing.

Method Summary
`int` | `addMovingPoint(int x, int y)` Add a point to the end of the polyline/polygon and then make it the moving one.
`int` | `addPoint(GrabPoint gp)` Add a point at a certain point in the polygon coordinate list.
`int` | `addPoint(GrabPoint gp, int position)` Add a point at a certain point in the polygon coordinate list.
`int` | `addPoint(int x, int y)` Add a point to the end of the polyline/polygon.
`int` | `addPoint(int x, int y, int position)` Add a point at a certain point in the polygon coordinate list.
`protected void` | `addPolyGrabPointsToOGP(OffsetGrabPoint ogp)` This method adds all the GrabPoints associated with the polygon nodes and adds them to the offset GrabPoint representing the lat/lon anchor point.
`void` | `assertGrabPoints()` Check to make sure the grab points are not null.
`void` | `attachToMovingGrabPoint(OffsetGrabPoint gp)` Attach to the Moving OffsetGrabPoint so if it moves, it will move this EditableOMGraphic with it.
`void` | `clearSelectedNode()` Make sure no node is highlighted.
`protected GrabPoint` | `createGrabPoint(int x, int y, int index, int last)` An internal method that tries to make sure that the grab point for the first node, and for the last, in case of an enclosed polygon, are OffsetGrabPoints.
`void` | `createGraphic(GraphicAttributes ga)` Create and set the graphic within the state machine.
`OMGraphic` | `createGraphic(int renderType, int lineType)` Extendable method to create specific subclasses of OMPolys.
`protected UndoEvent` | `createUndoEventForCurrentState(java.lang.String whatHappened)` Create an UndoEvent that can get an OMPoly back to what it looks like right now.
`void` | `deletePoint()` Delete a point off the end of the polyline/polygon.
`void` | `deletePoint(int position)` Delete a point at a certain point in the polygon coordinate list.
`void` | `detachFromMovingGrabPoint(OffsetGrabPoint gp)` Detach from a Moving OffsetGrabPoint.
`void` | `enablePolygonButton(boolean enable)`
`void` | `enablePolygonEditButtons(boolean enable)`
`void` | `enclose(boolean e)`
`boolean` | `evaluateEnclosed()` Method checks if the polygon should be enclosed, and then adds an addition point to the end of the polygon, setting the end point on top of the beginning point.
`boolean` | `generate(Projection proj)` Use the current projection to place the graphics on the screen.
`protected void` | `generateGrabPoints(Projection proj)` Generate the grab points, checking the OMGraphic to see if it contains information about what the grab points should look like.
`GrabPoint` | `getGrabPoint(int index)` Return a particular GrabPoint at a particular point in the array.
`GrabPoint[]` | `getGrabPoints()` Get the array of grab points used for the EditableOMGraphic.
`OMGraphic` | `getGraphic()` Get the OMGraphic being created/modified by the EditableOMPoly.
`java.awt.Component` | `getGUI(GraphicAttributes graphicAttributes)` Adds widgets to modify polygon.
`java.net.URL` | `getImageURL(java.lang.String imageName)`
`GrabPoint` | `getMovingPoint(java.awt.event.MouseEvent e)` Given a MouseEvent, find a GrabPoint that it is touching, and set the moving point to that GrabPoint.
`javax.swing.JComponent` | `getPolyGUI()`
`javax.swing.JComponent` | `getPolyGUI(boolean includeEnclose, boolean includeExt, boolean includeAdd, boolean includeDelete, int orientation)`
`javax.swing.JComponent` | `getPolyGUI(boolean includeEnclose, boolean includeExt, boolean includeAdd, boolean includeDelete, int orientation, javax.swing.JComponent buttonBox)`
`javax.swing.JComponent` | `getPolyGUI(int orientation, javax.swing.JComponent toolbar)`
`int` | `getSelectNodeIndex()`
`void` | `init()` Create and initialize the state machine that interprets the modifying gestures/commands, as well as initialize the grab points.
`boolean` | `isEnclosed()` Returns whether the graphic will be a polygon, instead of a polyline.
`void` | `move(java.awt.event.MouseEvent e)` Called to set the OffsetGrabPoint to the current mouse location, and update the OffsetGrabPoint with all the other GrabPoint locations, so everything can shift smoothly.
`void` | `regenerate(Projection proj)` Given a new projection, the grab points may need to be repositioned off the current position of the graphic.
`void` | `render(java.awt.Graphics graphics)` Draw the EditableOMPoly parts into the java.awt.Graphics object.
`void` | `setEnclosed(boolean set)` Set the flag to make the polygon enclosed, which automatically connects the last point with the first point.
`boolean` | `setGrabPoint(GrabPoint gb, int index)` Set the GrabPoint at a particule index of the array.
`void` | `setGrabPoints()` Take the current location of the GrabPoints, and modify the location parameters of the OMPoly with them.
`boolean` | `setGrabPoints(GrabPoint[] points)` Set the grab point objects within the EditableOMGraphic array.
`void` | `setGrabPoints(OMGraphic graphic)` Set the grab points for the graphic provided, setting them on the extents of the graphic.
`void` | `setGraphic(OMGraphic graphic)` Set the graphic within the state machine.
`void` | `setMovingPoint(GrabPoint gp)` Set the GrabPoint that is in the middle of being modified, as a result of a mouseDragged event, or other selection process.
`void` | `setSelectNodeIndex(int selectNodeIndex)`
`protected boolean` | `syncEnclosed()` Method connects the last point to the first point.
`protected boolean` | `unsyncEnclosed()` Method disconnects the last point from the first point.
`int` | `whichGrabPoint(GrabPoint gp)` Given a grab point, return its index into the polygon array.

Methods inherited from class com.bbn.openmap.omGraphics.EditableOMAbstractLine
`createArrowIcon, getArrowHeadMenu`

Methods inherited from class com.bbn.openmap.omGraphics.EditableOMGraphic
`_getMovingPoint, addEOMGListener, cleanMap, createAttributePanel, finalize, fireEvent, fireEvent, fireEvent, fireEvent, getActionMask, getCanGrabGraphic, getGUI, getMouseModeServiceList, getMovingPoint, getProjection, getProjectionPoint, getShowGUI, getStateMachine, getUndoStack, handleInitialMouseEvent, isMouseEventTouching, isMouseEventTouchingTheEdge, isPopupIsUp, isXorRendering, modifyOMGraphicForEditRender, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mouseMoved, mousePressed, mouseReleased, redraw, redraw, redraw, removeEOMGListener, repaint, repaintRender, reset, resetOMGraphicAfterEditRender, setActionMask, setCanGrabGraphic, setMouseModeServiceList, setPopupIsUp, setProjection, setShowGUI, setStateMachine, setUndoStack, setXorRendering, updateCurrentState`

Methods inherited from class java.lang.Object
`clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### polyGrabPoints

    protected java.util.List<GrabPoint> polyGrabPoints

### gpo

    protected OffsetGrabPoint gpo

### gpm

    protected OffsetGrabPoint gpm

### poly

    protected OMPoly poly

### manualEnclosed

    protected boolean manualEnclosed

  Whether the poly is a polygon, as opposed to a polyline. If the poly color is not clear (OMColor.clear) then it will be a polygon. If it is clear, then it can be set as a polygon - it's otherwise assumed to be a polyline.

### selectNodeIndex

    protected int selectNodeIndex

  Set the index of the grab point that should be rendered differently, in order to highlight a specific node.

### OFFSET_POINT_INDEX

    public static int OFFSET_POINT_INDEX

Constructor Detail

### EditableOMPoly

    public EditableOMPoly()

  Create the EditableOMPoly, setting the state machine to create the poly off of the gestures.

### EditableOMPoly

    public EditableOMPoly(GraphicAttributes ga)

  Create an EditableOMPoly with the polyType and renderType parameters in the GraphicAttributes object.

### EditableOMPoly

    public EditableOMPoly(OMPoly omp)

  Create the EditableOMPoly with an OMPoly already defined, ready for editing.

  Parameters:
    `omp` - OMPoly that should be edited.

Method Detail

### init

    public void init()

  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 EditableOMPoly.

### setGraphic

    public void setGraphic(OMGraphic graphic)

  Set the graphic within the state machine. If the graphic is null, then one shall be created, and located off screen until the gestures driving the state machine place it on the map.

  Specified by:
    `setGraphic` in class `EditableOMGraphic`
  Parameters:
    `graphic` - OMGraphic.

### evaluateEnclosed

    public boolean evaluateEnclosed()

  Method checks if the polygon should be enclosed, and then adds an addition point to the end of the polygon, setting the end point on top of the beginning point. The two points are OffsetGrabPoints that are tied to each other's position.

### syncEnclosed

    protected boolean syncEnclosed()

  Method connects the last point to the first point. Make sure they are both OffsetGrabPoints. Return true if the points cover the same pixel and if they were successfully joined.

### unsyncEnclosed

    protected boolean unsyncEnclosed()

  Method disconnects the last point from the first point. Make sure they are both OffsetGrabPoints.

### enclose

    public void enclose(boolean e)

### setEnclosed

    public void setEnclosed(boolean set)

  Set the flag to make the polygon enclosed, which automatically connects the last point with the first point.

### isEnclosed

    public boolean isEnclosed()

  Returns whether the graphic will be a polygon, instead of a polyline.

### createGraphic

    public void createGraphic(GraphicAttributes ga)

  Create and set the graphic within the state machine. The GraphicAttributes describe the type of poly to create.

  Specified by:
    `createGraphic` in class `EditableOMGraphic`
  Parameters:
    `ga` - GraphicAttributes, describing the graphic to be created.

### createGraphic

    public OMGraphic createGraphic(int renderType,
                                   int lineType)

  Extendable method to create specific subclasses of OMPolys.

### getGraphic

    public OMGraphic getGraphic()

  Get the OMGraphic being created/modified by the EditableOMPoly.

  Specified by:
    `getGraphic` in class `EditableOMGraphic`

### attachToMovingGrabPoint

    public void attachToMovingGrabPoint(OffsetGrabPoint gp)

  Attach to the Moving OffsetGrabPoint so if it moves, it will move this EditableOMGraphic with it. EditableOMGraphic version doesn't do anything, each subclass has to decide which of its OffsetGrabPoints should be attached to it.

  Overrides:
    `attachToMovingGrabPoint` in class `EditableOMGraphic`

### detachFromMovingGrabPoint

    public void detachFromMovingGrabPoint(OffsetGrabPoint gp)

  Detach from a Moving OffsetGrabPoint. The EditableOMGraphic version doesn't do anything, each subclass should remove whatever GrabPoint it would have attached to an OffsetGrabPoint.

  Overrides:
    `detachFromMovingGrabPoint` in class `EditableOMGraphic`

### setMovingPoint

    public void setMovingPoint(GrabPoint gp)

  Set the GrabPoint that is in the middle of being modified, as a result of a mouseDragged event, or other selection process.

  Overrides:
    `setMovingPoint` in class `EditableOMGraphic`

### getMovingPoint

    public GrabPoint getMovingPoint(java.awt.event.MouseEvent e)

  Given a MouseEvent, find a GrabPoint that it is touching, and set the moving point to that GrabPoint. Called when a MouseEvent happens, and you want to find out if a GrabPoint should be used to make modifications to the graphic or its position.

  Overrides:
    `getMovingPoint` in class `EditableOMGraphic`
  Parameters:
    `e` - MouseEvent
  Returns:
    GrabPoint that is touched by the MouseEvent, null if none are.

### assertGrabPoints

    public void assertGrabPoints()

  Check to make sure the grab points are not null. If they are, allocate them, and them assign them to the array.

### createGrabPoint

    protected GrabPoint createGrabPoint(int x,
                                        int y,
                                        int index,
                                        int last)

  An internal method that tries to make sure that the grab point for the first node, and for the last, in case of an enclosed polygon, are OffsetGrabPoints. All of the other points will be regular GrabPoints. Usually called when assigning points to a previously defined poly.

  Parameters:
    `x` - the horizontal pixel location of the grab point.
    `y` - the vertical pixel location of the grab point.
    `index` - the index of the grab point.
    `last` - the index of the last point.

### setGrabPoints

    public void setGrabPoints(OMGraphic graphic)

  Set the grab points for the graphic provided, setting them on the extents of the graphic. Called when you want to set the grab points off the points of the graphic.

### setGrabPoints

    public void setGrabPoints()

  Take the current location of the GrabPoints, and modify the location parameters of the OMPoly with them. Called when you want the graphic to change according to the grab points.

  Specified by:
    `setGrabPoints` in class `EditableOMGraphic`

### addMovingPoint

    public int addMovingPoint(int x,
                              int y)

  Add a point to the end of the polyline/polygon and then make it the moving one.

  Returns:
    the index for the point in the polygon, starting with 0.

### addPoint

    public int addPoint(int x,
                        int y)

  Add a point to the end of the polyline/polygon.

  Returns:
    the index for the point in the polygon, starting with 0.

### addPoint

    public int addPoint(int x,
                        int y,
                        int position)

  Add a point at a certain point in the polygon coordinate list. If the position is less than zero, the point will be the starting point. If the position is greater than the list of current points, the point will be added to the end of the poly.

  Returns:
    the index for the point in the polygon, starting with 0.

### addPoint

    public int addPoint(GrabPoint gp)

  Add a point at a certain point in the polygon coordinate list. If the position is less than zero, the point will be the starting point. If the position is greater than the list of current points, the point will be added to the end of the poly. This method is convenient because it lets you define the GrabPoint object to use for the node, in case you need a special type of GrabPoint.

  Parameters:
    `gp` - the GrabPoint set to the screen coordinates of the point to be added.
  Returns:
    the index for the point in the polygon, starting with 0.

### addPoint

    public int addPoint(GrabPoint gp,
                        int position)

  Add a point at a certain point in the polygon coordinate list. If the position is less than zero, the point will be the starting point. If the position is greater than the list of current points, the point will be added to the end of the poly. This method is convenient because it lets you define the GrabPoint object to use for the node, in case you need a special type of GrabPoint.

  Returns:
    the index for the point in the polygon, starting with 0.

### deletePoint

    public void deletePoint()

  Delete a point off the end of the polyline/polygon.

### deletePoint

    public void deletePoint(int position)

  Delete a point at a certain point in the polygon coordinate list. If the position is less than zero, the deleted point will be the starting point. If the position is greater than the list of current points, the point will be deleted from the end of the poly.

### move

    public void move(java.awt.event.MouseEvent e)

  Called to set the OffsetGrabPoint to the current mouse location, and update the OffsetGrabPoint with all the other GrabPoint locations, so everything can shift smoothly. Should also set the OffsetGrabPoint to the movingPoint. Should be called only once at the beginning of the general movement, in order to set the movingPoint. After that, redraw(e) should just be called, and the movingPoint will make the adjustments to the graphic that are needed.

  Specified by:
    `move` in class `EditableOMGraphic`

### addPolyGrabPointsToOGP

    protected void addPolyGrabPointsToOGP(OffsetGrabPoint ogp)

  This method adds all the GrabPoints associated with the polygon nodes and adds them to the offset GrabPoint representing the lat/lon anchor point.

### generate

    public boolean generate(Projection proj)

  Use the current projection to place the graphics on the screen. Has to be called to at least assure the graphics that they are ready for rendering. Called when the graphic position changes.

  Specified by:
    `generate` in class `EditableOMGraphic`
  Parameters:
    `proj` - com.bbn.openmap.proj.Projection
  Returns:
    true

### generateGrabPoints

    protected void generateGrabPoints(Projection proj)

  Generate the grab points, checking the OMGraphic to see if it contains information about what the grab points should look like.

  Parameters:
    `proj` -

### regenerate

    public void regenerate(Projection proj)

  Given a new projection, the grab points may need to be repositioned off the current position of the graphic. Called when the projection changes.

  Specified by:
    `regenerate` in class `EditableOMGraphic`

### render

    public void render(java.awt.Graphics graphics)

  Draw the EditableOMPoly parts into the java.awt.Graphics object. The grab points are only rendered if the poly machine state is PolySelectedState.POLY_SELECTED.

  Specified by:
    `render` in class `EditableOMGraphic`
  Parameters:
    `graphics` - java.awt.Graphics.

### setGrabPoints

    public boolean setGrabPoints(GrabPoint[] points)

  Set the grab point objects within the EditableOMGraphic array. For the EditableOMPoly, with its variable number of GrabPoints, this just sets up a new list of all the grab points to look at. It's different than the polyGrabPoints, which are the grab points just on the polygon. This list includes the offset grab point. This method should be called when a new point gets added to the polygon, and should take an array of all the GrabPoints created. It will add the offsetGrabPoint to the end of the array.

  Overrides:
    `setGrabPoints` in class `EditableOMGraphic`
  Parameters:
    `points` - a GrabPoint[] for the points on the polygon.
  Returns:
    true if the grab point array was exactly what the EditableOMGraphic was expecting, in terms of length of the GrabPoint array length. The method copies the array values that fit into the resident array.

### getGrabPoints

    public GrabPoint[] getGrabPoints()

  Get the array of grab points used for the EditableOMGraphic. Creates the array by copying all the grab points out of the List, and tacking the offset grab point to the end.

  Overrides:
    `getGrabPoints` in class `EditableOMGraphic`

### setGrabPoint

    public boolean setGrabPoint(GrabPoint gb,
                                int index)

  Set the GrabPoint at a particule index of the array. This can be used to tie two different grab points together. This used to work with the gPoints array declared in EditableOMGraphic - no longer. If the index is -1, the offset grab point is set, and any other index refers to the concurrent polygon point.

  Overrides:
    `setGrabPoint` in class `EditableOMGraphic`
  Parameters:
    `gb` - GrabPoint to assign within array.
    `index` - the index of the array to put the GrabPoint. This index should be -1 for the offset grab point, or the index of the corner of the poly, in order starting from 0.
  Returns:
    If the grab point or array is null, or if the index is outside the range of the array, false is returned. If everything goes OK, then true is returned.

### whichGrabPoint

    public int whichGrabPoint(GrabPoint gp)

  Given a grab point, return its index into the polygon array. If its not in the array, the next available index is returned.

### getGrabPoint

    public GrabPoint getGrabPoint(int index)

  Return a particular GrabPoint at a particular point in the array. The EditableOMGraphic should describe which indexes refer to which grab points in the EOMG GrabPoint array. If the index is OFFSET_POINT_INDEX, the offset point is returned. If the index is otherwise outside the range of the array, null is returned.

  Overrides:
    `getGrabPoint` in class `EditableOMGraphic`

### getGUI

    public java.awt.Component getGUI(GraphicAttributes graphicAttributes)

  Adds widgets to modify polygon.

  Overrides:
    `getGUI` in class `EditableOMAbstractLine`
  Parameters:
    `graphicAttributes` - the GraphicAttributes to use to get the GUI widget from to control those parameters for this EOMG.
  Returns:
    Component to use to control parameters for this EOMG.

### enablePolygonButton

    public void enablePolygonButton(boolean enable)

### enablePolygonEditButtons

    public void enablePolygonEditButtons(boolean enable)

### getPolyGUI

    public javax.swing.JComponent getPolyGUI()

### getPolyGUI

    public javax.swing.JComponent getPolyGUI(int orientation,
                                             javax.swing.JComponent toolbar)

### getPolyGUI

    public javax.swing.JComponent getPolyGUI(boolean includeEnclose,
                                             boolean includeExt,
                                             boolean includeAdd,
                                             boolean includeDelete,
                                             int orientation)

### getPolyGUI

    public javax.swing.JComponent getPolyGUI(boolean includeEnclose,
                                             boolean includeExt,
                                             boolean includeAdd,
                                             boolean includeDelete,
                                             int orientation,
                                             javax.swing.JComponent buttonBox)

### getImageURL

    public java.net.URL getImageURL(java.lang.String imageName)

### getSelectNodeIndex

    public int getSelectNodeIndex()

  Returns:
    the selectNodeIndex

### setSelectNodeIndex

    public void setSelectNodeIndex(int selectNodeIndex)

  Parameters:
    `selectNodeIndex` - the selectNodeIndex to set

### clearSelectedNode

    public void clearSelectedNode()

  Make sure no node is highlighted.

### createUndoEventForCurrentState

    protected UndoEvent createUndoEventForCurrentState(java.lang.String whatHappened)

  Create an UndoEvent that can get an OMPoly back to what it looks like right now.

  Overrides:
    `createUndoEventForCurrentState` in class `EditableOMGraphic`
  Parameters:
    `whatHappened` - String describing what got you here. You can leave this null if you just want to go with the default.
  Returns:
    UndoEvent reflecting current state. May be null if undo isn't handled. Returning null is the default action.

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (C) BBNT Solutions LLC; See http://openmap.bbn.com/ for details