com.planeth.common.geom
Class Shape

java.lang.Object
  extended bycom.planeth.common.geom.Shape
Direct Known Subclasses:
Cross, Ellipse, Line, Rectangle

public class Shape
extends java.lang.Object

A Base Shape implementation without any predifined vertexes

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

Nested Class Summary
static class Shape.Bounds
          Calculates the bounds (boundary vertexes) of an Array of vertexes.
 
Constructor Summary
protected Shape()
          Constructor for Shape.
  Shape(Vector2D[] vertexes)
          Constructor for Shape.
 
Method Summary
 Shape[] explode()
          Explodes the Shape in the max possible number of pieces
 Shape.Bounds getBounds()
          Returns the Bounds object of the Shape
 java.awt.Color getColor()
          Returns the color of the Shape
 Vector2D[] getVertexes()
          Returns the vertexes of the Shape
 void paint(java.awt.Graphics g, Vector2D pos)
          Paints the Shape into the passed Graphics at the passed position
 void randomize()
          Randomizes the Shape.
 void setColor(java.awt.Color color)
          Sets the color for the Shape
 void setFilled(boolean filled)
          If set to true, the Shape is filled
protected  void setVertexes(Vector2D[] vertexes)
          Sets the vertexes for the Shape
 void setVisible(boolean visible)
          If set to true, the Shape is visible
 Shape[] split(int pieces)
          Splits the Shape in the passed number of pieces
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Shape

protected Shape()
Constructor for Shape.


Shape

public Shape(Vector2D[] vertexes)
Constructor for Shape.

Parameters:
vertexes - the vertexes for the Shape
Method Detail

randomize

public void randomize()
Randomizes the Shape.
Moves the vertexes in a random direction with a predefined max movement.


split

public Shape[] split(int pieces)
Splits the Shape in the passed number of pieces

Parameters:
pieces - the number of pieces
Returns:
Returns the splitted pieces as an Array of Shapes

explode

public Shape[] explode()
Explodes the Shape in the max possible number of pieces

Returns:
Returns the splitted pieces as an Array of Shapes

getBounds

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

Returns:
Returns the Bounds object of the Shape

paint

public void paint(java.awt.Graphics g,
                  Vector2D pos)
Paints the Shape into the passed Graphics at the passed position

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

getVertexes

public Vector2D[] getVertexes()
Returns the vertexes of the Shape

Returns:
Returns the vertexes of the Shape

setVertexes

protected void setVertexes(Vector2D[] vertexes)
Sets the vertexes for the Shape

Parameters:
vertexes - The vertexes to set.

getColor

public java.awt.Color getColor()
Returns the color of the Shape

Returns:
Returns the color of the Shape

setColor

public void setColor(java.awt.Color color)
Sets the color for the Shape

Parameters:
color - The color to set.

setFilled

public void setFilled(boolean filled)
If set to true, the Shape is filled

Parameters:
filled - true = filled, false = drawed

setVisible

public void setVisible(boolean visible)
If set to true, the Shape is visible

Parameters:
visible - true = visible