Class TLcdAWTPath
- All Implemented Interfaces:
ILcdAWTPath
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
Modifier and TypeClassDescriptionstatic 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
ConstructorDescriptionCreates a newTLcdAWTPath
using the default initial capacity of 100 and the default capacity increment fraction of1.0
.TLcdAWTPath
(int aInitialCapacity) Creates a newTLcdAWTPath
using the given initial capacity and the default capacity increment fraction of1.0
.TLcdAWTPath
(int aInitialCapacity, double aCapacityIncrementFraction) Creates a newTLcdAWTPath
using the given initial capacity and capacity increment fraction and default ordinate values.TLcdAWTPath
(int aInitialCapacity, double aCapacityIncrementFraction, double aMinOrdinate, double aMaxOrdinate) Creates a newTLcdAWTPath
using the given initial capacity, capacity increment fraction, and ordinate values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends a line break to the path.void
Appends a polygon break to the path.void
calculateAWTBoundsSFCT
(Rectangle aBoundsSFCT) Returns the world bounds of the path in the side effect parameteraBoundsSFCT
.void
Closes the current polygon.void
drawPolygon
(Graphics aGraphics) Draws the outlines of the path as a polygon.void
drawPolyline
(Graphics aGraphics) 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 thisILcdAWTPath
.void
reset()
Resets the path.void
setWindingRule
(TLcdAWTPath.WindingRule aWindingRule) 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.
-
Constructor Details
-
TLcdAWTPath
public TLcdAWTPath()Creates a newTLcdAWTPath
using the default initial capacity of 100 and the default capacity increment fraction of1.0
. -
TLcdAWTPath
public TLcdAWTPath(int aInitialCapacity) Creates a newTLcdAWTPath
using the given initial capacity and the default capacity increment fraction of1.0
.- Parameters:
aInitialCapacity
- the initial capacity.
-
TLcdAWTPath
public TLcdAWTPath(int aInitialCapacity, double aCapacityIncrementFraction) Creates a newTLcdAWTPath
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 newTLcdAWTPath
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 interfaceILcdAWTPath
-
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 interfaceILcdAWTPath
- Parameters:
aX
- an x coordinate in AWT coordinatesaY
- 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 interfaceILcdAWTPath
- Parameters:
aX
- an x coordinate in AWT coordinatesaY
- 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 interfaceILcdAWTPath
-
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 interfaceILcdAWTPath
-
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 interfaceILcdAWTPath
-
getWindingRule
Returns how the interior of polygons is determined. This affects thepolygonContains(double, double)
and thefillPolygon(java.awt.Graphics, double[], double[], int)
behavior.- Returns:
- the winding rule to use
-
setWindingRule
Specifies how the interior of polygons is determined. This affects thepolygonContains(double, double)
and thefillPolygon(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 interfaceILcdAWTPath
- 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 interfaceILcdAWTPath
- 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 interfaceILcdAWTPath
- 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 interfaceILcdAWTPath
- 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 interfaceILcdAWTPath
- 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 interfaceILcdAWTPath
- 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 interfaceILcdAWTPath
- 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 interfaceILcdAWTPath
- 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 interfaceILcdAWTPath
- Parameters:
aSubpathIndex
- the given subpath index.aPointIndex
- the given point index.- Returns:
- the y coordinate of the subpath point at the given indices.
-
drawPolyline
Description copied from interface:ILcdAWTPath
Draws the outlines of the path as a polyline.- Specified by:
drawPolyline
in interfaceILcdAWTPath
- Parameters:
aGraphics
- the graphics on which to draw the path as a polyline.
-
drawPolygon
Description copied from interface:ILcdAWTPath
Draws the outlines of the path as a polygon.- Specified by:
drawPolygon
in interfaceILcdAWTPath
- Parameters:
aGraphics
- the graphics on which to draw the path as a polygon.
-
fillPolygon
Description copied from interface:ILcdAWTPath
Fills the path as a complex polygon that consists of one or more polygons.- Specified by:
fillPolygon
in interfaceILcdAWTPath
- 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 interfaceILcdAWTPath
- 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 thisILcdAWTPath
.- Specified by:
polygonContains
in interfaceILcdAWTPath
- 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
Description copied from interface:ILcdAWTPath
Returns the world bounds of the path in the side effect parameteraBoundsSFCT
.- Specified by:
calculateAWTBoundsSFCT
in interfaceILcdAWTPath
- Parameters:
aBoundsSFCT
- theRectangle
in which to store the bounds of the path.- Throws:
TLcdNoBoundsException
- if no bounds are available
-