JHotDraw 7.0.9

org.jhotdraw.draw
Class QuadTreeDrawing

java.lang.Object
  extended by org.jhotdraw.beans.AbstractBean
      extended by org.jhotdraw.draw.AbstractDrawing
          extended by org.jhotdraw.draw.QuadTreeDrawing
All Implemented Interfaces:
java.io.Serializable, java.lang.Cloneable, Drawing, DOMStorable
Direct Known Subclasses:
SVGDrawing

public class QuadTreeDrawing
extends AbstractDrawing

QuadTreeDrawing uses a QuadTree2DDouble to improve responsiveness of drawings which contain many figures.

FIXME - Rename this class to DefaultDrawingView.

Version:
2.2 2007-04-09 Added methods setCanvasSize, getCanvasSize.
2.1 2007-02-09 Moved FigureListener and UndoableEditListener into inner class.
2.0 2006-01-14 Changed to support double precision coordinates.
1.0 2003-12-01 Derived from JHotDraw 5.4b1.
Author:
Werner Randelshofer
See Also:
Serialized Form

Nested Class Summary
protected  class QuadTreeDrawing.FigureHandler
          Handles all figure events fired by Figures contained in the Drawing.
 
Field Summary
 
Fields inherited from class org.jhotdraw.draw.AbstractDrawing
listenerList
 
Fields inherited from class org.jhotdraw.beans.AbstractBean
propertySupport
 
Constructor Summary
QuadTreeDrawing()
          Creates a new instance.
 
Method Summary
 void basicAdd(int index, Figure figure)
          Reinserts a figure which was temporarily removed using basicRemove.
 void basicRemove(Figure figure)
          Removes a figure temporarily from the drawing.
 void bringToFront(Figure figure)
          Brings a figure to the front.
 boolean contains(Figure f)
          Returns true if this drawing contains the specified figure.
protected  QuadTreeDrawing.FigureHandler createFigureHandler()
           
 void draw(java.awt.Graphics2D g)
          Draws all the figures from back to front.
 void draw(java.awt.Graphics2D g, java.util.Collection<Figure> c)
           
 Figure findFigure(java.awt.geom.Point2D.Double p)
          Finds a top level Figure.
 Figure findFigureBehind(java.awt.geom.Point2D.Double p, java.util.Collection<Figure> figures)
          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 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 a figure but descends into a figure's children.
 java.util.List<Figure> findFigures(java.awt.geom.Rectangle2D.Double r)
          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.
 Dimension2DDouble getCanvasSize()
          Gets the canvas size of this drawing.
 java.util.List<Figure> getFigures()
          Returns the figures of the drawing.
 java.util.List<Figure> getFigures(java.awt.geom.Rectangle2D.Double bounds)
           
 java.util.List<Figure> getFiguresFrontToBack()
          Returns an iterator to iterate in Z-order front to back over the figures.
 int indexOf(Figure figure)
          Returns the index of the specified figure.
 void sendToBack(Figure figure)
          Sends a figure to the back of the drawing.
 void setCanvasSize(Dimension2DDouble newValue)
          Sets the canvas size for this drawing.
 java.util.List<Figure> sort(java.util.Collection<Figure> c)
          Implementation note: Sorting can not be done for orphaned figures.
 
Methods inherited from class org.jhotdraw.draw.AbstractDrawing
add, add, addAll, addAll, addDrawingListener, addUndoableEditListener, basicAdd, basicAddAll, basicRemoveAll, clear, fireAreaInvalidated, fireFigureAdded, fireFigureRemoved, fireUndoableEditHappened, getFigureCount, getFontRenderContext, getInputFormats, getLock, getOutputFormats, read, remove, removeAll, removeDrawingListener, removeUndoableEditListener, setFontRenderContext, setInputFormats, setOutputFormats, write
 
Methods inherited from class org.jhotdraw.beans.AbstractBean
addPropertyChangeListener, addPropertyChangeListener, clone, firePropertyChange, firePropertyChange, firePropertyChange, removePropertyChangeListener, removePropertyChangeListener
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

QuadTreeDrawing

public QuadTreeDrawing()
Creates a new instance.

Method Detail

createFigureHandler

protected QuadTreeDrawing.FigureHandler createFigureHandler()

indexOf

public int indexOf(Figure figure)
Description copied from interface: Drawing
Returns the index of the specified figure. Returns -1 if the Figure is not directly contained in this Drawing, for example if the Figure is a child of a CompositeFigure.


basicAdd

public void basicAdd(int index,
                     Figure figure)
Description copied from interface: Drawing
Reinserts a figure which was temporarily removed using basicRemove.

figure - that is part of the drawing and should be removed
See Also:
Drawing.basicRemove(Figure)

basicRemove

public void basicRemove(Figure figure)
Description copied from interface: Drawing
Removes a figure temporarily from the drawing.

Parameters:
figure - that is part of the drawing and should be removed
See Also:
#basicAdd(Figure

draw

public void draw(java.awt.Graphics2D g)
Description copied from interface: Drawing
Draws all the figures from back to front.


sort

public java.util.List<Figure> sort(java.util.Collection<Figure> c)
Implementation note: Sorting can not be done for orphaned figures.


draw

public void draw(java.awt.Graphics2D g,
                 java.util.Collection<Figure> c)

getFigures

public java.util.List<Figure> getFigures(java.awt.geom.Rectangle2D.Double bounds)

getFigures

public java.util.List<Figure> getFigures()
Description copied from interface: Drawing
Returns the figures of the drawing.

Returns:
A Collection of Figure's.

findFigureInside

public Figure findFigureInside(java.awt.geom.Point2D.Double p)
Description copied from interface: Drawing
Finds a figure but descends into a figure's children. Use this method to implement click-through hit detection, that is, you want to detect the inner most figure containing the given point.


getFiguresFrontToBack

public java.util.List<Figure> getFiguresFrontToBack()
Returns an iterator to iterate in Z-order front to back over the figures.


findFigure

public Figure findFigure(java.awt.geom.Point2D.Double p)
Description copied from interface: Drawing
Finds a top level Figure. Use this call for hit detection that should not descend into the figure's children.


findFigureExcept

public Figure findFigureExcept(java.awt.geom.Point2D.Double p,
                               Figure ignore)
Description copied from interface: Drawing
Finds a top level Figure. Use this call for hit detection that should not descend into the figure's children.


findFigureExcept

public Figure findFigureExcept(java.awt.geom.Point2D.Double p,
                               java.util.Collection ignore)
Description copied from interface: Drawing
Finds 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: Drawing
Finds a top level Figure which is behind the specified Figure.


findFigureBehind

public Figure findFigureBehind(java.awt.geom.Point2D.Double p,
                               java.util.Collection<Figure> figures)
Description copied from interface: Drawing
Finds a top level Figure which is behind the specified Figures.


findFigures

public java.util.List<Figure> findFigures(java.awt.geom.Rectangle2D.Double r)
Description copied from interface: Drawing
Returns 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: Drawing
Returns all figures that lie within the specified bounds. The figures are returned in Z-order from back to front.


bringToFront

public void bringToFront(Figure figure)
Description copied from interface: Drawing
Brings a figure to the front.

Parameters:
figure - that is part of the drawing

sendToBack

public void sendToBack(Figure figure)
Description copied from interface: Drawing
Sends a figure to the back of the drawing.

Parameters:
figure - that is part of the drawing

contains

public boolean contains(Figure f)
Description copied from interface: Drawing
Returns true if this drawing contains the specified figure.


setCanvasSize

public void setCanvasSize(Dimension2DDouble newValue)
Description copied from interface: Drawing
Sets the canvas size for this drawing.

If canvasSize is null, the size of the canvas is expected to be adjusted dynamically to fit the drawing areas of all figures contained in the drawing.

This is a bound property.

Parameters:
newValue - The canvas size, or null.

getCanvasSize

public Dimension2DDouble getCanvasSize()
Description copied from interface: Drawing
Gets the canvas size of this drawing. If null is returned, the canvas size needs to be adjusted dynamically to fit the drawing areas of all figures contained in the drawing.

Returns:
The canvas size, or null.

Copyright 1996-2007 (c) JHotDraw.org.
Some rights reserved.