Path

Instances of this class represent paths through the two-dimensional coordinate system. Paths do not have to be continuous, and can be described using lines, rectangles, arcs, cubic or quadratic bezier curves, glyphs, or other paths. <p> Application code must explicitly invoke the <code>Path.dispose()</code> method to release the operating system resources managed by each instance when those instances are no longer required. </p> <p> This class requires the operating system's advanced graphics subsystem which may not be available on some platforms. </p>

@see <a href="http://www.eclipse.org/swt/snippets/#path">Path, Pattern snippets</a> @see <a href="http://www.eclipse.org/swt/examples.php">SWT Example: GraphicsExample</a> @see <a href="http://www.eclipse.org/swt/">Sample code and further information</a>

@since 3.1

Constructors

this
this(Device device)

Constructs a new empty Path. <p> This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms. </p>

this
this(Device device, Path path, float flatness)

Constructs a new Path that is a copy of <code>path</code>. If <code>flatness</code> 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. <p> This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms. </p>

this
this(Device device, PathData data)

Constructs a new Path with the specifed PathData. <p> This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms. </p>

Members

Functions

addArc
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. <p> The resulting arc begins at <code>startAngle</code> and extends for <code>arcAngle</code> 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. </p><p> The center of the arc is the center of the rectangle whose origin is (<code>x</code>, <code>y</code>) and whose size is specified by the <code>width</code> and <code>height</code> arguments. </p><p> The resulting arc covers an area <code>width + 1</code> pixels wide by <code>height + 1</code> pixels tall. </p>

addPath
void addPath(Path path)

Adds to the receiver the path described by the parameter.

addRectangle
void addRectangle(float x, float y, float width, float height)

Adds to the receiver the rectangle specified by x, y, width and height.

addString
void addString(String str, 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).

close
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.

contains
bool contains(float x, float y, GC gc, bool outline)

Returns <code>true</code> if the specified point is contained by the receiver and false otherwise. <p> If outline is <code>true</code>, the point (x, y) checked for containment in the receiver's outline. If outline is <code>false</code>, the point is checked to see if it is contained within the bounds of the (closed) area covered by the receiver.

cubicTo
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.

getBounds
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).

getCurrentPoint
void getCurrentPoint(float[] point)

Replaces the first two elements in the parameter with values that describe the current point of the path.

getPathData
PathData getPathData()

Returns a device independent representation of the receiver.

isDisposed
bool isDisposed()

Returns <code>true</code> if the Path has been disposed, and <code>false</code> otherwise. <p> This method gets the dispose state for the Path. When a Path has been disposed, it is an error to invoke any other method using the Path.

lineTo
void lineTo(float x, float y)

Adds to the receiver a line from the current point to the point specified by (x, y).

moveTo
void moveTo(float x, float y)

Sets the current point of the receiver to the point specified by (x, y). Note that this starts a new sub path.

quadTo
void quadTo(float cx, float cy, float x, float y)

Adds to the receiver a quadratic curve based on the parameters.

toString
String toString()

Returns a string containing a concise, human-readable description of the receiver.

Variables

handle
org.eclipse.swt.internal.gtk.OS.cairo_t* handle;

the OS resource for the Path (Warning: This field is platform dependent) <p> <b>IMPORTANT:</b> This field is <em>not</em> 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. </p>

Inherited Members

From Resource

device
Device device;

the device where this resource was created

dispose
void dispose()

Disposes of the operating system resources associated with this resource. Applications must dispose of all resources which they allocate.

getDevice
Device getDevice()

Returns the <code>Device</code> where this resource was created.

isDisposed
bool isDisposed()

Returns <code>true</code> if the resource has been disposed, and <code>false</code> otherwise. <p> This method gets the dispose state for the resource. When a resource has been disposed, it is an error to invoke any other method using the resource.

Meta