|
JHotDraw 7.0.9 | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface Figure
The interface of a graphical figure.
A figure knows its bounds and can draw itself.
A figure has a set of Handles to manipulate its shape or attributes. A figure has one or more Connectors that define how to locate a connection point.
Figures can have an open ended set of attributes. An attribute is identified by an AttributeKey.
A figure can be composed of several figures, it can connect other figures, it can hold a text or an image or both. A figure should implement the corresponding subinterface, to allow manipulation of these features through editing tools. For example CompositeFigure, ConnectionFigure, ImageHolderFigure TextHolderFigure.
A figure can be composed of several figures. Such a figure should implement the CompositeFigure interface, to allow manipulation of the child figures through editing tools.
A figure can connect other figures. Such a figures should implement the ConnectionFigure interface, to allow manipulation of the composition through editing tools.
A figure can hold a text or an image or both. Such a figure should implement the ImageHolder and TextHolder interfaces, to allo
Default implementations for the Figure interface are provided by AbstractFigure.
Method Summary | |
---|---|
void |
addFigureListener(FigureListener l)
Adds a listener for FigureEvent's. |
void |
addNotify(Drawing d)
Informs a figure, that it has been added to the specified drawing. |
boolean |
canConnect()
Checks if this Figure can be connected. |
void |
changed()
Informs that a Figure changed its shape. |
java.lang.Object |
clone()
Returns a clone of the figure. |
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. |
void |
draw(java.awt.Graphics2D g)
Draws the figure and its decorator figure. |
Connector |
findCompatibleConnector(Connector c,
boolean isStartConnector)
Gets a compatible connector. |
Connector |
findConnector(java.awt.geom.Point2D.Double p,
ConnectionFigure prototype)
Gets a connector for this figure at the given location. |
Figure |
findFigureInside(java.awt.geom.Point2D.Double p)
Returns the figure that contains the given point. |
java.util.Collection<javax.swing.Action> |
getActions(java.awt.geom.Point2D.Double p)
Returns a collection of Action's for the specified location. |
java.lang.Object |
getAttribute(AttributeKey key)
Gets an attribute from the Figure. |
java.util.Map<AttributeKey,java.lang.Object> |
getAttributes()
Returns a view to all attributes of this figure. |
java.lang.Object |
getAttributesRestoreData()
Gets data which can be used to restore the attributes of the figure after a setAttribute has been applied to it. |
java.awt.geom.Rectangle2D.Double |
getBounds()
Returns the untransformed logicalbounds of the figure as a Rectangle. |
java.util.Collection<Connector> |
getConnectors(ConnectionFigure prototype)
Returns all connectors of this Figure for the specified prototype of a ConnectionFigure. |
java.awt.Cursor |
getCursor(java.awt.geom.Point2D.Double p)
Returns a cursor for the specified location. |
java.util.Collection<Figure> |
getDecomposition()
Returns a decompositon of a figure into its parts. |
java.awt.geom.Rectangle2D.Double |
getDrawingArea()
Returns the drawing area of the figure as a Rectangle. |
java.awt.geom.Point2D.Double |
getEndPoint()
Returns the untransformed logical end point of the bounds. |
int |
getLayer()
Gets the layer of the figure. |
Dimension2DDouble |
getPreferredSize()
The preferred size is used by Layouter to determine the preferred size of a Figure. |
java.awt.geom.Point2D.Double |
getStartPoint()
Returns the untransformed logical start point of the bounds. |
Tool |
getTool(java.awt.geom.Point2D.Double p)
Returns a specialized tool for the specified location. |
java.lang.String |
getToolTipText(java.awt.geom.Point2D.Double p)
Returns a tooltip for the specified location. |
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 |
handleDrop(java.awt.geom.Point2D.Double p,
java.util.Collection<Figure> droppedFigures,
DrawingView view)
Handles a drop. |
boolean |
handleMouseClick(java.awt.geom.Point2D.Double p,
java.awt.event.MouseEvent evt,
DrawingView view)
Handles a mouse click. |
boolean |
includes(Figure figure)
Checks whether the given figure is contained in this figure. |
void |
invalidate()
Informs that a Figure has invalidated its display area and needs to be drawn. |
boolean |
isInteractive()
Returns true, if the user can manipulate this figure. |
boolean |
isVisible()
A Figure is only drawn by a Drawing and by CompositeFigure, if it is visible. |
void |
remap(java.util.Map<Figure,Figure> oldToNew)
After cloning a collection of figures, the ConnectionFigures contained in this collection still connect to the original figures instead of to the clones. |
void |
removeFigureListener(FigureListener l)
Removes a listener for FigureEvent's. |
void |
removeNotify(Drawing d)
Informs a figure, that it has been removed from the specified drawing. |
void |
requestRemove()
Fires a FigureListener.figureRequestRemove event. |
void |
restoreAttributesTo(java.lang.Object restoreData)
Restores the attributes of the figure to a previously stored state. |
void |
restoreTransformTo(java.lang.Object restoreData)
Restores the transform of the figure to a previously stored state. |
void |
setAttribute(AttributeKey key,
java.lang.Object value)
Sets an attribute of the figure without firing events. |
void |
setBounds(java.awt.geom.Point2D.Double start,
java.awt.geom.Point2D.Double end)
Sets the logical and untransformed bounds of the figure and of its decorator figure. |
void |
setVisible(boolean newValue)
Changes the visible state of the Figure. |
void |
transform(java.awt.geom.AffineTransform tx)
Transforms the shape of the Figure. |
void |
willChange()
Informs that a Figure is about to change its shape. |
Methods inherited from interface org.jhotdraw.xml.DOMStorable |
---|
read, write |
Method Detail |
---|
void draw(java.awt.Graphics2D g)
g
- The Graphics2D to draw to.int getLayer()
FigureListener.figureChanged
event to
its figure listeners.
FIXME - Replace int value by a Layer object.
boolean isVisible()
void setVisible(boolean newValue)
The Figure fires FigureListener.figureChanged
and
UndoableEditListener.undoableEditHappened
,
if this operation changed its visible state.
void setBounds(java.awt.geom.Point2D.Double start, java.awt.geom.Point2D.Double end)
This is used by Tool's which create a new Figure and by Tool's which connect a Figure to another Figure.
This is a basic operation which does not fire events. Use the following code sequence, if you need event firing:
aFigure.willChange(); aFigure.setBounds(...); aFigure.changed();
start
- the start point of the boundsend
- the end point of the boundsgetBounds()
java.awt.geom.Point2D.Double getStartPoint()
setBounds(java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Double)
java.awt.geom.Point2D.Double getEndPoint()
setBounds(java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Double)
java.awt.geom.Rectangle2D.Double getBounds()
java.awt.geom.Rectangle2D.Double getDrawingArea()
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.
Dimension2DDouble getPreferredSize()
java.lang.Object getTransformRestoreData()
transform(AffineTransform)
void restoreTransformTo(java.lang.Object restoreData)
void transform(java.awt.geom.AffineTransform tx)
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.getTransformRestoreData()
,
restoreTransformTo(java.lang.Object)
void setAttribute(AttributeKey key, java.lang.Object value)
Use AttributeKey.basicSet
for typesafe access to this
method.
This is a basic operation which does not fire events. Use method
setAttribute
if you need event firing, or - alternatively - the following
code sequence:
aFigure.willChange(); Object oldData = aFigure.getAttributesRestoreData(); STROKE_COLOR.basicSet(aFigure, ...); aFigure.changed(); Object newData = aFigure.getAttributesRestoreData(); ...fire an UndoableEditEvent oldData and newData...
AttributeKey.basicSet(org.jhotdraw.draw.Figure, T)
java.lang.Object getAttribute(AttributeKey key)
Use AttributeKey.get()
for typesafe access to this method.
AttributeKey.get(org.jhotdraw.draw.Figure)
java.util.Map<AttributeKey,java.lang.Object> getAttributes()
java.lang.Object getAttributesRestoreData()
#basicSetAttribue(AttributeKey,Object)
void restoreAttributesTo(java.lang.Object restoreData)
boolean isInteractive()
boolean contains(java.awt.geom.Point2D.Double p)
This is used for hit testing by Tool's.
java.util.Collection<Handle> createHandles(int detailLevel)
detailLevel
- The detail level of the handles. Usually this is 0 for
bounding box handles and 1 for point handles.
Handle
java.awt.Cursor getCursor(java.awt.geom.Point2D.Double p)
java.util.Collection<javax.swing.Action> getActions(java.awt.geom.Point2D.Double p)
The collection may contain null entries. These entries are used interpreted as separators in the popup menu.
Actions can use the property Figure.ACTION_SUBMENU to specify a submenu.
Tool getTool(java.awt.geom.Point2D.Double p)
Returns null, if no specialized tool is available.
java.lang.String getToolTipText(java.awt.geom.Point2D.Double p)
boolean canConnect()
Connector findConnector(java.awt.geom.Point2D.Double p, ConnectionFigure prototype)
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.Connector findCompatibleConnector(Connector c, boolean isStartConnector)
java.util.Collection<Connector> getConnectors(ConnectionFigure prototype)
This is used by connection tools and connection handles to visualize the connectors when the user is about to create a ConnectionFigure to this Figure.
prototype
- The prototype used to create a connection or null if
unknown. This allows for specific connectors for different
connection figures.boolean includes(Figure figure)
Figure findFigureInside(java.awt.geom.Point2D.Double p)
java.util.Collection<Figure> getDecomposition()
java.lang.Object clone()
void remap(java.util.Map<Figure,Figure> oldToNew)
void addNotify(Drawing d)
void removeNotify(Drawing d)
void willChange()
willChange
and changed
are typically used
as pairs before and after invoking one or multiple basic-methods on
the Figure.
void changed()
FigureListener.figureChanged
event for the current display bounds of the figure.
willChange()
void invalidate()
FigureListener.areaInvalidated
event.
void requestRemove()
FigureListener.figureRequestRemove
event.
boolean handleDrop(java.awt.geom.Point2D.Double p, java.util.Collection<Figure> droppedFigures, DrawingView view)
p
- The location of the mouse event.droppedFigures
- The dropped figures.view
- The drawing view which is the source of the mouse event.
boolean handleMouseClick(java.awt.geom.Point2D.Double p, java.awt.event.MouseEvent evt, DrawingView view)
p
- The location of the mouse event.evt
- The mouse event.view
- The drawing view which is the source of the mouse event.
void addFigureListener(FigureListener l)
void removeFigureListener(FigureListener l)
|
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 |