Top Description Fields Constructors Methods
org.eclipse.swt.graphics

public Class Path

extends Resource
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.cairo.*

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.

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.

Since
3.1
See Also
Path, Pattern snippets, SWT Example: GraphicsExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv boolean
public long
handle

the OS resource for the Path (Warning: This field is platform dependent)

Important Note

This field is not part of the SWT public API.

pack-priv boolean
Inherited from org.eclipse.swt.graphics.Resource:
device

Constructor Summary

AccessConstructor and Description
public
Path(Device
the device on which to allocate the path
device
)

Constructs a new empty Path.

public
Path(Device
the device on which to allocate the path
device
,
Path
the path to make a copy
path
,
float
the flatness value
flatness
)

Constructs a new Path that is a copy of path.

public
Path(Device
the device on which to allocate the path
device
,
PathData
the data for the path
data
)

Constructs a new Path with the specified PathData.

Method Summary

Modifier and TypeMethod and Description
public void
addArc(float
the x coordinate of the upper-left corner of the arc
x
,
float
the y coordinate of the upper-left corner of the arc
y
,
float
the width of the arc
width
,
float
the height of the arc
height
,
float
the beginning angle
startAngle
,
float
the angular extent of the arc, relative to the start angle
arcAngle
)

Adds to the receiver a circular or elliptical arc that lies within the specified rectangular area.

pack-priv void
addArcInPixels(float x, float y, float width, float height, float startAngle, float arcAngle)

public void
addPath(Path
the path to add to the receiver
path
)

Adds to the receiver the path described by the parameter.

public void
addRectangle(float
the x coordinate of the rectangle to add
x
,
float
the y coordinate of the rectangle to add
y
,
float
the width of the rectangle to add
width
,
float
the height of the rectangle to add
height
)

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

pack-priv void
addRectangleInPixels(float x, float y, float width, float height)

public void
addString(String
the text to use
string
,
float
the x coordinate of the starting point
x
,
float
the y coordinate of the starting point
y
,
Font
the font to use
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).

pack-priv void
addStringInPixels(String string, float x, float y, Font font)

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

public boolean

Returns:

true if the path contains the point and false otherwise
contains
(float
the x coordinate of the point to test for containment
x
,
float
the y coordinate of the point to test for containment
y
,
GC
the GC to use when testing for containment
gc
,
boolean
controls whether to check the outline or contained area of the path
outline
)

Returns true if the specified point is contained by the receiver and false otherwise.

pack-priv boolean
containsInPixels(float x, float y, GC gc, boolean outline)

public void
cubicTo(float
the x coordinate of the first control point of the spline
cx1
,
float
the y coordinate of the first control of the spline
cy1
,
float
the x coordinate of the second control of the spline
cx2
,
float
the y coordinate of the second control of the spline
cy2
,
float
the x coordinate of the end point of the spline
x
,
float
the y coordinate of the end point of the spline
y
)

Adds to the receiver a cubic bezier curve based on the parameters.

pack-priv void
cubicToInPixels(float cx1, float cy1, float cx2, float cy2, float x, float y)

pack-priv void
public void
getBounds(float[]
the array to hold the result
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).

pack-priv void
getBoundsInPixels(float[] bounds)

public void
getCurrentPoint(float[]
the array to hold the result
point
)

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

pack-priv void
getCurrentPointInPixels(float[] point)

public PathData

Returns:

the PathData for the receiver
getPathData
()

Returns a device independent representation of the receiver.

pack-priv PathData
pack-priv void
init(PathData data)

public boolean

Returns:

true when the Path is disposed, and false otherwise
isDisposed
()

Implements abstract org.eclipse.swt.graphics.Resource.isDisposed.

Returns true if the Path has been disposed, and false otherwise.
public void
lineTo(float
the x coordinate of the end of the line to add
x
,
float
the y coordinate of the end of the line to add
y
)

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

pack-priv void
lineToInPixels(float x, float y)

public void
moveTo(float
the x coordinate of the new end point
x
,
float
the y coordinate of the new end point
y
)

Sets the current point of the receiver to the point specified by (x, y).

pack-priv void
moveToInPixels(float x, float y)

public void
quadTo(float
the x coordinate of the control point of the spline
cx
,
float
the y coordinate of the control point of the spline
cy
,
float
the x coordinate of the end point of the spline
x
,
float
the y coordinate of the end point of the spline
y
)

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

pack-priv void
quadToInPixels(float cx, float cy, float x, float y)

public String

Returns:

a string representation of the receiver
toString
()

Overrides java.lang.Object.toString.

Returns a string containing a concise, human-readable description of the receiver.
Inherited from org.eclipse.swt.graphics.Resource:
disposegetDeviceignoreNonDisposedinitinitNonDisposeTrackingsetNonDisposeHandler

Field Detail

closedback to summary
pack-priv boolean closed
handleback to summary
public long handle

the OS resource for the Path (Warning: This field is platform dependent)

Important Note

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.

movedback to summary
pack-priv boolean moved

Constructor Detail

Pathback to summary
public Path(Device device)

Constructs a new empty Path.

This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.

You must dispose the path when it is no longer required.

Parameters
device:Device

the device on which to allocate the path

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the device is null and there is no current device
SWTException:
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
SWTError:
  • ERROR_NO_HANDLES if a handle for the path could not be obtained
See Also
dispose()
Pathback to summary
public Path(Device device, Path path, float flatness)

Constructs a new Path that is a copy of 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.

You must dispose the path when it is no longer required.

Parameters
device:Device

the device on which to allocate the path

path:Path

the path to make a copy

flatness:float

the flatness value

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the device is null and there is no current device
  • ERROR_NULL_ARGUMENT - if the path is null
  • ERROR_INVALID_ARGUMENT - if the path has been disposed
SWTException:
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
SWTError:
  • ERROR_NO_HANDLES if a handle for the path could not be obtained
Since
3.4
See Also
dispose()
Pathback to summary
public Path(Device device, PathData data)

Constructs a new Path with the specified PathData.

This operation requires the operating system's advanced graphics subsystem which may not be available on some platforms.

You must dispose the path when it is no longer required.

Parameters
device:Device

the device on which to allocate the path

data:PathData

the data for the path

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the device is null and there is no current device
  • ERROR_NULL_ARGUMENT - if the data is null
SWTException:
  • ERROR_NO_GRAPHICS_LIBRARY - if advanced graphics are not available
SWTError:
  • ERROR_NO_HANDLES if a handle for the path could not be obtained
Since
3.4
See Also
dispose()

Method Detail

addArcback to summary
public 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.

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 points wide by height + 1 points tall.

Parameters
x:float

the x coordinate of the upper-left corner of the arc

y:float

the y coordinate of the upper-left corner of the arc

width:float

the width of the arc

height:float

the height of the arc

startAngle:float

the beginning angle

arcAngle:float

the angular extent of the arc, relative to the start angle

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
addArcInPixelsback to summary
pack-priv void addArcInPixels(float x, float y, float width, float height, float startAngle, float arcAngle)
addPathback to summary
public void addPath(Path path)

Adds to the receiver the path described by the parameter.

Parameters
path:Path

the path to add to the receiver

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parameter is null
  • ERROR_INVALID_ARGUMENT - if the parameter has been disposed
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
addRectangleback to summary
public void addRectangle(float x, float y, float width, float height)

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

Parameters
x:float

the x coordinate of the rectangle to add

y:float

the y coordinate of the rectangle to add

width:float

the width of the rectangle to add

height:float

the height of the rectangle to add

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
addRectangleInPixelsback to summary
pack-priv void addRectangleInPixels(float x, float y, float width, float height)
addStringback to summary
public void addString(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).

Parameters
string:String

the text to use

x:float

the x coordinate of the starting point

y:float

the y coordinate of the starting point

font:Font

the font to use

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the font is null
  • ERROR_INVALID_ARGUMENT - if the font has been disposed
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
addStringInPixelsback to summary
pack-priv void addStringInPixels(String string, float x, float y, Font font)
closeback to summary
public 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.

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
containsback to summary
public boolean contains(float x, float y, GC gc, boolean outline)

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

Parameters
x:float

the x coordinate of the point to test for containment

y:float

the y coordinate of the point to test for containment

gc:GC

the GC to use when testing for containment

outline:boolean

controls whether to check the outline or contained area of the path

Returns:boolean

true if the path contains the point and false otherwise

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the gc is null
  • ERROR_INVALID_ARGUMENT - if the gc has been disposed
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
containsInPixelsback to summary
pack-priv boolean containsInPixels(float x, float y, GC gc, boolean outline)
cubicToback to summary
public 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.

Parameters
cx1:float

the x coordinate of the first control point of the spline

cy1:float

the y coordinate of the first control of the spline

cx2:float

the x coordinate of the second control of the spline

cy2:float

the y coordinate of the second control of the spline

x:float

the x coordinate of the end point of the spline

y:float

the y coordinate of the end point of the spline

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
cubicToInPixelsback to summary
pack-priv void cubicToInPixels(float cx1, float cy1, float cx2, float cy2, float x, float y)
destroyback to summary
pack-priv void destroy()

Overrides org.eclipse.swt.graphics.Resource.destroy.

Annotations
@Override
getBoundsback to summary
public 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).

Parameters
bounds:float[]

the array to hold the result

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parameter is null
  • ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the bounding box
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
getBoundsInPixelsback to summary
pack-priv void getBoundsInPixels(float[] bounds)
getCurrentPointback to summary
public void getCurrentPoint(float[] point)

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

Parameters
point:float[]

the array to hold the result

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parameter is null
  • ERROR_INVALID_ARGUMENT - if the parameter is too small to hold the end point
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
getCurrentPointInPixelsback to summary
pack-priv void getCurrentPointInPixels(float[] point)
getPathDataback to summary
public PathData getPathData()

Returns a device independent representation of the receiver.

Returns:PathData

the PathData for the receiver

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also
PathData
getPathDataInPixelsback to summary
pack-priv PathData getPathDataInPixels()
initback to summary
pack-priv void init(PathData data)
isDisposedback to summary
public boolean isDisposed()

Implements abstract org.eclipse.swt.graphics.Resource.isDisposed.

Returns 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 dispose()) using the Path.

Returns:boolean

true when the Path is disposed, and false otherwise

Annotations
@Override
lineToback to summary
public void lineTo(float x, float y)

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

Parameters
x:float

the x coordinate of the end of the line to add

y:float

the y coordinate of the end of the line to add

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
lineToInPixelsback to summary
pack-priv void lineToInPixels(float x, float y)
moveToback to summary
public 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.

Parameters
x:float

the x coordinate of the new end point

y:float

the y coordinate of the new end point

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
moveToInPixelsback to summary
pack-priv void moveToInPixels(float x, float y)
quadToback to summary
public void quadTo(float cx, float cy, float x, float y)

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

Parameters
cx:float

the x coordinate of the control point of the spline

cy:float

the y coordinate of the control point of the spline

x:float

the x coordinate of the end point of the spline

y:float

the y coordinate of the end point of the spline

Exceptions
SWTException:
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
quadToInPixelsback to summary
pack-priv void quadToInPixels(float cx, float cy, float x, float y)
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

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

Returns:String

a string representation of the receiver

Annotations
@Override