|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectedu.umd.cs.piccolo.PNode
edu.umd.cs.piccolo.nodes.PPath
public class PPath
PPath is a wrapper around a java.awt.geom.GeneralPath. The setBounds method works by scaling the path to fit into the specified bounds. This normally works well, but if the specified base bounds get too small then it is impossible to expand the path shape again since all its numbers have tended to zero, so application code may need to take this into consideration.
One option that applications have is to call startResizeBounds
before starting an interaction that may make the bounds very small, and
calling endResizeBounds
when this interaction is finished. When
this is done PPath will use a copy of the original path to do the resizing so
the numbers in the path wont loose resolution.
This class also provides methods for constructing common shapes using a general path.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.PNode |
---|
PNode.PSceneGraphDelegate |
Field Summary | |
---|---|
static int |
PROPERTY_CODE_PATH
The property code that identifies a change of this node's path (see getPathReference ). |
static int |
PROPERTY_CODE_STROKE
The property code that identifies a change of this node's stroke (see getStroke ). |
static int |
PROPERTY_CODE_STROKE_PAINT
The property code that identifies a change of this node's stroke paint (see getStrokePaint ). |
static String |
PROPERTY_PATH
The property name that identifies a change of this node's path (see getPathReference ). |
static String |
PROPERTY_STROKE
The property name that identifies a change of this node's stroke (see getStroke ). |
static String |
PROPERTY_STROKE_PAINT
The property name that identifies a change of this node's stroke paint (see getStrokePaint ). |
Fields inherited from interface java.awt.print.Printable |
---|
NO_SUCH_PAGE, PAGE_EXISTS |
Constructor Summary | |
---|---|
PPath()
Creates an empty PPath with the default paint and stroke. |
|
PPath(Shape aShape)
Creates an PPath in the given shape with the default paint and stroke. |
|
PPath(Shape aShape,
Stroke aStroke)
Construct this path with the given shape and stroke. |
Method Summary | |
---|---|
void |
append(Shape aShape,
boolean connect)
|
void |
closePath()
|
static PPath |
createEllipse(float x,
float y,
float width,
float height)
Creates a PPath object in the shape of an ellipse. |
static PPath |
createLine(float x1,
float y1,
float x2,
float y2)
Creates a PPath in the shape of a line. |
static PPath |
createPolyline(float[] xp,
float[] yp)
Creates a PPath for the poly-line for the given points. |
static PPath |
createPolyline(Point2D[] points)
Creates a PPath for the poly-line for the given points. |
static PPath |
createRectangle(float x,
float y,
float width,
float height)
Creates a PPath object in the shape of a rectangle. |
static PPath |
createRoundRectangle(float x,
float y,
float width,
float height,
float arcWidth,
float arcHeight)
Creates a PPath object in the shape of a rounded rectangle. |
void |
curveTo(float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
|
void |
endResizeBounds()
Notify this node that you have finished a resize bounds sequence. |
Rectangle2D |
getPathBoundsWithStroke()
|
GeneralPath |
getPathReference()
|
Stroke |
getStroke()
|
Paint |
getStrokePaint()
Returns the stroke paint of the PPath. |
protected void |
internalUpdateBounds(double x,
double y,
double width,
double height)
Set the bounds of this path. |
boolean |
intersects(Rectangle2D aBounds)
Return true if this node intersects the given rectangle specified in local bounds. |
void |
lineTo(float x,
float y)
|
void |
moveTo(float x,
float y)
|
protected void |
paint(PPaintContext paintContext)
Paint this node behind any of its children nodes. |
void |
quadTo(float x1,
float y1,
float x2,
float y2)
|
void |
reset()
|
void |
setPathTo(Shape aShape)
|
void |
setPathToEllipse(float x,
float y,
float width,
float height)
|
void |
setPathToPolyline(float[] xp,
float[] yp)
|
void |
setPathToPolyline(Point2D[] points)
|
void |
setPathToRectangle(float x,
float y,
float width,
float height)
|
void |
setStroke(Stroke aStroke)
|
void |
setStrokePaint(Paint aPaint)
|
void |
startResizeBounds()
Notify this node that you will begin to repeatedly call setBounds
. |
void |
updateBoundsFromPath()
|
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String PROPERTY_STROKE_PAINT
getStrokePaint
). Both old and new value will
be set correctly to Paint objects in any property change event.
public static final int PROPERTY_CODE_STROKE_PAINT
getStrokePaint
). Both old and new value will
be set correctly to Paint objects in any property change event.
public static final String PROPERTY_STROKE
getStroke
). Both old and new value will be set
correctly to Stroke objects in any property change event.
public static final int PROPERTY_CODE_STROKE
getStroke
). Both old and new value will be set
correctly to Stroke objects in any property change event.
public static final String PROPERTY_PATH
getPathReference
). In any property change event
the new value will be a reference to this node's path, but old value will
always be null.
public static final int PROPERTY_CODE_PATH
getPathReference
). In any property change event
the new value will be a reference to this node's path, but old value will
always be null.
Constructor Detail |
---|
public PPath()
public PPath(Shape aShape)
aShape
- the desired shapepublic PPath(Shape aShape, Stroke aStroke)
aShape
- desired shape or null if you desire an empty pathaStroke
- desired strokeMethod Detail |
---|
public static PPath createRectangle(float x, float y, float width, float height)
x
- left of the rectangley
- top of the rectanglewidth
- width of the rectangleheight
- height of the rectangle
public static PPath createRoundRectangle(float x, float y, float width, float height, float arcWidth, float arcHeight)
x
- left of the rectangley
- top of the rectanglewidth
- width of the rectangleheight
- height of the rectanglearcWidth
- the arc width at the corners of the rectanglearcHeight
- the arc height at the corners of the rectangle
public static PPath createEllipse(float x, float y, float width, float height)
x
- left of the ellipsey
- top of the ellipsewidth
- width of the ellipseheight
- height of the ellipse
public static PPath createLine(float x1, float y1, float x2, float y2)
x1
- x component of the first pointy1
- y component of the first pointx2
- x component of the second pointy2
- y component of the second point
public static PPath createPolyline(Point2D[] points)
points
- array of points for the point lines
public static PPath createPolyline(float[] xp, float[] yp)
xp
- array of x components of the points of the poly-linesyp
- array of y components of the points of the poly-lines
public Paint getStrokePaint()
public void setStrokePaint(Paint aPaint)
public Stroke getStroke()
public void setStroke(Stroke aStroke)
public void startResizeBounds()
PNode
setBounds
. When you
are done call endResizeBounds
to let the node know that you
are done.
startResizeBounds
in class PNode
public void endResizeBounds()
PNode
endResizeBounds
in class PNode
protected void internalUpdateBounds(double x, double y, double width, double height)
internalUpdateBounds
in class PNode
x
- x position of boundsy
- y position of boundswidth
- width to apply to the boundsheight
- height to apply to the boundspublic boolean intersects(Rectangle2D aBounds)
PNode
fullIntersects
is used for quick rejects before calling this
method.
intersects
in class PNode
aBounds
- the bounds to test for intersection against
public Rectangle2D getPathBoundsWithStroke()
public void updateBoundsFromPath()
protected void paint(PPaintContext paintContext)
PNode
paint
in class PNode
paintContext
- the paint context to use for painting the nodepublic GeneralPath getPathReference()
public void moveTo(float x, float y)
public void lineTo(float x, float y)
public void quadTo(float x1, float y1, float x2, float y2)
public void curveTo(float x1, float y1, float x2, float y2, float x3, float y3)
public void append(Shape aShape, boolean connect)
public void setPathTo(Shape aShape)
public void setPathToRectangle(float x, float y, float width, float height)
public void setPathToEllipse(float x, float y, float width, float height)
public void setPathToPolyline(Point2D[] points)
public void setPathToPolyline(float[] xp, float[] yp)
public void closePath()
public void reset()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |