CH.ifa.draw.standard
Class StandardDrawingView
- java.lang.Object
-
- java.awt.Component
-
- java.awt.Container
-
- javax.swing.JComponent
-
- javax.swing.JPanel
-
- CH.ifa.draw.standard.StandardDrawingView
-
- All Implemented Interfaces:
- DrawingChangeListener, DrawingView, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible
- Direct Known Subclasses:
- JooneStandardDrawingView
public class StandardDrawingView extends javax.swing.JPanel implements DrawingView, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener
The standard implementation of DrawingView.- See Also:
DrawingView,Painter,Tool, Serialized Form
-
-
Nested Class Summary
-
Field Summary
-
Fields inherited from class javax.swing.JComponent
TOOL_TIP_TEXT_KEY, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
-
-
Constructor Summary
Constructors Constructor and Description StandardDrawingView(DrawingEditor editor, int width, int height)Constructs the view.
-
Method Summary
All Methods Instance Methods Concrete 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.voidaddBackground(Painter painter)Adds a background.voidaddForeground(Painter painter)Adds a foreground.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()Refreshes the drawing if there is some accumulated damagevoidclearSelection()Clears the current selection.voiddrawAll(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.voiddrawingInvalidated(DrawingChangeEvent e)Sent when an area is invalidvoiddrawingRequestUpdate(DrawingChangeEvent e)Sent when the drawing wants to be refreshedDrawingEditoreditor()Gets the editor.HandlefindHandle(int x, int y)Finds a handle at the given coordinates.voidfreezeView()Freezes the view by acquiring the drawing lock.PointConstrainergetConstrainer()Gets the current constrainer.FigureSelectiongetFigureSelection()Gets the current selection as a FigureSelection.java.awt.DimensiongetMinimumSize()Gets the minimum dimension of the drawing.java.awt.DimensiongetPreferredSize()Gets the preferred dimension of the drawing..booleanisFocusTraversable()voidkeyPressed(java.awt.event.KeyEvent e)Handles key down events.voidkeyReleased(java.awt.event.KeyEvent e)voidkeyTyped(java.awt.event.KeyEvent e)java.awt.PointlastClick()Gets the position of the last click inside the view.voidmouseClicked(java.awt.event.MouseEvent e)voidmouseDragged(java.awt.event.MouseEvent e)Handles mouse drag events.voidmouseEntered(java.awt.event.MouseEvent e)voidmouseExited(java.awt.event.MouseEvent e)voidmouseMoved(java.awt.event.MouseEvent e)Handles mouse move events.voidmousePressed(java.awt.event.MouseEvent e)Handles mouse down events.voidmouseReleased(java.awt.event.MouseEvent e)Handles mouse up events.voidpaint(java.awt.Graphics g)Paints the drawing view.Figureremove(Figure figure)Removes a figure from the drawing.voidremoveBackground(Painter painter)Removes a background.voidremoveForeground(Painter painter)Removes a foreground.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.voidsetConstrainer(PointConstrainer c)Sets the grid spacing that is used to constrain points.voidsetDisplayUpdate(Painter updateStrategy)Sets the current display update strategy.voidsetDisplayUpdate1(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.voidupdate(java.awt.Graphics g)Updates the drawing view.-
Methods inherited from class javax.swing.JPanel
getAccessibleContext, getUI, getUIClassID, setUI, updateUI
-
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintImmediately, paintImmediately, print, printAll, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction
-
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate
-
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, createImage, createImage, createVolatileImage, createVolatileImage, dispatchEvent, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface CH.ifa.draw.framework.DrawingView
createImage, getBackground, getGraphics, getSize, setBackground, setCursor
-
-
-
-
Constructor Detail
-
StandardDrawingView
public StandardDrawingView(DrawingEditor editor, int width, int height)
Constructs the view.
-
-
Method Detail
-
setEditor
public void setEditor(DrawingEditor editor)
Sets the view's editor.- Specified by:
setEditorin interfaceDrawingView
-
tool
public Tool tool()
Gets the current tool.- Specified by:
toolin interfaceDrawingView
-
drawing
public Drawing drawing()
Gets the drawing.- Specified by:
drawingin interfaceDrawingView
-
setDrawing
public void setDrawing(Drawing d)
Sets and installs another drawing in the view.- Specified by:
setDrawingin interfaceDrawingView
-
editor
public DrawingEditor editor()
Gets the editor.- Specified by:
editorin interfaceDrawingView
-
add
public Figure add(Figure figure)
Adds a figure to the drawing.- Specified by:
addin interfaceDrawingView- Returns:
- the added figure.
-
remove
public Figure remove(Figure figure)
Removes a figure from the drawing.- Specified by:
removein interfaceDrawingView- Returns:
- the removed figure
-
addAll
public void addAll(java.util.Vector figures)
Adds a vector of figures to the drawing.- Specified by:
addAllin interfaceDrawingView
-
getMinimumSize
public java.awt.Dimension getMinimumSize()
Gets the minimum dimension of the drawing.- Specified by:
getMinimumSizein interfaceDrawingView- Overrides:
getMinimumSizein classjavax.swing.JComponent
-
getPreferredSize
public java.awt.Dimension getPreferredSize()
Gets the preferred dimension of the drawing..- Specified by:
getPreferredSizein interfaceDrawingView- Overrides:
getPreferredSizein classjavax.swing.JComponent
-
setDisplayUpdate1
public void setDisplayUpdate1(Painter updateStrategy)
Sets the current display update strategy.- See Also:
Painter
-
selection
public java.util.Vector selection()
Gets the currently selected figures.- Specified by:
selectionin interfaceDrawingView- Returns:
- a vector with the selected figures. The vector is a copy of the current selection.
-
selectionElements
public FigureEnumeration selectionElements()
Gets an enumeration over the currently selected figures.- Specified by:
selectionElementsin interfaceDrawingView
-
selectionZOrdered
public java.util.Vector selectionZOrdered()
Gets the currently selected figures in Z order.- Specified by:
selectionZOrderedin interfaceDrawingView- Returns:
- a vector with the selected figures. The vector is a copy of the current selection.
- See Also:
selection()
-
selectionCount
public int selectionCount()
Gets the number of selected figures.- Specified by:
selectionCountin interfaceDrawingView
-
addToSelection
public void addToSelection(Figure figure)
Adds a figure to the current selection.- Specified by:
addToSelectionin interfaceDrawingView
-
addToSelectionAll
public void addToSelectionAll(java.util.Vector figures)
Adds a vector of figures to the current selection.- Specified by:
addToSelectionAllin interfaceDrawingView
-
removeFromSelection
public void removeFromSelection(Figure figure)
Removes a figure from the selection.- Specified by:
removeFromSelectionin interfaceDrawingView
-
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.- Specified by:
toggleSelectionin interfaceDrawingView
-
clearSelection
public void clearSelection()
Clears the current selection.- Specified by:
clearSelectionin interfaceDrawingView
-
getFigureSelection
public FigureSelection getFigureSelection()
Gets the current selection as a FigureSelection. A FigureSelection can be cut, copied, pasted.- Specified by:
getFigureSelectionin interfaceDrawingView
-
findHandle
public Handle findHandle(int x, int y)
Finds a handle at the given coordinates.- Specified by:
findHandlein interfaceDrawingView- Returns:
- the hit handle, null if no handle is found.
-
lastClick
public java.awt.Point lastClick()
Gets the position of the last click inside the view.- Specified by:
lastClickin interfaceDrawingView
-
setConstrainer
public void setConstrainer(PointConstrainer c)
Sets the grid spacing that is used to constrain points.- Specified by:
setConstrainerin interfaceDrawingView
-
getConstrainer
public PointConstrainer getConstrainer()
Gets the current constrainer.- Specified by:
getConstrainerin interfaceDrawingView
-
mousePressed
public void mousePressed(java.awt.event.MouseEvent e)
Handles mouse down events. The event is delegated to the currently active tool.- Specified by:
mousePressedin interfacejava.awt.event.MouseListener
-
mouseDragged
public void mouseDragged(java.awt.event.MouseEvent e)
Handles mouse drag events. The event is delegated to the currently active tool.- Specified by:
mouseDraggedin interfacejava.awt.event.MouseMotionListener
-
mouseMoved
public void mouseMoved(java.awt.event.MouseEvent e)
Handles mouse move events. The event is delegated to the currently active tool.- Specified by:
mouseMovedin interfacejava.awt.event.MouseMotionListener
-
mouseReleased
public void mouseReleased(java.awt.event.MouseEvent e)
Handles mouse up events. The event is delegated to the currently active tool.- Specified by:
mouseReleasedin interfacejava.awt.event.MouseListener
-
keyPressed
public void keyPressed(java.awt.event.KeyEvent e)
Handles key down events. Cursor keys are handled by the view the other key events are delegated to the currently active tool.- Specified by:
keyPressedin interfacejava.awt.event.KeyListener
-
checkDamage
public void checkDamage()
Refreshes the drawing if there is some accumulated damage- Specified by:
checkDamagein interfaceDrawingView
-
repairDamage
public void repairDamage()
Description copied from interface:DrawingViewRepair the damaged area- Specified by:
repairDamagein interfaceDrawingView
-
drawingInvalidated
public void drawingInvalidated(DrawingChangeEvent e)
Description copied from interface:DrawingChangeListenerSent when an area is invalid- Specified by:
drawingInvalidatedin interfaceDrawingChangeListener
-
drawingRequestUpdate
public void drawingRequestUpdate(DrawingChangeEvent e)
Description copied from interface:DrawingChangeListenerSent when the drawing wants to be refreshed- Specified by:
drawingRequestUpdatein interfaceDrawingChangeListener
-
update
public void update(java.awt.Graphics g)
Updates the drawing view.- Overrides:
updatein classjavax.swing.JComponent
-
paint
public void paint(java.awt.Graphics g)
Paints the drawing view. The actual drawing is delegated to the current update strategy.- Specified by:
paintin interfaceDrawingView- Overrides:
paintin classjavax.swing.JComponent- See Also:
Painter
-
drawAll
public 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.- Specified by:
drawAllin interfaceDrawingView
-
drawHandles
public void drawHandles(java.awt.Graphics g)
Draws the currently active handles.- Specified by:
drawHandlesin interfaceDrawingView
-
drawDrawing
public void drawDrawing(java.awt.Graphics g)
Draws the drawing.- Specified by:
drawDrawingin interfaceDrawingView
-
drawBackground
public 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.- Specified by:
drawBackgroundin interfaceDrawingView
-
addBackground
public void addBackground(Painter painter)
Adds a background.
-
removeBackground
public void removeBackground(Painter painter)
Removes a background.
-
removeForeground
public void removeForeground(Painter painter)
Removes a foreground.
-
addForeground
public void addForeground(Painter painter)
Adds a foreground.
-
freezeView
public void freezeView()
Freezes the view by acquiring the drawing lock.- Specified by:
freezeViewin interfaceDrawingView- See Also:
Drawing.lock()
-
unfreezeView
public void unfreezeView()
Unfreezes the view by releasing the drawing lock.- Specified by:
unfreezeViewin interfaceDrawingView- See Also:
Drawing.unlock()
-
isFocusTraversable
public boolean isFocusTraversable()
- Overrides:
isFocusTraversablein classjava.awt.Component
-
mouseEntered
public void mouseEntered(java.awt.event.MouseEvent e)
- Specified by:
mouseEnteredin interfacejava.awt.event.MouseListener
-
mouseExited
public void mouseExited(java.awt.event.MouseEvent e)
- Specified by:
mouseExitedin interfacejava.awt.event.MouseListener
-
mouseClicked
public void mouseClicked(java.awt.event.MouseEvent e)
- Specified by:
mouseClickedin interfacejava.awt.event.MouseListener
-
keyTyped
public void keyTyped(java.awt.event.KeyEvent e)
- Specified by:
keyTypedin interfacejava.awt.event.KeyListener
-
keyReleased
public void keyReleased(java.awt.event.KeyEvent e)
- Specified by:
keyReleasedin interfacejava.awt.event.KeyListener
-
setDisplayUpdate
public void setDisplayUpdate(Painter updateStrategy)
Description copied from interface:DrawingViewSets the current display update strategy.- Specified by:
setDisplayUpdatein interfaceDrawingView- See Also:
Painter
-
-
DataMelt 3.0 © DataMelt by jWork.ORG