Interface ILcdGXYLabelPainter2

All Superinterfaces:
Cloneable, ILcdGXYLabelPainter, ILcdGXYMultiLabelPainter, ILcdPropertyChangeSource, Serializable
All Known Implementing Classes:
ALcdGXYLabelPainter, TLcdAIXM51AirspaceLabelPainter, TLcdAIXM51NavaidLabelPainter, TLcdAIXM51XPathLabelPainter, TLcdGXYCompositeLabelPainter, TLcdGXYCurvedPathLabelPainter, TLcdGXYDataObjectLabelPainter, TLcdGXYDataObjectPolygonLabelPainter, TLcdGXYDataObjectPolylineLabelPainter, TLcdGXYFeaturedLabelPainter, TLcdGXYFeaturedPolygonLabelPainter, TLcdGXYFeaturedPolylineLabelPainter, TLcdGXYHaloLabelPainter2, TLcdGXYLabelPainter, TLcdGXYLabelPainterAdapter, TLcdGXYMultiFontLabelPainter, TLcdGXYOffsetIconPainter, TLcdGXYOutlinePolylineLabelPainter, TLcdGXYPolygonLabelPainter, TLcdGXYPolygonStampLabelPainter, TLcdGXYPolylineLabelPainter, TLcdGXYPolylineStampLabelPainter, TLcdGXYStampLabelPainter, TLcdICAOAirspaceDetailedLabelPainter, TLcdICAOAirspaceLabelPainter, TLcdICAOAreaMinimumAltitudeLabelPainter, TLcdICAODMELabelPainter, TLcdICAONavaidLabelPainter, TLcdICAONDBLabelPainter, TLcdICAOTACANLabelPainter, TLcdICAOVORLabelPainter, TLcdMagneticNorthGXYLabelPainter, TLcdSLDFeatureTypeStylePainter, TLcdSLDRulePainter

public interface ILcdGXYLabelPainter2 extends ILcdGXYMultiLabelPainter, ILcdPropertyChangeSource

Extension of ILcdGXYMultiLabelPainter that allows free label placement next to the discrete label placement offered by the super interface. This interface also adds methods similar to those in ILcdGXYPainter to support better interaction with the labels, such as checking if a label is touched (selection), snapping, painting labels in an editing state (translating), ...

Free label placement

With the discrete placement of the super interface, one had to choose one label location (setLocationIndex), from a set of label locations (getPossibleLocationCount) offered by the label painter itself.

This interface supports both free and discrete placement by setting a TLcdLabelLocation to it. This TLcdLabelLocation contains all needed information on where to put the label: at one of the possible discrete locations or at a free location (specified in pixels on the view).

Free locations determine the label location as shown in the following figure of a labeled point:

free label placement

  1. the label anchor point, retrieved through labelAnchorPointSFCT and specified by the TLcdLabelLocation.
  2. the label's upper left corner, retrieved through labelBoundsSFCT. The relationship with the label anchor point is determined by the label painter implementation.
  3. the AWT origin, determining the base offset of the label anchor point when the TLcdLabelLocation uses absolute positioning
  4. the object anchor point, as retrieved through ILcdGXYPainter.anchorPointSFCT, determining the base offset of the label anchor point when the TLcdLabelLocation uses relative positioning.

Usage

Implementations of this interface require that the object, the label location and the label- and sublabel-index are set (in that order) before the other methods can be used. Setting the location index is no longer needed. Typically, users of this interface will retrieve and store the TLcdLabelLocation of a particular label using the ALcdLabelLocations of an ILcdGXYEditableLabelsLayer.

Since:
7.0
See Also:
  • Field Details

  • Method Details

    • setLabelLocation

      void setLabelLocation(TLcdLabelLocation aLabelLocation)

      Sets the label location of the label. This label location will be used to determine what the bounds of the label are, where it must be painted, etc.

      Note that aLabelLocation also contains a label location index. This is independent of the ILcdGXYLabelPainter.getLocationIndex() of the super interface. Contrary to the location index returned by getLocationIndex, the location index in aLabelLocation can be less than 0, in which case the labels are freely placed.

      This method has to be called after setObject(java.lang.Object) has been called, as calling setObject clears this label location.

      Parameters:
      aLabelLocation - The TLcdLabelLocation instance containing all the information about the location of the label.
      See Also:
    • setObject

      void setObject(Object aObject)
      Sets the Object to be labeled by this ILcdGXYLabelPainter.

      Setting the object should set the TLcdLabelLocation to null, to ensure that older code which has not been adapted to this new interface keeps working.

      Specified by:
      setObject in interface ILcdGXYLabelPainter
      Parameters:
      aObject - The object to be labeled.
      See Also:
    • getLabelLocation

      TLcdLabelLocation getLabelLocation()
      Returns the TLcdLabelLocation that was previously set that contains the information on the whereabouts of the label.
      Returns:
      The label location that was previously set.
      See Also:
    • paintLabel

      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

      Specified by:
      paintLabel in interface ILcdGXYLabelPainter
      Parameters:
      aGraphics - The graphics object to paint the label on
      aMode - A bitwise combination of
      aGXYContext - the drawing context for the label
      See Also:
    • labelBoundsSFCT

      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.

      Specified by:
      labelBoundsSFCT in interface ILcdGXYLabelPainter
      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:
    • isLabelTouched

      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.

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

      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.

      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 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:
    • supportLabelSnap

      boolean supportLabelSnap(Graphics aGraphics, ILcdGXYContext aGXYContext)

      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.

      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:
    • labelSnapTarget

      Object labelSnapTarget(Graphics aGraphics, ILcdGXYContext aGXYContext)
      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).
      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.
    • getLabelCursor

      Cursor getLabelCursor(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext)
      Returns a Cursor to indicate the type of editing aMode and aGXYContext.
      Parameters:
      aGraphics - The Graphics instance on which the label is painted.
      aMode - The mode to consider. See 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.
    • getDisplayName

      String getDisplayName()
      Returns:
      the display name of this ILcdGXYLabelPainter2
    • clone

      Object clone()
      Redefines Object.clone to make it public.
      Specified by:
      clone in interface ILcdGXYLabelPainter