CH.ifa.draw.framework
Interface DrawingView
-
- All Superinterfaces:
- DrawingChangeListener, java.util.EventListener, java.awt.image.ImageObserver
- All Known Implementing Classes:
- JooneStandardDrawingView, 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
Observer
DrawingView observes drawing for changes via the DrawingListener interface.
State
DrawingView plays the role of the StateContext in the State pattern. Tool is the State.
Strategy
DrawingView is the StrategyContext in the Strategy pattern with regard to the UpdateStrategy.
DrawingView is the StrategyContext for the PointConstrainer.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method and Description Figureadd(Figure figure)Adds a figure to the drawing.voidaddAll(java.util.Vector figures)Adds a vector of figures to the drawing.voidaddToSelection(Figure figure)Adds a figure to the current selection.voidaddToSelectionAll(java.util.Vector figures)Adds a vector of figures to the current selection.voidcheckDamage()Checks whether the drawing has some accumulated damagevoidclearSelection()Clears the current selection.java.awt.ImagecreateImage(int width, int height)Creates an image with the given dimensionsvoiddrawAll(java.awt.Graphics g)Draws the contents of the drawing view.voiddrawBackground(java.awt.Graphics g)Draws the background.voiddrawDrawing(java.awt.Graphics g)Draws the drawing.voiddrawHandles(java.awt.Graphics g)Draws the currently active handles.Drawingdrawing()Gets the drawing.DrawingEditoreditor()Gets the editor.HandlefindHandle(int x, int y)Finds a handle at the given coordinates.voidfreezeView()Freezes the view by acquiring the drawing lock.java.awt.ColorgetBackground()Gets the background color of the DrawingViewPointConstrainergetConstrainer()Gets the current grid setting.FigureSelectiongetFigureSelection()Gets the current selection as a FigureSelection.java.awt.GraphicsgetGraphics()Gets a graphic to draw intojava.awt.DimensiongetMinimumSize()Gets the minimum dimension of the drawing.java.awt.DimensiongetPreferredSize()Gets the preferred dimension of the drawing..java.awt.DimensiongetSize()Gets the size of the drawing.java.awt.PointlastClick()Gets the position of the last click inside the view.voidpaint(java.awt.Graphics g)Paints the drawing view.Figureremove(Figure figure)Removes a figure from the drawing.voidremoveFromSelection(Figure figure)Removes a figure from the selection.voidrepairDamage()Repair the damaged areajava.util.Vectorselection()Gets the currently selected figures.intselectionCount()Gets the number of selected figures.FigureEnumerationselectionElements()Gets an enumeration over the currently selected figures.java.util.VectorselectionZOrdered()Gets the currently selected figures in Z order.voidsetBackground(java.awt.Color c)Gets the background color of the DrawingViewvoidsetConstrainer(PointConstrainer p)Sets the current point constrainer.voidsetCursor(java.awt.Cursor c)Sets the cursor of the DrawingViewvoidsetDisplayUpdate(Painter updateStrategy)Sets the current display update strategy.voidsetDrawing(Drawing d)Sets and installs another drawing in the view.voidsetEditor(DrawingEditor editor)Sets the view's editor.voidtoggleSelection(Figure figure)If a figure isn't selected it is added to the selection.Tooltool()Gets the current tool.voidunfreezeView()Unfreezes the view by releasing the drawing lock.-
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.
-
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()
-
-
DataMelt 3.0 © DataMelt by jWork.ORG