DrawableSurface
Class DrawableSurface

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--DrawableSurface.DrawableSurface
Direct Known Subclasses:
ModifiedPaintSurface, PaintSurface

public class DrawableSurface
extends Canvas

This is the base class. We can draw an animated Image on it.

Version:
1.0
Author:
Sebastien Baehni
See Also:
Serialized Form

Field Summary
protected  AnimatedImage animatedImage
          This is the animated image of the surface.
protected  int height
          The height of the animatedimage
protected  boolean painted
          This is the boolean preventing from the nullpointer exception
protected  int width
          The width of the animatedImage
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Constructor Summary
DrawableSurface(int width, int height)
          The second constructor.
DrawableSurface(int width, int height, Color backgroundColor)
          The constructor.
 
Method Summary
 AnimatedImage animatedImage()
          This method returns the animated image of our drawable surface.
 void eraseSurface(Color color)
          This method erase the drawable surface whith the color defined in parameter.
 int height()
          This method returns the height of our drawable surface.
 void paint(Graphics g)
          The paint method.
 void start()
          Method which set the boolean to true.
 void update(Graphics g)
          The update method.
 int width()
          This method returns the width of our drawable surface.
 
Methods inherited from class java.awt.Canvas
addNotify
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputContext, getInputMethodRequests, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

animatedImage

protected AnimatedImage animatedImage
This is the animated image of the surface.

painted

protected boolean painted
This is the boolean preventing from the nullpointer exception

width

protected int width
The width of the animatedImage

height

protected int height
The height of the animatedimage
Constructor Detail

DrawableSurface

public DrawableSurface(int width,
                       int height,
                       Color backgroundColor)
The constructor.
Parameters:
width - The width of our drawable surface.
height - The height of our drawable surface.
backgroundColor - The background color of our drawable surface.

DrawableSurface

public DrawableSurface(int width,
                       int height)
The second constructor. It is identic to the first one except that the background color is white.
Parameters:
width - The width of our drawable surface.
height - The height of our drawable surface.
Method Detail

start

public void start()
Method which set the boolean to true. We can now without problems draw our image.

paint

public void paint(Graphics g)
The paint method. It draw an image (animated image) on the drawable surface.
Parameters:
g - The graphics context.
Overrides:
paint in class Canvas

update

public void update(Graphics g)
The update method. It calls paint only when it has the right to do so.
Overrides:
update in class Component

eraseSurface

public void eraseSurface(Color color)
This method erase the drawable surface whith the color defined in parameter.
Parameters:
color - The new backgroundColor.

width

public int width()
This method returns the width of our drawable surface.
Returns:
The width of the drawableSurface.

height

public int height()
This method returns the height of our drawable surface.
Returns:
The height of the drawableSurface.

animatedImage

public AnimatedImage animatedImage()
This method returns the animated image of our drawable surface.
Returns:
The animatedImage of the drawableSurface.
See Also:
AnimatedImage