gui.playfield
Class PlayFieldGraphic

java.lang.Object
  extended by gui.playfield.PlayFieldGraphic
Direct Known Subclasses:
MapGraphic, MessageGraphic, NodeGraphic, PathGraphic, ScaleReferenceGraphic

public abstract class PlayFieldGraphic
extends java.lang.Object

Superclass for all graphics to be drawn on the "play field".


Field Summary
protected static double scale
          Common scaling factor for all playfield graphics.
 
Constructor Summary
PlayFieldGraphic()
           
 
Method Summary
abstract  void draw(java.awt.Graphics2D g2)
          Draws the graphic component to the graphics context g2
static double getScale()
          Returns the currently used scaling factor
static double invScale(double value)
          Performs an inverse of the scaling procedure with current scale.
static int scale(double value)
          Scales the value according to current zoom level
static int scale(int value)
          Scales the value according to current zoom level
static void setScale(double newScale)
          Set the zooming factor of the graphics to be drawn
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scale

protected static double scale
Common scaling factor for all playfield graphics.

See Also:
setScale(double)
Constructor Detail

PlayFieldGraphic

public PlayFieldGraphic()
Method Detail

setScale

public static void setScale(double newScale)
Set the zooming factor of the graphics to be drawn

Parameters:
newScale - New scale

getScale

public static double getScale()
Returns the currently used scaling factor

Returns:
The scaling factor

draw

public abstract void draw(java.awt.Graphics2D g2)
Draws the graphic component to the graphics context g2

Parameters:
g2 - The context to draw the graphics to

scale

public static int scale(double value)
Scales the value according to current zoom level

Parameters:
value - Value to scale
Returns:
Scaled value bit-truncated (casted) to an integer

scale

public static int scale(int value)
Scales the value according to current zoom level

Parameters:
value - Value to scale
Returns:
Scaled value bit-truncated (casted) to an integer

invScale

public static double invScale(double value)
Performs an inverse of the scaling procedure with current scale. NOTE: invScale(scale(value)) != value because of rounding to integer at scale() -methods

Parameters:
value - The value to inverse-scale
Returns:
Inverse-scaled value
See Also:
scale(double)