JHotDraw 7.0.9

org.jhotdraw.draw
Interface DrawingView

All Known Implementing Classes:
DefaultDrawingView

public interface DrawingView

DrawingView renders a Drawing and listens to its changes. It receives user input and forwards it to registered listeners.

Version:
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

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 editor's constrainer.
 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.
 double getScaleFactor()
          Gets the scale factor of the drawing view.
 java.util.Set<Figure> getSelectedFigures()
          Gets the current selection as a FigureSelection.
 int getSelectionCount()
          Gets the number of selected figures.
 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 setConstrainer(Constrainer constrainer)
          Sets the editor's 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 setScaleFactor(double newValue)
          Sets the scale factor of the drawing view.
 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.
 

Method Detail

getDrawing

Drawing getDrawing()
Gets the drawing.


setDrawing

void setDrawing(Drawing d)
Sets and installs another drawing in the view.


setCursor

void setCursor(java.awt.Cursor c)
Sets the cursor of the DrawingView


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 current selection as a FigureSelection. A FigureSelection can be cut, copied, pasted.


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.


setConstrainer

void setConstrainer(Constrainer constrainer)
Sets the editor's constrainer.


getConstrainer

Constrainer getConstrainer()
Gets the editor's constrainer.


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.


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.


getHandleDetailLevel

int getHandleDetailLevel()
Returns the detail level of the handles.


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.


addPropertyChangeListener

void addPropertyChangeListener(java.beans.PropertyChangeListener listener)

removePropertyChangeListener

void removePropertyChangeListener(java.beans.PropertyChangeListener listener)

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