Eclipse Remote Application Platform

org.eclipse.swt.graphics
Class Path

java.lang.Object
  extended by org.eclipse.swt.graphics.Resource
      extended by org.eclipse.swt.graphics.Path

public class Path
extends Resource

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.

Since:
2.1

Constructor Summary
Path(Device device)
          Constructs a new empty Path.
Path(Device device, PathData data)
          Constructs a new Path with the specified PathData.
 
Method Summary
 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 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.
 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.
 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.
 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.
 
Methods inherited from class org.eclipse.swt.graphics.Resource
dispose, getDevice, isDisposed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Path

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.

Parameters:
device - the device on which to allocate the path
Throws:
java.lang.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:
Resource.dispose()

Path

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.

Parameters:
device - the device on which to allocate the path
data - the data for the path
Throws:
java.lang.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
See Also:
Resource.dispose()
Method Detail

addPath

public void addPath(Path path)
Adds to the receiver the path described by the parameter.

Parameters:
path - the path to add to the receiver
Throws:
java.lang.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

addRectangle

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 - the x coordinate of the rectangle to add
y - the y coordinate of the rectangle to add
width - the width of the rectangle to add
height - the height of the rectangle to add
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

moveTo

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 - the x coordinate of the new end point
y - the y coordinate of the new end point
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

lineTo

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 - the x coordinate of the end of the line to add
y - the y coordinate of the end of the line to add
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

quadTo

public void quadTo(float cx,
                   float cy,
                   float x,
                   float y)
Adds to the receiver a quadratic curve based on the parameters.

Parameters:
cx - the x coordinate of the control point of the spline
cy - the y coordinate of the control point of the spline
x - the x coordinate of the end point of the spline
y - the y coordinate of the end point of the spline
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

cubicTo

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 - the x coordinate of the first control point of the spline
cy1 - the y coordinate of the first control of the spline
cx2 - the x coordinate of the second control of the spline
cy2 - the y coordinate of the second control of the spline
x - the x coordinate of the end point of the spline
y - the y coordinate of the end point of the spline
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

close

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.

Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed

getPathData

public PathData getPathData()
Returns a device independent representation of the receiver.

Returns:
the PathData for the receiver
Throws:
SWTException -
  • ERROR_GRAPHIC_DISPOSED - if the receiver has been disposed
See Also:
PathData

getCurrentPoint

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 - the array to hold the result
Throws:
java.lang.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

Eclipse Remote Application Platform

Copyright (c) EclipseSource and others 2002, 2013. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0