edu.ohiou.cs456_badabing.sceneapi.visualize
Class PieChart

java.lang.Object
  extended by edu.ohiou.cs456_badabing.sceneapi.basic.ANode
      extended by edu.ohiou.cs456_badabing.sceneapi.visualize.PieChart

public class PieChart
extends ANode

Node that renders a Pie Chart

Description: Renders a pie chart where each slice represents numbers put in by the user.

Copyright: Copyright (c) 2008, Lev A Neiman

Company: Ohio University EECS


Field Summary
static java.awt.Color[] colors
          Colors to use for different members.
private static double d_size_mesh
          size of the mesh as a double.
private static double detail
          controls the detail of the chart.
private  java.util.HashMap<java.lang.String,java.lang.Double> members
          Members of this pie chart.
private static java.util.ArrayList<Triangle> mesh
          Array of triangles that comprise the mesh of the PieChart.
private static Material mtl
          material properties for the pie chart.
private static boolean need_to_build_mesh
          true if the mesh needs to be (re)build.
private static java.nio.FloatBuffer normals
          FloatBuffer of normals (normal vectors).
static double PI
          value of PI = 3.14159265;
private static double radius
          radius of the chart.
private  java.util.ArrayList<java.lang.Double> slices
          Array of Doubles that represents shares of different slices.
private static double thickness
          depth of the chart as a ratio between its radius.
private static boolean use_vertex_arrays
          true if user wants to use vertex arrays.
private static boolean vertex_arrays_supported
          true of this PC is capable of using vertex array.
private static int vertexCount
          count of vertices * 3 in the mesh.
private static java.nio.FloatBuffer vertices
          FloatBuffer of vertices.
 
Fields inherited from class edu.ohiou.cs456_badabing.sceneapi.basic.ANode
children, display_list, name, no_disp_list, parent, ppop, rotation, rotation_angle, scale, show, translation
 
Constructor Summary
PieChart()
          default constructor.
 
Method Summary
private static void buildMesh()
          builds the mesh for the PieCharts.
 void clear()
          clears the contents of this PieChart
static void flipUseVertexArrays()
          gets called when use clicks on "Disable vertex arrays" option in menu.
 java.lang.Double get(java.lang.String a)
          get Double that represents share of a.
 java.lang.Double put(java.lang.String name, java.lang.Double share)
          Put new member into pie chart.
 void render(GLAutoDrawable panel)
          renders the chart.
private  int roundN3(int a)
          take a and round it to the next number that is divisble by 3.
static void setTransperency(float t)
          changes transperency of the PieChart to t.
 
Methods inherited from class edu.ohiou.cs456_badabing.sceneapi.basic.ANode
addChild, countNodes, drawCube, getName, getNormal, hideTree, pushPop, renderTree, rotation, scale, setName, setParent, setPushPop, showTree, translation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mtl

private static Material mtl
material properties for the pie chart.


PI

public static final double PI
value of PI = 3.14159265;

See Also:
Constant Field Values

slices

private java.util.ArrayList<java.lang.Double> slices
Array of Doubles that represents shares of different slices.


members

private java.util.HashMap<java.lang.String,java.lang.Double> members
Members of this pie chart.


colors

public static java.awt.Color[] colors
Colors to use for different members.


thickness

private static double thickness
depth of the chart as a ratio between its radius.


radius

private static double radius
radius of the chart.


detail

private static double detail
controls the detail of the chart. the lower it is the more triangles are drawn.


mesh

private static java.util.ArrayList<Triangle> mesh
Array of triangles that comprise the mesh of the PieChart.


need_to_build_mesh

private static boolean need_to_build_mesh
true if the mesh needs to be (re)build.


d_size_mesh

private static double d_size_mesh
size of the mesh as a double.


vertexCount

private static int vertexCount
count of vertices * 3 in the mesh.


vertices

private static java.nio.FloatBuffer vertices
FloatBuffer of vertices.


normals

private static java.nio.FloatBuffer normals
FloatBuffer of normals (normal vectors).


vertex_arrays_supported

private static boolean vertex_arrays_supported
true of this PC is capable of using vertex array.


use_vertex_arrays

private static boolean use_vertex_arrays
true if user wants to use vertex arrays.

Constructor Detail

PieChart

public PieChart()
default constructor.

Method Detail

setTransperency

public static void setTransperency(float t)
changes transperency of the PieChart to t. 0 <= t <= 1

Parameters:
t - float

put

public java.lang.Double put(java.lang.String name,
                            java.lang.Double share)
Put new member into pie chart.

Parameters:
name - String
share - Double
Returns:
Double

get

public java.lang.Double get(java.lang.String a)
get Double that represents share of a.

Parameters:
a - String
Returns:
Double

clear

public void clear()
clears the contents of this PieChart


roundN3

private int roundN3(int a)
take a and round it to the next number that is divisble by 3. if a is divisble by 3 return a.

Parameters:
a - int
Returns:
int

buildMesh

private static void buildMesh()
builds the mesh for the PieCharts.


flipUseVertexArrays

public static void flipUseVertexArrays()
gets called when use clicks on "Disable vertex arrays" option in menu.


render

public void render(GLAutoDrawable panel)
renders the chart.

Overrides:
render in class ANode
Parameters:
panel - GLAutoDrawable