org.jrabbit.base.graphics.skins.primitive
Class PolygonSkin

java.lang.Object
  extended by org.jrabbit.base.graphics.skins.primitive.PrimitiveSkin
      extended by org.jrabbit.base.graphics.skins.primitive.PolygonSkin
All Implemented Interfaces:
Renderable, Skin, Dimensioned, Vertexed

public class PolygonSkin
extends PrimitiveSkin

A PolygonSkin renders and geometrically represents a complex polygon. It is created from supplied vertex data upon initialization. The polygon described has very few limitations - it can be convex or concave, have any number of vertices, have its center not be at the origin; but for the rendered shape to look like the described polygon, it cannot "bend back" on itself in relation to the origin. To understand what this means, first you need to know how the Polygon is rendered - it's a "Triangle fan." A vertex is rendered at [0, 0], and then all of the polygon's vertices are rendered, in order, around the shape.

Author:
Chris Molini

Field Summary
private  int dLID
          The ID of the compiled DisplayList to use.
private  float height
          The calculated height of the polygon.
private  float[][] vertices
          The coordinate data.
private  float width
          The calculated width of the polygon.
 
Constructor Summary
PolygonSkin(float[][] vertices)
          Creates a PolygonSkin that renders the indicated Polygon.
 
Method Summary
 float height()
          Learns about the dimensions of the polygon.
 void render()
          Renders the polygon.
 void setVertices(float[][] vertices)
          Redefines the PolygonSkin.
 float[][] vertices()
          Accesses the polygon's geometry data.
 float width()
          Learns about the dimensions of the polygon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

width

private float width
The calculated width of the polygon.


height

private float height
The calculated height of the polygon.


dLID

private int dLID
The ID of the compiled DisplayList to use.


vertices

private float[][] vertices
The coordinate data.

Constructor Detail

PolygonSkin

public PolygonSkin(float[][] vertices)
Creates a PolygonSkin that renders the indicated Polygon.

Parameters:
vertices - The vertex data that describes the Polygon to render.
Method Detail

setVertices

public void setVertices(float[][] vertices)
Redefines the PolygonSkin.

Parameters:
vertices - The vertex data that describes the Polygon to render.

width

public float width()
Learns about the dimensions of the polygon.

Specified by:
width in interface Dimensioned
Overrides:
width in class PrimitiveSkin
Returns:
The base width of the polygon.

height

public float height()
Learns about the dimensions of the polygon.

Specified by:
height in interface Dimensioned
Overrides:
height in class PrimitiveSkin
Returns:
The base height of the polygon.

render

public void render()
Renders the polygon.


vertices

public float[][] vertices()
Accesses the polygon's geometry data.

Returns:
The list of vertices describing the polygon.