Class DefaultDrawing
- java.lang.Object
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, CompositeFigure, Drawing, Figure, DOMStorable
public class DefaultDrawing extends AbstractDrawing
A default implementation ofDrawinguseful for drawings which contain only a few figures.For larger drawings,
QuadTreeDrawingis recommended.FIXME - Maybe we should rename this class to SimpleDrawing or we should get rid of this class altogether.
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface org.jhotdraw.draw.CompositeFigure
LAYOUT_INSETS
-
Fields inherited from interface org.jhotdraw.draw.Figure
CONNECTABLE_PROPERTY, REMOVABLE_PROPERTY, SELECTABLE_PROPERTY, TRANSFORMABLE_PROPERTY
-
-
Constructor Summary
Constructors Constructor and Description DefaultDrawing()Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidbasicAdd(int index, Figure figure)Adds a child to the figure at the specified index without firing events.voiddraw(java.awt.Graphics2D g)Draws the figure.voiddraw(java.awt.Graphics2D g, java.util.Collection<Figure> children)voiddrawCanvas(java.awt.Graphics2D g)Draws on the canvas area.FigurefindFigure(java.awt.geom.Point2D.Double p)Finds a top level Figure.FigurefindFigureBehind(java.awt.geom.Point2D.Double p, java.util.Collection<? extends Figure> children)Finds a top level Figure which is behind the specified Figures.FigurefindFigureBehind(java.awt.geom.Point2D.Double p, Figure figure)Finds a top level Figure which is behind the specified Figure.FigurefindFigureExcept(java.awt.geom.Point2D.Double p, java.util.Collection<? extends Figure> ignore)Finds a top level Figure.FigurefindFigureExcept(java.awt.geom.Point2D.Double p, Figure ignore)Finds a top level Figure.FigurefindFigureInside(java.awt.geom.Point2D.Double p)Finds the innermost figure at the specified location.java.util.List<Figure>findFigures(java.awt.geom.Rectangle2D.Double bounds)Returns all figures that lie within or intersect the specified bounds.java.util.List<Figure>findFiguresWithin(java.awt.geom.Rectangle2D.Double bounds)Returns all figures that lie within the specified bounds.java.util.List<Figure>getFiguresFrontToBack()Returns an iterator to iterate in Z-order front to back over the children.intindexOf(Figure figure)Returns the index of the specified child.java.util.List<Figure>sort(java.util.Collection<? extends Figure> c)Returns a copy of the provided collection which is sorted in z order from back to front.-
Methods inherited from class org.jhotdraw.draw.AbstractDrawing
addInputFormat, addOutputFormat, addUndoableEditListener, clone, fireUndoableEditHappened, getDrawing, getFontRenderContext, getInputFormats, getLock, getOutputFormats, read, removeUndoableEditListener, setFontRenderContext, setInputFormats, setOutputFormats, write
-
Methods inherited from class org.jhotdraw.draw.AbstractAttributedCompositeFigure
drawFigure, get, getAttributes, getAttributesRestoreData, getFigureDrawBounds, getStroke, getStrokeMiterLimitFactor, hasAttribute, isAttributeEnabled, removeAttribute, restoreAttributesTo, set, setAttributeEnabled, setAttributes
-
Methods inherited from class org.jhotdraw.draw.AbstractCompositeFigure
add, add, addAll, addAll, addCompositeFigureListener, addNotify, basicAdd, basicAddAll, basicRemove, basicRemoveAll, basicRemoveAllChildren, basicRemoveChild, bringToFront, changed, contains, contains, createHandles, findChild, findChildIndex, getBounds, getChild, getChildCount, getChildren, getChildrenFrontToBack, getDecomposition, getDrawingArea, getLayouter, getPreferredSize, getTransformRestoreData, layout, remove, removeAll, removeAllChildren, removeChild, removeCompositeFigureListener, removeNotify, restoreTransformTo, sendToBack, setBounds, setLayouter, transform, willChange
-
Methods inherited from class org.jhotdraw.draw.AbstractFigure
addFigureListener, findCompatibleConnector, findConnector, fireAreaInvalidated, fireFigureChanged, getActions, getConnectors, getCursor, getEndPoint, getLayer, getStartPoint, getTool, getToolTipText, handleDrop, handleMouseClick, includes, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, remap, removeFigureListener, requestRemove, setBounds, setConnectable, setRemovable, setSelectable, setTransformable, setVisible, toString
-
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.Drawing
add, add, addAll, addAll, basicAdd, basicAddAll, basicRemove, basicRemoveAll, bringToFront, remove, removeAll, sendToBack
-
Methods inherited from interface org.jhotdraw.draw.CompositeFigure
addCompositeFigureListener, basicRemoveAllChildren, basicRemoveChild, contains, getChild, getChildCount, getChildren, getLayouter, layout, removeAllChildren, removeChild, removeCompositeFigureListener, setLayouter
-
Methods inherited from interface org.jhotdraw.draw.Figure
addFigureListener, addNotify, addPropertyChangeListener, changed, contains, createHandles, findCompatibleConnector, findConnector, get, getActions, getAttributes, getAttributesRestoreData, getBounds, getConnectors, getCursor, getDecomposition, getDrawingArea, getEndPoint, getLayer, getPreferredSize, getStartPoint, getTool, getToolTipText, getTransformRestoreData, handleDrop, handleMouseClick, includes, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, remap, removeFigureListener, removeNotify, removePropertyChangeListener, requestRemove, restoreAttributesTo, restoreTransformTo, set, setBounds, transform, willChange
-
-
-
-
Method Detail
-
basicAdd
public void basicAdd(int index, Figure figure)Description copied from interface:CompositeFigureAdds a child to the figure at the specified index without firing events.This method can be used to reinsert a child figure which has been temporarily removed from this CompositeFigure (for example to reorder the sequence of the children) and to efficiently build a drawing from an
InputFormat.- Specified by:
basicAddin interfaceCompositeFigure- Specified by:
basicAddin interfaceDrawing- Overrides:
basicAddin classAbstractCompositeFigurefigure- that is part of the drawing and should be removed- See Also:
Drawing.basicRemove(Figure)
-
draw
public void draw(java.awt.Graphics2D g)
Description copied from interface:FigureDraws the figure.- Specified by:
drawin interfaceFigure- Overrides:
drawin classAbstractCompositeFigure- Parameters:
g- The Graphics2D to draw to.
-
draw
public void draw(java.awt.Graphics2D g, java.util.Collection<Figure> children)
-
sort
public java.util.List<Figure> sort(java.util.Collection<? extends Figure> c)
Description copied from interface:DrawingReturns a copy of the provided collection which is sorted in z order from back to front.
-
findFigure
public Figure findFigure(java.awt.geom.Point2D.Double p)
Description copied from interface:DrawingFinds a top level Figure. Use this call for hit detection that should not descend into children of composite figures.Use
Drawing.findFigureInside(java.awt.geom.Point2D.Double)If you need to descend into children of composite figures.
-
findFigureExcept
public Figure findFigureExcept(java.awt.geom.Point2D.Double p, Figure ignore)
Description copied from interface:DrawingFinds a top level Figure. Use this call for hit detection that should not descend into the figure's children.
-
findFigureBehind
public Figure findFigureBehind(java.awt.geom.Point2D.Double p, Figure figure)
Description copied from interface:DrawingFinds a top level Figure which is behind the specified Figure.
-
findFigureBehind
public Figure findFigureBehind(java.awt.geom.Point2D.Double p, java.util.Collection<? extends Figure> children)
Description copied from interface:DrawingFinds a top level Figure which is behind the specified Figures.
-
findFigureExcept
public Figure findFigureExcept(java.awt.geom.Point2D.Double p, java.util.Collection<? extends Figure> ignore)
Description copied from interface:DrawingFinds a top level Figure. Use this call for hit detection that should not descend into the figure's children.
-
findFigures
public java.util.List<Figure> findFigures(java.awt.geom.Rectangle2D.Double bounds)
Description copied from interface:DrawingReturns all figures that lie within or intersect the specified bounds. The figures are returned in Z-order from back to front.
-
findFiguresWithin
public java.util.List<Figure> findFiguresWithin(java.awt.geom.Rectangle2D.Double bounds)
Description copied from interface:DrawingReturns all figures that lie within the specified bounds. The figures are returned in Z-order from back to front.
-
findFigureInside
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 interfaceDrawing- Specified by:
findFigureInsidein interfaceFigure- Overrides:
findFigureInsidein classAbstractCompositeFigure- 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.
-
getFiguresFrontToBack
public java.util.List<Figure> getFiguresFrontToBack()
Returns an iterator to iterate in Z-order front to back over the children.
-
indexOf
public int indexOf(Figure figure)
Description copied from interface:CompositeFigureReturns the index of the specified child.This is a convenience method for calling
getChildren().indexOf(index);.- Specified by:
indexOfin interfaceCompositeFigure- Overrides:
indexOfin classAbstractCompositeFigure- Returns:
- The index of the child, or -1 if the specified figure is not a child of this CompositeFigure.
-
drawCanvas
public void drawCanvas(java.awt.Graphics2D g)
Description copied from interface:DrawingDraws on the canvas area. The canvas is the background area onto which the drawing is drawn.By convention this method is only invoked by
DrawingView.AttributeKeysdefines a number of attribute keys which can be used to determine what to draw on the canvas.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG