Interface ILcdGXYPainter

All Superinterfaces:
Cloneable, ILcdCloneable, ILcdPropertyChangeSource, Serializable
All Known Subinterfaces:
ILcdGXYPathPainter, ILcdRasterPainter
All Known Implementing Classes:
ALcdEarthGXYPainter, ALcdGXYAreaPainter, ALcdGXYPainter, ALcdRasterPainter, ALcdSLDFeatureTypeStylePainter, ALcdSLDRulePainter, TLcdAllInMemoryRasterPainter, TLcdCompassGridPainter, TLcdDGNCellGXYPainter, TLcdDGNComplexShapeGXYPainter, TLcdDGNEllipse2DGXYPainter, TLcdEarthGXYElevationRasterPainter, TLcdEarthGXYMultivaluedRasterPainter, TLcdEarthGXYRasterPainter, TLcdEarthGXYSinglevaluedRasterPainter, TLcdEarthGXYVectorPainter, TLcdEarthGXYVertexArrayPainter, TLcdGRIBRasterPainter, TLcdGXYAISIconProviderPainter, TLcdGXYAISPointListPainter, TLcdGXYArcBandPainter, TLcdGXYArcPainter, TLcdGXYAreaShapeListPainter, TLcdGXYBoundsPainter, TLcdGXYBufferPainter, TLcdGXYCircleBy3PointsPainter, TLcdGXYCirclePainter, TLcdGXYCircularArcPainter, TLcdGXYClippingPainterWrapper, TLcdGXYCompositeCurvePainter, TLcdGXYCompositeRingPainter, TLcdGXYDynamicSegmentationEventPainter, TLcdGXYEditableLabelPainter, TLcdGXYEllipsePainter, TLcdGXYGeoBufferPainter, TLcdGXYHaloPainter, TLcdGXYIconPainter, TLcdGXYILSPainter, TLcdGXYImageIconPainter, TLcdGXYImagePainter, TLcdGXYLonLatHeightBufferPainter, TLcdGXYOffsetIconPainter, TLcdGXYPointListPainter, TLcdGXYPointShapeListPainter, TLcdGXYPolylineShapeListPainter, TLcdGXYProcedureTrajectoryPainter, TLcdGXYRefuelingTrackPainter, TLcdGXYRoundedPointListPainter, TLcdGXYRoutePainter, TLcdGXYShapeListPainter, TLcdGXYShapePainter, TLcdGXYSurfacePainter, TLcdGXYTextPainter, TLcdGXYTiledWMSProxyPainter, TLcdHypsometricEarthPainter, TLcdHypsometricMultilevelRasterPainter, TLcdHypsometricRasterPainter, TLcdICAOAirspacePainter, TLcdICAORunwayPainter, TLcdLonLatBorderGridPainter, TLcdLonLatGridPainter, TLcdMagneticNorthGXYPainter, TLcdMultilevelRasterPainter, TLcdMultivaluedRasterPainter, TLcdNoWarpMultilevelRasterPainter, TLcdNoWarpRasterPainter, TLcdPOLPainter, TLcdRasterPainter, TLcdShadedMultilevelRasterPainter, TLcdShadedRasterPainter, TLcdSLDFeatureTypeStylePainter, TLcdSLDRulePainter, TLcdUTMZonePainter, TLcdVPFPointListPainter, TLcdVPFPointPainter, TLcdWarpMultilevelRasterPainter, TLcdWarpRasterPainter, TLcdWMSProxyGXYPainter

public interface ILcdGXYPainter extends Serializable, ILcdCloneable, ILcdPropertyChangeSource
Locates and paints the representation of an object on an ILcdGXYView.

An ILcdGXYPainter implementation, or painter, is used by an ILcdGXYLayer to handle the visual representation of an object, in an ILcdGXYView. A painter is responsible for three types of operations:

  • defining the visual representation of an object and painting the representation in an ILcdGXYView. For the sake of brevity, the visual representation of an object is called the 'painted object'.
  • providing information to locate the painted object in an ILcdGXYView, and
  • providing information on possible targets that can be used for snapping.

The painted object must not be confused with the object itself, as an object may have different representations. For example, a road could be painted as a polyline, or it could be painted as a road sign containing the road number.

To define the painted object, a painter will typically take into account an object's geometry and may use other information available in the object. A road may be painted as a polyline, while the thickness and color of the polyline vary based on the type of the road: an alley, a street, a highway, ... Painting an object in a view is handled in the paint method.

A painter provides information on the whereabouts of the painted object in the view, so that for example, one can tell whether the painted object is being touched with the mouse. Localization of a representation of an object is handled in the boundsSFCT, isTouched and anchorPointSFCT methods .

When editing or creating other objects in the view, a painter provides information on which parts of the painted object can be snapped to, called the snap target, in snapTarget. The paint method must highlight the snap target on the painted object.

Note that these tasks are not independent as the location of a painted object will depend on how the object is painted. The method paint must be implemented consistently with the boundsSFCT, isTouched and anchorPointSFCT methods as these methods rely on the representation of the object.

In order to be able to perform these tasks, the painter requires information which is passed in two parameters:

  • the context the painter operates in, and
  • the mode of the painted object.

The context, passed as an ILcdGXYContext, contains information on:

  • the view the object will be painted in,
  • the layer the object is part of,
  • the current location(s) of the mouse or input device, and the location(s) of where the mouse or input device was last pressed,
  • the pen, which governs how points are connected, and
  • the transformations that can be used to transform points and bounds of objects to coordinates in the view space.

The mode parameter indicates different visualization modes the painter must support. They denote the part of the object that must be painted, whether the object must be painted with highlighting as if it were selected or not, and whether the object is being created or edited. The constants indicating what part of the object must be represented are:

  • BODY
  • HANDLES
  • SNAPS
The body is typically a schematic representation of the object, the handles indicate what parts of the painted object can be used to manipulate the object via the view, and the snaps display what parts of the object are available as targets for snapping. These constants may be combined in the mode.

The constants indicating whether the object must be painted as selected or not are:

  • DEFAULT
  • SELECTED
The values are mutually exclusive: the mode must only contain one of them. Painting an object as selected usually involves some sort of highlighting of the painted object.

These constants indicate whether the object is being edited or created:

  • TRANSLATING
  • RESHAPING
  • CREATING
Only one of these constants must appear in the mode.

Note that these constants must not be confused with the ILcdGXYLayer constants which govern the representation of all objects in its model.

The object to paint is passed in the method setObject, which must be called before any of the above methods is called for that object. This enables subsequent calling of multiple methods, while pre-processing the object only once (when the geometry of an object has to be composed based on several properties of the object, for example). This makes implementations of this interface not re-entrant and inherently not thread-safe.

A good understanding of the difference between model coordinates/space, world coordinates/space and view coordinates/space is recommended to fully understand the requirements a painter implementation must meet.

Refer to Implementing a painter and editor in a GXY view for more information on how to implement an painter.

See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
    Mode to indicate that the body of the painted object must be taken into account.
    static final int
    Mode to indicate that the representation of the object is subject to user interaction (via mouse movements) with the intent to initialize the object.
    static final int
    The default representation of the object.
    static final int
    Mode to indicate that the handles of the painted object must be taken into account.
    static final int
    Second mode to indicate that the representation of the object is subject to user interaction (via mouse movements) with the intent to edit the object.
    static final int
    The representation of the object when it is selected.
    static final int
    Mode to indicate that the (part of the) painted object that can serve as snap target must be taken into account.
    static final int
    Mode to indicate that the painted object is subject to user interaction (via mouse movements) with the intent to edit the object.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    anchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT)
    Moves the Point passed to the location (in view coordinates, pixels) of the anchor point of the representation of the object in the given mode taking into account the given context.
    void
    boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT)
    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.
    getCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
    Returns a cursor that clarifies the mode and context the painter is operating in.
    Returns a textual representation of this painter.
    Returns the Object for which the representation is currently being handled by this painter.
    boolean
    isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
    Checks if the representation of the object in the given mode is touched at the location as defined in the supplied context.
    void
    paint(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
    Displays the representation of the object in the given mode on the Graphics passed, taking into account the supplied context.
    void
    setObject(Object aObject)
    Sets the Object for which the representation shall be handled by this painter.
    snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
    Returns an object that can be used as snapping target when graphically editing an object.
    boolean
    supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
    Returns whether the painter can provide a snap target based on the representation of the object in the given context.

    Methods inherited from interface com.luciad.util.ILcdCloneable

    clone

    Methods inherited from interface com.luciad.util.ILcdPropertyChangeSource

    addPropertyChangeListener, removePropertyChangeListener
  • Field Details

    • BODY

      static final int BODY
      Mode to indicate that the body of the painted object must be taken into account. The body of an object is typically a schematic representation of the object.
      See Also:
    • HANDLES

      static final int HANDLES
      Mode to indicate that the handles of the painted object must be taken into account. Handles are used as an indication of where the user can interact with the shape, for example to edit the shape.
      See Also:
    • SNAPS

      static final int SNAPS
      Mode to indicate that the (part of the) painted object that can serve as snap target must be taken into account.
      See Also:
    • DEFAULT

      static final int DEFAULT
      The default representation of the object.
      See Also:
    • SELECTED

      static final int SELECTED
      The representation of the object when it is selected. This is typically painted on top of the default representation of the same object.
      See Also:
    • TRANSLATING

      static final int TRANSLATING
      Mode to indicate that the painted object is subject to user interaction (via mouse movements) with the intent to edit the object. This mode is typically used to indicate that the user interaction will result in a translation of the object as a whole.
      See Also:
    • RESHAPING

      static final int RESHAPING
      Second mode to indicate that the representation of the object is subject to user interaction (via mouse movements) with the intent to edit the object. This mode is typically used to indicate that the user interaction will result in a deformation of the object.
      See Also:
    • CREATING

      static final int CREATING
      Mode to indicate that the representation of the object is subject to user interaction (via mouse movements) with the intent to initialize the object.
      See Also:
  • Method Details

    • setObject

      void setObject(Object aObject)
      Sets the Object for which the representation shall be handled by this painter.

      Setting the object on the painter may have an effect on the internal state of the painter, for example, the color to use.

      When the object is set to a painter, the context parameter in subsequent calls to methods in this class must contain a layer that contains this object and for which the painter for this object is this painter.

      Parameters:
      aObject - the object for which the representation shall be handled by this painter.
      Throws:
      IllegalArgumentException - if the given parameter aObject could not be set.
      See Also:
    • getObject

      Object getObject()
      Returns the Object for which the representation is currently being handled by this painter.
      Returns:
      the Object for which the representation is currently being handled by this painter.
      See Also:
    • paint

      void paint(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      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.

      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.
    • boundsSFCT

      void boundsSFCT(Graphics aGraphics, int aMode, 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.

      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is represented in (see class documentation). For example, an object may be represented differently in SELECTED mode compared to DEFAULT mode. The returned bounds of the representation must take this different representation into account.
      aGXYContext - the context for which the representation of the object is painted. It contains amongst others the transformations from model to world and world to view.
      aBoundsSFCT - the bounds that must be adapted to encompass the representation of the object in the given mode and context. These bounds must not be taken into account when the method has thrown an exception.
      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:
    • isTouched

      boolean isTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Checks if the representation of the object in the given mode is touched at the location as defined in the supplied context.

      The location that must be taken into account to check whether the representation is touched can be retrieved from the context passed with the methods ILcdGXYContext.getX() and ILcdGXYContext.getY(). If the check is part of an ongoing operation of user interaction, for example, when the mouse is being dragged, the location of the start of the operation can also be taken into account using the methods ILcdGXYContext.getDeltaX() and ILcdGXYContext.getDeltaY(). The context contains the transformations required to convert this location into the equivalent location in model space. Implementations of this interface usually follow either of the following patterns:

      • transform the location of the interaction back to model space and compare the coordinates with the object in model space.
      • transform the location to world space and compare with a world representation of the object. This forces the painter into caching a world representation of the object. Caching a view representation of an object is not very practical as it would have to change whenever the view's scale changes or when it is panned. A world representation of an object only changes when the view's XYWorldReference changes, which happens less frequently.

      As the mode influences the way an object is represented, it must also be taken into account when checking whether that representation is being touched. When the mode contains CREATING, RESHAPING or TRANSLATING which indicate that the object must be represented in a state for an ongoing operation, the location of the start of the operation may be taken into account as mentioned above. The painting result can take into account multiple locations, to respond to, for example, multi-touch input. When the mode contains SELECTED, the painter should also check if the non-selected representation is touched, since these are always painted on top of each other.

      The boundsSFCT is often used to speed up the performance of this method as a location outside these bounds can never touch the representation of the object.

      Note that this method does not give an indication of what part of the object is touched. It is up to the painter implementations to provide methods to make this distinction. The method does also not indicate what sensitivity must be applied when checking if an object is touched. It is up to the implementation to decide what should be the maximum distance between the location given in the context and the closest relevant point or area of the representation of the object.

      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is represented in
      aGXYContext - contains the location of the interaction and the transformations to convert this location into model coordinates
      Returns:
      true if the representation of the object in the given mode is touched by the location as defined in the context passed, false otherwise
      See Also:
    • anchorPointSFCT

      void anchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException
      Moves the Point passed to the location (in view coordinates, pixels) of the anchor point of the representation of the object in the given mode taking into account the given context.

      The anchor point is an important point of the representation, typically the point which would be used when the object would be represented as a single point. The anchor point is mostly used to attach extra information to the representation of an object, for example, using labels. A typical implementation of this method for painters which can handle ILcdShape objects is the location of the focus point of the shape.

      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the mode the object is painted in (see class documentation)
      aGXYContext - the context for which the representation of the object is painted. It contains amongst others the transformations from model to world and world to view.
      aPointSFCT - the point that has to be moved to the location of the anchor point of the representation of the object. This point must not be taken into account when the method has thrown a TLcdNoBoundsException.
      Throws:
      TLcdNoBoundsException - if no anchor point can be determined for the representation of the object. This can be 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 projection as set in the views world reference.
      See Also:
    • supportSnap

      boolean supportSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
      Returns whether the painter can provide a snap target based on the representation of the object in the given context.
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aGXYContext - the context in which this object is represented and in which the editing of an object occurs.
      Returns:
      true if an object can be returned that can be used to snap to in the given context, false otherwise.
    • snapTarget

      Object snapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
      Returns an object that can be used as snapping target when graphically editing an object. For example, an object which is beneath the current mouse position (as given in the context).

      This method must only be called when supportSnap returns true for the given context.

      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aGXYContext - the context in which this object is represented and in which the editing of an object occurs.
      Returns:
      an object that can be used as snapping target when graphically editing an object. It must be defined in the same model reference as the object set to this painter.
      See Also:
    • getCursor

      Cursor getCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Returns a cursor that clarifies the mode and context the painter is operating in. For example, when the mode is TRANSLATING, the cursor could be the MOVE cursor. When no specific cursor is required implementations must return null.
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - the rendering mode to return the cursor for.
      aGXYContext - the context in which the rendering occurs.
      Returns:
      a Cursor to indicate the type of operating aMode and aGXYContext. Returns null if no particular Cursor is required.
    • getDisplayName

      String getDisplayName()
      Returns a textual representation of this painter. This can be useful when different representations of an object are handled by different painter implementations. Having a textual representation can facilitate choosing between different painter implementations.
      Returns:
      a textual representation of this painter.