Class AbstractFigure
- java.lang.Object
-
- org.jhotdraw.beans.AbstractBean
-
- org.jhotdraw.draw.AbstractFigure
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, Figure
- Direct Known Subclasses:
- AbstractAttributedFigure, AbstractCompositeFigure
public abstract class AbstractFigure extends AbstractBean implements Figure
This abstract class can be extended to implement aFigure.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.jhotdraw.draw.Figure
CONNECTABLE_PROPERTY, REMOVABLE_PROPERTY, SELECTABLE_PROPERTY, TRANSFORMABLE_PROPERTY
-
-
Constructor Summary
Constructors Constructor and Description AbstractFigure()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidaddFigureListener(FigureListener l)Adds a listener for FigureEvent's.voidaddNotify(Drawing d)Informs a figure, that it has been added to a drawing.voidchanged()Informs that a figure changed the area of its display box.AbstractFigureclone()Returns a clone of the figure, with clones of all aggregated figures, such as children and decorators.java.util.Collection<Handle>createHandles(int detailLevel)Creates handles used to manipulate the figure.ConnectorfindCompatibleConnector(Connector c, boolean isStart)Gets a compatible connector.ConnectorfindConnector(java.awt.geom.Point2D.Double p, ConnectionFigure prototype)Returns the Figures connector for the specified location.FigurefindFigureInside(java.awt.geom.Point2D.Double p)Finds the innermost figure at the specified location.voidfireAreaInvalidated()Notify all listenerList that have registered interest for notification on this event type.voidfireFigureChanged()java.util.Collection<javax.swing.Action>getActions(java.awt.geom.Point2D.Double p)Returns a collection of actions which are presented to the user in a popup menu.java.util.Collection<Connector>getConnectors(ConnectionFigure prototype)Returns all connectors of this Figure for the specified prototype of a ConnectionFigure.java.awt.CursorgetCursor(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.Point2D.DoublegetEndPoint()Returns the untransformed logical end point of the bounds.intgetLayer()AbstractFigure always returns 0.Dimension2DDoublegetPreferredSize()The preferred size is used by Layouter to determine the preferred size of a Figure.java.awt.geom.Point2D.DoublegetStartPoint()Returns the untransformed logical start point of the bounds.ToolgetTool(java.awt.geom.Point2D.Double p)Returns a specialized tool for the given coordinate.java.lang.StringgetToolTipText(java.awt.geom.Point2D.Double p)Returns a tooltip for the specified location on the figure.booleanhandleDrop(java.awt.geom.Point2D.Double p, java.util.Collection<Figure> droppedFigures, DrawingView view)Handles a drop.booleanhandleMouseClick(java.awt.geom.Point2D.Double p, java.awt.event.MouseEvent evt, DrawingView view)Handles a mouse click.booleanincludes(Figure figure)Checks whether the given figure is contained in this figure.booleanisConnectable()Checks whether this figure is connectable.booleanisRemovable()Checks whether this figure is removable.booleanisSelectable()Checks whether this figure is selectable.booleanisTransformable()Checks whether this figure is transformable.booleanisVisible()Checks whether this figure is visible.voidremap(java.util.Map<Figure,Figure> oldToNew, boolean disconnectIfNotInMap)After cloning a collection of figures, the ConnectionFigures contained in this collection still connect to the original figures instead of to the clones.voidremoveFigureListener(FigureListener l)Removes a listener for FigureEvent's.voidremoveNotify(Drawing d)Informs a figure, that it has been removed from a drawing.voidrequestRemove()Fires aFigureListener.figureRequestRemoveevent.voidsetBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)Sets the logical and untransformed bounds of the figure.voidsetBounds(java.awt.geom.Rectangle2D.Double bounds)voidsetConnectable(boolean newValue)voidsetRemovable(boolean newValue)voidsetSelectable(boolean newValue)voidsetTransformable(boolean newValue)voidsetVisible(boolean newValue)java.lang.StringtoString()voidwillChange()Informs that a figure is about to change something that affects the contents of its display box.-
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jhotdraw.draw.Figure
addPropertyChangeListener, contains, draw, get, getAttributes, getAttributesRestoreData, getBounds, getDrawingArea, getTransformRestoreData, removePropertyChangeListener, restoreAttributesTo, restoreTransformTo, set, transform
-
-
-
-
Method Detail
-
addFigureListener
public void addFigureListener(FigureListener l)
Description copied from interface:FigureAdds a listener for FigureEvent's.- Specified by:
addFigureListenerin interfaceFigure
-
removeFigureListener
public void removeFigureListener(FigureListener l)
Description copied from interface:FigureRemoves a listener for FigureEvent's.- Specified by:
removeFigureListenerin interfaceFigure
-
addNotify
public void addNotify(Drawing d)
Description copied from interface:FigureInforms a figure, that it has been added to a drawing. The figure must inform all FigureListeners that it has been added.
-
removeNotify
public void removeNotify(Drawing d)
Description copied from interface:FigureInforms a figure, that it has been removed from a drawing. The figure must inform all FigureListeners that it has been removed.- Specified by:
removeNotifyin interfaceFigure
-
fireAreaInvalidated
public void fireAreaInvalidated()
Notify all listenerList that have registered interest for notification on this event type.
-
fireFigureChanged
public void fireFigureChanged()
-
clone
public AbstractFigure clone()
Description copied from interface:FigureReturns a clone of the figure, with clones of all aggregated figures, such as children and decorators. The cloned figure does not clone the list of FigureListeners from its original.- Specified by:
clonein interfaceFigure- Overrides:
clonein classAbstractBean
-
remap
public void remap(java.util.Map<Figure,Figure> oldToNew, boolean disconnectIfNotInMap)
Description copied from interface:FigureAfter cloning a collection of figures, the ConnectionFigures contained in this collection still connect to the original figures instead of to the clones. Using This operation and providing a map, which maps from the original collection of figures to the new collection, connections can be remapped to the new figures.
-
createHandles
public java.util.Collection<Handle> createHandles(int detailLevel)
Description copied from interface:FigureCreates handles used to manipulate the figure.- Specified by:
createHandlesin interfaceFigure- Parameters:
detailLevel- The detail level of the handles. Usually this is 0 for bounding box handles and 1 for point handles. The value -1 is used by the SelectAreaTracker and the HandleTracker to highlight figures, over which the mouse pointer is hovering.- Returns:
- a Collection of handles
- See Also:
Handle
-
getCursor
public java.awt.Cursor getCursor(java.awt.geom.Point2D.Double p)
Description copied from interface:FigureReturns a cursor for the specified location.
-
setBounds
public final void setBounds(java.awt.geom.Rectangle2D.Double bounds)
-
setBounds
public void setBounds(java.awt.geom.Point2D.Double anchor, java.awt.geom.Point2D.Double lead)Description copied from interface:FigureSets the logical and untransformed bounds of the figure.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:
figure.willChange(); figure.setBounds(...); figure.changed();
- Specified by:
setBoundsin interfaceFigure- Parameters:
anchor- the start point of the boundslead- the end point of the bounds- See Also:
Figure.getBounds()
-
willChange
public void willChange()
Informs that a figure is about to change something that affects the contents of its display box.- Specified by:
willChangein interfaceFigure- See Also:
Figure.changed()
-
changed
public void changed()
Informs that a figure changed the area of its display box.- Specified by:
changedin interfaceFigure- See Also:
Figure.willChange()
-
findConnector
public Connector findConnector(java.awt.geom.Point2D.Double p, ConnectionFigure prototype)
Returns the Figures connector for the specified location. By default a ChopBoxConnector is returned.- Specified by:
findConnectorin interfaceFigure- Parameters:
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.- See Also:
ChopRectangleConnector
-
includes
public boolean includes(Figure figure)
Description copied from interface:FigureChecks whether the given figure is contained in this figure. A figure includes itself.
-
findFigureInside
@Nullable public Figure findFigureInside(java.awt.geom.Point2D.Double p)
Description copied from interface:FigureFinds the innermost figure at the specified location.In case of a
CompositeFigure, this method descends into its children and into its children's children until the innermost figure is found.This functionality is implemented using the Chain of Responsibility design pattern. A figure which is not composed of other figures returns itself if the point is contained by the figure. Composed figures pass the method call down to their children.
- Specified by:
findFigureInsidein interfaceFigure- Parameters:
p- A location on the drawing.- Returns:
- Returns the innermost figure at the location, or null if the location is not contained in a figure.
-
findCompatibleConnector
public Connector findCompatibleConnector(Connector c, boolean isStart)
Description copied from interface:FigureGets a compatible connector. If the provided connector is part of this figure, return the connector. If the provided connector is part of another figure, return a connector with the same semantics for this figure. Returns null, if no compatible connector is available.- Specified by:
findCompatibleConnectorin interfaceFigure
-
getActions
public java.util.Collection<javax.swing.Action> getActions(java.awt.geom.Point2D.Double p)
Returns a collection of actions which are presented to the user in a popup menu.The collection may contain null entries. These entries are used interpreted as separators in the popup menu.
- Specified by:
getActionsin interfaceFigure
-
getTool
public Tool getTool(java.awt.geom.Point2D.Double p)
Returns a specialized tool for the given coordinate.Returns null, if no specialized tool is available.
-
handleMouseClick
public boolean handleMouseClick(java.awt.geom.Point2D.Double p, java.awt.event.MouseEvent evt, DrawingView view)Handles a mouse click.- Specified by:
handleMouseClickin interfaceFigure- Parameters:
p- The location of the mouse event.evt- The mouse event.view- The drawing view which is the source of the mouse event.- Returns:
- Returns true, if the event was consumed.
-
handleDrop
public boolean handleDrop(java.awt.geom.Point2D.Double p, java.util.Collection<Figure> droppedFigures, DrawingView view)Description copied from interface:FigureHandles a drop.- Specified by:
handleDropin interfaceFigure- Parameters:
p- The location of the mouse event.droppedFigures- The dropped figures.view- The drawing view which is the source of the mouse event.- Returns:
- Returns true, if the figures should snap back to the location they were dragged from.
-
getEndPoint
public java.awt.geom.Point2D.Double getEndPoint()
Description copied from interface:FigureReturns the untransformed logical end point of the bounds.- Specified by:
getEndPointin interfaceFigure- See Also:
Figure.setBounds(java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Double)
-
getStartPoint
public java.awt.geom.Point2D.Double getStartPoint()
Description copied from interface:FigureReturns the untransformed logical start point of the bounds.- Specified by:
getStartPointin interfaceFigure- See Also:
Figure.setBounds(java.awt.geom.Point2D.Double, java.awt.geom.Point2D.Double)
-
getPreferredSize
public Dimension2DDouble getPreferredSize()
Description copied from interface:FigureThe preferred size is used by Layouter to determine the preferred size of a Figure. For most Figure's this is the same as the dimensions returned by getBounds.- Specified by:
getPreferredSizein interfaceFigure
-
isConnectable
public boolean isConnectable()
Checks whether this figure is connectable. By defaultAbstractFigurecan be connected.- Specified by:
isConnectablein interfaceFigure
-
setConnectable
public void setConnectable(boolean newValue)
-
isSelectable
public boolean isSelectable()
Checks whether this figure is selectable. By defaultAbstractFigurecan be selected.- Specified by:
isSelectablein interfaceFigure
-
setSelectable
public void setSelectable(boolean newValue)
-
isRemovable
public boolean isRemovable()
Checks whether this figure is removable. By defaultAbstractFigurecan be removed.- Specified by:
isRemovablein interfaceFigure
-
setRemovable
public void setRemovable(boolean newValue)
-
isTransformable
public boolean isTransformable()
Checks whether this figure is transformable. By defaultAbstractFigurecan be transformed.- Specified by:
isTransformablein interfaceFigure- See Also:
Figure.transform(java.awt.geom.AffineTransform)
-
setTransformable
public void setTransformable(boolean newValue)
-
isVisible
public boolean isVisible()
Checks whether this figure is visible. By defaultAbstractFigureis visible.
-
setVisible
public void setVisible(boolean newValue)
-
getDecomposition
public java.util.Collection<Figure> getDecomposition()
Description copied from interface:FigureReturns a decompositon of a figure into its parts. A figure is considered as a part of itself.- Specified by:
getDecompositionin interfaceFigure
-
requestRemove
public void requestRemove()
Description copied from interface:FigureFires aFigureListener.figureRequestRemoveevent.- Specified by:
requestRemovein interfaceFigure
-
getLayer
public int getLayer()
AbstractFigure always returns 0. Override this method if your figure needs to be on a different layer.
-
getToolTipText
public java.lang.String getToolTipText(java.awt.geom.Point2D.Double p)
Description copied from interface:FigureReturns a tooltip for the specified location on the figure.- Specified by:
getToolTipTextin interfaceFigure
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getConnectors
public java.util.Collection<Connector> getConnectors(ConnectionFigure prototype)
Description copied from interface:FigureReturns all connectors of this Figure for the specified prototype of a ConnectionFigure.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.
- Specified by:
getConnectorsin interfaceFigure- Parameters:
prototype- The prototype used to create a connection or null if unknown. This allows for specific connectors for different connection figures.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG