|
JHotDraw 7.1 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.jhotdraw.beans.AbstractBean
org.jhotdraw.draw.AbstractFigure
org.jhotdraw.draw.AbstractAttributedFigure
org.jhotdraw.draw.BezierFigure
public class BezierFigure
A BezierFigure can be used to draw arbitrary shapes using a BezierPath
.
It can be used to draw an open path or a closed shape.
A BezierFigure can have straight path segments and curved segments. A straight path segment can be added by clicking on the drawing area. Curved segments can be added by dragging the mouse pointer over the drawing area.
To creation of the BezierFigure can be finished by adding a segment which closes the path, or by double clicking on the drawing area, or by selecting a different tool in the DrawingEditor.
BezierPath
,
Serialized FormField Summary | |
---|---|
protected BezierPath |
path
The BezierPath. |
Fields inherited from class org.jhotdraw.draw.AbstractFigure |
---|
changingDepth, listenerList |
Fields inherited from class org.jhotdraw.beans.AbstractBean |
---|
propertySupport |
Constructor Summary | |
---|---|
BezierFigure()
Creates an empty BezierFigure , for example without any
BezierPath.Node s. |
|
BezierFigure(boolean isClosed)
Creates an empty BezierFigure, for example without any BezierPath.Node s. |
Method Summary | |
---|---|
void |
addNode(BezierPath.Node p)
Adds a control point. |
void |
addNode(int index,
BezierPath.Node p)
Adds a node to the list of points. |
boolean |
canConnect()
Checks if this figure can be connected. |
java.awt.geom.Point2D.Double |
chop(java.awt.geom.Point2D.Double p)
|
BezierFigure |
clone()
Returns a clone of the figure, with clones of all aggregated figures, such as chilrend and decorators. |
boolean |
contains(java.awt.geom.Point2D.Double p)
Checks if a point is contained by the figure. |
java.util.Collection<Handle> |
createHandles(int detailLevel)
Creates handles used to manipulate the figure. |
protected void |
drawCaps(java.awt.Graphics2D g)
|
protected void |
drawFill(java.awt.Graphics2D g)
This method is called by method draw() to draw the fill area of the figure. |
protected void |
drawStroke(java.awt.Graphics2D g)
This method is called by method draw() to draw the text of the figure . |
Connector |
findCompatibleConnector(Connector c,
boolean isStart)
Gets a compatible connector. |
Connector |
findConnector(java.awt.geom.Point2D.Double p,
ConnectionFigure prototype)
Returns the Figures connector for the specified location. |
int |
findNode(java.awt.geom.Point2D.Double p)
Finds a control point index. |
int |
findSegment(java.awt.geom.Point2D.Double find)
Gets the segment of the polyline that is hit by the given Point2D.Double. |
BezierPath |
getBezierPath()
Returns a clone of the bezier path of this figure. |
java.awt.geom.Rectangle2D.Double |
getBounds()
Returns the untransformed logicalbounds of the figure as a Rectangle. |
protected BezierPath |
getCappedPath()
Returns a path which is cappedPath at the ends, to prevent it from drawing under the end caps. |
java.awt.geom.Point2D.Double |
getCenter()
|
java.awt.geom.Rectangle2D.Double |
getDrawingArea()
Returns the drawing area of the figure as a Rectangle. |
java.awt.geom.Point2D.Double |
getEndPoint()
Convenience method for getting the end point. |
BezierPath.Node |
getNode(int index)
Gets a control point. |
int |
getNodeCount()
Gets the node count. |
java.awt.geom.Point2D.Double |
getOutermostPoint()
|
java.awt.geom.Point2D.Double |
getPoint(int index)
Convenience method for getting the point coordinate of the first control point of the specified node. |
java.awt.geom.Point2D.Double |
getPoint(int index,
int coord)
Gets the point coordinate of a control point. |
java.awt.geom.Point2D.Double |
getPointOnPath(float relative,
double flatness)
|
java.awt.geom.Point2D.Double |
getStartPoint()
Convenience method for getting the start point. |
java.lang.Object |
getTransformRestoreData()
Gets data which can be used to restore the transformation of the figure without loss of precision, after a transform has been applied to it. |
boolean |
handleMouseClick(java.awt.geom.Point2D.Double p,
java.awt.event.MouseEvent evt,
DrawingView view)
Handles a mouse click. |
void |
invalidate()
Invalidates cached data of the Figure. |
boolean |
isClosed()
|
boolean |
joinSegments(java.awt.geom.Point2D.Double join)
Joins two segments into one if the given Point2D.Double hits a node of the polyline. |
int |
joinSegments(java.awt.geom.Point2D.Double join,
float tolerance)
Joins two segments into one if the given Point2D.Double hits a node of the polyline. |
void |
layout()
|
void |
read(DOMInput in)
|
protected void |
readPoints(DOMInput in)
|
protected void |
removeAllNodes()
Removes the Point2D.Double at the specified index. |
BezierPath.Node |
removeNode(int index)
Removes the Node at the specified index. |
void |
restoreTransformTo(java.lang.Object geometry)
Restores the transform of the figure to a previously stored state. |
void |
setAttribute(AttributeKey key,
java.lang.Object newValue)
Sets an attribute of the figure. |
void |
setBezierPath(BezierPath newValue)
|
void |
setBounds(java.awt.geom.Point2D.Double anchor,
java.awt.geom.Point2D.Double lead)
Sets the location of the first and the last BezierPath.Node
of the BezierFigure. |
void |
setClosed(boolean newValue)
|
void |
setEndPoint(java.awt.geom.Point2D.Double p)
Convenience method for setting the point coordinate of the end point. |
void |
setNode(int index,
BezierPath.Node p)
Sets a control point. |
void |
setPoint(int index,
int coord,
java.awt.geom.Point2D.Double p)
Sets the point coordinate of a control point. |
void |
setPoint(int index,
java.awt.geom.Point2D.Double p)
Sets the point coordinate of control point 0 at the specified node. |
void |
setStartPoint(java.awt.geom.Point2D.Double p)
Convenience method for setting the point coordinate of the start point. |
int |
splitSegment(java.awt.geom.Point2D.Double split)
Splits the segment at the given Point2D.Double if a segment was hit. |
int |
splitSegment(java.awt.geom.Point2D.Double split,
float tolerance)
Splits the segment at the given Point2D.Double if a segment was hit. |
void |
transform(java.awt.geom.AffineTransform tx)
Transforms the shape of the Figure. |
protected void |
validate()
|
void |
write(DOMOutput out)
|
protected void |
writePoints(DOMOutput out)
|
Methods inherited from class org.jhotdraw.draw.AbstractAttributedFigure |
---|
applyAttributesTo, draw, drawText, getAttribute, getAttributeKey, getAttributes, getAttributesRestoreData, getStroke, getStrokeMiterLimitFactor, hasAttribute, isAttributeEnabled, readAttributes, removeAttribute, restoreAttributesTo, setAttributeEnabled, setAttributes, writeAttributes |
Methods inherited from class org.jhotdraw.beans.AbstractBean |
---|
addPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener, removePropertyChangeListener |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected BezierPath path
Constructor Detail |
---|
public BezierFigure()
BezierFigure
, for example without any
BezierPath.Node
s.
The BezierFigure will not draw anything, if at least two nodes
are added to it. The BezierPath
created by this constructor
is not closed.
public BezierFigure(boolean isClosed)
BezierPath.Node
s.
The BezierFigure will not draw anything, unless at least two nodes
are added to it.
isClosed
- Specifies whether the BezierPath
shall
be closed.Method Detail |
---|
public Connector findConnector(java.awt.geom.Point2D.Double p, ConnectionFigure prototype)
findConnector
in interface Figure
findConnector
in class AbstractFigure
p
- the location of the connector.prototype
- The prototype used to create a connection or null if
unknown. This allows for specific connectors for different
connection figures.ChopDiamondConnector
public Connector findCompatibleConnector(Connector c, boolean isStart)
Figure
findCompatibleConnector
in interface Figure
findCompatibleConnector
in class AbstractFigure
protected void drawStroke(java.awt.Graphics2D g)
AbstractAttributedFigure
drawStroke
in class AbstractAttributedFigure
protected void drawCaps(java.awt.Graphics2D g)
protected void drawFill(java.awt.Graphics2D g)
AbstractAttributedFigure
drawFill
in class AbstractAttributedFigure
public boolean contains(java.awt.geom.Point2D.Double p)
Figure
This is used for hit testing by Tool's.
public boolean canConnect()
canConnect
in interface Figure
canConnect
in class AbstractFigure
public java.util.Collection<Handle> createHandles(int detailLevel)
Figure
createHandles
in interface Figure
createHandles
in class AbstractFigure
detailLevel
- The detail level of the handles. Usually this is 0 for
bounding box handles and 1 for point handles.
Handle
public java.awt.geom.Rectangle2D.Double getBounds()
Figure
public java.awt.geom.Rectangle2D.Double getDrawingArea()
Figure
The drawing area needs to be large enough, to take line width, line caps and other decorations into account that exceed the bounds of the Figure.
getDrawingArea
in interface Figure
getDrawingArea
in class AbstractAttributedFigure
protected void validate()
validate
in class AbstractFigure
public BezierPath getBezierPath()
public void setBezierPath(BezierPath newValue)
public java.awt.geom.Point2D.Double getPointOnPath(float relative, double flatness)
public boolean isClosed()
public void setClosed(boolean newValue)
public void setAttribute(AttributeKey key, java.lang.Object newValue)
AbstractAttributedFigure
setAttribute
in interface Figure
setAttribute
in class AbstractAttributedFigure
AttributeKey.set(org.jhotdraw.draw.Figure, T)
public void setBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)
BezierPath.Node
of the BezierFigure.
If the BezierFigure has not at least two nodes, nodes are added
to the figure until the BezierFigure has at least two nodes.
setBounds
in interface Figure
setBounds
in class AbstractFigure
anchor
- the start point of the boundslead
- the end point of the boundsFigure.getBounds()
public void transform(java.awt.geom.AffineTransform tx)
Figure
This is a basic operation which does not fire events. Use the following code sequence, if you need event firing:
aFigure.willChange(); aFigure.transform(...); aFigure.changed();
tx
- The transformation.Figure.getTransformRestoreData()
,
Figure.restoreTransformTo(java.lang.Object)
public void invalidate()
AbstractFigure
invalidate
in class AbstractFigure
protected BezierPath getCappedPath()
public void layout()
public void addNode(BezierPath.Node p)
public void addNode(int index, BezierPath.Node p)
public void setNode(int index, BezierPath.Node p)
public BezierPath.Node getNode(int index)
public java.awt.geom.Point2D.Double getPoint(int index)
public java.awt.geom.Point2D.Double getPoint(int index, int coord)
public void setPoint(int index, java.awt.geom.Point2D.Double p)
public void setPoint(int index, int coord, java.awt.geom.Point2D.Double p)
public void setStartPoint(java.awt.geom.Point2D.Double p)
public void setEndPoint(java.awt.geom.Point2D.Double p)
public java.awt.geom.Point2D.Double getStartPoint()
getStartPoint
in interface Figure
getStartPoint
in class AbstractFigure
Figure.setBounds(java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Double)
public java.awt.geom.Point2D.Double getEndPoint()
getEndPoint
in interface Figure
getEndPoint
in class AbstractFigure
Figure.setBounds(java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Double)
public int findNode(java.awt.geom.Point2D.Double p)
public int findSegment(java.awt.geom.Point2D.Double find)
public boolean joinSegments(java.awt.geom.Point2D.Double join)
public int splitSegment(java.awt.geom.Point2D.Double split)
public BezierPath.Node removeNode(int index)
protected void removeAllNodes()
public int getNodeCount()
public BezierFigure clone()
Figure
clone
in interface Figure
clone
in class AbstractAttributedFigure
public void restoreTransformTo(java.lang.Object geometry)
Figure
public java.lang.Object getTransformRestoreData()
Figure
Figure.transform(AffineTransform)
public java.awt.geom.Point2D.Double chop(java.awt.geom.Point2D.Double p)
public java.awt.geom.Point2D.Double getCenter()
public java.awt.geom.Point2D.Double getOutermostPoint()
public int joinSegments(java.awt.geom.Point2D.Double join, float tolerance)
public int splitSegment(java.awt.geom.Point2D.Double split, float tolerance)
public boolean handleMouseClick(java.awt.geom.Point2D.Double p, java.awt.event.MouseEvent evt, DrawingView view)
handleMouseClick
in interface Figure
handleMouseClick
in class AbstractFigure
p
- The location of the mouse event.evt
- The mouse event.view
- The drawing view which is the source of the mouse event.
public void write(DOMOutput out) throws java.io.IOException
write
in interface DOMStorable
write
in class AbstractAttributedFigure
java.io.IOException
protected void writePoints(DOMOutput out) throws java.io.IOException
java.io.IOException
public void read(DOMInput in) throws java.io.IOException
read
in interface DOMStorable
read
in class AbstractAttributedFigure
java.io.IOException
protected void readPoints(DOMInput in) throws java.io.IOException
java.io.IOException
|
Copyright 1996-2007 (c) JHotDraw.org. Some rights reserved. |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |