Class TLcdGeneralPath
- All Implemented Interfaces:
ILcdGeneralPath
ILcdGeneralPath
.
Like a Vector, each TLcdGeneralPath tries to optimize storage management by maintaining a capacity and a capacityIncrementFraction, in this case for storing all of its points. 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.
-
Constructor Summary
ConstructorDescriptionTLcdGeneralPath
(int aInitialCapacity) TLcdGeneralPath
(int aInitialCapacity, double aCapacityIncrementFraction) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Appends a line break to the path.void
Appends a polygon break to the path.void
calculateWorldBoundsSFCT
(ILcd2DEditableBounds aBoundsSFCT) Returns a bounding box of thisILcdGeneralPath
(in world coordinates) in the side effect parameteraBoundsSFCT
.void
Closes the current polygon.void
ensureCapacity
(int aMinimumCapacity) Ensures a given point capacity for this TLcdGeneralPath.double
getX
(int aSubpathIndex, int aPointIndex) double
getY
(int aSubpathIndex, int aPointIndex) void
lineTo
(double aX, double aY) Appends a line to the world point(aX, aY)
.int
void
moveTo
(double aX, double aY) Breaks the current line and moves to the world point(aX, aY)
.boolean
polygonContains
(double aX, double aY) Checks whether the given point is contained by the polygon represented by thisILcdGeneralPath
.void
reset()
Resets the path.boolean
subPathBreaksLine
(int aSubpathIndex) boolean
subPathBreaksPolygon
(int aSubpathIndex) boolean
subPathClosesPolygon
(int aSubpathIndex) int
int
subPathLength
(int aSubpathIndex) void
Trims this TLcdAWTPath so that it occupies as little memory as possible.
-
Constructor Details
-
TLcdGeneralPath
public TLcdGeneralPath() -
TLcdGeneralPath
public TLcdGeneralPath(int aInitialCapacity) -
TLcdGeneralPath
public TLcdGeneralPath(int aInitialCapacity, double aCapacityIncrementFraction)
-
-
Method Details
-
reset
public void reset()Description copied from interface:ILcdGeneralPath
Resets the path. The path becomes empty, containing no subpaths and thus no points.- Specified by:
reset
in interfaceILcdGeneralPath
-
moveTo
public void moveTo(double aX, double aY) Description copied from interface:ILcdGeneralPath
Breaks the current line and moves to the world point(aX, aY)
.- Specified by:
moveTo
in interfaceILcdGeneralPath
-
lineTo
public void lineTo(double aX, double aY) Description copied from interface:ILcdGeneralPath
Appends a line to the world point(aX, aY)
.- Specified by:
lineTo
in interfaceILcdGeneralPath
-
breakLine
public void breakLine()Description copied from interface:ILcdGeneralPath
Appends a line break to the path. Subsequent points will define a new polyline. The points will continue to define the same current polygon, however. For example, when a polygon in a model is represented by more than 1 polygon in world coordinates. This is possible in some projections where the polygon is at the edge of the projection and wraps around to the other edge.- Specified by:
breakLine
in interfaceILcdGeneralPath
-
breakPolygon
public void breakPolygon()Description copied from interface:ILcdGeneralPath
Appends a polygon break to the path. Subsequent points will define a detached polygonal piece of the current polygon.- Specified by:
breakPolygon
in interfaceILcdGeneralPath
-
closePolygon
public void closePolygon()Description copied from interface:ILcdGeneralPath
Closes the current polygon. Subsequent points will define a new polygon or hole.- Specified by:
closePolygon
in interfaceILcdGeneralPath
-
ensureCapacity
public void ensureCapacity(int aMinimumCapacity) Ensures a given point capacity for this TLcdGeneralPath.- Parameters:
aMinimumCapacity
- the minimum number of points this TLcdGeneralPath 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 interfaceILcdGeneralPath
- Returns:
- the number of subpaths.
-
subPathLength
public int subPathLength(int aSubpathIndex) - Specified by:
subPathLength
in interfaceILcdGeneralPath
- Returns:
- the length of the subpath at the given index.
-
subPathBreaksLine
public boolean subPathBreaksLine(int aSubpathIndex) - Specified by:
subPathBreaksLine
in interfaceILcdGeneralPath
- Returns:
- whether the subpath at the given index represents a broken line.
-
subPathBreaksPolygon
public boolean subPathBreaksPolygon(int aSubpathIndex) - Specified by:
subPathBreaksPolygon
in interfaceILcdGeneralPath
- Returns:
- whether the subpath at the given index represents a broken part of a polygon.
-
subPathClosesPolygon
public boolean subPathClosesPolygon(int aSubpathIndex) - Specified by:
subPathClosesPolygon
in interfaceILcdGeneralPath
- Returns:
- whether the subpath at the given index represents a closing part of a polygon.
-
maxSubpathLength
public int maxSubpathLength() -
getX
public double getX(int aSubpathIndex, int aPointIndex) - Specified by:
getX
in interfaceILcdGeneralPath
- Returns:
- the x coordinate of the subpath point at the given indices.
-
getY
public double getY(int aSubpathIndex, int aPointIndex) - Specified by:
getY
in interfaceILcdGeneralPath
- Returns:
- the y coordinate of the subpath point at the given indices.
-
calculateWorldBoundsSFCT
Description copied from interface:ILcdGeneralPath
Returns a bounding box of thisILcdGeneralPath
(in world coordinates) in the side effect parameteraBoundsSFCT
.- Specified by:
calculateWorldBoundsSFCT
in interfaceILcdGeneralPath
- Throws:
TLcdNoBoundsException
- if no bounds are available
-
polygonContains
public boolean polygonContains(double aX, double aY) Description copied from interface:ILcdGeneralPath
Checks whether the given point is contained by the polygon represented by thisILcdGeneralPath
.- Specified by:
polygonContains
in interfaceILcdGeneralPath
-