Class TLcdGXYOffsetIconPainter

java.lang.Object
com.luciad.view.gxy.ALcdGXYLabelPainter
com.luciad.view.gxy.painter.TLcdGXYOffsetIconPainter
All Implemented Interfaces:
ILcdCloneable, ILcdPropertyChangeSource, ILcdGXYEditor, ILcdGXYEditorProvider, ILcdGXYLabelEditor, ILcdGXYLabelEditorProvider, ILcdGXYLabelPainter, ILcdGXYLabelPainter2, ILcdGXYLabelPainterProvider, ILcdGXYMultiLabelPainter, ILcdGXYPainter, ILcdGXYPainterProvider, Serializable, Cloneable

Wrapper for an ILcdGXYPainter that paints objects at a certain offset. This typically applies to objects which are painted as icons. This can be useful to avoid clutter in areas on the map where there are a lot of domain object clustered together, by moving the representations away from each other.

The offset icon is painted as a label, so that existing label decluttering algorithms can be reused to declutter the icons. It paints this label when the label index and sublabel index are both 0.

This painter is

  • an ILcdGXYPainter, to draw the anchor points (where the icon would normally be located). The painting of this anchor point is delegated to the ILcdGXYPainter specified in the constructor.
  • an ILcdGXYLabelPainter to draw the offset icon as a label and to draw the labels of the delegate label painter. The painting of the offset icon is delegated to the ILcdGXYPainter specified in the constructor. The painting of the other labels is delegated to the ILcdGXYLabelPainter specified in the constructor, if there is one.
  • an ILcdGXYEditor so that the domain object can be moved. This editing is delegated to the ILcdGXYEditor specified in the constructor.
  • an ILcdGXYLabelEditor so that the domain object can be moved when the label is moved and so that the icon offset can be changed using the mouse. This label editing is not delegated.

Following image illustrates the usage of the delegate painters:

The offset icon is always painted as the label specified by the label index 0 and the sublabel index 0.

This class supports snapping:

  • It can provide snap targets: when the location in the context specifies a position near the anchor point or near the offset icon, the focus point of the set object is returned as snap target.
  • It can snap to other snap targets: the snapping behaviour is delegated to the ILcdGXYEditor specified in the constructor of this class. When the context contains a snapping target accepted by that editor, the editor will snap the domain object to that snap target.

This painter must be used as ILcdGXYPainter, ILcdGXYEditor, ILcdGXYLabelPainter and ILcdGXYLabelEditor for correct operation.

This painter is also a provider for all of these interfaces. It always returns itself as painter, editor, label painter and label editor.

Remarks:

  • This painter passes ( null, null ) to the delegate label painter's getLabelCount method when this offset icon painter is configured to paint all labels as sublabels (cfr. TLcdGXYOffsetIconPainter) ; the delegate label painter should take this possibility into account.
  • This painter does not cooperate well with the interactive labels of TLcdGXYStampLabelPainter. The interactive labels will be positioned as if there was no offset, which results in erratic behavior.
  • As the offset icons are painted as labels, make sure to set setLabeled(true) on the layer.
  • If the icons should be selectable, a controller that allows selecting labels is needed: TLcdGXYSelectController2 .
  • As labels are painted on top of the bodies (regular objects), the offset icons can appear on top of objects that would otherwise be painted below.
  • If the offset icons should be editable, a call to setLabelsEditable(true) on the layer is required because the offset icons are treated as labels.
  • For the same reason, a controller that allows editing labels is needed: TLcdGXYEditController2.

Since:
7.2
See Also:
  • Field Details

    • SOUTH_EAST

      public static final int SOUTH_EAST
      Integer code to place label at south east of the anchor point.
      See Also:
    • NORTH_WEST

      public static final int NORTH_WEST
      Integer code to place label at north west of the anchor point.
      See Also:
    • NORTH_EAST

      public static final int NORTH_EAST
      Integer code to place label at north east of the anchor point.
      See Also:
    • SOUTH_WEST

      public static final int SOUTH_WEST
      Integer code to place label at south west of the anchor point.
      See Also:
    • EAST

      public static final int EAST
      Integer code to place label at east of the anchor point.
      See Also:
    • WEST

      public static final int WEST
      Integer code to place label at west of the anchor point.
      See Also:
    • NORTH

      public static final int NORTH
      Integer code to place label at north of the anchor point.
      See Also:
    • SOUTH

      public static final int SOUTH
      Integer code to place label at south of the anchor point.
      See Also:
    • CENTER

      public static final int CENTER
      Integer code to place label at center of the anchor point.
      See Also:
    • MAXIMUM_AVAILABLE_LOCATIONS

      public static int MAXIMUM_AVAILABLE_LOCATIONS
      Maximum number of available locations.
  • Constructor Details

    • TLcdGXYOffsetIconPainter

      public TLcdGXYOffsetIconPainter(ILcdGXYPainter aDelegateAnchorPainter, ILcdGXYPainter aDelegateOffsetIconPainter, ILcdGXYEditor aDelegateOffsetEditor, ILcdGXYLabelPainter aDelegateLabelPainter)

      Creates an offset icon painter that delegates its operations to the specified painters and editor. If aDelegateLabelPainterThis is not an instance of ILcdGXYLabelPainter2, this offset icon painter will be configured to use sublabels. The overloading constructor can be used if you want to set this option explicitly.

      See Also:
    • TLcdGXYOffsetIconPainter

      public TLcdGXYOffsetIconPainter(ILcdGXYPainter aDelegateAnchorPainter, ILcdGXYPainter aDelegateOffsetIconPainter, ILcdGXYEditor aDelegateOffsetEditor, ILcdGXYLabelPainter aDelegateLabelPainter, boolean aMapAllToSublabels)

      Creates an offset icon painter that delegates its operations to the specified painters and editor.

      The aMapAllToSublabels flag determines how the label- and sublabel indices are mapped from the delegate label painter to this label painter. This is especially useful for decluttering behavior, which can differ for labels and sublabels. Please refer to paintLabel for a table visualizing this mapping.

      Parameters:
      aDelegateAnchorPainter - The ILcdGXYPainter that will be used to paint the anchor. This parameter must not be null
      aDelegateOffsetIconPainter - The ILcdGXYPainter that will be used to paint the offset representation. This will typically be some sort of icon painter. This parameter must not be null.
      aDelegateOffsetEditor - The ILcdGXYEditor that will be used to edit the domain object on user interaction. This editor must not be null if this painter will be used as an editor.
      aDelegateLabelPainter - The ILcdGXYLabelPainter that will be used to paint the regular labels. This parameter may be null if no regular labels need to be painted.
      aMapAllToSublabels - If true, the getLabelCount method will always return 1. All labels of aDelegateLabelPainter and their sublabels are drawn as sublabels of this one label, together with the label representing the offset icon. If false, only the label indices will be shifted to compensate for the offset icon, but the sublabel indices will remain the same.
  • Method Details

    • getDelegateAnchorPainter

      public ILcdGXYPainter getDelegateAnchorPainter()
      Returns the delegate anchor painter that was specified in the constructor.
      Returns:
      The delegate anchor painter that was specified in the constructor. This cannot be null.
      See Also:
    • getDelegateOffsetIconPainter

      public ILcdGXYPainter getDelegateOffsetIconPainter()
      Returns the delegate icon painter that was specified in the constructor.
      Returns:
      The delegate icon painter that was specified in the constructor. This cannot be null.
      See Also:
    • getDelegateOffsetEditor

      public ILcdGXYEditor getDelegateOffsetEditor()
      Returns the delegate editor that was specified in the constructor.
      Returns:
      The delegate editor that was specified in the constructor. This can be null.
      See Also:
    • getDelegateLabelPainter

      public ILcdGXYLabelPainter getDelegateLabelPainter()
      Returns the delegate label painter that was specified in the constructor.
      Returns:
      The delegate label painter that was specified in the constructor. This can be null.
      See Also:
    • isMakeLabelsStickyOnEdit

      public boolean isMakeLabelsStickyOnEdit()
      Returns whether this editor makes a label sticky when it edits this label. The default is false
      Returns:
      true if this label editor makes a label sticky when it edits this label, false otherwise.
      See Also:
    • setMakeLabelsStickyOnEdit

      public void setMakeLabelsStickyOnEdit(boolean aMakeLabelsStickyOnEdit)
      Determines whether this editor makes a label sticky when it edits this label.
      Parameters:
      aMakeLabelsStickyOnEdit - true if the label should be made sticky, false otherwise.
      See Also:
    • isWithPin

      public boolean isWithPin()
      Returns whether or not this painter draws a line (the "pin") from the offset icon to the anchor point of the domain object.
      Returns:
      true if the pin is drawn, false if not.
    • setWithPin

      public void setWithPin(boolean aWithPin)
      Specifies whether or not a line (the "pin") should be drawn from the offset icon to the anchor point of the domain object.
      Parameters:
      aWithPin - true if the pin should be drawn, false if not.
    • setPinStyle

      public void setPinStyle(ILcdGXYPainterStyle aPinStyle)
      Sets the painter style to be used when painting the pin. Its setupGraphics method will be called right before the pin is drawn.
      Parameters:
      aPinStyle - The pin style to use when drawing the pin. This must not be null.
    • getPinStyle

      public ILcdGXYPainterStyle getPinStyle()
      Returns the painter style that is used when drawing the pin.
      Returns:
      The painter style that is used when drawing the pin. This is never null.
    • getSnapIcon

      public ILcdIcon getSnapIcon()

      Returns the ILcdIcon to paint snap target points of the object set to this painter. This icon is only used when the mouse is near the offset icon. Otherwise the snapping functionality is delegated to the anchor painter.

      Returns:
      The ILcdIcon to paint snap the snap target when the context indicates a location near the offset icon.
      See Also:
    • setSnapIcon

      public void setSnapIcon(ILcdIcon aSnapIcon)

      Sets the ILcdIcon to paint snap target points of the object set to this painter. This icon is only used when the mouse is near the offset icon. Otherwise the snapping functionality is delegated to the anchor painter.

      Parameters:
      aSnapIcon - The ILcdIcon to paint snap the snap target when the context indicates a location near the offset icon.
      See Also:
    • getDisplayName

      public String getDisplayName()
      Description copied from class: ALcdGXYLabelPainter
      This default implementation returns the display name set with setDisplayName, or toString() if this was set to null.
      Specified by:
      getDisplayName in interface ILcdGXYEditor
      Specified by:
      getDisplayName in interface ILcdGXYLabelEditor
      Specified by:
      getDisplayName in interface ILcdGXYLabelPainter2
      Specified by:
      getDisplayName in interface ILcdGXYPainter
      Overrides:
      getDisplayName in class ALcdGXYLabelPainter
      Returns:
      the display name of this ILcdGXYLabelPainter2
    • getLabelCount

      public int getLabelCount(Graphics aGraphics, ILcdGXYContext aGXYContext)

      Return the number of labels for the currently set object. The default implementation returns 1. Override this method if you need to support multiple labels.

      If this label painter is configured to paint all labels as sublabels (cfr the constructor) this will always return 1. Otherwise this method will return the number of labels as specified by the delegate label painter, plus 1 for the offset icon.

      Please refer to paintLabel for documention on how the label- and sublabel indices set on this label painter are mapped to the label- and sublabel indices of the delegate label painter.

      Specified by:
      getLabelCount in interface ILcdGXYLabelEditor
      Specified by:
      getLabelCount in interface ILcdGXYMultiLabelPainter
      Overrides:
      getLabelCount in class ALcdGXYLabelPainter
      Parameters:
      aGraphics - The Graphics instance on which the labels would be painted.
      aGXYContext - The context containing information about the layer and the view for which the label would be drawn.
      Returns:
      The number of labels for the set object. This should be greater than 0.
    • getSubLabelCount

      public int getSubLabelCount(int aLabelIndex)

      Returns the number of sublabels for the set object and the given label index. The default implementation returns 1. Override this method if you need to support multiple sublabels.

      If this label painter is configured to paint all labels as sublabels (cfr the constructor) this will return the sum of all the sublabels of all the labels as specified by the delegate label painter, plus one for the offset icon.

      Otherwise it returns 1 when aLabelIndex is 0, for the offset icon, or the subLabelCount of the label with index aLabelIndex - 1 as specified by the delegate label painter.

      Specified by:
      getSubLabelCount in interface ILcdGXYLabelEditor
      Specified by:
      getSubLabelCount in interface ILcdGXYMultiLabelPainter
      Overrides:
      getSubLabelCount in class ALcdGXYLabelPainter
      Parameters:
      aLabelIndex - The label index for which you need to know the number of sublabels.
      Returns:
      The number of sublabels. This should be greater than 0.
      See Also:
    • getLabelCursor

      public Cursor getLabelCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Description copied from class: ALcdGXYLabelPainter
      Returns a Cursor to indicate the type of editing aMode and aGXYContext.

      This default implementation always returns null. Override this method if you want to display custom cursors.

      Specified by:
      getLabelCursor in interface ILcdGXYLabelPainter2
      Overrides:
      getLabelCursor in class ALcdGXYLabelPainter
      Parameters:
      aGraphics - The Graphics instance on which the label is painted.
      aMode - The mode to consider. See ILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, ILcdGXYContext) for more information.
      aGXYContext - The ILcdGXYContext containing extra information, such as the layer, the view and the mouse position.
      Returns:
      a Cursor to indicate the type of editing aMode and aGXYContext. Returns null if no particular Cursor is required.
    • isLabelTouched

      public boolean isLabelTouched(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Tests if the label specified by setObject, setLabelIndex and setSubLabelIndex is touched at view location (specified by aGXYContext.getX() and aGXYContext.getY()), considering the mode and the ILcdGXYContext instance.

      Before calling this method, the domain object, the label index, the sublabel index and the location of the label should be set using the respective methods.

      If the label index and sublabel index are both 0, this method tests whether the offset icon is touched, otherwise the delegate label painter is used to determine whether the specified label is touched.

      Please refer to paintLabel for documentation on which information is passed to the delegate painters.

      Specified by:
      isLabelTouched in interface ILcdGXYLabelPainter2
      Parameters:
      aGraphics - The Graphics instance on which the label is painted.
      aMode - the mode to consider. This is a bitwise combinations of several constants. See ILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext) for more information.
      aGXYContext - the ILcdGXYContext to consider.
      Returns:
      true if the representation of the Object returned by getObject() is touched, false otherwise
      See Also:
    • labelAnchorPointSFCT

      public void labelAnchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException

      Sets aPointSFCT to the anchor point of the label specified by setObject, setLabelIndex and setSubLabelIndex.

      If the location index is less than 0, the label anchor point is unambiguously determined by the label location. The actual label is to be painted somewhere around this anchor point. This method is typically called to compare the result with the label bounds, thus determining the exact relation between the label and its location.

      Before calling this method, the domain object, the label index, the sublabel index and the location of the label should be set using the respective methods.

      If the label index and sublabel index are both 0, this method sets aPointSFCT to the anchor point of the offset icon; otherwise the delegate label painter is used to determine the anchor point.

      Please refer to paintLabel for documentation on which information is passed to the delegate painters.

      Specified by:
      labelAnchorPointSFCT in interface ILcdGXYLabelPainter2
      Parameters:
      aGraphics - The Graphics instance on which the label is painted.
      aMode - The mode to consider. This can be a bitwise combination of several constants. See ILcdGXYLabelPainter2.paintLabel(java.awt.Graphics, int, com.luciad.view.gxy.ILcdGXYContext) for more information.
      aGXYContext - The ILcdGXYContext that can be used to retrieve extra information.
      aPointSFCT - The point which will be updated to reflect the location of the anchor point.
      Throws:
      TLcdNoBoundsException - if the Object doesn't have any valid anchor point, e.g. if it is always invisible in the current projection.
      See Also:
    • labelBoundsSFCT

      public double labelBoundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Rectangle aRectangleSFCT) throws TLcdNoBoundsException

      Calculates the bounds of the label that can be painted. The bounds are set as a side effect in aRectangleSFCT, the orientation of aRectangleSFCT is returned as an angle.

      The bounds represent the upper left point of the label, and a width and a height. The rotation value represents the rotation of the label bounds around the upper left point.

      The domain object, the label index, the sublabel index and the location of the label for which the bounds are retrieved should be set before calling this method using the respective methods.

      Note that if this label painter is used in conjunction with a labeling algorithm, the bounds should preferably be independent of the location, as this will yield the best results.

      If the label index and sublabel index are both 0, this method sets aRectangleSFCT to the bounds of the offset icon; otherwise the delegate label painter is used to determine the bounds.

      Please refer to paintLabel for documentation on which information is passed to the delegate painters.

      Specified by:
      labelBoundsSFCT in interface ILcdGXYLabelPainter
      Specified by:
      labelBoundsSFCT in interface ILcdGXYLabelPainter2
      Parameters:
      aGraphics - the aGraphics to consider.
      aMode - the representation mode of the label.
      aGXYContext - the ILcdGXYContext the drawing depends on.
      aRectangleSFCT - the Rectangle containing the bounds of the label in view / graphics coordinates as side effect.
      Returns:
      the angle orientation of the rectangle around the labels in RADIANs, clockwise, 0 at 3 o'clock.
      Throws:
      TLcdNoBoundsException - if the Object doesn't have any valid bounds, e.g. if it is always invisible in the current projection.
      See Also:
    • paintLabel

      public void paintLabel(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)

      Paints the label specified by setObject, setLabelIndex and setSubLabelIndex on aGraphics. aGXYContext should contain the ILcdGXYView for which the label is painted and ILcdGXYLayer to which the object belongs

      The implementation of this method shall define how to paint the specified label in the given mode, considering aGXYContext and the set TLcdLabelLocation.

      The domain object, label index, sublabel index and the label location should be set before calling this method using the respective methods.

      This interface extends the original contract of the paintLabel method to allow for more modes. Where in the super interface the mode could only be one of ILcdGXYLabelPainter.DEFAULT or ILcdGXYLabelPainter.SELECTED, the mode now can be a bitwise combination of several constants

      When the label- and sublabel index are both 0, the offset icon is painted. This icon is painted by the delegate offset icon painter. The graphics and the context passed to this ILcdGXYPainter are modified to take the offset into account, given by the set TLcdLabelLocation.

      If any other combination of label- and sublabel index is set, this combination is mapped to the corresponding label- and sublabel index of the delegate label painter, as explained in the table below. The graphics and the context given to the delegate label painters are modified to take the offset into account, as well as the label location. The label location given to the delegate label painter is modified so that it cancels the offset of the icon. This allows the label painter to keep painting a line to the anchor point of the domain object.
      In this case the offset is retrieved from the ILcdGXYEditableLabelsLayer in the given context: it is specified by the label location of the label with label- and sublabel index 0.

      The table below visualizes the mapping from label- and sublabel indices of the delegate label painter to the label- and sublabel indices of this label painter. In this table the example is given of a delegate label painter that has two labels: one with two sublabels, and the second with three sublabels.

      Delegate label painter Mapping with aMapAllToSublabels == false Mapping with aMapAllToSublabels == true
      Label indexSublabel index Label index Sublabel index Label index Sublabel index
      Offset icon 0 0 0 0
      0 0 1 0 1
      1 1 2
      1 0 2 0 3
      1 1 4
      2 2 5
      Specified by:
      paintLabel in interface ILcdGXYLabelPainter
      Specified by:
      paintLabel in interface ILcdGXYLabelPainter2
      Parameters:
      aGraphics - The graphics object to paint the label on
      aMode - A bitwise combination of
      aGXYContext - the drawing context for the label
      See Also:
    • supportLabelSnap

      public boolean supportLabelSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)
      Description copied from class: ALcdGXYLabelPainter

      Returns whether this label painter supports snapping for the label specified by setObject, setLabelIndex and setSubLabelIndex, considering the given ILcdGXYContext instance. When the label painter supports snap for the specified label and context, it can return a snap target for this label and context.

      Before calling this method, the domain object, the label index, the sublabel index and the location of the label should be set using the respective methods.

      This default implementation returns false. Override this method if you want to support snapping.

      Specified by:
      supportLabelSnap in interface ILcdGXYLabelPainter2
      Overrides:
      supportLabelSnap in class ALcdGXYLabelPainter
      Parameters:
      aGraphics - the Graphics on which is worked.
      aGXYContext - the ILcdGXYContext of the snapping.
      Returns:
      true if this label painter supports snapping for the specified label.
      See Also:
    • getPossibleLocationCount

      public int getPossibleLocationCount(Graphics aGraphics)
      Description copied from interface: ILcdGXYLabelPainter
      Returns the number of possible locations where this ILcdGXYLabelPainter can paint/draw the labels of the set domain Object.

      The domain Object for which the location count is retrieved should be set before calling this method using the ILcdGXYLabelPainter.setObject(java.lang.Object) method.

      Specified by:
      getPossibleLocationCount in interface ILcdGXYLabelPainter
      Parameters:
      aGraphics - the Graphics the label will be painted on.
      Returns:
      the number of possible locations where this ILcdGXYLabelPainter can paint/draw the labels of the set Object.
      See Also:
    • acceptSnapTargetForLabel

      public boolean acceptSnapTargetForLabel(Graphics aGraphics, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYLabelEditor

      Returns whether the label specified by setObject, setLabelIndex and setSubLabelIndex accepts the snap target in the given ILcdGXYContext.

      The snap target is the Object returned by aGXYContext.getSnapTarget(), and is on the ILcdGXYLayer returned by aGXYContext.getSnapTargetLayer().

      Specified by:
      acceptSnapTargetForLabel in interface ILcdGXYLabelEditor
      Parameters:
      aGraphics - The Graphics on which the label is painted.
      aGXYContext - The ILcdGXYContext containing the snapping information.
      Returns:
      true if the label accepts the snap target, false otherwise.
      See Also:
    • editLabel

      public boolean editLabel(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)

      Adapts the set TLcdLabelLocation according to the information present in aGXYContext. If the method returns true, the TLcdLabelLocation was modified, if false is returned, it wasn't changed.

      The implementation of this method shall define how to edit the label specified by the set domain Object , label index and sublabel index, considering the given mode and aGXYContext. These should all be set before calling this method. Note that if aMode is one of the creating modes, the (sub) label indices are irrelevant.

      In case aMode == ILcdGXYLabelEditor.TRANSLATED:
      When the set label- and sublabel index indicate the offset icon, this method will translate the domain object (ie. not the label position) using the delegate editor specified in the constructor. The set label location will not be changed, unless its label edit mode indicates absolute placement.
      If the set label- and sublabel index indicate another label, the set label location will only be changed if its label edit mode indicates absolute placement.

      In case aMode == ILcdGXYLabelEditor.RESHAPED:
      The set label location will be adjusted according to the given context. This means that for the offset icon the offset will be changed, and for the regular labels their position will be changed.

      Specified by:
      editLabel in interface ILcdGXYLabelEditor
      Parameters:
      aGraphics - The Graphics on which the label is painted.
      aMode - the mode to consider when editing aObject: aMode shall be a combination of
      • ILcdGXYLabelEditor.TRANSLATED,
      • ILcdGXYLabelEditor.RESHAPED,
      • ILcdGXYLabelEditor.START_CREATION,
      • ILcdGXYLabelEditor.CREATING,
      • ILcdGXYLabelEditor.END_CREATION.
      .
      aGXYContext - contains the information to consider when editing the set Object.
      Returns:
      true if the label of the set Object has changed, false otherwise.
      See Also:
    • getLabelCreationClickCount

      public int getLabelCreationClickCount()
      Description copied from interface: ILcdGXYLabelEditor
      Returns the number of points required to initialize the label of the set Object.
      Specified by:
      getLabelCreationClickCount in interface ILcdGXYLabelEditor
      Returns:
      the number of points required to initialize the label of the set Object or -1 if this is undefined like for a polyline or a polygon. 0 means graphical creation of labels is not supported.
    • anchorPointSFCT

      public void anchorPointSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, Point aPointSFCT) throws TLcdNoBoundsException
      Description copied from interface: ILcdGXYPainter
      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.

      Specified by:
      anchorPointSFCT in interface ILcdGXYPainter
      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:
    • boundsSFCT

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

      This painter delegates this call to the delegate anchor painter specified in the constructor.

      Specified by:
      boundsSFCT 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). 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:
    • getCursor

      public Cursor getCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYPainter
      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.
      Specified by:
      getCursor in interface ILcdGXYPainter
      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.
    • isTouched

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

      This painter delegates this call to the delegate anchor painter specified in the constructor.

      Specified by:
      isTouched in interface ILcdGXYPainter
      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:
    • paint

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

      This painter delegates this call to the delegate anchor painter specified in the constructor.

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

      protected ILcdPoint getFocusPoint()
      Returns the focus point of the set object if it is an ILcdShape. Override this method if you want this painter to be able to work with domain objects that are no ILcdShape.
      Returns:
      The focus point of the set object if it is an ILcdShape, null otherwise.
    • snapTarget

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

      If the set object is an ILcdShape and the offset icon is touched (taking the given context into account), this method returns the focus point of the set shape as the snap target. Otherwise it lets the delegate anchor painter handle this call.

      Specified by:
      snapTarget in interface ILcdGXYPainter
      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:
    • labelSnapTarget

      public Object labelSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
      Description copied from class: ALcdGXYLabelPainter
      Returns an Object that can be used as snapping target when graphically editing another Object or label than the one this ILcdGXYLabelPainter2 represents. The returned Object can be the Object this ILcdGXYLabelPainter2 represents or any other (e.g. an ILcdPoint if getObject() is an ILcdPointList).

      This default implementation always returns null. Override this method if you want to support snapping.

      Specified by:
      labelSnapTarget in interface ILcdGXYLabelPainter2
      Overrides:
      labelSnapTarget in class ALcdGXYLabelPainter
      Parameters:
      aGraphics - the Graphics on which is worked.
      aGXYContext - the ILcdGXYContext of the snapping.
      Returns:
      an Object that can be used as snapping target when graphically editing another Object or label than the one this ILcdGXYLabelPainter2 represents (returned by getObject()). This object can be null.
    • supportSnap

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

      This painter supports snapping if the getFocusPoint method returns a non-null value, or if the delegate anchor painter supports snapping.

      Specified by:
      supportSnap in interface ILcdGXYPainter
      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.
    • acceptSnapTarget

      public boolean acceptSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYEditor
      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.

      Specified by:
      acceptSnapTarget in interface ILcdGXYEditor
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aGXYContext - the context containing the information on the user interaction and the snap target.
      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.
      See Also:
    • edit

      public boolean edit(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      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.

      This call is delegated to the delegate anchor editor specified in the constructor. The specified mode is modified so the ILcdGXYEditor.RESHAPED constant is replaced by the ILcdGXYEditor.TRANSLATED constant.

      Specified by:
      edit in interface ILcdGXYEditor
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aMode - indicates how the user interaction should be interpreted. Is one of the following:
      • TRANSLATED,
      • RESHAPED,
      • START_CREATION,
      • CREATING,
      • END_CREATION.
      aGXYContext - contains information on the user interaction and the transformations to transform from view space to the object model space.
      Returns:
      true if the object has changed when this method returns, false otherwise.
      See Also:
    • getCreationClickCount

      public int getCreationClickCount()
      Description copied from interface: ILcdGXYEditor
      Returns the number user interactions required to complete the initialization of an object set to this editor. For example, for a circle this can be two: one to determine the center point of the circle and one to determine the radius of the circle. A negative number indicates that there is no upper limit to the number of user interactions. For example, for a polyline this could be -2: it requires a minimum of two clicks to establish a polyline, but there is no upper limit on the number of polyline points.
      Specified by:
      getCreationClickCount in interface ILcdGXYEditor
      Returns:
      the number of user interactions required to initialize the object set to this editor.
    • getGXYPainter

      public ILcdGXYPainter getGXYPainter(Object aObject)
      Description copied from interface: ILcdGXYPainterProvider
      Finds an ILcdGXYPainter that can be used to paint or locate the object passed.

      The painter provider is responsible for setting the object to the painter before returning the painter. An implementation should therefore have the following structure:

      
       public ILcdGXYPainter getGXYPainter(Object aObject) {
         ILcdGXYPainter painter = ... // find the painter for the object
         if (painter != null) {
          painter.setObject(aObject);
         }
         return painter;
       }
       

      Specified by:
      getGXYPainter in interface ILcdGXYPainterProvider
      Parameters:
      aObject - the object to find a painter for
      Returns:
      a painter that can be used to paint or locate the object; or null if no painter could be found for the given object, or the object could not be set on the retrieved painter.
    • getGXYEditor

      public ILcdGXYEditor getGXYEditor(Object aObject)
      Description copied from interface: ILcdGXYEditorProvider
      Finds an ILcdGXYEditor that can be used to edit the object passed.

      The editor provider is responsible for setting the object to the editor before returning the editor. An implementation should therefore have the following structure:

      
       public ILcdGXYEditor getGXYEditor(Object aObject) {
         ILcdGXYEditor editor = ... // find the editor for the object
         editor.setObject( aObject );
         return editor;
       }
       

      Specified by:
      getGXYEditor in interface ILcdGXYEditorProvider
      Parameters:
      aObject - the object to find an editor for
      Returns:
      an editor that can be used to edit the object.
    • getGXYLabelPainter

      public ILcdGXYLabelPainter getGXYLabelPainter(Object aObject)
      Description copied from interface: ILcdGXYLabelPainterProvider
      Finds an ILcdGXYLabelPainter that can be used to label the object passed.

      The label painter provider is responsible for setting the object to the label painter before returning the label painter. An implementation should therefore have the following structure:

      
       public ILcdGXYLabelPainter getGXYLabelPainter(Object aObject) {
         ILcdGXYLabelPainter labelPainter = ... // find the label painter for the object
         if (labelPainter != null) {
          labelPainter.setObject(aObject);
         }
         return labelPainter;
       }
       

      Specified by:
      getGXYLabelPainter in interface ILcdGXYLabelPainterProvider
      Parameters:
      aObject - the object to find a label painter for
      Returns:
      a label painter that can be used to label the object; or null if no label painter could be found for the given object, or the object could not be set on the retrieved label painter.
    • getGXYLabelEditor

      public ILcdGXYLabelEditor getGXYLabelEditor(Object aObject)
      Description copied from interface: ILcdGXYLabelEditorProvider

      Returns a valid ILcdGXYLabelEditor for editing the labels of aObject. The returned ILcdGXYLabelEditor must have aObject set on it. The TLcdLabelLocation must not yet be set on it.

      Specified by:
      getGXYLabelEditor in interface ILcdGXYLabelEditorProvider
      Parameters:
      aObject - the Object for which to obtain a ILcdGXYLabelEditor.
      Returns:
      a valid ILcdGXYLabelEditor for editing the labels of aObject with aObject set on it.
      See Also:
    • setDisplayLabels

      public void setDisplayLabels(boolean aDisplayLabels)

      Configures whether the regular labels should be painted. If this property is false, the labels of the delegate label painter are not painted. This is useful when adjusting the layer to respect its labeled property: since the offset icon is painted as a label, the layer should always be labeled. You can extend layer implementation to always paint labels, but let this label painter then respect the labeled property of this layer.

      Parameters:
      aDisplayLabels - false if you do not want the labels of the delegate label painter to be drawn, true otherwise.
    • isDisplayLabels

      public boolean isDisplayLabels()

      Returns whether this painter will paint the labels of the delegate label painter.

      Returns:
      true if the labels are painted, false otherwise.
      See Also:
    • isDisplayOffsetIcons

      public boolean isDisplayOffsetIcons()
      Returns whether this painter paints the offset icons. Please refer to setDisplayLabels for how this property can be useful.
      Returns:
      true if this painter paints the offset icons, false otherwise
    • setDisplayOffsetIcons

      public void setDisplayOffsetIcons(boolean aDisplayOffsetIcons)

      Configures whether this painter should paint the offset icons.

      Parameters:
      aDisplayOffsetIcons - true if this painter should paint the offset icons, false otherwise.
    • clone

      public Object clone()
      Description copied from class: ALcdGXYLabelPainter
      Returns a new instance of this ALcdGXYLabelPainter. The label location of the clone is a clone of the label location of the original. No other objects are cloned.
      Specified by:
      clone in interface ILcdCloneable
      Specified by:
      clone in interface ILcdGXYEditorProvider
      Specified by:
      clone in interface ILcdGXYLabelEditor
      Specified by:
      clone in interface ILcdGXYLabelEditorProvider
      Specified by:
      clone in interface ILcdGXYLabelPainter
      Specified by:
      clone in interface ILcdGXYLabelPainter2
      Specified by:
      clone in interface ILcdGXYLabelPainterProvider
      Specified by:
      clone in interface ILcdGXYPainterProvider
      Overrides:
      clone in class ALcdGXYLabelPainter
      Returns:
      A new instance of this ALcdGXYLabelPainter of which the label location is a deep clone.
      See Also:
    • setPositionList

      public void setPositionList(int[] aPositionList)

      Sets a new position list. This list is only used when the labels are not placed freely.

      Parameters:
      aPositionList - the list of possible positions to place the labels.
      See Also:
    • getPositionList

      public int[] getPositionList()
      Returns the list of possible positions to place the labels.
      Returns:
      the list of possible positions to place the labels.
      See Also:
    • setShiftLabelPosition

      public void setShiftLabelPosition(int aShift)

      Sets how many pixels the label must be removed from the anchor point of the domain object when labels are not placed freely (i.e. getLabelLocation().getLocationIndex() != -1). If the position of the label is east or west, this shift is applied in horizontal direction; if the position is north or south, this shift is applied in vertical direction. In case of north east, south east, south west or north west, this shift is applied in both directions. If the location of the label is center, the shift is ignored.

      The default for this value is 20 pixels.

      Parameters:
      aShift - the distance, expressed in pixels, that the label must be removed from the domain object.
      See Also:
    • getShiftLabelPosition

      public int getShiftLabelPosition()
      Returns how many pixels the label must be removed from the anchor point of the domain object when labels are not placed freely (i.e. getLabelLocation().getLocationIndex() != -1).
      Returns:
      the distance, expressed in pixels, that the label must be removed from the domain object.
      See Also:
    • setClassTraceOn

      public static void setClassTraceOn(boolean aClassTraceOn)
      Deprecated.
      This method has been deprecated. It is recommended to use the standard Java logging framework directly.
      Enables tracing for all instances of this class. If the argument is true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.
      Parameters:
      aClassTraceOn - if true then all log messages are recorded, otherwise only the informative, warning and error messages are recorded.