public class DefaultDrawing extends AbstractDrawing
Drawing useful for drawings which
contain only a few figures.
For larger drawings, QuadTreeDrawing is recommended.
FIXME - Maybe we should rename this class to SimpleDrawing or we should get rid of this class altogether.
AbstractCompositeFigure.EventHandlercachedBounds, cachedDrawingArea, children, eventHandler, layouterchangingDepth, listenerListpropertySupportLAYOUT_INSETSCONNECTABLE_PROPERTY, REMOVABLE_PROPERTY, SELECTABLE_PROPERTY, TRANSFORMABLE_PROPERTY| Constructor and Description |
|---|
DefaultDrawing()
Creates a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
void |
basicAdd(int index,
Figure figure)
Adds a child to the figure at the specified index without
firing events.
|
void |
draw(java.awt.Graphics2D g)
Draws the figure.
|
void |
draw(java.awt.Graphics2D g,
java.util.Collection<Figure> children) |
void |
drawCanvas(java.awt.Graphics2D g)
Draws on the canvas area.
|
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
.
|
Figure |
findFigure(java.awt.geom.Point2D.Double p)
Finds a top level Figure.
|
Figure |
findFigureBehind(java.awt.geom.Point2D.Double p,
java.util.Collection<? extends Figure> children)
Finds a top level Figure which is behind the specified Figures.
|
Figure |
findFigureBehind(java.awt.geom.Point2D.Double p,
Figure figure)
Finds a top level Figure which is behind the specified Figure.
|
Figure |
findFigureExcept(java.awt.geom.Point2D.Double p,
java.util.Collection<? extends Figure> ignore)
Finds a top level Figure.
|
Figure |
findFigureExcept(java.awt.geom.Point2D.Double p,
Figure ignore)
Finds a top level Figure.
|
Figure |
findFigureInside(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.
|
int |
indexOf(Figure figure)
Returns the index of the specified child.
|
protected void |
setAttributeOnChildren(AttributeKey key,
java.lang.Object newValue) |
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.
|
addInputFormat, addOutputFormat, addUndoableEditListener, clone, fireUndoableEditHappened, getDrawing, getFontRenderContext, getInputFormats, getLock, getOutputFormats, read, removeUndoableEditListener, setFontRenderContext, setInputFormats, setOutputFormats, writeapplyAttributesTo, drawChildren, drawFigure, drawText, get, getAttributeKey, getAttributes, getAttributesRestoreData, getFigureDrawBounds, getStroke, getStrokeMiterLimitFactor, hasAttribute, isAttributeEnabled, readAttributes, removeAttribute, restoreAttributesTo, set, setAttributeEnabled, setAttributes, writeAttributesadd, add, addAll, addAll, addCompositeFigureListener, addNotify, basicAdd, basicAddAll, basicRemove, basicRemoveAll, basicRemoveAllChildren, basicRemoveChild, bringToFront, changed, contains, contains, createEventHandler, createHandles, findChild, findChildIndex, fireFigureAdded, fireFigureRemoved, getBounds, getChild, getChildCount, getChildren, getChildrenFrontToBack, getDecomposition, getDrawingArea, getLayouter, getPreferredSize, getTransformRestoreData, invalidate, layout, remove, removeAll, removeAllChildren, removeChild, removeCompositeFigureListener, removeNotify, restoreTransformTo, sendToBack, setBounds, setLayouter, transform, validate, willChangeaddFigureListener, findCompatibleConnector, findConnector, fireAreaInvalidated, fireAreaInvalidated, fireAreaInvalidated, fireAttributeChanged, fireFigureAdded, fireFigureChanged, fireFigureChanged, fireFigureChanged, fireFigureHandlesChanged, fireFigureRemoved, fireFigureRequestRemove, getActions, getChangingDepth, getConnectors, getCursor, getEndPoint, getLayer, getStartPoint, getTool, getToolTipText, handleDrop, handleMouseClick, includes, isChanging, isConnectable, isRemovable, isSelectable, isTransformable, isVisible, remap, removeFigureListener, requestRemove, setBounds, setConnectable, setRemovable, setSelectable, setTransformable, setVisible, toStringaddPropertyChangeListener, addPropertyChangeListener, firePropertyChange, firePropertyChange, firePropertyChange, getPropertyChangeListeners, removePropertyChangeListener, removePropertyChangeListenerequals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitadd, add, addAll, addAll, basicAdd, basicAddAll, basicRemove, basicRemoveAll, bringToFront, remove, removeAll, sendToBackaddCompositeFigureListener, basicRemoveAllChildren, basicRemoveChild, contains, getChild, getChildCount, getChildren, getLayouter, layout, removeAllChildren, removeChild, removeCompositeFigureListener, setLayouteraddFigureListener, 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, willChangepublic void basicAdd(int index,
Figure figure)
CompositeFigure
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.
basicAdd in interface CompositeFigurebasicAdd in interface DrawingbasicAdd in class AbstractCompositeFigurefigure - that is part of the drawing and should be removedDrawing.basicRemove(Figure)public void draw(java.awt.Graphics2D g)
Figuredraw in interface Figuredraw in class AbstractCompositeFigureg - The Graphics2D to draw to.public void draw(java.awt.Graphics2D g,
java.util.Collection<Figure> children)
public java.util.List<Figure> sort(java.util.Collection<? extends Figure> c)
Drawingpublic Figure findFigure(java.awt.geom.Point2D.Double p)
Drawing
Use Drawing.findFigureInside(java.awt.geom.Point2D.Double) If you need to descend into children of
composite figures.
public Figure findFigureExcept(java.awt.geom.Point2D.Double p, Figure ignore)
Drawingpublic Figure findFigureBehind(java.awt.geom.Point2D.Double p, Figure figure)
Drawingpublic Figure findFigureBehind(java.awt.geom.Point2D.Double p, java.util.Collection<? extends Figure> children)
Drawingpublic Figure findFigureExcept(java.awt.geom.Point2D.Double p, java.util.Collection<? extends Figure> ignore)
Drawingpublic java.util.List<Figure> findFigures(java.awt.geom.Rectangle2D.Double bounds)
Drawingpublic java.util.List<Figure> findFiguresWithin(java.awt.geom.Rectangle2D.Double bounds)
Drawingpublic Figure findFigureInside(java.awt.geom.Point2D.Double p)
Figure
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.
findFigureInside in interface DrawingfindFigureInside in interface FigurefindFigureInside in class AbstractCompositeFigurep - A location on the drawing.public java.util.List<Figure> getFiguresFrontToBack()
protected void setAttributeOnChildren(AttributeKey key, java.lang.Object newValue)
setAttributeOnChildren in class AbstractAttributedCompositeFigurepublic int indexOf(Figure figure)
CompositeFigure
This is a convenience method for calling
getChildren().indexOf(index);.
indexOf in interface CompositeFigureindexOf in class AbstractCompositeFigureprotected void drawFill(java.awt.Graphics2D g)
AbstractAttributedCompositeFiguredrawFill in class AbstractAttributedCompositeFigureprotected void drawStroke(java.awt.Graphics2D g)
AbstractAttributedCompositeFiguredrawStroke in class AbstractAttributedCompositeFigurepublic void drawCanvas(java.awt.Graphics2D g)
Drawing
By convention this method is only invoked by DrawingView.
AttributeKeys defines a number of attribute keys which can be
used to determine what to draw on the canvas.