All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class CH.ifa.draw.standard.StandardDrawingView

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----java.awt.Panel
                           |
                           +----CH.ifa.draw.standard.StandardDrawingView

public class StandardDrawingView
extends Panel
implements DrawingView, MouseListener, MouseMotionListener, KeyListener
The standard implementation of DrawingView.

See Also:
DrawingView, Painter, Tool

Constructor Index

 o StandardDrawingView(DrawingEditor, int, int)
Constructs the view.

Method Index

 o add(Figure)
Adds a figure to the drawing.
 o addAll(Vector)
Adds a vector of figures to the drawing.
 o addBackground(Painter)
Adds a background.
 o addForeground(Painter)
Adds a foreground.
 o addToSelection(Figure)
Adds a figure to the current selection.
 o addToSelectionAll(Vector)
Adds a vector of figures to the current selection.
 o checkDamage()
Refreshes the drawing if there is some accumulated damage
 o clearSelection()
Clears the current selection.
 o constrainPoint(Point)
Constrains a point to the current grid.
 o drawAll(Graphics)
Draws the contents of the drawing view.
 o drawBackground(Graphics)
Draws the background.
 o drawDrawing(Graphics)
Draws the drawing.
 o drawHandles(Graphics)
Draws the currently active handles.
 o drawing()
Gets the drawing.
 o drawingInvalidated(DrawingChangeEvent)
 o drawingRequestUpdate(DrawingChangeEvent)
 o editor()
Gets the editor.
 o findHandle(int, int)
Finds a handle at the given coordinates.
 o freezeView()
Freezes the view by acquiring the drawing lock.
 o getConstrainer()
Gets the current constrainer.
 o getFigureSelection()
Gets the current selection as a FigureSelection.
 o getMinimumSize()
Gets the minimum dimension of the drawing.
 o getPreferredSize()
Gets the preferred dimension of the drawing..
 o handleCursorKey(int)
Handles cursor keys by moving all the selected figures one grid point in the cursor direction.
 o isFocusTraversable()
 o keyPressed(KeyEvent)
Handles key down events.
 o keyReleased(KeyEvent)
 o keyTyped(KeyEvent)
 o lastClick()
Gets the position of the last click inside the view.
 o mouseClicked(MouseEvent)
 o mouseDragged(MouseEvent)
Handles mouse drag events.
 o mouseEntered(MouseEvent)
 o mouseExited(MouseEvent)
 o mouseMoved(MouseEvent)
Handles mouse move events.
 o mousePressed(MouseEvent)
Handles mouse down events.
 o mouseReleased(MouseEvent)
Handles mouse up events.
 o paint(Graphics)
Paints the drawing view.
 o remove(Figure)
Removes a figure from the drawing.
 o removeBackground(Painter)
Removes a background.
 o removeForeground(Painter)
Removes a foreground.
 o removeFromSelection(Figure)
Removes a figure from the selection.
 o repairDamage()
 o selection()
Gets the currently selected figures.
 o selectionChanged()
Informs that the current selection changed.
 o selectionCount()
Gets the number of selected figures.
 o selectionElements()
Gets an enumeration over the currently selected figures.
 o selectionZOrdered()
Gets the currently selected figures in Z order.
 o setConstrainer(PointConstrainer)
Sets the grid spacing that is used to constrain points.
 o setDisplayUpdate(Painter)
Sets the current display update strategy.
 o setDrawing(Drawing)
Sets and installs another drawing in the view.
 o setEditor(DrawingEditor)
Sets the view's editor.
 o toggleSelection(Figure)
If a figure isn't selected it is added to the selection.
 o tool()
Gets the current tool.
 o unfreezeView()
Unfreezes the view by releasing the drawing lock.
 o update(Graphics)
Updates the drawing view.

Constructors

 o StandardDrawingView
 public StandardDrawingView(DrawingEditor editor,
                            int width,
                            int height)
Constructs the view.

Methods

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

 o tool
 public Tool tool()
Gets the current tool.

 o drawing
 public Drawing drawing()
Gets the drawing.

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

 o editor
 public DrawingEditor editor()
Gets the editor.

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

Returns:
the added figure.
 o remove
 public Figure remove(Figure figure)
Removes a figure from the drawing.

Returns:
the removed figure
 o addAll
 public void addAll(Vector figures)
Adds a vector of figures to the drawing.

 o getMinimumSize
 public Dimension getMinimumSize()
Gets the minimum dimension of the drawing.

Overrides:
getMinimumSize in class Container
 o getPreferredSize
 public Dimension getPreferredSize()
Gets the preferred dimension of the drawing..

Overrides:
getPreferredSize in class Container
 o setDisplayUpdate
 public void setDisplayUpdate(Painter updateStrategy)
Sets the current display update strategy.

See Also:
UpdateStrategy
 o selection
 public Vector selection()
Gets the currently selected figures.

Returns:
a vector with the selected figures. The vector is a copy of the current selection.
 o selectionElements
 public FigureEnumeration selectionElements()
Gets an enumeration over the currently selected figures.

 o selectionZOrdered
 public 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
 o selectionCount
 public int selectionCount()
Gets the number of selected figures.

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

 o addToSelectionAll
 public void addToSelectionAll(Vector figures)
Adds a vector of figures to the current selection.

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

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

 o clearSelection
 public void clearSelection()
Clears the current selection.

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

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

Returns:
the hit handle, null if no handle is found.
 o selectionChanged
 protected void selectionChanged()
Informs that the current selection changed. By default this event is forwarded to the drawing editor.

 o lastClick
 public Point lastClick()
Gets the position of the last click inside the view.

 o setConstrainer
 public void setConstrainer(PointConstrainer c)
Sets the grid spacing that is used to constrain points.

 o getConstrainer
 public PointConstrainer getConstrainer()
Gets the current constrainer.

 o constrainPoint
 protected Point constrainPoint(Point p)
Constrains a point to the current grid.

 o mousePressed
 public void mousePressed(MouseEvent e)
Handles mouse down events. The event is delegated to the currently active tool.

Returns:
whether the event was handled.
 o mouseDragged
 public void mouseDragged(MouseEvent e)
Handles mouse drag events. The event is delegated to the currently active tool.

Returns:
whether the event was handled.
 o mouseMoved
 public void mouseMoved(MouseEvent e)
Handles mouse move events. The event is delegated to the currently active tool.

Returns:
whether the event was handled.
 o mouseReleased
 public void mouseReleased(MouseEvent e)
Handles mouse up events. The event is delegated to the currently active tool.

Returns:
whether the event was handled.
 o keyPressed
 public void keyPressed(KeyEvent e)
Handles key down events. Cursor keys are handled by the view the other key events are delegated to the currently active tool.

Returns:
whether the event was handled.
 o handleCursorKey
 protected void handleCursorKey(int key)
Handles cursor keys by moving all the selected figures one grid point in the cursor direction.

 o checkDamage
 public synchronized void checkDamage()
Refreshes the drawing if there is some accumulated damage

 o repairDamage
 public void repairDamage()
 o drawingInvalidated
 public void drawingInvalidated(DrawingChangeEvent e)
 o drawingRequestUpdate
 public void drawingRequestUpdate(DrawingChangeEvent e)
 o update
 public void update(Graphics g)
Updates the drawing view.

Overrides:
update in class Component
 o paint
 public void paint(Graphics g)
Paints the drawing view. The actual drawing is delegated to the current update strategy.

Overrides:
paint in class Container
See Also:
Painter
 o drawAll
 public void drawAll(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.

 o drawHandles
 public void drawHandles(Graphics g)
Draws the currently active handles.

 o drawDrawing
 public void drawDrawing(Graphics g)
Draws the drawing.

 o drawBackground
 public void drawBackground(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.

 o addBackground
 public void addBackground(Painter painter)
Adds a background.

 o removeBackground
 public void removeBackground(Painter painter)
Removes a background.

 o removeForeground
 public void removeForeground(Painter painter)
Removes a foreground.

 o addForeground
 public void addForeground(Painter painter)
Adds a foreground.

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

See Also:
lock
 o unfreezeView
 public void unfreezeView()
Unfreezes the view by releasing the drawing lock.

See Also:
unlock
 o isFocusTraversable
 public boolean isFocusTraversable()
Overrides:
isFocusTraversable in class Component
 o mouseEntered
 public void mouseEntered(MouseEvent e)
 o mouseExited
 public void mouseExited(MouseEvent e)
 o mouseClicked
 public void mouseClicked(MouseEvent e)
 o keyTyped
 public void keyTyped(KeyEvent e)
 o keyReleased
 public void keyReleased(KeyEvent e)

All Packages  Class Hierarchy  This Package  Previous  Next  Index