public class Path extends Resource
Application code must explicitly invoke the Path.dispose()
method to release the operating system resources managed by each instance
when those instances are no longer required.
This class requires the operating system's advanced graphics subsystem which may not be available on some platforms.
Modifier and Type | Field and Description |
---|---|
(package private) PointF |
currentPoint |
int |
handle
the OS resource for the Path
(Warning: This field is platform dependent)
IMPORTANT: This field is not part of the SWT
public API.
|
(package private) PointF |
startPoint |
Constructor and Description |
---|
Path(Device device)
Constructs a new empty Path.
|
Path(Device device,
PathData data)
Constructs a new Path with the specifed PathData.
|
Path(Device device,
Path path,
float flatness)
Constructs a new Path that is a copy of
path . |
Modifier and Type | Method and Description |
---|---|
void |
addArc(float x,
float y,
float width,
float height,
float startAngle,
float arcAngle)
Adds to the receiver a circular or elliptical arc that lies within
the specified rectangular area.
|
void |
addPath(Path path)
Adds to the receiver the path described by the parameter.
|
void |
addRectangle(float x,
float y,
float width,
float height)
Adds to the receiver the rectangle specified by x, y, width and height.
|
void |
addString(java.lang.String string,
float x,
float y,
Font font)
Adds to the receiver the pattern of glyphs generated by drawing
the given string using the given font starting at the point (x, y).
|
void |
close()
Closes the current sub path by adding to the receiver a line
from the current point of the path back to the starting point
of the sub path.
|
boolean |
contains(float x,
float y,
GC gc,
boolean outline)
Returns
true if the specified point is contained by
the receiver and false otherwise. |
void |
cubicTo(float cx1,
float cy1,
float cx2,
float cy2,
float x,
float y)
Adds to the receiver a cubic bezier curve based on the parameters.
|
(package private) void |
destroy() |
void |
getBounds(float[] bounds)
Replaces the first four elements in the parameter with values that
describe the smallest rectangle that will completely contain the
receiver (i.e. the bounding box).
|
void |
getCurrentPoint(float[] point)
Replaces the first two elements in the parameter with values that
describe the current point of the path.
|
PathData |
getPathData()
Returns a device independent representation of the receiver.
|
(package private) void |
init(PathData data) |
boolean |
isDisposed()
Returns
true if the Path has been disposed,
and false otherwise. |
void |
lineTo(float x,
float y)
Adds to the receiver a line from the current point to
the point specified by (x, y).
|
void |
moveTo(float x,
float y)
Sets the current point of the receiver to the point
specified by (x, y).
|
void |
quadTo(float cx,
float cy,
float x,
float y)
Adds to the receiver a quadratic curve based on the parameters.
|
java.lang.String |
toString()
Returns a string containing a concise, human-readable
description of the receiver.
|
public int handle
IMPORTANT: This field is not part of the SWT public API. It is marked public only so that it can be shared within the packages provided by SWT. It is not available on all platforms and should never be accessed from application code.
PointF currentPoint
PointF startPoint
public Path(Device device)
This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
device
- the device on which to allocate the pathjava.lang.IllegalArgumentException
- SWTException
- SWTError
- Resource.dispose()
public Path(Device device, Path path, float flatness)
path
. If
flatness
is less than or equal to zero, an unflatten
copy of the path is created. Otherwise, it specifies the maximum
error between the path and its flatten copy. Smaller numbers give
better approximation.
This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
device
- the device on which to allocate the pathpath
- the path to make a copyflatness
- the flatness valuejava.lang.IllegalArgumentException
- SWTException
- SWTError
- Resource.dispose()
public Path(Device device, PathData data)
This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.
device
- the device on which to allocate the pathdata
- the data for the pathjava.lang.IllegalArgumentException
- SWTException
- SWTError
- Resource.dispose()
public void addArc(float x, float y, float width, float height, float startAngle, float arcAngle)
The resulting arc begins at startAngle
and extends
for arcAngle
degrees.
Angles are interpreted such that 0 degrees is at the 3 o'clock
position. A positive value indicates a counter-clockwise rotation
while a negative value indicates a clockwise rotation.
The center of the arc is the center of the rectangle whose origin
is (x
, y
) and whose size is specified by the
width
and height
arguments.
The resulting arc covers an area width + 1
pixels wide
by height + 1
pixels tall.
x
- the x coordinate of the upper-left corner of the arcy
- the y coordinate of the upper-left corner of the arcwidth
- the width of the archeight
- the height of the arcstartAngle
- the beginning anglearcAngle
- the angular extent of the arc, relative to the start angleSWTException
- public void addPath(Path path)
path
- the path to add to the receiverjava.lang.IllegalArgumentException
- SWTException
- public void addRectangle(float x, float y, float width, float height)
x
- the x coordinate of the rectangle to addy
- the y coordinate of the rectangle to addwidth
- the width of the rectangle to addheight
- the height of the rectangle to addSWTException
- public void addString(java.lang.String string, float x, float y, Font font)
string
- the text to usex
- the x coordinate of the starting pointy
- the y coordinate of the starting pointfont
- the font to usejava.lang.IllegalArgumentException
- SWTException
- public void close()
SWTException
- public boolean contains(float x, float y, GC gc, boolean outline)
true
if the specified point is contained by
the receiver and false otherwise.
If outline is true
, the point (x, y) checked for containment in
the receiver's outline. If outline is false
, the point is
checked to see if it is contained within the bounds of the (closed) area
covered by the receiver.
x
- the x coordinate of the point to test for containmenty
- the y coordinate of the point to test for containmentgc
- the GC to use when testing for containmentoutline
- controls whether to check the outline or contained area of the pathtrue
if the path contains the point and false
otherwisejava.lang.IllegalArgumentException
- SWTException
- public void cubicTo(float cx1, float cy1, float cx2, float cy2, float x, float y)
cx1
- the x coordinate of the first control point of the splinecy1
- the y coordinate of the first control of the splinecx2
- the x coordinate of the second control of the splinecy2
- the y coordinate of the second control of the splinex
- the x coordinate of the end point of the spliney
- the y coordinate of the end point of the splineSWTException
- public void getBounds(float[] bounds)
bounds
- the array to hold the resultjava.lang.IllegalArgumentException
- SWTException
- public void getCurrentPoint(float[] point)
point
- the array to hold the resultjava.lang.IllegalArgumentException
- SWTException
- public PathData getPathData()
SWTException
- PathData
public void lineTo(float x, float y)
x
- the x coordinate of the end of the line to addy
- the y coordinate of the end of the line to addSWTException
- void init(PathData data)
public boolean isDisposed()
true
if the Path has been disposed,
and false
otherwise.
This method gets the dispose state for the Path.
When a Path has been disposed, it is an error to
invoke any other method (except Resource.dispose()
) using the Path.
isDisposed
in class Resource
true
when the Path is disposed, and false
otherwisepublic void moveTo(float x, float y)
x
- the x coordinate of the new end pointy
- the y coordinate of the new end pointSWTException
- public void quadTo(float cx, float cy, float x, float y)
cx
- the x coordinate of the control point of the splinecy
- the y coordinate of the control point of the splinex
- the x coordinate of the end point of the spliney
- the y coordinate of the end point of the splineSWTException
- public java.lang.String toString()
toString
in class java.lang.Object