public class TLcdAWTPath extends Object implements 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.Modifier and Type | Class and Description |
---|---|
static class |
TLcdAWTPath.WindingRule
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 and Description |
---|
TLcdAWTPath()
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. |
Modifier and Type | Method and Description |
---|---|
void |
breakLine()
Appends a line break to the path.
|
void |
breakPolygon()
Appends a polygon break to the path.
|
void |
calculateAWTBoundsSFCT(Rectangle aBoundsSFCT)
Returns the world bounds of the path in the side effect parameter
aBoundsSFCT . |
void |
closePolygon()
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.
|
TLcdAWTPath.WindingRule |
getWindingRule()
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 |
maxSubpathLength() |
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 |
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 |
subPathCount() |
int |
subPathLength(int aSubpathIndex)
Returns the length of the subpath at the given index.
|
void |
trimToSize()
Trims this TLcdAWTPath so that it occupies as little memory as possible.
|
public TLcdAWTPath()
TLcdAWTPath
using the default initial capacity of 100 and
the default capacity increment fraction of 1.0
.public TLcdAWTPath(int aInitialCapacity)
TLcdAWTPath
using the given initial capacity and the default
capacity increment fraction of 1.0
.aInitialCapacity
- the initial capacity.public TLcdAWTPath(int aInitialCapacity, double aCapacityIncrementFraction)
TLcdAWTPath
using the given initial capacity and capacity increment
fraction and default ordinate values.aInitialCapacity
- the initial capacity.aCapacityIncrementFraction
- the capacity increment fraction.public TLcdAWTPath(int aInitialCapacity, double aCapacityIncrementFraction, double aMinOrdinate, double aMaxOrdinate)
TLcdAWTPath
using the given initial capacity, capacity increment
fraction, and ordinate values.aInitialCapacity
- the initial capacity.aCapacityIncrementFraction
- the capacity increment fraction.aMinOrdinate
- the min ordinate value.aMaxOrdinate
- the max ordinate value.public void reset()
ILcdAWTPath
reset
in interface ILcdAWTPath
public void moveTo(double aX, double aY)
ILcdAWTPath
(aX, aY)
.moveTo
in interface ILcdAWTPath
aX
- an x coordinate in AWT coordinatesaY
- an y coordinate in AWT coordinatespublic void lineTo(double aX, double aY)
ILcdAWTPath
(aX, aY)
.lineTo
in interface ILcdAWTPath
aX
- an x coordinate in AWT coordinatesaY
- an y coordinate in AWT coordinatespublic void breakLine()
ILcdAWTPath
breakLine
in interface ILcdAWTPath
public void breakPolygon()
ILcdAWTPath
breakPolygon
in interface ILcdAWTPath
public void closePolygon()
ILcdAWTPath
closePolygon
in interface ILcdAWTPath
public TLcdAWTPath.WindingRule getWindingRule()
polygonContains(double, double)
and the fillPolygon(java.awt.Graphics, double[], double[], int)
behavior.public void setWindingRule(TLcdAWTPath.WindingRule aWindingRule)
polygonContains(double, double)
and the fillPolygon(java.awt.Graphics, double[], double[], int)
behavior.aWindingRule
- the winding rule to usepublic void ensureCapacity(int aMinimumCapacity)
aMinimumCapacity
- the minimum number of points this AWTPath should
be able to store without reallocating memory.public void trimToSize()
public int subPathCount()
subPathCount
in interface ILcdAWTPath
public int subPathLength(int aSubpathIndex)
ILcdAWTPath
subPathLength
in interface ILcdAWTPath
aSubpathIndex
- the given subpath index.public int maxSubpathLength()
public boolean subPathBreaksLine(int aSubpathIndex)
ILcdAWTPath
subPathBreaksLine
in interface ILcdAWTPath
aSubpathIndex
- the given subpath index.public boolean subPathBreaksPolygon(int aSubpathIndex)
ILcdAWTPath
subPathBreaksPolygon
in interface ILcdAWTPath
aSubpathIndex
- the given subpath index.public boolean subPathClosesPolygon(int aSubpathIndex)
ILcdAWTPath
subPathClosesPolygon
in interface ILcdAWTPath
aSubpathIndex
- the given subpath index.public int getX(int aSubpathIndex, int aPointIndex)
ILcdAWTPath
getX
in interface ILcdAWTPath
aSubpathIndex
- the given subpath index.aPointIndex
- the given point index.public int getY(int aSubpathIndex, int aPointIndex)
ILcdAWTPath
getY
in interface ILcdAWTPath
aSubpathIndex
- the given subpath index.aPointIndex
- the given point index.public double getXAsDouble(int aSubpathIndex, int aPointIndex)
ILcdAWTPath
getXAsDouble
in interface ILcdAWTPath
aSubpathIndex
- the given subpath index.aPointIndex
- the given point index.public double getYAsDouble(int aSubpathIndex, int aPointIndex)
ILcdAWTPath
getYAsDouble
in interface ILcdAWTPath
aSubpathIndex
- the given subpath index.aPointIndex
- the given point index.public void drawPolyline(Graphics aGraphics)
ILcdAWTPath
drawPolyline
in interface ILcdAWTPath
aGraphics
- the graphics on which to draw the path as a polyline.public void drawPolygon(Graphics aGraphics)
ILcdAWTPath
drawPolygon
in interface ILcdAWTPath
aGraphics
- the graphics on which to draw the path as a polygon.public void fillPolygon(Graphics aGraphics)
ILcdAWTPath
fillPolygon
in interface ILcdAWTPath
aGraphics
- the graphics on which to fill the path as a complex polygon.public boolean isPolylineTouched(double aX, double aY, int aSensitivity)
ILcdAWTPath
isPolylineTouched
in interface ILcdAWTPath
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.public boolean polygonContains(double aX, double aY)
ILcdAWTPath
ILcdAWTPath
.polygonContains
in interface ILcdAWTPath
aX
- the x coordinate of the given point in AWT coordinates.aY
- the y coordinate of the given point in AWT coordinates.ILcdAWTPath
.public void calculateAWTBoundsSFCT(Rectangle aBoundsSFCT) throws TLcdNoBoundsException
ILcdAWTPath
aBoundsSFCT
.calculateAWTBoundsSFCT
in interface ILcdAWTPath
aBoundsSFCT
- the Rectangle
in which to store the bounds of the path.TLcdNoBoundsException
- if no bounds are available