Class TLcdCompassGridPainter

java.lang.Object
com.luciad.view.gxy.ALcdGXYPainter
com.luciad.view.map.painter.TLcdCompassGridPainter
All Implemented Interfaces:
ILcdCloneable, ILcdPropertyChangeSource, ILcdGXYPainter, ILcdGXYPainterProvider, Serializable, Cloneable

public class TLcdCompassGridPainter extends ALcdGXYPainter implements ILcdGXYPainter
This painter displays a polar grid centered on a domain object. The grid consists of a number of concentric circles indicating distances, and rhumb lines indicating angles.

The painter accepts any ILcdPoint as object. In addition, the painter supports painting a compass grid for an object in another layer. To do this, it needs an ILcdAssoc as object, with the original domain object as key and the other layer as value.

The compass grid has a maximum range, and can draw a heading line.

See Also:
  • Field Details

    • MTR

      public static final int MTR
      Constant for meters as unit of measure.
      See Also:
    • KM

      public static final int KM
      Constant for kilometers as unit of measure.
      See Also:
    • YD

      public static final int YD
      Constant for yards as unit of measure.
      See Also:
    • NM

      public static final int NM
      Constant for nautical miles as unit of measure.
      See Also:
  • Constructor Details

    • TLcdCompassGridPainter

      public TLcdCompassGridPainter()
      Creates a default painter instance with the following settings:
      • nautical miles
      • ray line every 10 degrees
      • maximum of 16 circles covering 100 nautical miles
  • Method Details

    • setObject

      public void setObject(Object aObject)
      Sets the Object to be represented by this ILcdGXYPainter.
      Specified by:
      setObject in interface ILcdGXYPainter
      Parameters:
      aObject - the object for which the representation shall be handled by this painter.
      See Also:
    • getObject

      public Object getObject()
      Gets the Object this ILcdGXYPainter represents
      Specified by:
      getObject in interface ILcdGXYPainter
      Returns:
      the Object for which the representation is currently being handled by this painter.
      See Also:
    • isAntiAliasing

      public boolean isAntiAliasing()
      Returns whether to use anti-aliasing when painting.
      Returns:
      whether to use anti-aliasing when painting
      See Also:
    • setAntiAliasing

      public void setAntiAliasing(boolean aAntiAliasing)
      Sets whether to use anti-aliasing when painting.
      Parameters:
      aAntiAliasing - if true, uses anti-aliasing when painting
      See Also:
    • getCircleColor

      public Color getCircleColor()
      Returns the value of the property circleColor which determines the color of the concentric circles of the compass.
    • setCircleColor

      public void setCircleColor(Color aColor)
      Sets the property circleColor which determines the color of the concentric circles of the compass to aColor.
    • getRayColor

      public Color getRayColor()
      Returns the value of the property rayColor which determines the color of the rays of the compass.
    • setRayColor

      public void setRayColor(Color aColor)
      Sets the property rayColor which determines the color of the rays of the compass to aColor.
    • isDrawHeadingLine

      public boolean isDrawHeadingLine()
      drawHeadingLine is the boolean property that determines whether to draw the heading line or not.
    • setDrawHeadingLine

      public void setDrawHeadingLine(boolean aDrawHeadingLine)
      Sets whether to draw a heading line with a certain azimuth. The azimuth is determined from the object (either the ILcdPoint itself or ILcdAssoc's key value) using ILcdFeatured or using ILcdDataObject. The feature must be of type Number.
    • setHeadingColor

      public void setHeadingColor(Color aHeadingColor)
      Sets headingColor which is the color of the heading line that is drawn.
    • getHeadingColor

      public Color getHeadingColor()
      headingColor is the property that holds the color of the heading line that is drawn.
      Returns:
      headingColor
    • setHeadingLineWidth

      public void setHeadingLineWidth(int aHeadingLineWidth)
      headingLineWidth is the property that holds the width of the heading line that is drawn. This property has an effect for Java2 and up. For lower versions, the line width will be always 1.
      Parameters:
      aHeadingLineWidth - the line width to set.
    • getHeadingLineWidth

      public int getHeadingLineWidth()
      headingLineWidth is the property that holds the width of the heading line that is drawn. This property has an effect for Java2 and up. For lower versions, the line width will be always 1.
      Returns:
      the current line width.
    • setHeadingExpression

      public void setHeadingExpression(String aExpression)
      headingExpression determines the expression that when evaluated yields the azimuth of the heading to be painted. This expression should be set to handle objects that implement ILcdDataObject.
    • getHeadingExpression

      public String getHeadingExpression()
      headingExpression determines the expression of the ILcdDataObject that when evaluated yields the azimuth of the heading to be painted.
      Returns:
      the expression of the ILcdDataObject that contains the azimuth of the heading to be painted
      See Also:
    • setHeadingFeatureIndex

      public void setHeadingFeatureIndex(int aHeadingFeatureIndex)
      headingFeatureIndex determines the index of the ILcdFeatured that contains the azimuth of the heading to be painted This index should be set to handle objects that implement ILcdFeatured.
    • getHeadingFeatureIndex

      public int getHeadingFeatureIndex()
      headingFeatureIndex determines the index of the ILcdFeatured that contains the azimuth of the heading to be painted
      Returns:
      the index of the ILcdFeatured that contains the azimuth of the heading to be painted
    • isLabeled

      public boolean isLabeled()
      Returns:
      true if the compass grid includes labels
    • setLabeled

      public void setLabeled(boolean aLabeled)
      The property labeled determines whether the compass labels should be painted. Sets the property labeled to aLabeled.
    • getRangeDelta

      public double getRangeDelta()
      The property rangeDelta determines the distance between two consecutive concentric circles in the compass. Returns the value of the property rangeDelta in the unit of measure.
    • setRangeDelta

      public void setRangeDelta(double aRangeDelta)
      The property rangeDelta determines the distance between two consecutive concentric circles in the compass. Sets the value of the property rangeDelta to aRangeDelta (in the unit of measure).
    • getBearingDelta

      public double getBearingDelta()
      The property bearingDelta determines the angle between two consecutive rays of the compass. Returns the value of the property bearingDelta.
    • setBearingDelta

      public void setBearingDelta(double aBearingDelta)
      The property bearingDelta determines the angle between two consecutive rays of the compass. Sets the value of the property bearingDelta to aBearingDelta.
    • setRangeMax

      public void setRangeMax(double aRangeMax)
      The property rangeMax determines the maximal range of the compass. Sets the value of the property rangeMax to aRangeMax (in the unit of measure).
    • getRangeMax

      public double getRangeMax()
      The property rangeMax determines the maximal range of the compass. Returns the value of the property rangeMax in the unit of measure.
    • getCircleMax

      public int getCircleMax()
      The property circleMax determines the maximal number of circles in the compass. Returns the value of the property circleMax.
    • setCircleMax

      public void setCircleMax(int aCircleMax)
      The property circleMax determines the maximal number of circles in the compass. Sets the value of the property circleMax to aCircleMax.
    • getUnitOfMeasure

      public int getUnitOfMeasure()
      The unit of measure can be meters, kilometers, yards or nautical miles.
      Returns:
      the unitOfMeasure, which is one of the following: TLcdCompassGridPainter.MTR, TLcdCompassGridPainter.KM, TLcdCompassGridPainter.YD or TLcdCompassGridPainter.NM.
    • setUnitOfMeasure

      public void setUnitOfMeasure(int aUnitOfMeasure)
      The unit of measure can be meters, kilometers, yards or nautical miles. Sets the property unitOfMeasure to aUnitOfMeasure.
    • paint

      public void paint(Graphics aGraphics, int aState, ILcdGXYContext aGXYContext)
      Paints a compass grid centered at the given domain object. If the object is an ILcdPoint, that location is used. Else, the object is expected to be an ILcdAssoc key-value pair, where the key is an object in another layer and the value is the layer containing the object. In this case, the layer's painter is used to calculate an anchor point for the object.
      Specified by:
      paint in interface ILcdGXYPainter
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aState - the mode the object is represented in (see class documentation).
      aGXYContext - the ILcdGXYContext the drawing depends on.
    • getExpressionLanguage

      public ALcdDataObjectExpressionLanguage getExpressionLanguage()
      Returns the expression language that is used to evaluate the heading expression.
      Returns:
      the expression language that is used to evaluate the heading expression
      See Also:
    • setExpressionLanguage

      public void setExpressionLanguage(ALcdDataObjectExpressionLanguage aLanguage)
      Sets the expression language that is used to evaluate the heading expression. By default, this object is initialized with an instance of TLcdDataObjectExpressionLanguage.
      See Also:
    • isTouched

      public boolean isTouched(Graphics aGraphics, int aState, ILcdGXYContext aGXYContext)
      Description copied from interface: ILcdGXYPainter
      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.

      Specified by:
      isTouched in interface ILcdGXYPainter
      Parameters:
      aGraphics - the Graphics on which the representation of the object is painted
      aState - 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:
    • boundsSFCT

      public void boundsSFCT(Graphics aGraphics, int aMode, ILcdGXYContext aGXYContext, ILcd2DEditableBounds aBoundsSFCT) throws TLcdNoBoundsException
      Description copied from interface: ILcdGXYPainter
      Sets the supplied bounds (in view coordinates, pixels) so that it encompasses the representation of the object in the given mode taking into account the given context.

      If this method returns without exception the bounds argument must encompass the representation of the object. A point outside the bounds will not be contained within the painted object.

      The bounds returned in this method can be seen as the equivalent in the view space of the bounds in the model space for ILcdBounded objects.

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

      public String toString()
      Overrides:
      toString in class Object
      Returns:
      "CompassPainter".
    • clone

      public Object clone()
      Description copied from interface: ILcdCloneable

      Makes Object.clone() public.

      When for example extending from java.lang.Object, it can be implemented like this:
      
       public Object clone() {
         try {
           return super.clone();
         } catch ( CloneNotSupportedException e ) {
           // Cannot happen: extends from Object and implements Cloneable (see also Object.clone)
           throw new RuntimeException( e );
         }
       }
       
      Specified by:
      clone in interface ILcdCloneable
      Specified by:
      clone in interface ILcdGXYPainterProvider
      Overrides:
      clone in class ALcdGXYPainter
      Returns:
      a clone of this painter provider.
      See Also: