Class TLcdGXYBufferPainter

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

public class TLcdGXYBufferPainter extends ALcdGXYAreaPainter implements ILcdGXYPainter, ILcdGXYEditor, ILcdGXYEditorProvider
Paints, locates and enables visual editing of TLcdLonLatBuffer and TLcdLonLatHeightBuffer objects in an ILcdGXYView.

We recommend using TLcdGXYGeoBufferPainter instead, as it offers higher quality visualization and supports the ILcdGeoBuffer or ILcdVariableGeoBuffer shapes as well.

See Also:
  • Field Details

    • OUTLINED

      public static final int OUTLINED
      Draw only the outline of the buffer.
      Since:
      1.4
      See Also:
    • FILLED

      public static final int FILLED
      Draw the area defined by the buffer filled with the foreground color.
      Since:
      LuciadLightspeed1.4
      See Also:
    • OUTLINED_FILLED

      public static final int OUTLINED_FILLED
      Draw the buffer as an outlined and filled area.
      See Also:
    • OUTLINED_OPEN

      public static final int OUTLINED_OPEN
      Draw the outline of the buffer which is open at both ends.
      See Also:
    • OUTLINED_FILLED_OPEN

      public static final int OUTLINED_FILLED_OPEN
      Draw the buffer as an outlined and filled area where the outline is open at both ends.
      See Also:
    • POLYGON

      public static final int POLYGON
      Deprecated.
      use OUTLINED instead
      Draw only the outline of the buffer.
      See Also:
    • AREA

      public static final int AREA
      Deprecated.
      use FILLED instead
      Draw the area defined by the buffer filled with the foreground color.
      See Also:
  • Constructor Details

    • TLcdGXYBufferPainter

      public TLcdGXYBufferPainter()
      Creates a new TLcdGXYBufferPainter.
  • 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 with this painter/editor.
      Specified by:
      setObject in interface ILcdGXYEditor
      Specified by:
      setObject in interface ILcdGXYPainter
      Parameters:
      aObject - the object to paint or edit with this painter/editor.
      See Also:
    • getObject

      public final Object getObject()
      Returns the object set to paint or edit.
      Specified by:
      getObject in interface ILcdGXYEditor
      Specified by:
      getObject in interface ILcdGXYPainter
      Returns:
      the object set to paint or edit.
      See Also:
    • setPaintCache

      public void setPaintCache(boolean aPaintCache)
      The property paintCache determines whether the painter will cache the points it has drawn. When the object has to be repainted, the points that haven't been edited, can then be drawn more quickly.
      Parameters:
      aPaintCache - the new PaintCache value.
      See Also:
    • getPaintCache

      public boolean getPaintCache()
      Returns whether caching will be used when painting the buffer.
      Returns:
      true if caching will be used when painting the buffer.
      See Also:
    • setCreationBufferWidth

      public void setCreationBufferWidth(double aBufferWidth)
      Sets the width of the buffer to be set at creation time. In case a negative value is specified the buffer width will be proportional to the length of the first buffer segment.
      Parameters:
      aBufferWidth - the new CreationBufferWidth value.
      See Also:
    • getCreationBufferWidth

      public double getCreationBufferWidth()
      Returns the buffer width set for creation of a new buffer.
      Returns:
      the buffer width set for creation of a new buffer.
      See Also:
    • setMode

      public void setMode(int aMode)
      Description copied from class: ALcdGXYAreaPainter
      Sets the mode to decide how to paint an object: the outline (ALcdGXYAreaPainter.OUTLINED), as a filled area (ALcdGXYAreaPainter.FILLED), or as a filled and outlined area (ALcdGXYAreaPainter.OUTLINED_FILLED).
      Overrides:
      setMode in class ALcdGXYAreaPainter
      Parameters:
      aMode - The mode deciding how to paint an object.
      See Also:
    • setSelectionMode

      public void setSelectionMode(int aSelectionMode)
      Description copied from class: ALcdGXYAreaPainter
      Sets the selection mode to decide how to paint a selected object: the outline (ALcdGXYAreaPainter.OUTLINED), as a filled area (ALcdGXYAreaPainter.FILLED), or as a filled and outlined area (ALcdGXYAreaPainter.OUTLINED_FILLED).
      Overrides:
      setSelectionMode in class ALcdGXYAreaPainter
      Parameters:
      aSelectionMode - The mode deciding how to paint a selected object.
      See Also:
    • setDrawIntersection

      public void setDrawIntersection(boolean aDrawIntersection)
      Deprecated.
      This property is not used.
      Determines whether to paint the point on the central axis that is the closest to the point on the corridor at which the width of the corridor is made to change. Next to the axis point the width is then displayed. The default value is true.
      Parameters:
      aDrawIntersection - true to paint the point on the central axis that is the closest to the point on the corridor at which the width of the corridor is made to change.
      See Also:
    • isDrawIntersection

      public boolean isDrawIntersection()
      Deprecated.
      This property is not used.
      Returns whether to paint the point on the central axis that is the closest to the point on the corridor at which the width of the corridor is made to change.
      Returns:
      true to paint the point on the central axis that is the closest to the point on the corridor at which the width of the corridor is made to change.
      See Also:
    • getDrawIntersection

      public boolean getDrawIntersection()
      Deprecated.
      This property is not used.
      See Also:
    • setDrawAxis

      public void setDrawAxis(boolean aDrawAxis)
      drawAxis determines whether to paint the central axis when the object is not in ILcdGXYPainter.SELECTED mode.
      Parameters:
      aDrawAxis - true to paint the axis when painting the buffer.
      See Also:
    • isDrawAxis

      public boolean isDrawAxis()
      Returns whether the axis should be painted.
      Returns:
      true to paint the axis.
      See Also:
    • getDrawAxis

      public boolean getDrawAxis()
      Returns:
      the return value of isDrawAxis.
    • setDrawAxisWhenSelected

      public void setDrawAxisWhenSelected(boolean aDrawAxisWhenSelected)
      Sets whether the axis of the buffer should be drawn when selected.
      Parameters:
      aDrawAxisWhenSelected - the new drawAxisWhenSelected property value.
      See Also:
    • isDrawAxisWhenSelected

      public boolean isDrawAxisWhenSelected()
      Returns whether the painter draws the axis of the buffer when it is painted in selected mode.
      Returns:
      whether the painter draws the axis of the buffer when it is painted in selected mode.
      See Also:
    • setDrawAxisPoints

      public void setDrawAxisPoints(boolean aDrawAxisPoints)
      DrawAxisPoints determines whether to paint the central axis point when the object is not in ILcdGXYPainter.SELECTED mode.
      Parameters:
      aDrawAxisPoints - true to paint the axis points when painting the buffer.
      See Also:
    • isDrawAxisPoints

      public boolean isDrawAxisPoints()
      Returns whether the axis points should be painted.
      Returns:
      true to paint the axis points.
      See Also:
    • setDrawAxisPointsWhenSelected

      public void setDrawAxisPointsWhenSelected(boolean aDrawAxisPointsWhenSelected)
      Sets whether the axis points of the buffer should be drawn when selected.
      Parameters:
      aDrawAxisPointsWhenSelected - the new drawAxisPointsWhenSelected property value.
      See Also:
    • isDrawAxisPointsWhenSelected

      public boolean isDrawAxisPointsWhenSelected()
      Returns whether the painter draws the axis points of the buffer when it is painted in selected mode.
      Returns:
      whether the painter draws the axis points of the buffer when it is painted in selected mode.
      See Also:
    • setSnapToInvisiblePoints

      public void setSnapToInvisiblePoints(boolean aSnapToInvisiblePoints)
      Sets whether the other shapes can snap to invisible points of this shape. For buffer, all axis points are invisible points if there are not drawn.
      Parameters:
      aSnapToInvisiblePoints - the new snapToInvisiblePoints property value.
      See Also:
    • isSnapToInvisiblePoints

      public boolean isSnapToInvisiblePoints()
      Returns whether the painter allows snapping to the invisible points of the shape.
      Returns:
      whether the painter allows snapping to the invisible points of the shape.
      See Also:
    • setWidthFormat

      public void setWidthFormat(Format aWidthFormat)
      Deprecated.
      This property is not used, because the width is not displayed when editing the buffer.
      Controls how the width will be displayed when editing the buffer.
      Parameters:
      aWidthFormat - formats a Double, the distance between the center axis and the contour, as a String containing information on the width of the buffer.
    • setSnapIcon

      public void setSnapIcon(ILcdIcon aSnapIcon)
      Sets the icon to paint snap target points of the object set to this painter.
      Parameters:
      aSnapIcon - the icon to paint snap target points of the object set to this painter.
      See Also:
    • getSnapIcon

      public ILcdIcon getSnapIcon()
      Returns the icon to paint snap target points of the object set to this painter.
      Returns:
      the icon to paint snap target points of the object set to this painter.
      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
    • getCursor

      public Cursor getCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Implements ILcdGXYPainter.getCursor. A non-null cursor is returned only if aMode is equal to ILcdGXYPainter.RESHAPING or ILcdGXYPainter.TRANSLATING. The kind of cursor that is returned depends on location of the mouse: Cursor.CROSSHAIR_CURSOR, if the mouse pointer is positioned on an axis point. Cursor.MOVE_CURSOR, if the mouse pointer is positioned on an axis segment line. Either Cursor.N_RESIZE_CURSOR, Cursor.W_RESIZE_CURSOR , Cursor.NE_RESIZE_CURSOR or Cursor.NW_RESIZE_CURSOR, if the mouse pointer is positioned on a contour segment line. Which one is actually returned depends on the orientation of the contour segment line.
      Specified by:
      getCursor in interface ILcdGXYPainter
      Overrides:
      getCursor in class ALcdGXYPainter
      Parameters:
      aGraphics - the Graphics to get the cursor on.
      aMode - the painting mode for which to get the cursor.
      aGXYContext - the context in which to get the cursor.
      Returns:
      if the mode is equal to ILcdGXYPainter.RESHAPING or ILcdGXYPainter.TRANSLATING and:
      • Cursor.CROSSHAIR_CURSOR, if the mouse pointer is positioned on an axis point.
      • Cursor.MOVE_CURSOR, if the mouse pointer is positioned on an axis segment line.
      • Cursor.N_RESIZE_CURSOR, Cursor.W_RESIZE_CURSOR , Cursor.NE_RESIZE_CURSOR or Cursor.NW_RESIZE_CURSOR, if the mouse pointer is positioned on a contour segment line depending on the orientation of the contour segment line.
      null otherwise.
    • getGXYEditor

      public ILcdGXYEditor getGXYEditor(Object aObject)
      This implementation always returns this instance as an editor, with the object passed set as object.
      Specified by:
      getGXYEditor in interface ILcdGXYEditorProvider
      Parameters:
      aObject - the object to retrieve an editor for.
      Returns:
      this.
    • isTouched

      public boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Depending on the painter mode, returns whether the current object of the painter is touched by the mouse in the given context.
      Specified by:
      isTouched in interface ILcdGXYPainter
      Parameters:
      aGraphics - the graphics to check on whether the object in this painter is touched.
      aMode - the painting mode to check in whether this painters object is touched.
      aGXYContext - the context to check in whether this painters object is touched.
      Returns:
      returns true, depending on the mode of the painter (not aMode, setMode(int)) if
      • OUTLINED: the mouse is on a line segment of the axis or the contour of the buffer,
      • OUTLINED_OPEN: the mouse is on a line segment of the axis or the contour of the buffer is touched, except for the line segments at the ends of the buffer,
      • FILLED, OUTLINED_FILLED, OUTLINED_FILLED_OPEN: the mouse is over the interior of the buffer,
          false otherwise.
      See Also:
    • getCreationClickCount

      public int getCreationClickCount()
      Returns the number of points needed for creation of a new buffer. This implementation returns -2, meaning unlimited number of point for creation.
      Specified by:
      getCreationClickCount in interface ILcdGXYEditor
      Returns:
      -2, meaning unlimited number of point for creation, with a minimum of two.
    • paint

      public void paint(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYPainter
      Displays the representation of the object in the given mode on the Graphics passed, taking into account the supplied context.

      The visual representation of an object depends on the context. Depending on the context (e.g. is the location covered by the view), an object may or may not have a representation. The context contains:

      • transformations which allow to compute the location in view space of points and bounds given in model, space
      • a pen which can connect points with a line or create arcs around a point,
      • the view for which the object's representation must be painted. This can be useful when the painted object depends on the scale of the view, or the presence of other layers in the view.
      • the current location(s) of the mouse or input device and the last location(s) the mouse or input device was pressed.

      The mode passed in this method indicates what part of the object must be painted, whether it should be painted as selected or not, and whether user interaction (via mouse movements) must be taken into account.

      When the mode passed contains either TRANSLATING, RESHAPING or CREATING, this method is also responsible for interpreting interaction on the representation of an object and modifying the representation of the object accordingly. The painter is not responsible for modifying the object itself, this is done by a corresponding ILcdGXYEditor . Implementations of ILcdGXYPainter and ILcdGXYEditor interfaces must be consistent for an object: the painter must display the result of the user interaction on the object, while the editor is responsible for modifying the object as a result of the user interaction. A good practice to ensure a consistent implementation is to implement both the ILcdGXYPainter and ILcdGXYEditor interfaces in a single class.

      When the mode passed includes SNAPS, the part of the representation which corresponds to the object returned as snap target by the method snapTarget must be painted in order to provide the user with a visual indication of the snap target.

      The Graphics passed in this method can be different from the Graphics returned by a view due to techniques such as double buffering (as applied in Swing). Basic drawing operations must always be performed on the Graphics passed as an argument in this method.

      Specified by:
      paint in interface ILcdGXYPainter
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is represented in (see class documentation).
      aGXYContext - the ILcdGXYContext the drawing depends on.
    • edit

      public boolean edit(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYEditor
      Defines how an object shall be edited by this editor, taking into account the mode and the context passed.

      The mode passed indicates how the interaction should be interpreted. It can be one of the following:

      • TRANSLATED
      • RESHAPED
      • START_CREATION
      • CREATING
      • END_CREATION

      The first two modes designate that the object should be modified, the last three modes are passed when initializing an object. From an implementation point of view there is no difference between TRANSLATED and RESHAPED. These constants only differ in semantics. For ILcdShape objects TRANSLATED can be seen as the mode that will be passed when the shape as a whole is moved. RESHAPED is used more often for moving part of a shape.

      The context contains information on the user interaction at hand. The methods getX and getY contain the location(s) of the user interaction. The methods getDeltaX and getDeltaY contain the distance(s) 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 editing behavior can take into account multiple locations, to respond to, for example, multi-touch input.

      When a snap target is accepted, the implementation of this method should take that fact into account when editing or initializing an object.

      Specified by:
      edit in interface ILcdGXYEditor
      Parameters:
      aGraphics - the graphics on which the buffer is being edited. This might be of importance e.g. when a scale or a clip is set on the graphics.
      aMode - the editing mode, it will contain either ILcdGXYEditor.TRANSLATING or ILcdGXYEditor.RESHAPING
      aGXYContext - the context in which the buffer will be edited. This contains the graphics on which the buffer is painted, the current and previous mouse position, model to world, world to view transformations and possible snap targets.
      Returns:
      true if the buffer was actually changed.
      See Also:
    • boundsSFCT

      public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
      Description copied from interface: ILcdGXYPainter
      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 -
      aMode -
      aGXYContext -
      aBoundsSFCT -
      Throws:
      TLcdNoBoundsException
      See Also:
    • supportSnap

      public boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
      This implementation supports snapping.
      Specified by:
      supportSnap in interface ILcdGXYPainter
      Overrides:
      supportSnap in class ALcdGXYPainter
      Parameters:
      aGraphics - the Graphics on which the painter supports snap.
      aGXYContext - the context in which the painter supports snap.
      Returns:
      true
    • snapTarget

      public Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
      Returns one of the axis or contour points of the buffer if it is touched. An axis points is only returned if the axis point is drawn (see isDrawAxisPoints() and isDrawAxis()) or when snapping to invisible points is enabled (see isSnapToInvisiblePoints()).
      Specified by:
      snapTarget in interface ILcdGXYPainter
      Overrides:
      snapTarget in class ALcdGXYPainter
      Parameters:
      aGraphics - the Graphics on which the snap target is given.
      aGXYContext - the context in which the snap target is given.
      Returns:
      the snappable ILcdPoint that is touched, otherwise null.
      See Also:
    • setModelModelTransformationClass

      public void setModelModelTransformationClass(Class aModel2ModelTransformationClass)
      Sets the transformation class to use to transform points when snapping to points in models with non equal model references. 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.

      Setting this property allows to snap to points defined in a different model reference.

      Parameters:
      aModel2ModelTransformationClass - the transformation to use as described above. Instances of this class should implement ILcdModelModelTransformation
    • 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 buffer to the given snap target if the following conditions are met:
      • The snap target is an ILcdPoint whose coordinates are expressed in the same coordinate system as the current objects coordinate system or the model to model transformation can transform the point to a point in the objects coordinate system.
      • The axis doesn't contain any points or one of its axis points is touched. The axis points can be touched if they are painted (see isDrawAxisPoints() or isDrawAxisPointsWhenSelected()) or when the axis itself is drawn (see isDrawAxis() or isDrawAxisWhenSelected())
      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:
    • setupGraphicsForLine

      protected void setupGraphicsForLine(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      This method is called by this ILcdGXYPainter just before drawing lines on aGraphics. It can be redefined in order to set specific Graphics properties like Color, etc ... It calls getLineStyle().setupGraphics if such method returns a non null value.
      Parameters:
      aGraphics - the graphics to paint the object on.
      aMode - the mode to paint the object in.
      aGXYContext - the context to paint the object in.
    • setupGraphicsForFill

      protected void setupGraphicsForFill(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      This method is called by this ILcdGXYPainter just before drawing Fills on aGraphics. It can be redefined in order to set specific Graphics properties like Color, etc ... It calls getFillStyle().setupGraphics if such method returns a non null value.
      Parameters:
      aGraphics - the graphics to paint the object on.
      aMode - the mode to paint the object in.
      aGXYContext - the context to paint the object in.
    • calculateBoundsSFCT

      protected void calculateBoundsSFCT(int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
      Computes the bounds of the current object of the paint as the bounds that holds all contour points which are visible in the given context.
      Parameters:
      aMode - the painting mode to calculate the bounds in.
      aGXYContext - the context in which to calculate the bounds
      aBoundsSFCT - the bounds to adapt to the bounds of the object of this painter.
      Throws:
      TLcdNoBoundsException - if the axis of the buffer contains less than 2 points or if no points of the buffer are visible in the given context.
    • 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: