com.planeth.gtroids.obj.base
Class PaintableObject

java.lang.Object
  extended bycom.planeth.gtroids.obj.base.PaintableObject
Direct Known Subclasses:
AbstractGameObject

public class PaintableObject
extends java.lang.Object

A simple paintable object

Author:
Andreas Grässer, gal@planet-h.com.
created Jun 12, 2005

Constructor Summary
PaintableObject(Shape baseShape)
          Constructor for PaintableObject.
 
Method Summary
protected  void addShape(Shape shape)
          Adds a Shape to the object
protected  Shape[] explodeBaseShape()
          Explodes the baseShape (splits it into the max possible number of pieces)
 double getAvgDiameter()
          Returns the average diameter of the object
protected  Vector2D getAvgVector()
          Returns the average Vector of the baseShape's vertexes
protected  java.awt.Color getBaseColor()
          Returns the baseColor of the object
 Vector2D[] getBaseVertexes()
          Returns the vertexes of the baseShape
 Shape.Bounds getBounds()
          Returns the current Bounds of the Shape
 double getMaxRadius()
          Returns the the max radius of the object
 int getNrOfVertexes()
          Returns the number of all vertexes of the object (incl. the invisible ones)
 Vector2D getOrientation()
          Returns the orientation of the object
 Vector2D getPos()
          Returns the position of the object
 void move(Vector2D movementVector)
          Moves the object with the values of the passed vector
 void paint(java.awt.Graphics g)
          Paints the object into the passed Graphics
protected  void paintAtPos(java.awt.Graphics g, Vector2D pos)
          Paints the object into the passed Graphics at a different position than object's stored position.
protected  void randomizeBaseShape()
          Randomizes the baseShape
 void rotate(Vector2D rotationCenter, double theta)
          Rotates the object at the passed rotationCenter with the angle theta.
protected  void setBaseColor(java.awt.Color color)
          Sets the baseColor of the object
protected  Shape[] splitBaseShape()
          Splits the object into 2 pieces
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PaintableObject

public PaintableObject(Shape baseShape)
Constructor for PaintableObject.

Parameters:
baseShape - the baseShape of the object
Method Detail

paint

public void paint(java.awt.Graphics g)
Paints the object into the passed Graphics

Parameters:
g - Graphics to paint into

paintAtPos

protected void paintAtPos(java.awt.Graphics g,
                          Vector2D pos)
Paints the object into the passed Graphics at a different position than object's stored position.

Parameters:
g - Graphics to paint into
pos - the position to paint the object

rotate

public void rotate(Vector2D rotationCenter,
                   double theta)
Rotates the object at the passed rotationCenter with the angle theta.

Parameters:
rotationCenter - the rotationCenter in the local coordinateSystem of the object
theta - the rotation angle in radians

move

public void move(Vector2D movementVector)
Moves the object with the values of the passed vector

Parameters:
movementVector - the movement to be done

getAvgVector

protected Vector2D getAvgVector()
Returns the average Vector of the baseShape's vertexes

Returns:
Vector2D Returns the average Vector of the baseShape's vertexes

getBaseVertexes

public Vector2D[] getBaseVertexes()
Returns the vertexes of the baseShape

Returns:
Returns the vertexes of the baseShape

getBaseColor

protected java.awt.Color getBaseColor()
Returns the baseColor of the object

Returns:
Returns the baseColor of the object

setBaseColor

protected void setBaseColor(java.awt.Color color)
Sets the baseColor of the object

Parameters:
color - the color to set

randomizeBaseShape

protected void randomizeBaseShape()
Randomizes the baseShape

See Also:
Shape.randomize()

splitBaseShape

protected Shape[] splitBaseShape()
Splits the object into 2 pieces

Returns:
Returns the result shapes
See Also:
Shape.split(int)

explodeBaseShape

protected Shape[] explodeBaseShape()
Explodes the baseShape (splits it into the max possible number of pieces)

Returns:
Returns the result shapes
See Also:
Shape.explode()

getBounds

public Shape.Bounds getBounds()
Returns the current Bounds of the Shape

Returns:
Returns the current Bounds of the Shape

getNrOfVertexes

public int getNrOfVertexes()
Returns the number of all vertexes of the object (incl. the invisible ones)

Returns:
Returns the number of all vertexes of the object (incl. the invisible ones)

getPos

public Vector2D getPos()
Returns the position of the object

Returns:
Returns the position of the object

getOrientation

public Vector2D getOrientation()
Returns the orientation of the object

Returns:
Returns the orientation of the object

addShape

protected void addShape(Shape shape)
Adds a Shape to the object

Parameters:
shape - the Shape to add

getAvgDiameter

public double getAvgDiameter()
Returns the average diameter of the object

Returns:
Returns the average diameter of the object

getMaxRadius

public double getMaxRadius()
Returns the the max radius of the object

Returns:
Returns the the max radius of the object