Class Animation2D

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by Animation2D
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, javax.accessibility.Accessible

public class Animation2D
extends java.awt.Canvas

Animation2D uses classes developed in last week's Transform2DTest project to confirm the applicability of Matrix-defined transformations to simple animations. Note: Add Path to Transform2DTest folder in Classes Tab of your JDK Profile. The Space Invaders Tutorial at http://www.planetalia.com/cursos/Java-Invaders/JAVA-INVADERS-11.tutorial was useful.

Author:
C. D'Arcy
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static double domain
          assists in converting cartesian coordinates to screen coordinates
static int HEIGHT
          The height of the Canvas
static double maxX
          Cartesian parameters: domain, range, minX, maxX, minY, maxY
static double maxY
           
static double minX
           
static double minY
           
static double range
          assists in converting Cartesian coordinates to Screen coordinates
static int SPEED
          SPEED controls the delay of the utility Thread
static Sprite sprite
          an instance of the Sprite class to be animated
 java.awt.image.BufferStrategy strategy
          Specialized class to support double buffering
static int WIDTH
          The width of the Canvas
 
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, PROPERTIES, SOMEBITS
 
Constructor Summary
Animation2D()
          Single constructor (supplied)
 
Method Summary
static void main(java.lang.String[] args)
          Instantiates an animation object,a sprite with some meaningful set of points and then calls the run method.
 void paintPanel()
          Creates a BufferedImage object, obtains its Graphics2D drawing context, and goes to work drawing to the image.
 void run()
          Sequencer to organize calls and prove an animation speed.
 int scrX(double x)
          Converts Cartesian x-coordinate to relative Screen x-coordinate
 int scrY(double y)
          Converts Cartesian y-coordinate to relative Screen y-coordinate
 void updateScene()
          updateScene prepares and applies the matrix transform(s) to the Sprite object
 
Methods inherited from class java.awt.Canvas
addNotify, createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy, paint, update
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, 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, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WIDTH

public static final int WIDTH
The width of the Canvas

See Also:
Constant Field Values

HEIGHT

public static final int HEIGHT
The height of the Canvas

See Also:
Constant Field Values

SPEED

public static final int SPEED
SPEED controls the delay of the utility Thread

See Also:
Constant Field Values

strategy

public java.awt.image.BufferStrategy strategy
Specialized class to support double buffering


maxX

public static double maxX
Cartesian parameters: domain, range, minX, maxX, minY, maxY


minX

public static double minX

maxY

public static double maxY

minY

public static double minY

domain

public static double domain
assists in converting cartesian coordinates to screen coordinates


range

public static double range
assists in converting Cartesian coordinates to Screen coordinates


sprite

public static Sprite sprite
an instance of the Sprite class to be animated

Constructor Detail

Animation2D

public Animation2D()
Single constructor (supplied)

Method Detail

updateScene

public void updateScene()
updateScene prepares and applies the matrix transform(s) to the Sprite object


scrX

public int scrX(double x)
Converts Cartesian x-coordinate to relative Screen x-coordinate


scrY

public int scrY(double y)
Converts Cartesian y-coordinate to relative Screen y-coordinate


paintPanel

public void paintPanel()
Creates a BufferedImage object, obtains its Graphics2D drawing context, and goes to work drawing to the image. Calls sprite's getData() method to obtain the set of points (vertices) transformed, drawn and connected. Hint. Consider copying the points to a java.awt.Polygon shape, and using the drawPoly(poly) method. Once rendered, obtain the visible drawing context from the strategy object, copying the BufferedImage to the visible canvas with the drawImage() method. Finally, strategy.show().


run

public void run()
Sequencer to organize calls and prove an animation speed.


main

public static void main(java.lang.String[] args)
Instantiates an animation object,a sprite with some meaningful set of points and then calls the run method.