CH.ifa.draw.framework
Interface DrawingView

All Superinterfaces:
DrawingChangeListener, java.util.EventListener, java.awt.image.ImageObserver
All Known Implementing Classes:
StandardDrawingView

public interface DrawingView
extends java.awt.image.ImageObserver, DrawingChangeListener

DrawingView renders a Drawing and listens to its changes. It receives user input and delegates it to the current tool.


Design Patterns

 o Observer
DrawingView observes drawing for changes via the DrawingListener interface.
 o State
DrawingView plays the role of the StateContext in the State pattern. Tool is the State.
 o Strategy
DrawingView is the StrategyContext in the Strategy pattern with regard to the UpdateStrategy.
DrawingView is the StrategyContext for the PointConstrainer.

See Also:
Drawing, Painter, Tool

Field Summary
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Method Summary
 Figure add(Figure figure)
          Adds a figure to the drawing.
 void addAll(java.util.Vector figures)
          Adds a vector of figures to the drawing.
 void addToSelection(Figure figure)
          Adds a figure to the current selection.
 void addToSelectionAll(java.util.Vector figures)
          Adds a vector of figures to the current selection.
 void checkDamage()
          Checks whether the drawing has some accumulated damage
 void clearSelection()
          Clears the current selection.
 java.awt.Image createImage(int width, int height)
          Creates an image with the given dimensions
 void drawAll(java.awt.Graphics g)
          Draws the contents of the drawing view.
 void drawBackground(java.awt.Graphics g)
          Draws the background.
 void drawDrawing(java.awt.Graphics g)
          Draws the drawing.
 void drawHandles(java.awt.Graphics g)
          Draws the currently active handles.
 Drawing drawing()
          Gets the drawing.
 DrawingEditor editor()
          Gets the editor.
 Handle findHandle(int x, int y)
          Finds a handle at the given coordinates.
 void freezeView()
          Freezes the view by acquiring the drawing lock.
 java.awt.Color getBackground()
          Gets the background color of the DrawingView
 PointConstrainer getConstrainer()
          Gets the current grid setting.
 FigureSelection getFigureSelection()
          Gets the current selection as a FigureSelection.
 java.awt.Graphics getGraphics()
          Gets a graphic to draw into
 java.awt.Dimension getMinimumSize()
          Gets the minimum dimension of the drawing.
 java.awt.Dimension getPreferredSize()
          Gets the preferred dimension of the drawing..
 java.awt.Dimension getSize()
          Gets the size of the drawing.
 java.awt.Point lastClick()
          Gets the position of the last click inside the view.
 void paint(java.awt.Graphics g)
          Paints the drawing view.
 Figure remove(Figure figure)
          Removes a figure from the drawing.
 void removeFromSelection(Figure figure)
          Removes a figure from the selection.
 void repairDamage()
          Repair the damaged area
 java.util.Vector selection()
          Gets the currently selected figures.
 int selectionCount()
          Gets the number of selected figures.
 FigureEnumeration selectionElements()
          Gets an enumeration over the currently selected figures.
 java.util.Vector selectionZOrdered()
          Gets the currently selected figures in Z order.
 void setBackground(java.awt.Color c)
          Gets the background color of the DrawingView
 void setConstrainer(PointConstrainer p)
          Sets the current point constrainer.
 void setCursor(java.awt.Cursor c)
          Sets the cursor of the DrawingView
 void setDisplayUpdate(Painter updateStrategy)
          Sets the current display update strategy.
 void setDrawing(Drawing d)
          Sets and installs another drawing in the view.
 void setEditor(DrawingEditor editor)
          Sets the view's editor.
 void toggleSelection(Figure figure)
          If a figure isn't selected it is added to the selection.
 Tool tool()
          Gets the current tool.
 void unfreezeView()
          Unfreezes the view by releasing the drawing lock.
 
Methods inherited from interface java.awt.image.ImageObserver
imageUpdate
 
Methods inherited from interface CH.ifa.draw.framework.DrawingChangeListener
drawingInvalidated, drawingRequestUpdate
 

Method Detail

setEditor

void setEditor(DrawingEditor editor)
Sets the view's editor.


tool

Tool tool()
Gets the current tool.


drawing

Drawing drawing()
Gets the drawing.


setDrawing

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


editor

DrawingEditor editor()
Gets the editor.


add

Figure add(Figure figure)
Adds a figure to the drawing.

Returns:
the added figure.

remove

Figure remove(Figure figure)
Removes a figure from the drawing.

Returns:
the removed figure

addAll

void addAll(java.util.Vector figures)
Adds a vector of figures to the drawing.


getSize

java.awt.Dimension getSize()
Gets the size of the drawing.


getMinimumSize

java.awt.Dimension getMinimumSize()
Gets the minimum dimension of the drawing.


getPreferredSize

java.awt.Dimension getPreferredSize()
Gets the preferred dimension of the drawing..


setDisplayUpdate

void setDisplayUpdate(Painter updateStrategy)
Sets the current display update strategy.

See Also:
Painter

selection

java.util.Vector selection()
Gets the currently selected figures.

Returns:
a vector with the selected figures. The vector is a copy of the current selection.

selectionElements

FigureEnumeration selectionElements()
Gets an enumeration over the currently selected figures.


selectionZOrdered

java.util.Vector selectionZOrdered()
Gets the currently selected figures in Z order.

Returns:
a vector with the selected figures. The vector is a copy of the current selection.
See Also:
selection()

selectionCount

int selectionCount()
Gets the number of selected figures.


addToSelection

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


addToSelectionAll

void addToSelectionAll(java.util.Vector figures)
Adds a vector 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.


getFigureSelection

FigureSelection getFigureSelection()
Gets the current selection as a FigureSelection. A FigureSelection can be cut, copied, pasted.


findHandle

Handle findHandle(int x,
                  int y)
Finds a handle at the given coordinates.

Returns:
the hit handle, null if no handle is found.

lastClick

java.awt.Point lastClick()
Gets the position of the last click inside the view.


setConstrainer

void setConstrainer(PointConstrainer p)
Sets the current point constrainer.


getConstrainer

PointConstrainer getConstrainer()
Gets the current grid setting.


checkDamage

void checkDamage()
Checks whether the drawing has some accumulated damage


repairDamage

void repairDamage()
Repair the damaged area


paint

void paint(java.awt.Graphics g)
Paints the drawing view. The actual drawing is delegated to the current update strategy.

See Also:
Painter

createImage

java.awt.Image createImage(int width,
                           int height)
Creates an image with the given dimensions


getGraphics

java.awt.Graphics getGraphics()
Gets a graphic to draw into


getBackground

java.awt.Color getBackground()
Gets the background color of the DrawingView


setBackground

void setBackground(java.awt.Color c)
Gets the background color of the DrawingView


drawAll

void drawAll(java.awt.Graphics g)
Draws the contents of the drawing view. The view has three layers: background, drawing, handles. The layers are drawn in back to front order.


drawHandles

void drawHandles(java.awt.Graphics g)
Draws the currently active handles.


drawDrawing

void drawDrawing(java.awt.Graphics g)
Draws the drawing.


drawBackground

void drawBackground(java.awt.Graphics g)
Draws the background. If a background pattern is set it is used to fill the background. Otherwise the background is filled in the background color.


setCursor

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


freezeView

void freezeView()
Freezes the view by acquiring the drawing lock.

See Also:
Drawing.lock()

unfreezeView

void unfreezeView()
Unfreezes the view by releasing the drawing lock.

See Also:
Drawing.unlock()