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
Nested ClassesModifier and TypeClassDescriptionstatic enumSpecifies 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
ConstructorsConstructorDescriptionCreates a newTLcdAWTPathusing the default initial capacity of 100 and the default capacity increment fraction of1.0.TLcdAWTPath(int aInitialCapacity) Creates a newTLcdAWTPathusing the given initial capacity and the default capacity increment fraction of1.0.TLcdAWTPath(int aInitialCapacity, double aCapacityIncrementFraction) Creates a newTLcdAWTPathusing the given initial capacity and capacity increment fraction and default ordinate values.TLcdAWTPath(int aInitialCapacity, double aCapacityIncrementFraction, double aMinOrdinate, double aMaxOrdinate) Creates a newTLcdAWTPathusing the given initial capacity, capacity increment fraction, and ordinate values. -
Method Summary
Modifier and TypeMethodDescriptionvoidAppends a line break to the path.voidAppends a polygon break to the path.voidcalculateAWTBoundsSFCT(Rectangle aBoundsSFCT) Returns the world bounds of the path in the side effect parameteraBoundsSFCT.voidCloses the current polygon.voiddrawPolygon(Graphics aGraphics) Draws the outlines of the path as a polygon.voiddrawPolyline(Graphics aGraphics) Draws the outlines of the path as a polyline.voidensureCapacity(int aMinimumCapacity) Ensures a given point capacity for the current subpath.voidfillPolygon(Graphics aGraphics) Fills the path as a complex polygon that consists of one or more polygons.Returns how the interior of polygons is determined.intgetX(int aSubpathIndex, int aPointIndex) Returns the x coordinate of the subpath point at the given indices.doublegetXAsDouble(int aSubpathIndex, int aPointIndex) Returns the x coordinate of the subpath point at the given indices.intgetY(int aSubpathIndex, int aPointIndex) Returns the y coordinate of the subpath point at the given indices.doublegetYAsDouble(int aSubpathIndex, int aPointIndex) Returns the y coordinate of the subpath point at the given indices.booleanisPolylineTouched(double aX, double aY, int aSensitivity) Checks whether the given point touches the path.voidlineTo(double aX, double aY) Appends a line to the AWT point(aX, aY).intvoidmoveTo(double aX, double aY) Breaks the current line and moves to the AWT point(aX, aY).booleanpolygonContains(double aX, double aY) Checks whether the given point is contained by the polygon represented by thisILcdAWTPath.voidreset()Resets the path.voidsetWindingRule(TLcdAWTPath.WindingRule aWindingRule) Specifies how the interior of polygons is determined.booleansubPathBreaksLine(int aSubpathIndex) Returns whether the subpath at the given index represents a broken line.booleansubPathBreaksPolygon(int aSubpathIndex) Returns whether the subpath at the given index represents a broken part of a polygon.booleansubPathClosesPolygon(int aSubpathIndex) Returns whether the subpath at the given index represents a closing part of a polygon.intintsubPathLength(int aSubpathIndex) Returns the length of the subpath at the given index.voidTrims this TLcdAWTPath so that it occupies as little memory as possible.
-
Constructor Details
-
TLcdAWTPath
public TLcdAWTPath()Creates a newTLcdAWTPathusing the default initial capacity of 100 and the default capacity increment fraction of1.0. -
TLcdAWTPath
public TLcdAWTPath(int aInitialCapacity) Creates a newTLcdAWTPathusing 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 newTLcdAWTPathusing 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 newTLcdAWTPathusing 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:ILcdAWTPathResets the path. The path becomes empty, containing no subpaths and thus no points.- Specified by:
resetin interfaceILcdAWTPath
-
moveTo
public void moveTo(double aX, double aY) Description copied from interface:ILcdAWTPathBreaks the current line and moves to the AWT point(aX, aY).- Specified by:
moveToin 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:ILcdAWTPathAppends a line to the AWT point(aX, aY).- Specified by:
lineToin interfaceILcdAWTPath- Parameters:
aX- an x coordinate in AWT coordinatesaY- an y coordinate in AWT coordinates
-
breakLine
public void breakLine()Description copied from interface:ILcdAWTPathAppends 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:
breakLinein interfaceILcdAWTPath
-
breakPolygon
public void breakPolygon()Description copied from interface:ILcdAWTPathAppends a polygon break to the path. Subsequent points will define a detached polygonal piece or a hole of the current polygon.- Specified by:
breakPolygonin interfaceILcdAWTPath
-
closePolygon
public void closePolygon()Description copied from interface:ILcdAWTPathCloses the current polygon. Subsequent points will define a new polygon, possibly with its own set of detached polygonal pieces or holes.- Specified by:
closePolygonin 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:
subPathCountin interfaceILcdAWTPath- Returns:
- the number of subpaths (separated by a line break).
-
subPathLength
public int subPathLength(int aSubpathIndex) Description copied from interface:ILcdAWTPathReturns the length of the subpath at the given index.- Specified by:
subPathLengthin 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:ILcdAWTPathReturns whether the subpath at the given index represents a broken line.- Specified by:
subPathBreaksLinein 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:ILcdAWTPathReturns whether the subpath at the given index represents a broken part of a polygon.- Specified by:
subPathBreaksPolygonin 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:ILcdAWTPathReturns whether the subpath at the given index represents a closing part of a polygon.- Specified by:
subPathClosesPolygonin 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:ILcdAWTPathReturns the x coordinate of the subpath point at the given indices.- Specified by:
getXin 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:ILcdAWTPathReturns the y coordinate of the subpath point at the given indices.- Specified by:
getYin 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:ILcdAWTPathReturns the x coordinate of the subpath point at the given indices.- Specified by:
getXAsDoublein 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:ILcdAWTPathReturns the y coordinate of the subpath point at the given indices.- Specified by:
getYAsDoublein 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:ILcdAWTPathDraws the outlines of the path as a polyline.- Specified by:
drawPolylinein interfaceILcdAWTPath- Parameters:
aGraphics- the graphics on which to draw the path as a polyline.
-
drawPolygon
Description copied from interface:ILcdAWTPathDraws the outlines of the path as a polygon.- Specified by:
drawPolygonin interfaceILcdAWTPath- Parameters:
aGraphics- the graphics on which to draw the path as a polygon.
-
fillPolygon
Description copied from interface:ILcdAWTPathFills the path as a complex polygon that consists of one or more polygons.- Specified by:
fillPolygonin 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:ILcdAWTPathChecks whether the given point touches the path.- Specified by:
isPolylineTouchedin 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:ILcdAWTPathChecks whether the given point is contained by the polygon represented by thisILcdAWTPath.- Specified by:
polygonContainsin 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:ILcdAWTPathReturns the world bounds of the path in the side effect parameteraBoundsSFCT.- Specified by:
calculateAWTBoundsSFCTin interfaceILcdAWTPath- Parameters:
aBoundsSFCT- theRectanglein which to store the bounds of the path.- Throws:
TLcdNoBoundsException- if no bounds are available
-