Class TLcdAWTPath

java.lang.Object
com.luciad.view.gxy.TLcdAWTPath
All Implemented Interfaces:
ILcdAWTPath

public class TLcdAWTPath extends Object implements ILcdAWTPath
This class provides an implementation of an ILcdAWTPath. It provides efficient storage and painting by simplifying the internal presentation of the path, without losing accuracy.

Like a Vector, each TLcdAWTPath tries to optimize storage management by maintaining a capacity and a capacityIncrementFraction, in this case for storing points in each subpath. The capacity is always at least as large as the number of stored points. It is usually larger, because as points are added to the path, the path's storage increases by a factor of capacityIncrementFraction. Note that this is a relative increment (e.g. 0.5 for 50%), unlike the increment for Vector, which is absolute. An application can ensure a certain capacity of a path before inserting a large number of points; this reduces the amount of incremental reallocation. An application can also trim the capacity to the actual size of the path after having inserted a set of points; this reduces the eventual memory usage.

This class also automatically clips polylines and polygons to a large rectangle, in order to improve the behavior of paint operations by the operating system (filling very large polygons leads to crashes on Windows 98, and it is very slow on many other operating systems). This rectangle's dimensions can be changed by defining the system properties com.luciad.view.gxy.TLcdAWTPath.maxOrdinate and com.luciad.view.gxy.TLcdAWTPath.minOrdinate when starting up the Java Virtual Machine, typically as follows:


   java -Dcom.luciad.view.gxy.TLcdAWTPath.maxOrdinate=8192 ....
 
An alternative to change the dimension of the clipping rectangle is to use the constructor which explicitly sets the max and min ordinate values.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static enum 
    Specifies how the interior of a shape is determined for self-intersecting polygons, i.e. how to calculate whether a point is outside or inside the shape.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a new TLcdAWTPath using the default initial capacity of 100 and the default capacity increment fraction of 1.0.
    TLcdAWTPath(int aInitialCapacity)
    Creates a new TLcdAWTPath using the given initial capacity and the default capacity increment fraction of 1.0.
    TLcdAWTPath(int aInitialCapacity, double aCapacityIncrementFraction)
    Creates a new TLcdAWTPath using the given initial capacity and capacity increment fraction and default ordinate values.
    TLcdAWTPath(int aInitialCapacity, double aCapacityIncrementFraction, double aMinOrdinate, double aMaxOrdinate)
    Creates a new TLcdAWTPath using the given initial capacity, capacity increment fraction, and ordinate values.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Appends a line break to the path.
    void
    Appends a polygon break to the path.
    void
    Returns the world bounds of the path in the side effect parameter aBoundsSFCT.
    void
    Closes the current polygon.
    void
    drawPolygon(Graphics aGraphics)
    Draws the outlines of the path as a polygon.
    void
    Draws the outlines of the path as a polyline.
    void
    ensureCapacity(int aMinimumCapacity)
    Ensures a given point capacity for the current subpath.
    void
    fillPolygon(Graphics aGraphics)
    Fills the path as a complex polygon that consists of one or more polygons.
    Returns how the interior of polygons is determined.
    int
    getX(int aSubpathIndex, int aPointIndex)
    Returns the x coordinate of the subpath point at the given indices.
    double
    getXAsDouble(int aSubpathIndex, int aPointIndex)
    Returns the x coordinate of the subpath point at the given indices.
    int
    getY(int aSubpathIndex, int aPointIndex)
    Returns the y coordinate of the subpath point at the given indices.
    double
    getYAsDouble(int aSubpathIndex, int aPointIndex)
    Returns the y coordinate of the subpath point at the given indices.
    boolean
    isPolylineTouched(double aX, double aY, int aSensitivity)
    Checks whether the given point touches the path.
    void
    lineTo(double aX, double aY)
    Appends a line to the AWT point (aX, aY).
    int
     
    void
    moveTo(double aX, double aY)
    Breaks the current line and moves to the AWT point (aX, aY).
    boolean
    polygonContains(double aX, double aY)
    Checks whether the given point is contained by the polygon represented by this ILcdAWTPath.
    void
    Resets the path.
    void
    Specifies how the interior of polygons is determined.
    boolean
    subPathBreaksLine(int aSubpathIndex)
    Returns whether the subpath at the given index represents a broken line.
    boolean
    subPathBreaksPolygon(int aSubpathIndex)
    Returns whether the subpath at the given index represents a broken part of a polygon.
    boolean
    subPathClosesPolygon(int aSubpathIndex)
    Returns whether the subpath at the given index represents a closing part of a polygon.
    int
     
    int
    subPathLength(int aSubpathIndex)
    Returns the length of the subpath at the given index.
    void
    Trims this TLcdAWTPath so that it occupies as little memory as possible.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • TLcdAWTPath

      public TLcdAWTPath()
      Creates a new TLcdAWTPath using the default initial capacity of 100 and the default capacity increment fraction of 1.0.
    • TLcdAWTPath

      public TLcdAWTPath(int aInitialCapacity)
      Creates a new TLcdAWTPath using the given initial capacity and the default capacity increment fraction of 1.0.
      Parameters:
      aInitialCapacity - the initial capacity.
    • TLcdAWTPath

      public TLcdAWTPath(int aInitialCapacity, double aCapacityIncrementFraction)
      Creates a new TLcdAWTPath using the given initial capacity and capacity increment fraction and default ordinate values.
      Parameters:
      aInitialCapacity - the initial capacity.
      aCapacityIncrementFraction - the capacity increment fraction.
    • TLcdAWTPath

      public TLcdAWTPath(int aInitialCapacity, double aCapacityIncrementFraction, double aMinOrdinate, double aMaxOrdinate)
      Creates a new TLcdAWTPath using the given initial capacity, capacity increment fraction, and ordinate values.
      Parameters:
      aInitialCapacity - the initial capacity.
      aCapacityIncrementFraction - the capacity increment fraction.
      aMinOrdinate - the min ordinate value.
      aMaxOrdinate - the max ordinate value.
  • Method Details

    • reset

      public void reset()
      Description copied from interface: ILcdAWTPath
      Resets the path. The path becomes empty, containing no subpaths and thus no points.
      Specified by:
      reset in interface ILcdAWTPath
    • moveTo

      public void moveTo(double aX, double aY)
      Description copied from interface: ILcdAWTPath
      Breaks the current line and moves to the AWT point (aX, aY).
      Specified by:
      moveTo in interface ILcdAWTPath
      Parameters:
      aX - an x coordinate in AWT coordinates
      aY - an y coordinate in AWT coordinates
    • lineTo

      public void lineTo(double aX, double aY)
      Description copied from interface: ILcdAWTPath
      Appends a line to the AWT point (aX, aY).
      Specified by:
      lineTo in interface ILcdAWTPath
      Parameters:
      aX - an x coordinate in AWT coordinates
      aY - an y coordinate in AWT coordinates
    • breakLine

      public void breakLine()
      Description copied from interface: ILcdAWTPath
      Appends a line break to the path. Subsequent points will define a new polyline. The points will continue to define the same current polygonal piece or hole, however.
      Specified by:
      breakLine in interface ILcdAWTPath
    • breakPolygon

      public void breakPolygon()
      Description copied from interface: ILcdAWTPath
      Appends a polygon break to the path. Subsequent points will define a detached polygonal piece or a hole of the current polygon.
      Specified by:
      breakPolygon in interface ILcdAWTPath
    • closePolygon

      public void closePolygon()
      Description copied from interface: ILcdAWTPath
      Closes the current polygon. Subsequent points will define a new polygon, possibly with its own set of detached polygonal pieces or holes.
      Specified by:
      closePolygon in interface ILcdAWTPath
    • getWindingRule

      public TLcdAWTPath.WindingRule getWindingRule()
      Returns how the interior of polygons is determined. This affects the polygonContains(double, double) and the fillPolygon(java.awt.Graphics, double[], double[], int) behavior.
      Returns:
      the winding rule to use
    • setWindingRule

      public void setWindingRule(TLcdAWTPath.WindingRule aWindingRule)
      Specifies how the interior of polygons is determined. This affects the polygonContains(double, double) and the fillPolygon(java.awt.Graphics, double[], double[], int) behavior.
      Parameters:
      aWindingRule - the winding rule to use
    • ensureCapacity

      public void ensureCapacity(int aMinimumCapacity)
      Ensures a given point capacity for the current subpath.
      Parameters:
      aMinimumCapacity - the minimum number of points this AWTPath should be able to store without reallocating memory.
    • trimToSize

      public void trimToSize()
      Trims this TLcdAWTPath so that it occupies as little memory as possible.
    • subPathCount

      public int subPathCount()
      Specified by:
      subPathCount in interface ILcdAWTPath
      Returns:
      the number of subpaths (separated by a line break).
    • subPathLength

      public int subPathLength(int aSubpathIndex)
      Description copied from interface: ILcdAWTPath
      Returns the length of the subpath at the given index.
      Specified by:
      subPathLength in interface ILcdAWTPath
      Parameters:
      aSubpathIndex - the given subpath index.
      Returns:
      the length of the subpath at the given index.
    • maxSubpathLength

      public int maxSubpathLength()
    • subPathBreaksLine

      public boolean subPathBreaksLine(int aSubpathIndex)
      Description copied from interface: ILcdAWTPath
      Returns whether the subpath at the given index represents a broken line.
      Specified by:
      subPathBreaksLine in interface ILcdAWTPath
      Parameters:
      aSubpathIndex - the given subpath index.
      Returns:
      whether the subpath at the given index represents a broken line.
    • subPathBreaksPolygon

      public boolean subPathBreaksPolygon(int aSubpathIndex)
      Description copied from interface: ILcdAWTPath
      Returns whether the subpath at the given index represents a broken part of a polygon.
      Specified by:
      subPathBreaksPolygon in interface ILcdAWTPath
      Parameters:
      aSubpathIndex - the given subpath index.
      Returns:
      whether the subpath at the given index represents a broken part of a polygon.
    • subPathClosesPolygon

      public boolean subPathClosesPolygon(int aSubpathIndex)
      Description copied from interface: ILcdAWTPath
      Returns whether the subpath at the given index represents a closing part of a polygon.
      Specified by:
      subPathClosesPolygon in interface ILcdAWTPath
      Parameters:
      aSubpathIndex - the given subpath index.
      Returns:
      whether the subpath at the given index represents a closing part of a polygon.
    • getX

      public int getX(int aSubpathIndex, int aPointIndex)
      Description copied from interface: ILcdAWTPath
      Returns the x coordinate of the subpath point at the given indices.
      Specified by:
      getX in interface ILcdAWTPath
      Parameters:
      aSubpathIndex - the given subpath index.
      aPointIndex - the given point index.
      Returns:
      the x coordinate of the subpath point at the given indices.
    • getY

      public int getY(int aSubpathIndex, int aPointIndex)
      Description copied from interface: ILcdAWTPath
      Returns the y coordinate of the subpath point at the given indices.
      Specified by:
      getY in interface ILcdAWTPath
      Parameters:
      aSubpathIndex - the given subpath index.
      aPointIndex - the given point index.
      Returns:
      the y coordinate of the subpath point at the given indices.
    • getXAsDouble

      public double getXAsDouble(int aSubpathIndex, int aPointIndex)
      Description copied from interface: ILcdAWTPath
      Returns the x coordinate of the subpath point at the given indices.
      Specified by:
      getXAsDouble in interface ILcdAWTPath
      Parameters:
      aSubpathIndex - the given subpath index.
      aPointIndex - the given point index.
      Returns:
      the x coordinate of the subpath point at the given indices.
    • getYAsDouble

      public double getYAsDouble(int aSubpathIndex, int aPointIndex)
      Description copied from interface: ILcdAWTPath
      Returns the y coordinate of the subpath point at the given indices.
      Specified by:
      getYAsDouble in interface ILcdAWTPath
      Parameters:
      aSubpathIndex - the given subpath index.
      aPointIndex - the given point index.
      Returns:
      the y coordinate of the subpath point at the given indices.
    • drawPolyline

      public void drawPolyline(Graphics aGraphics)
      Description copied from interface: ILcdAWTPath
      Draws the outlines of the path as a polyline.
      Specified by:
      drawPolyline in interface ILcdAWTPath
      Parameters:
      aGraphics - the graphics on which to draw the path as a polyline.
    • drawPolygon

      public void drawPolygon(Graphics aGraphics)
      Description copied from interface: ILcdAWTPath
      Draws the outlines of the path as a polygon.
      Specified by:
      drawPolygon in interface ILcdAWTPath
      Parameters:
      aGraphics - the graphics on which to draw the path as a polygon.
    • fillPolygon

      public void fillPolygon(Graphics aGraphics)
      Description copied from interface: ILcdAWTPath
      Fills the path as a complex polygon that consists of one or more polygons.
      Specified by:
      fillPolygon in interface ILcdAWTPath
      Parameters:
      aGraphics - the graphics on which to fill the path as a complex polygon.
    • isPolylineTouched

      public boolean isPolylineTouched(double aX, double aY, int aSensitivity)
      Description copied from interface: ILcdAWTPath
      Checks whether the given point touches the path.
      Specified by:
      isPolylineTouched in interface ILcdAWTPath
      Parameters:
      aX - the x coordinate of the given point in AWT coordinates.
      aY - the y coordinate of the given point in AWT coordinates.
      aSensitivity - the sensitivity in pixels.
      Returns:
      whether the given point touches the path.
    • polygonContains

      public boolean polygonContains(double aX, double aY)
      Description copied from interface: ILcdAWTPath
      Checks whether the given point is contained by the polygon represented by this ILcdAWTPath.
      Specified by:
      polygonContains in interface ILcdAWTPath
      Parameters:
      aX - the x coordinate of the given point in AWT coordinates.
      aY - the y coordinate of the given point in AWT coordinates.
      Returns:
      whether the given point is contained by the polygon represented by this ILcdAWTPath.
    • calculateAWTBoundsSFCT

      public void calculateAWTBoundsSFCT(Rectangle aBoundsSFCT) throws TLcdNoBoundsException
      Description copied from interface: ILcdAWTPath
      Returns the world bounds of the path in the side effect parameter aBoundsSFCT.
      Specified by:
      calculateAWTBoundsSFCT in interface ILcdAWTPath
      Parameters:
      aBoundsSFCT - the Rectangle in which to store the bounds of the path.
      Throws:
      TLcdNoBoundsException - if no bounds are available