JHotDraw 7.1

org.jhotdraw.draw
Interface DrawingView

All Known Implementing Classes:
DefaultDrawingView

public interface DrawingView

A DrawingView paints a Drawing on a JComponent.

To support editing, a DrawingView can paint Handles and the current Tool of the DrawingEditor on top of the drawing. It can render a Constrainer below the drawing.

Tools can register mouse and key listeners on the DrawingView.

A DrawingView can paint the drawing with a scale factor. It supports conversion between scaled view coordinates and drawing coordinates.

Version:
4.3 2007-12-25 Renamed property names from PROP_… to …_PROPERTY.
4.2 2007-09-12 The DrawingView is now responsible for holding the Constrainer objects which affect editing on this view.
4.1 2007-05-15 getSelectedFigures returns a Set instead of a Collection.
4.0 2006-12-03 Replaced operation getContainer by getComponent.
3.1 2006-03-15 Support for enabled state added.
3.0 2006-02-20 Changed to share a single DrawingEditor by multiple views.
2.0 2006-01-14 Changed to support double precision coordinates.
1.0 2003-12-01 Derived from JHotDraw 5.4b1.
Author:
Werner Randelshofer

Field Summary
static java.lang.String CONSTRAINER_PROPERTY
          This constant is used to identify the constrainer property of the DrawingView.
static java.lang.String CONSTRAINER_VISIBLE_PROPERTY
          This constant is used to identify the constrainer visible property of the DrawingView.
static java.lang.String CURSOR_PROPERTY
          This constant is used to identify the cursor property of the DrawingView.
static java.lang.String DRAWING_PROPERTY
          This constant is used to identify the drawing property of the DrawingView.
static java.lang.String ENABLED_PROPERTY
          This constant is used to identify the enabled property of the DrawingView.
static java.lang.String HANDLE_DETAIL_LEVEL_PROPERTY
          This constant is used to identify the handle detail level property of the DrawingView.
static java.lang.String INVISIBLE_CONSTRAINER_PROPERTY
          This constant is used to identify the invisible constrainer property of the DrawingView.
static java.lang.String SCALE_FACTOR_PROPERTY
          This constant is used to identify the scale factor property of the DrawingView.
static java.lang.String VISIBLE_CONSTRAINER_PROPERTY
          This constant is used to identify the visible constrainer property of the DrawingView.
 
Method Summary
 void addFigureSelectionListener(FigureSelectionListener fsl)
          Add a listener for selection changes in this DrawingView.
 void addKeyListener(java.awt.event.KeyListener l)
           
 void addMouseListener(java.awt.event.MouseListener l)
           
 void addMouseMotionListener(java.awt.event.MouseMotionListener l)
           
 void addNotify(DrawingEditor editor)
          Informs the view that it has been added to the specified editor.
 void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void addToSelection(java.util.Collection<Figure> figures)
          Adds a collection of figures to the current selection.
 void addToSelection(Figure figure)
          Adds a figure to the current selection.
 void clearSelection()
          Clears the current selection.
 java.awt.Point drawingToView(java.awt.geom.Point2D.Double p)
          Converts drawing coordinates to view coordinates.
 java.awt.Rectangle drawingToView(java.awt.geom.Rectangle2D.Double p)
          Converts drawing coordinates to view coordinates.
 Figure findFigure(java.awt.Point p)
          Finds a figure at the given point.
 java.util.Collection<Figure> findFigures(java.awt.Rectangle r)
          Returns all figures that lie within or intersect the specified bounds.
 java.util.Collection<Figure> findFiguresWithin(java.awt.Rectangle r)
          Returns all figures that lie within the specified bounds.
 Handle findHandle(java.awt.Point p)
          Finds a handle at the given coordinates.
 java.util.Collection<Handle> getCompatibleHandles(Handle handle)
          Gets compatible handles.
 javax.swing.JComponent getComponent()
          Returns the JComponent of the drawing view.
 Constrainer getConstrainer()
          Gets the current constrainer of this view.
 Drawing getDrawing()
          Gets the drawing.
 java.awt.geom.AffineTransform getDrawingToViewTransform()
          Gets an transform which can be used to convert drawing coordinates to view coordinates.
 int getHandleDetailLevel()
          Returns the detail level of the handles.
 Constrainer getInvisibleConstrainer()
          Gets the editor's constrainer for this view, for use, when the visible constrainer is turned off.
 double getScaleFactor()
          Gets the scale factor of the drawing view.
 java.util.Set<Figure> getSelectedFigures()
          Gets the selected figures.
 int getSelectionCount()
          Gets the number of selected figures.
 Constrainer getVisibleConstrainer()
          Gets the editor's constrainer for this view, for use, when the visible constrainer is turned on.
 boolean isConstrainerVisible()
          Returns true, if the visible Constrainer is in use, returns false, if the invisible Constrainer is in use.
 boolean isEnabled()
          Gets the enabled state of the drawing view.
 boolean isFigureSelected(Figure checkFigure)
          Test whether a given figure is selected.
 void removeFigureSelectionListener(FigureSelectionListener fsl)
          Remove a listener for selection changes in this DrawingView.
 void removeFromSelection(Figure figure)
          Removes a figure from the selection.
 void removeKeyListener(java.awt.event.KeyListener l)
           
 void removeMouseListener(java.awt.event.MouseListener l)
           
 void removeMouseMotionListener(java.awt.event.MouseMotionListener l)
           
 void removeNotify(DrawingEditor editor)
          Informs the view that it has been removed from the specified editor.
 void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
           
 void requestFocus()
           
 void selectAll()
          Selects all figures.
 void setConstrainerVisible(boolean newValue)
          Changes between a visible Constrainer and an invisible Constrainer.
 void setCursor(java.awt.Cursor c)
          Sets the cursor of the DrawingView.
 void setDrawing(Drawing d)
          Sets and installs another drawing in the view.
 void setEnabled(boolean newValue)
          Sets the enabled state of the drawing view.
 void setHandleDetailLevel(int newValue)
          The detail level of the handles.
 void setInvisibleConstrainer(Constrainer constrainer)
          Sets the editor's constrainer for this view, for use, when the visible constrainer is turned off.
 void setScaleFactor(double newValue)
          Sets the scale factor of the drawing view.
 void setVisibleConstrainer(Constrainer constrainer)
          Sets the editor's constrainer for this view, for use, when the visible constrainer is turned on.
 void toggleSelection(Figure figure)
          If a figure isn't selected it is added to the selection.
 java.awt.geom.Point2D.Double viewToDrawing(java.awt.Point p)
          Converts view coordinates to drawing coordinates.
 java.awt.geom.Rectangle2D.Double viewToDrawing(java.awt.Rectangle p)
          Converts view coordinates to drawing coordinates.
 

Field Detail

DRAWING_PROPERTY

static final java.lang.String DRAWING_PROPERTY
This constant is used to identify the drawing property of the DrawingView.

See Also:
Constant Field Values

CURSOR_PROPERTY

static final java.lang.String CURSOR_PROPERTY
This constant is used to identify the cursor property of the DrawingView.

See Also:
Constant Field Values

CONSTRAINER_PROPERTY

static final java.lang.String CONSTRAINER_PROPERTY
This constant is used to identify the constrainer property of the DrawingView.

See Also:
Constant Field Values

VISIBLE_CONSTRAINER_PROPERTY

static final java.lang.String VISIBLE_CONSTRAINER_PROPERTY
This constant is used to identify the visible constrainer property of the DrawingView.

See Also:
Constant Field Values

INVISIBLE_CONSTRAINER_PROPERTY

static final java.lang.String INVISIBLE_CONSTRAINER_PROPERTY
This constant is used to identify the invisible constrainer property of the DrawingView.

See Also:
Constant Field Values

CONSTRAINER_VISIBLE_PROPERTY

static final java.lang.String CONSTRAINER_VISIBLE_PROPERTY
This constant is used to identify the constrainer visible property of the DrawingView.

See Also:
Constant Field Values

SCALE_FACTOR_PROPERTY

static final java.lang.String SCALE_FACTOR_PROPERTY
This constant is used to identify the scale factor property of the DrawingView.

See Also:
Constant Field Values

HANDLE_DETAIL_LEVEL_PROPERTY

static final java.lang.String HANDLE_DETAIL_LEVEL_PROPERTY
This constant is used to identify the handle detail level property of the DrawingView.

See Also:
Constant Field Values

ENABLED_PROPERTY

static final java.lang.String ENABLED_PROPERTY
This constant is used to identify the enabled property of the DrawingView.

See Also:
Constant Field Values
Method Detail

getDrawing

Drawing getDrawing()
Gets the drawing. This is a bound property.


setDrawing

void setDrawing(Drawing d)
Sets and installs another drawing in the view. This is a bound property.


setCursor

void setCursor(java.awt.Cursor c)
Sets the cursor of the DrawingView. This is a bound property.


isFigureSelected

boolean isFigureSelected(Figure checkFigure)
Test whether a given figure is selected.


addToSelection

void addToSelection(Figure figure)
Adds a figure to the current selection.


addToSelection

void addToSelection(java.util.Collection<Figure> figures)
Adds a collection of figures to the current selection.


removeFromSelection

void removeFromSelection(Figure figure)
Removes a figure from the selection.


toggleSelection

void toggleSelection(Figure figure)
If a figure isn't selected it is added to the selection. Otherwise it is removed from the selection.


clearSelection

void clearSelection()
Clears the current selection.


selectAll

void selectAll()
Selects all figures.


getSelectedFigures

java.util.Set<Figure> getSelectedFigures()
Gets the selected figures. Returns an empty set, if no figures are selected.


getSelectionCount

int getSelectionCount()
Gets the number of selected figures.


findHandle

Handle findHandle(java.awt.Point p)
Finds a handle at the given coordinates.

Returns:
A handle, null if no handle is found.

getCompatibleHandles

java.util.Collection<Handle> getCompatibleHandles(Handle handle)
Gets compatible handles.

Returns:
A collection containing the handle and all compatible handles.

findFigure

Figure findFigure(java.awt.Point p)
Finds a figure at the given point.

Returns:
A figure, null if no figure is found.

findFigures

java.util.Collection<Figure> findFigures(java.awt.Rectangle r)
Returns all figures that lie within or intersect the specified bounds. The figures are returned in Z-order from back to front.


findFiguresWithin

java.util.Collection<Figure> findFiguresWithin(java.awt.Rectangle r)
Returns all figures that lie within the specified bounds. The figures are returned in Z-order from back to front.


addNotify

void addNotify(DrawingEditor editor)
Informs the view that it has been added to the specified editor. The view must draw the tool of the editor, if getActiveView() of the editor returns the view.


removeNotify

void removeNotify(DrawingEditor editor)
Informs the view that it has been removed from the specified editor. The view must not draw the tool from the editor anymore.


addMouseListener

void addMouseListener(java.awt.event.MouseListener l)

removeMouseListener

void removeMouseListener(java.awt.event.MouseListener l)

addKeyListener

void addKeyListener(java.awt.event.KeyListener l)

removeKeyListener

void removeKeyListener(java.awt.event.KeyListener l)

addMouseMotionListener

void addMouseMotionListener(java.awt.event.MouseMotionListener l)

removeMouseMotionListener

void removeMouseMotionListener(java.awt.event.MouseMotionListener l)

addFigureSelectionListener

void addFigureSelectionListener(FigureSelectionListener fsl)
Add a listener for selection changes in this DrawingView.

Parameters:
fsl - jhotdraw.framework.FigureSelectionListener

removeFigureSelectionListener

void removeFigureSelectionListener(FigureSelectionListener fsl)
Remove a listener for selection changes in this DrawingView.

Parameters:
fsl - jhotdraw.framework.FigureSelectionListener

requestFocus

void requestFocus()

drawingToView

java.awt.Point drawingToView(java.awt.geom.Point2D.Double p)
Converts drawing coordinates to view coordinates.


viewToDrawing

java.awt.geom.Point2D.Double viewToDrawing(java.awt.Point p)
Converts view coordinates to drawing coordinates.


drawingToView

java.awt.Rectangle drawingToView(java.awt.geom.Rectangle2D.Double p)
Converts drawing coordinates to view coordinates.


viewToDrawing

java.awt.geom.Rectangle2D.Double viewToDrawing(java.awt.Rectangle p)
Converts view coordinates to drawing coordinates.


getConstrainer

Constrainer getConstrainer()
Gets the current constrainer of this view. If isConstrainerVisible is true, this method returns getVisibleConstrainer, otherwise it returns getInvisibleConstrainer. This is a bound property.


setVisibleConstrainer

void setVisibleConstrainer(Constrainer constrainer)
Sets the editor's constrainer for this view, for use, when the visible constrainer is turned on. This is a bound property.


getVisibleConstrainer

Constrainer getVisibleConstrainer()
Gets the editor's constrainer for this view, for use, when the visible constrainer is turned on. This is a bound property.


setInvisibleConstrainer

void setInvisibleConstrainer(Constrainer constrainer)
Sets the editor's constrainer for this view, for use, when the visible constrainer is turned off. This is a bound property.


getInvisibleConstrainer

Constrainer getInvisibleConstrainer()
Gets the editor's constrainer for this view, for use, when the visible constrainer is turned off. This is a bound property.


setConstrainerVisible

void setConstrainerVisible(boolean newValue)
Changes between a visible Constrainer and an invisible Constrainer. This is a bound property.


isConstrainerVisible

boolean isConstrainerVisible()
Returns true, if the visible Constrainer is in use, returns false, if the invisible Constrainer is in use. This is a bound property.


getComponent

javax.swing.JComponent getComponent()
Returns the JComponent of the drawing view.


getDrawingToViewTransform

java.awt.geom.AffineTransform getDrawingToViewTransform()
Gets an transform which can be used to convert drawing coordinates to view coordinates.


getScaleFactor

double getScaleFactor()
Gets the scale factor of the drawing view. This is a bound property.


setScaleFactor

void setScaleFactor(double newValue)
Sets the scale factor of the drawing view. This is a bound property.


setHandleDetailLevel

void setHandleDetailLevel(int newValue)
The detail level of the handles. This is a bound property.


getHandleDetailLevel

int getHandleDetailLevel()
Returns the detail level of the handles. This is a bound property.


setEnabled

void setEnabled(boolean newValue)
Sets the enabled state of the drawing view. This is a bound property.


isEnabled

boolean isEnabled()
Gets the enabled state of the drawing view. This is a bound property.


addPropertyChangeListener

void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

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