megamek.client.ui.AWT
Class BoardView1.Sprite

java.lang.Object
  extended by megamek.client.ui.AWT.BoardView1.Sprite
All Implemented Interfaces:
java.awt.image.ImageObserver
Enclosing class:
BoardView1

abstract class BoardView1.Sprite
extends java.lang.Object
implements java.awt.image.ImageObserver

Everything in the main map view is either the board or it's a sprite displayed on top of the board. Most sprites store a transparent image which they draw onto the screen when told to. Sprites keep a bounds rectangle, so it's easy to tell when they'return onscreen.


Field Summary
protected  java.awt.Rectangle bounds
           
protected  boolean hidden
           
protected  java.awt.Image image
           
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
BoardView1.Sprite()
           
 
Method Summary
 void drawOnto(java.awt.Graphics g, int x, int y, java.awt.image.ImageObserver observer)
          Draws this sprite onto the specified graphics context.
 void drawOnto(java.awt.Graphics g, int x, int y, java.awt.image.ImageObserver observer, boolean makeTranslucent)
           
 java.awt.Rectangle getBounds()
          Returns our bounding rectangle.
 java.lang.String[] getTooltip()
          Since most sprites being drawn correspond to something in the game, this returns a little info for a tooltip.
 boolean imageUpdate(java.awt.Image image, int infoflags, int x, int y, int width, int height)
          When we draw our buffered images, it's necessary to implement the ImageObserver interface.
 boolean isInside(java.awt.Point point)
          Returns true if the point is inside this sprite.
 boolean isReady()
          Are we ready to draw?
abstract  void prepare()
          Do any necessary preparation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

bounds

protected java.awt.Rectangle bounds

image

protected java.awt.Image image

hidden

protected boolean hidden
Constructor Detail

BoardView1.Sprite

BoardView1.Sprite()
Method Detail

prepare

public abstract void prepare()
Do any necessary preparation. This is called after creation, but before drawing, when a device context is ready to draw with.


imageUpdate

public boolean imageUpdate(java.awt.Image image,
                           int infoflags,
                           int x,
                           int y,
                           int width,
                           int height)
When we draw our buffered images, it's necessary to implement the ImageObserver interface. This provides the necesasry functionality.

Specified by:
imageUpdate in interface java.awt.image.ImageObserver

getBounds

public java.awt.Rectangle getBounds()
Returns our bounding rectangle. The coordinates here are stored with the top left corner of the _board_ being 0, 0, so these do not always correspond to screen coordinates.


isReady

public boolean isReady()
Are we ready to draw? By default, checks to see that our buffered image has been created.


drawOnto

public void drawOnto(java.awt.Graphics g,
                     int x,
                     int y,
                     java.awt.image.ImageObserver observer)
Draws this sprite onto the specified graphics context.


drawOnto

public void drawOnto(java.awt.Graphics g,
                     int x,
                     int y,
                     java.awt.image.ImageObserver observer,
                     boolean makeTranslucent)

isInside

public boolean isInside(java.awt.Point point)
Returns true if the point is inside this sprite. Uses board coordinates, not screen coordinates. By default, just checks our bounding rectangle, though some sprites override this for a smaller sensitive area.


getTooltip

public java.lang.String[] getTooltip()
Since most sprites being drawn correspond to something in the game, this returns a little info for a tooltip.