objectdraw
Class JDrawingCanvas

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--javax.swing.JComponent
                    |
                    +--objectdraw.JDrawingCanvas
All Implemented Interfaces:
java.awt.event.ComponentListener, DrawingCanvas, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class JDrawingCanvas
extends javax.swing.JComponent
implements DrawingCanvas, java.awt.event.ComponentListener

The JDrawingCanvas is the implementation of DrawingCanvas that is used for compatability with the Swing libraries. It calls corresponding methods of the CanvasManager in order to actually modify the canvas.

See Also:
Serialized Form

Inner classes inherited from class javax.swing.JComponent
javax.swing.JComponent.AccessibleJComponent
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static java.awt.Dimension DEFAULT_PREFERRED_SIZE
           
 
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
JDrawingCanvas()
          Creates a new DrawingCanvas.
JDrawingCanvas(java.awt.Dimension size)
          Creates a new DrawingCanvas.
JDrawingCanvas(int width, int height)
          Creates a new DrawingCanvas.
 
Method Summary
 void addToCanvas(Drawable d)
          Adds the Drawable d to the JDrawingCanvas
 void clear()
          Clears the canvas.
 void componentHidden(java.awt.event.ComponentEvent e)
          Invoked when component has been hidden.
 void componentMoved(java.awt.event.ComponentEvent e)
          Invoked when component has been moved.
 void componentResized(java.awt.event.ComponentEvent e)
          Invoked when component has been resized.
 void componentShown(java.awt.event.ComponentEvent e)
          Invoked when component has been shown.
 void disableAutoRepaint()
          Turns auto repaint off so the programmer must indicate when the canvas should be repainted.
 void enableAutoRepaint()
          Turns auto repaint on so the programmer does not have to manually repaint after changing the canvas
 CanvasManager getCanvasContent()
          Returns an instance of the CanvasContainer
 java.awt.Dimension getPreferredSize()
          Retrieves the object's preferred size.
 boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int width, int height)
          Notifies the CanvasManager of a change in state and calls the native java method imageUpdate.
 void paint(java.awt.Graphics g)
          Paints the canvas by calling the real paint method of the CanvasManager
 void removeFromCanvas(Drawable d)
          Removes the Drawable d from the JDrawingCanvas
 void update(java.awt.Graphics g)
          Updates the screen.
 
Methods inherited from class javax.swing.JComponent
addAncestorListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getAccessibleContext, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAutoscrolls, getBorder, getBounds, getClientProperty, getComponentGraphics, getConditionForKeyStroke, getDebugGraphicsOptions, getGraphics, getHeight, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getUIClassID, getVerifyInputWhenFocusTarget, getVisibleRect, getWidth, getX, getY, grabFocus, hasFocus, hide, isDoubleBuffered, isFocusCycleRoot, isFocusTraversable, isLightweightComponent, isManagingFocus, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isOptimizedDrawingEnabled, isPaintingTile, isPreferredSizeSet, isRequestFocusEnabled, isValidateRoot, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, paramString, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processFocusEvent, processKeyBinding, processKeyEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setDebugGraphicsOptions, setDoubleBuffered, setEnabled, setFont, setForeground, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateUI
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getLayout, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, getBackground, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphicsConfiguration, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocationOnScreen, getName, getParent, getPeer, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, inside, isDisplayable, isEnabled, isLightweight, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface objectdraw.DrawingCanvas
addComponentListener, addKeyListener, addMouseListener, addMouseMotionListener, createImage, getBackground, getForeground, getGraphics, getHeight, getSize, getWidth, prepareImage, repaint, setBackground, setForeground
 

Field Detail

DEFAULT_PREFERRED_SIZE

public static final java.awt.Dimension DEFAULT_PREFERRED_SIZE
Constructor Detail

JDrawingCanvas

public JDrawingCanvas()
Creates a new DrawingCanvas.

JDrawingCanvas

public JDrawingCanvas(int width,
                      int height)
Creates a new DrawingCanvas.
Parameters:
width - the canvas' preferred width
height - the canvas' preferred height

JDrawingCanvas

public JDrawingCanvas(java.awt.Dimension size)
Creates a new DrawingCanvas.
Parameters:
size - the canvas' preferred dimensions
Method Detail

getCanvasContent

public CanvasManager getCanvasContent()
Returns an instance of the CanvasContainer
Specified by:
getCanvasContent in interface DrawingCanvas

addToCanvas

public void addToCanvas(Drawable d)
Adds the Drawable d to the JDrawingCanvas
Specified by:
addToCanvas in interface DrawingCanvas

removeFromCanvas

public void removeFromCanvas(Drawable d)
Removes the Drawable d from the JDrawingCanvas
Specified by:
removeFromCanvas in interface DrawingCanvas

getPreferredSize

public java.awt.Dimension getPreferredSize()
Retrieves the object's preferred size.
Overrides:
getPreferredSize in class javax.swing.JComponent
Returns:
the object's preferred size

clear

public void clear()
Clears the canvas.
Specified by:
clear in interface DrawingCanvas

paint

public void paint(java.awt.Graphics g)
Paints the canvas by calling the real paint method of the CanvasManager
Overrides:
paint in class javax.swing.JComponent
Parameters:
g - the canvas' graphics context.

update

public void update(java.awt.Graphics g)
Updates the screen.
Overrides:
update in class javax.swing.JComponent
Parameters:
g - the canvas' graphics context

enableAutoRepaint

public void enableAutoRepaint()
Turns auto repaint on so the programmer does not have to manually repaint after changing the canvas
Specified by:
enableAutoRepaint in interface DrawingCanvas

disableAutoRepaint

public void disableAutoRepaint()
Turns auto repaint off so the programmer must indicate when the canvas should be repainted.
Specified by:
disableAutoRepaint in interface DrawingCanvas

componentResized

public void componentResized(java.awt.event.ComponentEvent e)
Invoked when component has been resized.
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent e)
Invoked when component has been moved.
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent e)
Invoked when component has been shown.
Specified by:
componentShown in interface java.awt.event.ComponentListener

componentHidden

public void componentHidden(java.awt.event.ComponentEvent e)
Invoked when component has been hidden.
Specified by:
componentHidden in interface java.awt.event.ComponentListener

imageUpdate

public boolean imageUpdate(java.awt.Image img,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
Notifies the CanvasManager of a change in state and calls the native java method imageUpdate. Returns true if the image has fully loaded or false otherwise
Specified by:
imageUpdate in interface java.awt.image.ImageObserver
Overrides:
imageUpdate in class java.awt.Component