Class TLcdGXYAISPointListPainter

All Implemented Interfaces:
ILcdCloneable, ILcdPropertyChangeSource, ILcdGXYEditor, ILcdGXYEditorProvider, ILcdGXYPainter, ILcdGXYPainterProvider, ILcdGXYPathPainter, Serializable, Cloneable

public class TLcdGXYAISPointListPainter extends TLcdGXYPointListPainter
This painter extends TLcdGXYPointListPainter, but paints an icon if the point list contains only a single point.

By default, the points are painted by a TLcdGXYAISIconProviderPainter. The symbology usage can be changed in two ways:

  • the setPointPainter method can be used to define another painter,
  • the getPointPainter method can be used to retrieve the default painter. The TLcdGXYAISIconProviderPainter class provides a setSymbolProvider method to change its symbol provider.

Like its super class, this painter accepts instances of any implementation of the ILcdPointList interface.

See Also:
  • Constructor Details

    • TLcdGXYAISPointListPainter

      public TLcdGXYAISPointListPainter()
      Constructs a new TLcdGXYAISPointListPainter object.

      By default, pointLists will be drawn as polygons, unless they contain only one point. In the latter case, an instance of the TLcdGXYAISIconProviderPainter class will be used to draw an icon at the location of the single point.

  • Method Details

    • 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 TLcdGXYPointListPainter
      Returns:
      a clone of this painter provider.
      See Also:
    • setObject

      public void setObject(Object aObject)
      Specifies the object to be painted.

      The specified object should be an instance of an implementation of the ILcdPointList interface.

      Specified by:
      setObject in interface ILcdGXYEditor
      Specified by:
      setObject in interface ILcdGXYPainter
      Overrides:
      setObject in class TLcdGXYPointListPainter
      Parameters:
      aObject - the object to be painted
      See Also:
    • paint

      public void paint(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Description copied from class: TLcdGXYPointListPainter
      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 (TLcdGXYPointListPainter.getMode()) is used.

      Note: when the paint mode is set to TLcdGXYPointListPainter.POINT or TLcdGXYPointListPainter.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
      Overrides:
      paint in class TLcdGXYPointListPainter
      Parameters:
      aGraphics - The graphics to paint the object on.
      aMode - The mode to render the object in.
      aGXYContext - The context to render the object in.
    • isTouched

      public boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Description copied from class: TLcdGXYPointListPainter
      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 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
      Overrides:
      isTouched in class TLcdGXYPointListPainter
      Parameters:
      aGraphics - The graphics to paint the object on.
      aMode - 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:
    • boundsSFCT

      public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds a2DEditableBounds) throws TLcdNoBoundsException
      Description copied from class: TLcdGXYPointListPainter
      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
      Overrides:
      boundsSFCT in class TLcdGXYPointListPainter
      Parameters:
      aGraphics - The graphics to paint the object on.
      aMode - The mode to render the object in.
      aGXYContext - The context to render the object in.
      a2DEditableBounds - 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)
      Description copied from class: TLcdGXYPointListPainter

      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 TLcdGXYPointListPainter
      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)
      Description copied from class: TLcdGXYPointListPainter

      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 TLcdGXYPointListPainter
      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 aMode, ILcdGXYContext aGXYContext)
      Description copied from class: TLcdGXYPointListPainter
      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 TLcdGXYPointListPainter
      Parameters:
      aGraphics - The graphics on which the object is painted.
      aMode - 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.
    • getPointPainter

      public ILcdGXYPainter getPointPainter()
      Returns the painter that will be used to paint pointLists consisting of only one point.

      This painter is able to paint instances of implementations of the ILcdPoint and the ILcdShape interface. It will paint an icon at the location of the point or at the location of the focus point of the shape.

      Returns:
      the painter that will be used to paint pointLists consisting of only one point
    • setPointPainter

      public void setPointPainter(ILcdGXYPainter aPointPainter)
      Specifies a painter that is able to paint instances of implementations of the ILcdPoint and the ILcdShape interface. It should paint an icon at the location of the point or at the location of the focus point of the shape.

      The given painter will be used to paint pointLists consisting of only one point.

      Parameters:
      aPointPainter - a painter that is able to paint an icon at the location of a point or at the location of the focus point of a shape