com.ericsson.tic.vi
Class Renderer

java.lang.Object
  extended by com.ericsson.tic.vi.Renderer
All Implemented Interfaces:
EventListener, GLEventListener

public class Renderer
extends Object
implements GLEventListener

This class handles all OpenGL calls and rendering.

Version:
1.0 (2008-12-05)
Author:
Sami Matilainen

Field Summary
 Camera camera
          The camera associated with the view which is being rendered.
private  float[] diffuseMaterial
          Used for shading/lighting.
 GLAutoDrawable drawableForAnimator
          A drawable.
private  float[] fogColor
          Used for shading/lighting.
 NumberFormat form
          Specifies the number formatting of floats.
 GL gl
          The OpenGL rendering context.
 float globeRadius
          Globe radius.
 GLU glu
          The GLU rendering context.
 GLUT glut
          A glut rendering context.
protected  int id
          The renderer id.
private  TextRenderer labelTextRenderer
          A text renderer field.
private  float[] lightAmbient0
          Used for shading/lighting.
private  float[] lightAmbient1
          Used for shading/lighting.
private  float[] lightDiffuse0
          Used for shading/lighting.
private  float[] lightDiffuse1
          Used for shading/lighting.
private  float[] lightPos0
          Used for shading/lighting.
private  float[] lightPos1
          Used for shading/lighting.
private  float[] lightSpecular0
          Used for shading/lighting.
private  float[] lightSpecular1
          Used for shading/lighting.
private  int limitedRenderCounter
          A counter used for the limit rendering functionality.
(package private)  float[] lineWidthRanges
          An array with the allowed line width ranges of this OGL environment.
private  float[] matSpecular
          Used for shading/lighting.
 int nodeMoveCounter
          A counter for node movement.
 float planeScale
          Scale of the plane.
private  ViewPanel pv
          The parent panel of this renderer.
 GLUquadric quadric
          A GLUquadric.
 boolean readyForAnimator
          Used by animator.
private  float skyboxRotation
          The rotation angle of the skybox.
private  TextRenderer textRenderer
          A text renderer field.
 
Constructor Summary
Renderer(int id, Camera camera, ViewPanel parentView)
          Sets up a renderer.
 
Method Summary
 void billboardCheatSphericalBegin()
          Renders objects so they are facing the camera head on (billboarding).
 void billboardCheatSphericalEnd()
          Renders objects so they are facing the camera head on (billboarding).
 void display(GLAutoDrawable drawable)
          Called by the OpenGL rendering engine every time the scene is redrawn.
 void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
          Called by the OpenGL rendering engine when the window is resized.
private  void drawBackPlane(boolean picking)
          Draws a neutral background for the plane view to block the stars.
 void drawBezierCurve(float[] start, float[] controlStart, float[] end, float[] controlEnd, float[] color4f)
          Draws a bezier curve.
 void drawBezierCurve(FloatBuffer points, float[] color4f)
          Draws a bezier curve.
 void drawBrushingMarkers()
          Draw brushingMarkers
 void drawCumulativeBar(GraphNode node, int barType, float[][] height, float[][] color3f)
          Draws a cumulative bar
 void drawCumulativeBars()
          Draw all cumulative bars
 void drawFloatingWindow(GraphNode node, boolean picking)
          Draws a floating window.
 void drawFloatingWindowCloseButton(float[] pos, byte[] pickingID, boolean picking)
          Draws the closing button for the floating window.
 void drawFloatingWindowFrame(GraphNode node, float[] pos, boolean picking, float[] frameColor, float[] borderColor, float width, float height)
          Draws a floating window frame.
private  void drawGlobe(boolean picking)
          Draws a globe.
 void drawHistogram(float[] pos, float width, float height, boolean ordered, float[][] values, float[][] realValues, float[][] color3f)
          Draws a histogram.
 void drawLabels(boolean picking)
          Draws all labels.
private  void drawNav()
          Draws three balls which show the axes to make navigation easier in debug mode.
 void drawNodeLabel(GraphNode node, boolean picking)
          Draws a node label.
private  void drawNodes(boolean picking)
          Draws the nodes.
 void drawPickingView()
          Draws the pickable and blocking objects only.
private  void drawPlane(boolean picking)
          Draws a plane.
private  void drawRelations(boolean picking)
          Draws all relations (lines).
private  void drawScene(GLAutoDrawable drawable)
          Draws the scene.
private  void drawSkybox()
          Draw the skybox.
 void drawView()
          Draws the objects specific to this view.
 float[][] getCategoryColors(int i)
          Retrieve the colors used for categories.
 boolean hasPositiveValue(float[][][] v, int node, int cat)
          Determine if the array has any positive values.
 void init(GLAutoDrawable drawable)
          Called by the OpenGL rendering engine when the scene is initated.
 void loadTextures()
          Load all predefined textures.
 void pick()
          Handles picking (selection) of objects using a color based algorithm.
 void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
          Called by the OpenGL rendering engine when the scene is reshaped when the window is resized.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

camera

public Camera camera
The camera associated with the view which is being rendered.


globeRadius

public float globeRadius
Globe radius.


planeScale

public float planeScale
Scale of the plane.


nodeMoveCounter

public int nodeMoveCounter
A counter for node movement.


id

protected int id
The renderer id.


skyboxRotation

private float skyboxRotation
The rotation angle of the skybox.


gl

public GL gl
The OpenGL rendering context.


glu

public GLU glu
The GLU rendering context.


glut

public GLUT glut
A glut rendering context.


quadric

public GLUquadric quadric
A GLUquadric.


pv

private ViewPanel pv
The parent panel of this renderer. pv stands for Parent View.


textRenderer

private TextRenderer textRenderer
A text renderer field.


labelTextRenderer

private TextRenderer labelTextRenderer
A text renderer field.


readyForAnimator

public boolean readyForAnimator
Used by animator. deprecated (?)


drawableForAnimator

public GLAutoDrawable drawableForAnimator
A drawable. Used by animator. deprecated (?)


form

public NumberFormat form
Specifies the number formatting of floats.


lineWidthRanges

float[] lineWidthRanges
An array with the allowed line width ranges of this OGL environment.


limitedRenderCounter

private int limitedRenderCounter
A counter used for the limit rendering functionality.


diffuseMaterial

private float[] diffuseMaterial
Used for shading/lighting.


matSpecular

private float[] matSpecular
Used for shading/lighting.


lightAmbient0

private float[] lightAmbient0
Used for shading/lighting.


lightDiffuse0

private float[] lightDiffuse0
Used for shading/lighting.


lightSpecular0

private float[] lightSpecular0
Used for shading/lighting.


lightPos0

private float[] lightPos0
Used for shading/lighting.


lightAmbient1

private float[] lightAmbient1
Used for shading/lighting.


lightDiffuse1

private float[] lightDiffuse1
Used for shading/lighting.


lightSpecular1

private float[] lightSpecular1
Used for shading/lighting.


lightPos1

private float[] lightPos1
Used for shading/lighting.


fogColor

private float[] fogColor
Used for shading/lighting.

Constructor Detail

Renderer

public Renderer(int id,
                Camera camera,
                ViewPanel parentView)
Sets up a renderer.

Parameters:
camera - The camera associated with the view.
id - The renderer id.
parentView - The parent ViewPanel of this renderer.
Method Detail

init

public void init(GLAutoDrawable drawable)
Called by the OpenGL rendering engine when the scene is initated.

Specified by:
init in interface GLEventListener
Parameters:
drawable - The Drawable.

display

public void display(GLAutoDrawable drawable)
Called by the OpenGL rendering engine every time the scene is redrawn.

Specified by:
display in interface GLEventListener
Parameters:
drawable - The Drawable.

drawScene

private void drawScene(GLAutoDrawable drawable)
Draws the scene.

Parameters:
drawable - The Drawable.

drawView

public void drawView()
Draws the objects specific to this view.


drawLabels

public void drawLabels(boolean picking)
Draws all labels.

Parameters:
picking - if true, renders using the picking color.

drawNodeLabel

public void drawNodeLabel(GraphNode node,
                          boolean picking)
Draws a node label.

Parameters:
node - The node which this label is associated with.
picking - if true, renders using the picking color.

drawGlobe

private void drawGlobe(boolean picking)
Draws a globe.

Parameters:
picking - if true, renders using the picking color.

drawPlane

private void drawPlane(boolean picking)
Draws a plane.

Parameters:
picking - if true, renders using the picking color.

drawBackPlane

private void drawBackPlane(boolean picking)
Draws a neutral background for the plane view to block the stars.

Parameters:
picking - if true, renders using the picking color.

drawSkybox

private void drawSkybox()
Draw the skybox.


drawNav

private void drawNav()
Draws three balls which show the axes to make navigation easier in debug mode. x = red, y = green and z = blue (as in "xyz = RGB")


drawNodes

private void drawNodes(boolean picking)
Draws the nodes.

Parameters:
picking - if true, renders using the picking color.

drawRelations

private void drawRelations(boolean picking)
Draws all relations (lines).

Parameters:
picking - if true, renders using the picking color.

drawCumulativeBars

public void drawCumulativeBars()
Draw all cumulative bars


drawCumulativeBar

public void drawCumulativeBar(GraphNode node,
                              int barType,
                              float[][] height,
                              float[][] color3f)
Draws a cumulative bar

Parameters:
node - A node.
barType - The type of the bar. this is a value between 0 and 9.
height - The expected height of the bar.
color3f - An array of colors to represent the multiple dimensional (cumulative) bar.

drawBrushingMarkers

public void drawBrushingMarkers()
Draw brushingMarkers


hasPositiveValue

public boolean hasPositiveValue(float[][][] v,
                                int node,
                                int cat)
Determine if the array has any positive values. Used by the brushing algorithm.

Parameters:
v - An array of values.

drawFloatingWindowFrame

public void drawFloatingWindowFrame(GraphNode node,
                                    float[] pos,
                                    boolean picking,
                                    float[] frameColor,
                                    float[] borderColor,
                                    float width,
                                    float height)
Draws a floating window frame.

Parameters:
node - The node this floating window is tied to.
pos - the position of the floating window in 3D-space.
picking - if true, renders using the picking color.
frameColor - The color of the frame.
borderColor - The color of the border.
width - the width of the floating window.
height - the height of the floating window.

drawFloatingWindowCloseButton

public void drawFloatingWindowCloseButton(float[] pos,
                                          byte[] pickingID,
                                          boolean picking)
Draws the closing button for the floating window.

Parameters:
pos - the relative position of the button in 3D-space.
picking - if true, renders using the picking color.
pickingID - A list of picking ID's.

drawFloatingWindow

public void drawFloatingWindow(GraphNode node,
                               boolean picking)
Draws a floating window.

Parameters:
node - The node this floating window is tied to.
picking - if true, renders using the picking color.

drawHistogram

public void drawHistogram(float[] pos,
                          float width,
                          float height,
                          boolean ordered,
                          float[][] values,
                          float[][] realValues,
                          float[][] color3f)
Draws a histogram.

Parameters:
pos - the position of the histogram in 3D-space.
ordered - Set to true to have bars ordered. (deprecated)
values - Values to be used for building up the componenets of the bars.
realValues - the real values used for the labels.
color3f - The color of the border.
width - the width of the floating window.
height - the height of the floating window.

drawBezierCurve

public void drawBezierCurve(float[] start,
                            float[] controlStart,
                            float[] end,
                            float[] controlEnd,
                            float[] color4f)
Draws a bezier curve.

Parameters:
start - point controlling the bezier curve.
controlStart - point controlling the bezier curve.
end - point controlling the bezier curve.
controlEnd - point controlling the bezier curve.
color4f - the color of the curve.

drawBezierCurve

public void drawBezierCurve(FloatBuffer points,
                            float[] color4f)
Draws a bezier curve.

Parameters:
points - Control points for the bezier curve.
color4f - the color of the curve.

billboardCheatSphericalBegin

public void billboardCheatSphericalBegin()
Renders objects so they are facing the camera head on (billboarding). I made this function for a project at KTH.


billboardCheatSphericalEnd

public void billboardCheatSphericalEnd()
Renders objects so they are facing the camera head on (billboarding). I made this function for a project at KTH.


loadTextures

public void loadTextures()
Load all predefined textures.


getCategoryColors

public float[][] getCategoryColors(int i)
Retrieve the colors used for categories.

Parameters:
i - An index denoting the category set.

pick

public void pick()
Handles picking (selection) of objects using a color based algorithm.


drawPickingView

public void drawPickingView()
Draws the pickable and blocking objects only. In picking colors.


displayChanged

public void displayChanged(GLAutoDrawable drawable,
                           boolean modeChanged,
                           boolean deviceChanged)
Called by the OpenGL rendering engine when the window is resized. Note: the Java implementation of OpenGL does not use this!

Specified by:
displayChanged in interface GLEventListener

reshape

public void reshape(GLAutoDrawable drawable,
                    int x,
                    int y,
                    int width,
                    int height)
Called by the OpenGL rendering engine when the scene is reshaped when the window is resized.

Specified by:
reshape in interface GLEventListener