|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.JPanel
org.jhotdraw.standard.NullDrawingView
public class NullDrawingView
This DrawingView provides a very basic implementation. It does not perform any functionality apart from keeping track of its state represented by some important fields. It is a Null-value object and is used instead of a null reference to avoid null pointer exception. This concept is known as the Null-value object bug pattern.
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class javax.swing.JPanel |
|---|
javax.swing.JPanel.AccessibleJPanel |
| Nested classes/interfaces inherited from class javax.swing.JComponent |
|---|
javax.swing.JComponent.AccessibleJComponent |
| Nested classes/interfaces inherited from class java.awt.Container |
|---|
java.awt.Container.AccessibleAWTContainer |
| Nested classes/interfaces inherited from class java.awt.Component |
|---|
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy |
| Field Summary | |
|---|---|
private static java.util.Hashtable |
drawingViewManager
|
private java.awt.Color |
myBackgroundColor
|
private Drawing |
myDrawing
|
private DrawingEditor |
myDrawingEditor
|
private Painter |
myUpdateStrategy
|
| Fields inherited from class javax.swing.JComponent |
|---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
| Fields inherited from class java.awt.Component |
|---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
| Fields inherited from interface java.awt.image.ImageObserver |
|---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
| Constructor Summary | |
|---|---|
protected |
NullDrawingView(DrawingEditor editor)
|
| Method Summary | |
|---|---|
Figure |
add(Figure figure)
Adds a figure to the drawing. |
void |
addAll(java.util.Collection figures)
Adds a collection of figures to the drawing. |
void |
addFigureSelectionListener(FigureSelectionListener fsl)
Add a listener for selection changes in this DrawingView. |
void |
addToSelection(Figure figure)
Adds a figure to the current selection. |
void |
addToSelectionAll(java.util.Collection figures)
Adds a Collection of figures to the current selection. |
void |
addToSelectionAll(FigureEnumeration fe)
Adds a FigureEnumeration 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 |
draw(java.awt.Graphics g,
FigureEnumeration fe)
Draws the given figures. |
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. |
void |
drawingInvalidated(DrawingEvent e)
Sent when an area is invalid |
void |
drawingRequestUpdate(DrawingEvent e)
Sent when the drawing wants to be refreshed |
void |
drawingTitleChanged(DrawingEvent e)
Sent when the drawing Title has changed |
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 |
FigureEnumeration |
getConnectionFigures(Figure inFigure)
Returns a FigureEnumeration of connection figures |
PointConstrainer |
getConstrainer()
Gets the current grid setting. |
Painter |
getDisplayUpdate()
Gets the current display update strategy. |
FigureSelection |
getFigureSelection()
Gets the current selection as a FigureSelection. |
java.awt.Graphics |
getGraphics()
Gets a graphic to draw into |
static DrawingView |
getManagedDrawingView(DrawingEditor editor)
|
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. |
FigureEnumeration |
insertFigures(FigureEnumeration inFigures,
int dx,
int dy,
boolean bCheck)
Inserts figures in a drawing at given offset. |
boolean |
isFigureSelected(Figure checkFigure)
Test whether a given figure is selected. |
boolean |
isInteractive()
Check whether the DrawingView is interactive, i.e. |
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 |
removeFigureSelectionListener(FigureSelectionListener fsl)
Remove a listener for selection changes in this DrawingView. |
void |
removeFromSelection(Figure figure)
Removes a figure from the selection. |
void |
repairDamage()
Repair the damaged area |
FigureEnumeration |
selection()
Gets an enumeration over the currently selected figures. |
int |
selectionCount()
Gets the number of selected figures. |
FigureEnumeration |
selectionZOrdered()
Gets the currently seleced figures in Z order. |
void |
setBackground(java.awt.Color c)
Sets the background color of the DrawingView |
void |
setConstrainer(PointConstrainer p)
Sets the current point constrainer. |
void |
setCursor(Cursor c)
Sets the cursor of the DrawingView |
void |
setDisplayUpdate(Painter newUpdateStrategy)
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 class javax.swing.JPanel |
|---|
getAccessibleContext, getUI, getUIClassID, paramString, setUI, updateUI |
| Methods inherited from class javax.swing.JComponent |
|---|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, 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, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update |
| Methods inherited from class java.awt.Container |
|---|
add, add, add, add, add, addContainerListener, addImpl, 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, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusBackward, transferFocusDownCycle, validate, validateTree |
| Methods inherited from class java.awt.Component |
|---|
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, 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, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, 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, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, 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, transferFocusUpCycle |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.awt.image.ImageObserver |
|---|
imageUpdate |
| Field Detail |
|---|
private DrawingEditor myDrawingEditor
private Drawing myDrawing
private Painter myUpdateStrategy
private java.awt.Color myBackgroundColor
private static java.util.Hashtable drawingViewManager
| Constructor Detail |
|---|
protected NullDrawingView(DrawingEditor editor)
| Method Detail |
|---|
public void setEditor(DrawingEditor editor)
setEditor in interface DrawingViewpublic Tool tool()
tool in interface DrawingViewpublic Drawing drawing()
drawing in interface DrawingViewpublic void setDrawing(Drawing d)
setDrawing in interface DrawingViewpublic DrawingEditor editor()
editor in interface DrawingViewpublic Figure add(Figure figure)
add in interface DrawingViewpublic Figure remove(Figure figure)
remove in interface DrawingViewpublic void addAll(java.util.Collection figures)
addAll in interface DrawingViewpublic java.awt.Dimension getSize()
getSize in interface DrawingViewgetSize in class java.awt.Componentpublic java.awt.Dimension getMinimumSize()
getMinimumSize in interface DrawingViewgetMinimumSize in class javax.swing.JComponentpublic java.awt.Dimension getPreferredSize()
getPreferredSize in interface DrawingViewgetPreferredSize in class javax.swing.JComponentpublic void setDisplayUpdate(Painter newUpdateStrategy)
setDisplayUpdate in interface DrawingViewPainterpublic Painter getDisplayUpdate()
getDisplayUpdate in interface DrawingViewPainterpublic FigureEnumeration selection()
selection in interface DrawingViewpublic FigureEnumeration selectionZOrdered()
selectionZOrdered in interface DrawingViewselection()public int selectionCount()
selectionCount in interface DrawingViewpublic boolean isFigureSelected(Figure checkFigure)
isFigureSelected in interface DrawingViewpublic void addToSelection(Figure figure)
addToSelection in interface DrawingViewpublic void addToSelectionAll(java.util.Collection figures)
addToSelectionAll in interface DrawingViewpublic void addToSelectionAll(FigureEnumeration fe)
addToSelectionAll in interface DrawingViewpublic void removeFromSelection(Figure figure)
removeFromSelection in interface DrawingViewpublic void toggleSelection(Figure figure)
toggleSelection in interface DrawingViewpublic void clearSelection()
clearSelection in interface DrawingViewpublic FigureSelection getFigureSelection()
getFigureSelection in interface DrawingView
public Handle findHandle(int x,
int y)
findHandle in interface DrawingViewpublic java.awt.Point lastClick()
lastClick in interface DrawingViewpublic void setConstrainer(PointConstrainer p)
setConstrainer in interface DrawingViewpublic PointConstrainer getConstrainer()
getConstrainer in interface DrawingViewpublic void checkDamage()
checkDamage in interface DrawingViewpublic void repairDamage()
repairDamage in interface DrawingViewpublic void paint(java.awt.Graphics g)
paint in interface DrawingViewpaint in class javax.swing.JComponentPainter
public java.awt.Image createImage(int width,
int height)
createImage in interface DrawingViewcreateImage in class java.awt.Componentpublic java.awt.Graphics getGraphics()
getGraphics in interface DrawingViewgetGraphics in class javax.swing.JComponentpublic java.awt.Color getBackground()
getBackground in interface DrawingViewgetBackground in class java.awt.Componentpublic void setBackground(java.awt.Color c)
setBackground in interface DrawingViewsetBackground in class javax.swing.JComponentpublic void drawAll(java.awt.Graphics g)
drawAll in interface DrawingView
public void draw(java.awt.Graphics g,
FigureEnumeration fe)
draw in interface DrawingViewpublic void drawHandles(java.awt.Graphics g)
drawHandles in interface DrawingViewpublic void drawDrawing(java.awt.Graphics g)
drawDrawing in interface DrawingViewpublic void drawBackground(java.awt.Graphics g)
drawBackground in interface DrawingViewpublic void setCursor(Cursor c)
setCursor in interface DrawingViewpublic void freezeView()
freezeView in interface DrawingViewDrawing.lock()public void unfreezeView()
unfreezeView in interface DrawingViewDrawing.unlock()public void addFigureSelectionListener(FigureSelectionListener fsl)
addFigureSelectionListener in interface DrawingViewfsl - jhotdraw.framework.FigureSelectionListenerpublic void removeFigureSelectionListener(FigureSelectionListener fsl)
removeFigureSelectionListener in interface DrawingViewfsl - jhotdraw.framework.FigureSelectionListenerpublic FigureEnumeration getConnectionFigures(Figure inFigure)
getConnectionFigures in interface DrawingView
public FigureEnumeration insertFigures(FigureEnumeration inFigures,
int dx,
int dy,
boolean bCheck)
insertFigures in interface DrawingViewpublic void drawingInvalidated(DrawingEvent e)
DrawingListener
drawingInvalidated in interface DrawingListenerpublic void drawingRequestUpdate(DrawingEvent e)
DrawingListener
drawingRequestUpdate in interface DrawingListenerpublic void drawingTitleChanged(DrawingEvent e)
DrawingListener
drawingTitleChanged in interface DrawingListenerpublic boolean isInteractive()
DrawingView
isInteractive in interface DrawingViewpublic static DrawingView getManagedDrawingView(DrawingEditor editor)
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||