Class TLcdGXYPointListPainter

All Implemented Interfaces:
ILcdCloneable, ILcdPropertyChangeSource, ILcdGXYEditor, ILcdGXYEditorProvider, ILcdGXYPainter, ILcdGXYPainterProvider, ILcdGXYPathPainter, Serializable, Cloneable
Direct Known Subclasses:
TLcdGXYAISPointListPainter, TLcdGXYRoundedPointListPainter, TLcdMagneticNorthGXYPainter, TLcdPOLPainter, TLcdVPFPointListPainter

public class TLcdGXYPointListPainter extends ALcdGXYAreaPainter implements ILcdGXYPainter, ILcdGXYEditor, ILcdGXYEditorProvider, ILcdGXYPathPainter
Paints and locates ILcdPointList objects (including ILcdComplexPolygon) and enables visual editing of ILcd2DEditablePointList objects in an ILcdGXYView.

Painting an ILcdPointList

Body

This painter provides five paint modes to paint the body of an ILcdPointList. The mode property can be set using the method setMode and allows the point list to be painted as:

A set of points
A polyline
A set of points (POINT)
A polyline (POLYLINE)

A polygon
A filled polygon
A filled and outlined polygon
An outlined polygon (POLYGON)
A filled polygon (FILLED)
A filled and outlined polygon (OUTLINED_FILLED)

Objects that are selected or that are being edited, are painted as defined by the selectionMode and editMode properties, respectively. The same values as above can be used for both mode properties. These properties are not taken into account when an object needs to be painted in the paint mode POINT or POLYLINE.

Handles

Every point of the point list is regarded as a handle of the point list. The following image clarifies the handle location, the points are represented by red points.

The different handles

Note that, when the paint mode is set to POINT, the points are more than only a handle. They are also the only visible part of the shape and should therefore always be painted independent of the rendering mode.

Snap targets

Every point of the point list can be returned on the condition that it is touched, see getTouchedPoint. The point returned as a snap target is highlighted with the snapIcon.

Styling options

The visualization of the ILcdPointList object is governed by the line style and fill style set to this painter. Depending on the paint mode chosen one or both of these will be taken into account.

Locating an ILcdPointList in a view

Anchor point of an ILcdPointList

When the ILcdPointList is also an ILcdShape, the anchor point is located at the focus point of the shape. Otherwise the anchor point is located at the center point of the point list.

When is an ILcdPointList touched

Depending on the paint mode, a point list is touched when either a point of the point list, a segment of the point list, or the internal area of the point list is touched. The methods getTouchedPoint, getTouchedSegment and insidePolygon provide information on which part of the point list is being touched.

Visually editing and creating an ILcd2DEditablePointList

Modifying an ILcd2DEditablePointList

This editor provides the following edit functionality for the different render modes:

  • RESHAPED: a point is added to the point list or removed from the point list, depending on whether a point or a segment of the point list is touched.

  • TRANSLATED: a single point or the whole point list is translated, depending on whether a point or a segment is touched. The images below illustrate the editing behavior. The small black arrow indicates the path of the mouse cursor while translating the point list.

    Moving a point
    Moving a segment
    Moving the interior
    Moving a point.
    Moving a segment.
    Moving the interior.

Creating an ILcd2DEditablePointList

The number of points in a point list is not limited. When initializing a point list via interaction through the view, a new point will be appended to the point list when calling edit with either START_CREATION, CREATING or END_CREATION mode.

Accepted snap targets

All points are accepted as snap target as long as:

  • the point can be transformed to the reference of the ILcdPointList object with the model to model transformation,
  • the point is not the last point of the ILcdPointList object set to this painter.

Additional properties

Caching

This painter implementation supports caching for objects implementing ILcdCache. Caching can be turned on/off with the setPaintCache method.

See Also:
  • Field Details

    • POLYGON

      public static final int POLYGON
      Draw the ILcdPointList object as an outlined polygon, only the contour of the polygon defined by the ILcdPointList is painted. This constant has the same value as the constant ALcdGXYAreaPainter.OUTLINED.
      See Also:
    • FILLED

      public static final int FILLED
      Draw the ILcdPointList object as a filled polygon, only the area of the polygon defined by the ILcdPointList is painted.
      Since:
      1.4
      See Also:
    • OUTLINED_FILLED

      public static final int OUTLINED_FILLED
      Draw the ILcdPointList object as an outlined and filled polygon, both the area and the contour of the polygon defined by the ILcdPointList are painted.
      Since:
      1.4
      See Also:
    • POINT

      public static final int POINT
      Draw the ILcdPointList as a list of points.
      See Also:
    • POLYLINE

      public static final int POLYLINE
      Draw the ILcdPointList as a polyline.
      See Also:
    • AREA

      public static final int AREA
      Deprecated.
      use FILLED instead
      Draw the ILcdPointList object as a filled polygon, only the area of the polygon defined by the ILcdPointList is painted.
      See Also:
    • OUTLINE_AREA

      public static final int OUTLINE_AREA
      Deprecated.
      use OUTLINED_FILLED instead
      Draw the ILcdPointList object as an outlined and filled polygon, both the area and the contour of the polygon defined by the ILcdPointList are painted.
      See Also:
    • MIDDLE_OF_BOUNDS

      public static final int MIDDLE_OF_BOUNDS
      Constant value indicating that the anchor point should be chosen in the middle of the bounds, calculated by boundsSFCT.
      See Also:
    • FOCUS_POINT

      public static final int FOCUS_POINT
      Constant value indicating that the anchor point should be chosen as the focus point of the point list if it implements ILcdShape. If it does not implement ILcdShape, the COORDINATES_AVERAGE method is used.
      See Also:
    • COORDINATES_AVERAGE

      public static final int COORDINATES_AVERAGE
      Constant value indicating that the anchor point should be chosen as the location determined by the average values of the x and y coordinates. If this method cannot return an anchor point, the MIDDLE_OF_BOUNDS method is used.
      See Also:
    • FIRST_POSSIBLE_POINT

      public static final int FIRST_POSSIBLE_POINT
      Constant value indicating that the anchor point should be chosen at the location of the first possible point. If the first point is invalid, then the second one is used, and so on... If no valid anchor point can be found, the MIDDLE_OF_BOUNDS method is used.
      See Also:
    • MEDIAN_POINT

      public static final int MEDIAN_POINT
      Constant value indicating that the anchor point should be chosen at the location of the point with index ( ( getPointCount() - 1 ) / 2 ). If no valid anchor point can be found, the MIDDLE_OF_BOUNDS method is used.
      See Also:
    • MIDDLE_OF_CURVE

      public static final int MIDDLE_OF_CURVE
      Constant value indicating that the anchor point should be chosen at the middle of the curve if ILcdCurve is implemented. If ILcdCurve is not implemented, or if no valid anchor point can be found, the MIDDLE_OF_BOUNDS method is used.
      See Also:
    • START_OF_CURVE

      public static final int START_OF_CURVE
      Constant value indicating that the anchor point should be chosen at the start of the curve if ILcdCurve is implemented. If ILcdCurve is not implemented, or if no valid anchor point can be found, the MIDDLE_OF_BOUNDS method is used.
      See Also:
    • END_OF_CURVE

      public static final int END_OF_CURVE
      Constant value indicating that the anchor point should be chosen at the end of the curve if ILcdCurve is implemented. If ILcdCurve is not implemented, or if no valid anchor point can be found, the MIDDLE_OF_BOUNDS method is used.
      See Also:
    • INSIDE_POLYGON

      public static final int INSIDE_POLYGON
      Constant value indicating that the anchor point should be chosen inside the polygon. This method works when this painter uses the POLYGON painting mode. If no anchor point could be calculated, the MIDDLE_OF_BOUNDS method is used instead.
      See Also:
  • Constructor Details

    • TLcdGXYPointListPainter

      public TLcdGXYPointListPainter()
      Constructs a default TLcdGXYPointListPainter in the default mode POLYLINE and, as display name, the result of the method getModeName() is used.
    • TLcdGXYPointListPainter

      public TLcdGXYPointListPainter(String aDisplayName)
      Constructs a default TLcdGXYPointListPainter in the default mode POLYLINE and with the given display name.
      Parameters:
      aDisplayName - The display name for this painter, used for textual representation of this painter.
    • TLcdGXYPointListPainter

      public TLcdGXYPointListPainter(int aDefaultMode)

      Constructs a TLcdGXYPointListPainter in the specified default mode and, as display name, the result of the method getModeName() is used.

      The default paint mode should be one of the following values: POINT, POLYLINE, POLYGON, FILLED, OUTLINED_FILLED.

      Parameters:
      aDefaultMode - The default paint mode to paint ILcdPointList objects.
      See Also:
    • TLcdGXYPointListPainter

      public TLcdGXYPointListPainter(String aDisplayName, int aDefaultMode)

      Constructs a TLcdGXYPointListPainter in the specified default mode and with the given display name.

      The default paint mode should be one of the following values: POINT, POLYLINE, POLYGON, FILLED, OUTLINED_FILLED.

      Parameters:
      aDisplayName - The display name for this painter, used for textual representation of this painter.
      aDefaultMode - The default paint mode to paint ILcdPointList objects.
      See Also:
  • Method Details

    • setTraceOn

      public void setTraceOn(boolean aTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for this class instance. Calling this method with either true or false as argument automatically turns off tracing for all other class instances for which setTraceOn has not been called. If the argument is false then only the informative, warning and error log messages are recorded.
      Overrides:
      setTraceOn in class ALcdGXYPainter
      Parameters:
      aTraceOn - if true then all log messages are recorded for this instance. If false, then only the informative, warning and error log messages are recorded.
    • isTraceOn

      public boolean isTraceOn()
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Returns true if tracing is enabled for this class.
      Overrides:
      isTraceOn in class ALcdGXYPainter
      Returns:
      true if tracing is enabled for this class, false otherwise.
    • setObject

      public void setObject(Object aObject)
      Sets the object to paint or edit. This painter needs an ILcdPointList for painting and (optionally) an ILcd2DEditablePointList for editing. You can change how the ILcdPointList is derived from the object by overriding retrievePointList(java.lang.Object).
      Specified by:
      setObject in interface ILcdGXYEditor
      Specified by:
      setObject in interface ILcdGXYPainter
      Parameters:
      aObject - The object to paint and edit.
      Throws:
      ClassCastException - when the object does not implement ILcdPointList.
      See Also:
    • retrievePointList

      protected ILcdPointList retrievePointList(Object aObject)
      Extracts an ILcdPointList from the given object. The default implementation simply casts the object to an ILcdPointList. Re-define this method to obtain the ILcdPointList by other means.
      Returns:
      the point list associated with the given object
      Throws:
      ClassCastException - when the point list cannot be derived
      Since:
      2022.0
      See Also:
    • getObject

      public Object getObject()
      Returns the object that can currently be painted or edited by this painter/editor.
      Specified by:
      getObject in interface ILcdGXYEditor
      Specified by:
      getObject in interface ILcdGXYPainter
      Returns:
      the object that can currently be painted or edited by this painter/editor.
      See Also:
    • setPaintCache

      public void setPaintCache(boolean aPaintCache)
      Turns caching of the representation of the object on or off. Caching greatly reduces the time to paint an object but requires more memory. The representation of an object can only be cached for objects which implement ILcdCache. By default, caching is turned on.
      Parameters:
      aPaintCache - A flag indicating whether to use caching when painting an object.
      See Also:
    • getPaintCache

      public boolean getPaintCache()
      Returns whether caching is used when painting this painter's object.
      Returns:
      true if caching is used to paint this painter's object, false otherwise.
      See Also:
    • setMode

      public void setMode(int aDefaultMode)
      Sets the default mode to decide how to paint an ILcdPointList. The point list can be painted as a set of individual points (POINT), as a polyline (POLYLINE), as an outlined polygon (POLYGON), as a filled polygon (FILLED), or as a filled and outlined polygon (OUTLINED_FILLED).

      As a side effect, this method will set the display name and initialize the line style if no line style was defined. The display name is retrieved using the method getModeName().

      This will also have an effect on the behavior of getCreationClickCount(), isTouched(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext), and edit(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext).

      Overrides:
      setMode in class ALcdGXYAreaPainter
      Parameters:
      aDefaultMode - The default paint mode to paint ILcdPointList objects.
      See Also:
    • getMode

      public int getMode()
      Returns the default mode to decide how to paint an ILcdPointList. The object can be painted as a set of individual points (POINT), as a polyline (POLYLINE), as an outlined polygon (POLYGON), as a filled polygon (FILLED), or as a filled and outlined polygon (OUTLINED_FILLED).
      Overrides:
      getMode in class ALcdGXYAreaPainter
      Returns:
      The default paint mode to paint ILcdPointList objects.
      See Also:
    • setModelModelTransformationClass

      public void setModelModelTransformationClass(Class aModel2ModelTransformationClass)

      Sets the transformation class that should be used when snapping to points that are defined in a different reference than the reference of this painter's object. The transformation will be instantiated and setup to transform points from the model of the snap layer to points in the model which contains the current object of this painter. The default value is the TLcdGeoReference2GeoReference class.

      This property allows the painter to snap to points defined in a different model reference.

      Instances of this specified class should implement ILcdModelModelTransformation, otherwise the snapping functionality to different model references will not work.

      Parameters:
      aModel2ModelTransformationClass - the transformation used as described above.
    • isMoveOnlyOnEdit

      public boolean isMoveOnlyOnEdit()
      Returns whether this painter only allows moving the shape as a whole. If false, other editing operations will be available as well.
      Returns:
      whether this painter allows only moving the shape while editing.
      See Also:
    • setMoveOnlyOnEdit

      public void setMoveOnlyOnEdit(boolean aMoveOnlyOnEdit)
      Sets whether this painter only allows moving the shape as a whole. If false, other editing operations will be available as well. By default, this value is set to false.
      Parameters:
      aMoveOnlyOnEdit - when set to true this painter can only move a ILcdPointList when editing and not change its shape.
      See Also:
    • setFillSelection

      public void setFillSelection(boolean aFillSelection)
      Determines whether the painter will fill the polygon when it is selected. This property is only valid when the default paint mode property is either POLYGON, FILLED or OUTLINED_FILLED. The default is false.
      Parameters:
      aFillSelection - A flag indicating whether to paint the object filled when selected.
      See Also:
    • getFillSelection

      public boolean getFillSelection()
      Deprecated.
      Returns whether the object is painted filled in the render mode ILcdGXYPainter.SELECTED.
      Returns:
      whether the object is painted filled in the render mode ILcdGXYPainter.SELECTED.
      See Also:
    • setMinimumEditDelta

      public void setMinimumEditDelta(int aDelta)
      Sets the minimum pixel distance the input device (a mouse, for example) must move before editing the shape. A larger value ensures that the object easily "snaps" back in place, a small value allows fine editing.
      Parameters:
      aDelta - the minimum pixel distance the input device should move in either the X or Y direction
    • getMinimumEditDelta

      public int getMinimumEditDelta()
      Returns the minimum pixel distance the input device (a mouse, for example) must move before editing the shape. A larger value ensures that the object easily "snaps" back in place, a small value allows fine editing. The default value is 3 pixels.
      Returns:
      the minimum pixel distance the input device should move in either the X or Y direction
    • getAnchorPointLocation

      public int getAnchorPointLocation()
      Returns the location of the anchor point (by default: FOCUS_POINT).
      Returns:
      one of MIDDLE_OF_BOUNDS, COORDINATES_AVERAGE, FOCUS_POINT, FIRST_POSSIBLE_POINT, MEDIAN_POINT, MIDDLE_OF_CURVE, START_OF_CURVE, END_OF_CURVE, INSIDE_POLYGON.
    • setAnchorPointLocation

      public void setAnchorPointLocation(int aAnchorPointLocation)
      Sets the preferred anchor point location.
      Parameters:
      aAnchorPointLocation - one of MIDDLE_OF_BOUNDS, COORDINATES_AVERAGE, FOCUS_POINT, FIRST_POSSIBLE_POINT, MEDIAN_POINT, MIDDLE_OF_CURVE, START_OF_CURVE, END_OF_CURVE, INSIDE_POLYGON.
    • getGXYEditor

      public ILcdGXYEditor getGXYEditor(Object aObject)
      Returns this instance as editor for editing the specified Object. If this Object is not the same as the Object set to this painter, the setObject(Object) method is called to update the object set to the painter.
      Specified by:
      getGXYEditor in interface ILcdGXYEditorProvider
      Parameters:
      aObject - the object to be edited.
      Returns:
      this instance as editor for editing the specified Object.
    • setSnapIcon

      public void setSnapIcon(ILcdIcon aSnapIcon)
      Sets the icon that marks snap targets of the object currently set to this painter. This icon is painted when the paint method is called with the render mode ILcdGXYPainter.SNAPS.
      Parameters:
      aSnapIcon - The icon that should be used to paint snap target points.
      See Also:
    • getSnapIcon

      public ILcdIcon getSnapIcon()
      Returns the icon that is used to paint snap target points of the object set to this painter.
      Returns:
      the icon that is used to paint snap target points of the object set to this painter.
      See Also:
    • getWindingRule

      public TLcdAWTPath.WindingRule getWindingRule()
      Returns how the interior of self-intersecting polygons is determined. This affects isTouched behavior and the fills.
      Returns:
      the winding rule to use
    • setWindingRule

      public void setWindingRule(TLcdAWTPath.WindingRule aWindingRule)
      Specifies how the interior of self-intersecting polygons is determined. This affects isTouched behavior and the fills.
      Parameters:
      aWindingRule - the winding rule to use
    • getModeName

      protected String getModeName()
      Returns the current default paint mode as a String. The method setMode(int) calls this method to adjust the display name of this instance depending on new mode property.
      Returns:
      the current default paint mode as a String.
    • setupGraphicsForLine

      protected void setupGraphicsForLine(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)

      Called just before painting a line on the specified Graphics object. It can be redefined in order to set specific Graphics properties like Color, etc...

      This implementation calls ILcdGXYPainterStyle.setupGraphics(java.awt.Graphics, java.lang.Object, int, com.luciad.view.gxy.ILcdGXYContext) on the lineStyle property if a line style has been set to this instance.

      Parameters:
      aGraphics - The graphics to paint the object on.
      aRenderMode - The mode to render the object in.
      aGXYContext - The context to render the object in.
    • setupGraphicsForFill

      protected void setupGraphicsForFill(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)

      Called just before filling polygons on the specified Graphics object. It can be redefined in order to set specific Graphics properties like Color, etc...

      This implementation calls ILcdGXYPainterStyle.setupGraphics(java.awt.Graphics, java.lang.Object, int, com.luciad.view.gxy.ILcdGXYContext) on the fillStyle property if a fill style has been set to this instance.

      Parameters:
      aGraphics - The graphics to paint the object on.
      aRenderMode - The mode to render the object in.
      aGXYContext - The context to render the object in.
    • setupGraphicsForPoint

      protected void setupGraphicsForPoint(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)

      Called just before painting points on the specified Graphics object. It can be redefined in order to set specific Graphics properties like Color, etc...

      This implementation calls ILcdGXYPainterStyle.setupGraphics(Graphics, Object, int, ILcdGXYContext) on the lineStyle property if a line style has been set to this instance.

      Note that points are painted using the method ILcdGXYPen.drawHotPoint(com.luciad.shape.ILcdPoint, com.luciad.transformation.ILcdModelXYWorldTransformation, com.luciad.view.gxy.ILcdGXYViewXYWorldTransformation, java.awt.Graphics). Therefore changes should be applied to the pen, not the graphics, since those are usually disregarded by the pen.

      Parameters:
      aGraphics - The graphics to paint the object on.
      aRenderMode - The mode to render the object in.
      aGXYContext - The context to render the object in.
    • anchorPointSFCT

      public void anchorPointSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException

      Moves the specified aPointSFCT to the anchor point of the ILcdPointList. This implementation first finds an anchor point in model coordinates and then transforms it into a view point.

      See getAnchorPointLocation() on how the anchor point is calculated.

      Specified by:
      anchorPointSFCT in interface ILcdGXYPainter
      Overrides:
      anchorPointSFCT in class ALcdGXYPainter
      Parameters:
      aGraphics - The graphics to paint the object on.
      aRenderMode - The mode to render the object in.
      aGXYContext - The context to render the object in.
      aPointSFCT - The point that needs to be updated.
      Throws:
      TLcdNoBoundsException - if the ILcdPointList object doesn't have a valid anchor point, e.g. if it is always invisible in the current projection.
      See Also:
    • paint

      public void paint(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
      Displays the representation of the object in the given mode on the Graphics passed, taking into account the context passed.

      This implementation will use the specified render mode to determine how the object needs to be rendered. In ILcdGXYPainter.TRANSLATING mode, the ILcdPointList object is rendered as if all points were moved along the same distance in view coordinates as passed in the context. In ILcdGXYPainter.RESHAPING mode, the object is painted with one point moved as defined in the context. In ILcdGXYPainter.CREATING mode, the object is painted as if the current mouse position is the last point of the ILcdPointList. In the above render modes, the object is painted using the edit paint mode (ALcdGXYAreaPainter.getEditMode()).

      In the render mode ILcdGXYPainter.SELECTED, the object is painted using the selection paint mode (ALcdGXYAreaPainter.getSelectionMode()). In all other render modes, the paint mode (getMode()) is used.

      Note: when the paint mode is set to POINT or POLYLINE, the objects will be painted as, respectively points and polylines. The selectionMode and editMode property are not taken into account when finding the mode in which the object should be painted.

      Specified by:
      paint in interface ILcdGXYPainter
      Parameters:
      aGraphics - The graphics to paint the object on.
      aRenderMode - The mode to render the object in.
      aGXYContext - The context to render the object in.
    • appendAWTPath

      public boolean appendAWTPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdAWTPath aAWTPathSFCT)
      Description copied from interface: ILcdGXYPathPainter
      Appends a discretized representation in view coordinates to the given path.
      Specified by:
      appendAWTPath in interface ILcdGXYPathPainter
      Parameters:
      aGXYContext - the graphics context
      aRenderMode - the rendering mode
      aAWTPathSFCT - the path to append to
      Returns:
      true if a discretization of the shape could be successfully appended to the path
    • appendGeneralPath

      public boolean appendGeneralPath(ILcdGXYContext aGXYContext, int aRenderMode, ILcdGeneralPath aGeneralPathSFCT)
      Description copied from interface: ILcdGXYPathPainter
      Appends a discretized representation in world coordinates to the given path.
      Specified by:
      appendGeneralPath in interface ILcdGXYPathPainter
      Parameters:
      aGXYContext - the graphics context
      aRenderMode - the rendering mode
      aGeneralPathSFCT - the path to append to
      Returns:
      true if a discretization of the shape could be successfully appended to the path
    • isTouched

      public boolean isTouched(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
      Depending on the render mode and paint mode, returns whether one of the handles (the source point list), the painted point list or the interior of the point list is touched.

      This implementation will use the specified paint mode to determine how the object is represented. Depending on the representation of the ILcdPointList object, the object is touched when

      • the painted point list is touched,
      • its interior space is touched when the paint mode is FILLED,
      • the source point list is touched when the render mode is ILcdGXYPainter.SELECTED.
      The coordinate for which the check is done is derived from the context passed as argument.

      The method insidePolygon determines whether the current mouse position is located inside the ILcdPointList object or not.

      It is not possible to derive from this method which part of the point list has been touched. To determine which part of the ILcdPointList object is touched, the methods getTouchedPoint and getTouchedSegment will return the required information.

      Specified by:
      isTouched in interface ILcdGXYPainter
      Parameters:
      aGraphics - The graphics to paint the object on.
      aRenderMode - The mode to render the object in.
      aGXYContext - The context in which the object is rendered.
      Returns:
      whether one of the points, segments or the interior of the point list is touched.
      See Also:
    • insidePolygon

      public boolean insidePolygon(ILcdGXYContext aGXYContext)
      Checks whether the current position of the mouse is on the inside of the point list set to this painter as if it was rendered as in polygon mode. This method is called by isTouched when the painter is configured to render the point list in FILLED or OUTLINED_FILLED mode.
      Parameters:
      aGXYContext - the context that contains a.o. the mouse position and the transformations.
      Returns:
      true if the mouse is positioned on the inside of the point list as if it is rendered as in polygon mode. False otherwise.
    • getTouchedPoint

      public int getTouchedPoint(ILcdGXYContext aGXYContext)

      Returns the index of the point in the ILcdPointList object that has been touched according to the screen (x,y) coordinates passed in the ILcdGXYContext, or -1 if none of the points were touched.

      If more than one point of the ILcdPointList object is touched, the index of the one with the smaller index is returned.

      Parameters:
      aGXYContext - The context in which the object is rendered.
      Returns:
      the index of the point in the ILcdPointList object that was touched, -1 if none of the points were touched.
    • getTouchedSegment

      public int getTouchedSegment(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)

      Returns the index of the segment in the ILcdPointList object that has been touched according to the coordinates in the context, or -1 if none of the segments were touched.

      If more than one segment of the ILcdPointList object is touched, the index of the one with the smaller index is returned.

      Parameters:
      aGraphics - The graphics to paint the object on.
      aRenderMode - The mode to render the object in.
      aGXYContext - The context in which the object is rendered.
      Returns:
      the index of the segment of the point list painted that was touched, -1 if none was touched.
    • getTouchedSegment

      public final int getTouchedSegment(ILcdGXYPen aPen, int aX, int aY, boolean includesHotPoints, ILcdModelXYWorldTransformation aMWT, ILcdGXYViewXYWorldTransformation aVWT)

      Returns the index of the segment in the ILcdPointList object that has been touched according to the specified screen (aX,aY) coordinates, or -1 if none of the segments were touched.

      If more than one segment of the ILcdPointList object is touched, the index of the one with the smaller index is returned.

      Parameters:
      aPen - the pen used to paint the segments on the screen.
      aX - the x screen coordinate
      aY - the y screen coordinate
      includesHotPoints - whether or not to include hot points.
      aMWT - the model to world transformation to use to transform the world coordinate to a model coordinate.
      aVWT - the view to world transformation to use to transform a view (screen) coordinate to a world coordinate.
      Returns:
      the index of the segment of the point list painted that was touched, -1 if none was touched.
    • boundsSFCT

      public void boundsSFCT(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
      Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object in the given mode taking into account the given context.

      If this method returns without exception the bounds argument must encompass the representation of the object. A point outside the bounds will not be contained within the painted object.

      The bounds returned in this method can be seen as the equivalent in the view space of the bounds in the model space for ILcdBounded objects.

      Specified by:
      boundsSFCT in interface ILcdGXYPainter
      Parameters:
      aGraphics - The graphics to paint the object on.
      aRenderMode - The mode to render the object in.
      aGXYContext - The context to render the object in.
      aBoundsSFCT - The bounds to update.
      Throws:
      TLcdNoBoundsException - if no bounds can be determined for the representation of the object. This can happen when the object does not have a representation in the given context, for example when it is located in a part of the world which is not visible in the current view.
      See Also:
    • supportSnap

      public boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)

      Supports snapping when the ILcdPointList object set to this painter contains at least one point.

      Specified by:
      supportSnap in interface ILcdGXYPainter
      Overrides:
      supportSnap in class ALcdGXYPainter
      Parameters:
      aGraphics - the graphics on which is worked.
      aGXYContext - the context of the snapping.
      Returns:
      true if the ILcdPointList object contains at least one point, false otherwise.
    • snapTarget

      public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)

      Returns a point of the ILcdPointList object if the point is touched. If no point was touched, null will be returned.

      Specified by:
      snapTarget in interface ILcdGXYPainter
      Overrides:
      snapTarget in class ALcdGXYPainter
      Parameters:
      aGraphics - the graphics on which is worked.
      aGXYContext - the context of the snapping.
      Returns:
      a point of the ILcdPointList object if the point is touched, null otherwise.
      See Also:
    • getCursor

      public Cursor getCursor(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)
      Returns a Cursor that clarifies the render mode and context this painter is operating in. When no specific Cursor is required, null is returned.
      Specified by:
      getCursor in interface ILcdGXYPainter
      Overrides:
      getCursor in class ALcdGXYPainter
      Parameters:
      aGraphics - The graphics on which the object is painted.
      aRenderMode - The mode to render the object in.
      aGXYContext - The context in which the object is rendered.
      Returns:
      a cursor to indicate the type of operating mode and context. Returns null if no particular cursor is required.
    • removePointAt

      public void removePointAt(ILcd2DEditablePointList a2DEditablePointList, int aIndex, int aRenderMode, ILcdGXYContext aGXYContext)
      Removes the point at the given index from the specified ILcd2DEditablePointList.
      Parameters:
      a2DEditablePointList - the point list to remove a point from.
      aIndex - a valid index in the list of ILcdPoint objects.
      aRenderMode - a mode which in this implementation isn't taken into account.
      aGXYContext - a context which in this implementation isn't taken into account.
    • retrieveMinimalPointcount

      protected int retrieveMinimalPointcount(int aPainterMode)

      Returns the number of points the ILcdPointList should retain when removing points. In the POINT paint mode, this is 1, in the POLYLINE paint mode, it is 2 and in the different polygon paint modes, the minimal point count is 3.

      The method is used in the edit method to prevent the user from removing too many points from the ILcdPointList.

      Parameters:
      aPainterMode - the painter mode for which the point count is wanted.
      Returns:
      the number of points the ILcdPointList should retain when removing points.
    • insert2DPoint

      public void insert2DPoint(ILcd2DEditablePointList a2DEditablePointList, int aIndex, double aX, double aY, int aRenderMode, ILcdGXYContext aGXYContext)

      Inserts a point at the given index into the specified ILcd2DEditablePointList.

      The specified coordinates are defined in the model reference.

      Parameters:
      a2DEditablePointList - the point list to insert a point into.
      aIndex - a valid index in the list of ILcdPoint objects.
      aX - the X-coordinate of the new point.
      aY - the Y-coordinate of the new point.
      aRenderMode - a mode which in this implementation isn't taken into account.
      aGXYContext - a context which in this implementation isn't taken into account.
    • append2DPoint

      public void append2DPoint(ILcd2DEditablePointList a2DEditablePointList, double aX, double aY, int aRenderMode, ILcdGXYContext aGXYContext)

      Appends a point to the end of the specified ILcd2DEditablePointList.

      The specified coordinates are defined in the model reference.

      Parameters:
      a2DEditablePointList - the point list to append a point to.
      aX - the X-coordinate of the new point.
      aY - the Y-coordinate of the new point.
      aRenderMode - a mode which in this implementation isn't taken into account.
      aGXYContext - a context which in this implementation isn't taken into account.
    • translate2D

      public void translate2D(ILcd2DEditablePointList a2DEditablePointList, double aDeltaX, double aDeltaY, int aRenderMode, ILcdGXYContext aGXYContext)

      Translates all the points of the specified ILcd2DEditablePointList from their current positions over the given translation vector in the 2D space. Only the first two dimensions of the points are considered. The third dimension is left unchanged.

      The specified translation coordinates are defined in the model reference.

      Parameters:
      a2DEditablePointList - the point list to translate.
      aDeltaX - the X-coordinate of the translation vector.
      aDeltaY - the Y-coordinate of the translation vector.
      aRenderMode - a mode which in this implementation isn't taken into account.
      aGXYContext - a context which in this implementation isn't taken into account.
    • move2DPoint

      public void move2DPoint(ILcd2DEditablePointList a2DEditablePointList, int aIndex, double aX, double aY, int aRenderMode, ILcdGXYContext aGXYContext)

      Moves the point at the given index in the specified ILcd2DEditablePointList to the given point in the 2D space. Only the first two dimensions of the points are considered. The third dimension is left unchanged.

      The specified coordinates are defined in the model reference.

      Parameters:
      a2DEditablePointList - the point list to move a point of.
      aIndex - a valid index in the list of ILcdPoint objects.
      aX - the X-coordinate of the new point.
      aY - the Y-coordinate of the new point.
      aRenderMode - a mode which in this implementation isn't taken into account.
      aGXYContext - a context which in this implementation isn't taken into account.
    • translate2DPoint

      public void translate2DPoint(ILcd2DEditablePointList a2DEditablePointList, int aIndex, double aDeltaX, double aDeltaY, int aRenderMode, ILcdGXYContext aGXYContext)

      Translates the point at the given index in the specified ILcd2DEditablePointList from its current position over the given translation vector in the 2D space. Only the first two dimensions of the points are considered. The third dimension is left unchanged.

      The specified translation coordinates are defined in the model reference.

      Parameters:
      a2DEditablePointList - the point list to translate a point of.
      aIndex - a valid index in the list of ILcdPoint objects.
      aDeltaX - the X-coordinate of the translation vector.
      aDeltaY - the Y-coordinate of the translation vector.
      aRenderMode - which in this implementation isn't taken into account.
      aGXYContext - a context which in this implementation isn't taken into account.
    • edit

      public boolean edit(Graphics aGraphics, int aRenderMode, ILcdGXYContext aGXYContext)

      This implementation edits the retrieved ILcdPointList. The point list needs to implement the interface ILcd2DEditablePointList.

      In ILcdGXYEditor.TRANSLATED render mode, the ILcdPointList is edited as follows:

      • While touching a point, the point gets translated.
      • While touching a segment, the object gets translated as a whole.
      • While touching the interior and the selected object is painted as filled, the object gets translated as a whole.

      In ILcdGXYEditor.RESHAPED render mode, the ILcdPointList is edited as follows:

      • While touching a point and moving the mouse pointer, the point gets translated.
      • While touching a point and not moving the mouse pointer, the point gets removed.
      • While touching a segment, a new point is added beneath the mouse pointer.
      • While touching the interior, the object remains unchanged.

      In the creation render modes, new points are created beneath the mouse pointer and added to the ILcdPointList.

      If, in all render modes, a snap target is found for a moved or created point, the snap target location is used for the moved/created point.

      Specified by:
      edit in interface ILcdGXYEditor
      Parameters:
      aGraphics - The graphics to edit the object on.
      aRenderMode - The mode to render the object in.
      aGXYContext - The context to render the object in.
      Returns:
      true if the object has changed when this method returns, false otherwise.
      Throws:
      ClassCastException - if the painter's point list does not implement ILcd2DEditablePointList.
      See Also:
    • acceptSnapTarget

      public boolean acceptSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
      Returns whether the object set to the editor can be edited so that (part of) the object snaps to the object passed as snap target in the context. If the snap target is accepted, a call to the edit method with this context passed should edit the object so that (part of) the object snaps to the object passed as snap target in the context.

      The context contains information on the user interaction at hand: the current location of the user interaction, given by its X and Y coordinates, and the distance in X direction and distance in Y direction over which the user interaction is taking place. For example, getX and getY may contain the current mouse location while getDeltaX and getDeltaY contain the distance over which the mouse has been dragged. The context also contains the candidate snap target and the layer the snap target is contained in.

      This editor can snap the current object to the given target if the following conditions are met:

      • The current object is an ILcd2DEditablePointList or an ILcdEditableComplexPolygon with ILcd2DEditablePointList instances
      • the target to snap to is an ILcdPoint whose coordinates are expressed in the same coordinate system as the current object or the model to model transformation can transform the point to a point in the objects coordinate system.
      • One of the current point list's points is touched (in other words: you are translating a specific point of the pointlist) or the pointlist is empty.
      • The touched point is not the last point of the current point list. If this is wanted, override this function and return true if the touched point is the last point.
      Specified by:
      acceptSnapTarget in interface ILcdGXYEditor
      Parameters:
      aGraphics - the graphics on which the snap target should be checked.
      aGXYContext - the context in which the snap target should be checked.
      Returns:
      true if the above conditions are met, false otherwise.
      See Also:
    • linkToSnapTarget

      protected boolean linkToSnapTarget(Graphics aGraphics, ILcd2DEditablePointList aPointList, int aPointIndex, int aRenderMode, ILcdGXYContext aGXYContext)
      Edits the specified ILcdPointList so that, if the snap target is accepted, the point (specified by its index) snaps to this snap target. The method does nothing otherwise.
      Parameters:
      aGraphics - the Graphics on which to snap to the target.
      aPointList - the point list to edit.
      aPointIndex - the index of the point in the point list that should snap to the target.
      aRenderMode - the mode in which the snapping occurs. The mode is not taken into account in this implementation.
      aGXYContext - the context in which to snap to the target.
      Returns:
      true if the specified point is snapped to the snap target, false otherwise.
    • getCreationClickCount

      public int getCreationClickCount()
      Returns the number of user interactions required to complete the initialization of an ILcdPointList object set to this editor. In the paint mode POINT, only one click is required. For the other modes, a negative number is returned, meaning that an unlimited number of points can be used. The polyline mode returns -2, whereas the polygon modes return -3, indicating a minimum click count of 2 and 3, respectively.
      Specified by:
      getCreationClickCount in interface ILcdGXYEditor
      Returns:
      1 if the paint mode equals POINT, -2 if the mode equals POLYLINE, -3 otherwise.
    • clone

      public Object clone()
      Description copied from interface: ILcdCloneable

      Makes Object.clone() public.

      When for example extending from java.lang.Object, it can be implemented like this:
      
       public Object clone() {
         try {
           return super.clone();
         } catch ( CloneNotSupportedException e ) {
           // Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
           throw new RuntimeException( e );
         }
       }
       
      Specified by:
      clone in interface ILcdCloneable
      Specified by:
      clone in interface ILcdGXYEditorProvider
      Specified by:
      clone in interface ILcdGXYPainterProvider
      Overrides:
      clone in class ALcdGXYAreaPainter
      Returns:
      a clone of this painter provider.
      See Also: