y25.view
Class Graph25DView

java.lang.Object
  extended byy25.view.Graph25DView
All Implemented Interfaces:
EventListener, GLEventListener

public class Graph25DView
extends Object
implements GLEventListener

Displays and navigates a Graph25D.

Usually, this class is used in the following way:

 // 1. create a Graph25D
 Graph25D graph25d = new Graph25D();
 
 // 2. create a Graph25DView and associate view modes with it
 Graph25DView view25d = new Graph25DView();
 view25d.setGraph25D(graph25d);
 view25d.addViewMode25D(new NavigationMode25D());
 
 // 3. create a panel and put the view inside
 JPanel panel = new JPanel();
 panel.add(view25d.getGLCanvas());
 


Field Summary
protected  Animator animator
          The animator that drives the redraw of the entire scene every frame.
protected  Camera camera
          Handles the viewing transform.
protected  GLCanvas glCanvas
          The OpenGL canvas that this view uses for rendering.
protected  Graph25D graph25D
          A reference to the graph that is displayed.
protected  LinkedList viewModes
          Stores the view modes associated with this view.
 
Constructor Summary
Graph25DView()
          Creates an empty Graph25DView.
 
Method Summary
 void addViewMode25D(ViewMode25D vm)
          Adds the given view mode to this view and makes it active.
 void display(GLAutoDrawable drawable)
          Renders the scene into the given drawable.
 void displayChanged(GLAutoDrawable drawable, boolean modeChanged, boolean deviceChanged)
          Currently, this method is empty.
protected  void displayGraph25D(GLAutoDrawable drawable)
          Renders the Graph25D that is associated with this view into the given drawable.
protected  void displayGraph2D(GLAutoDrawable drawable, Graph2D g2D)
          Renders a Graph2D into the given drawable.
protected  void displayGraph2DLayer(GLAutoDrawable drawable, Graph2D g2D)
          Renders the layer representation of the given Graph2D into the given drawable.
 Camera getCamera()
          Returns the camera this view uses for displaying the scene.
 GLCanvas getGLCanvas()
          Returns the OpenGL canvas this view renders into.
 Graph25D getGraph25D()
          Returns the graph that is displayed in this view.
 BufferedImage getPicture()
          Takes a screenshot of the current view and returns it.
 Iterator getViewModes()
          Returns an interator to all view modes that have been added to this view.
 void init(GLAutoDrawable drawable)
          Initializes the view.
 void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
          Adjusts camera parameters when the canvas this view renders into is resized.
 void setActiveViewMode(ViewMode25D vm)
          Sets the given view mode as the active view mode.
 void setGraph25D(Graph25D g)
          Sets the graph that is displayed in this view.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

glCanvas

protected GLCanvas glCanvas
The OpenGL canvas that this view uses for rendering.


animator

protected Animator animator
The animator that drives the redraw of the entire scene every frame.


camera

protected Camera camera
Handles the viewing transform.


viewModes

protected LinkedList viewModes
Stores the view modes associated with this view.


graph25D

protected Graph25D graph25D
A reference to the graph that is displayed.

Constructor Detail

Graph25DView

public Graph25DView()
Creates an empty Graph25DView.

Method Detail

getGLCanvas

public GLCanvas getGLCanvas()
Returns the OpenGL canvas this view renders into.


getCamera

public Camera getCamera()
Returns the camera this view uses for displaying the scene.


setGraph25D

public void setGraph25D(Graph25D g)
Sets the graph that is displayed in this view.


getGraph25D

public Graph25D getGraph25D()
Returns the graph that is displayed in this view. Returns null if no graph is associated with the view.


getPicture

public BufferedImage getPicture()
Takes a screenshot of the current view and returns it.


init

public void init(GLAutoDrawable drawable)
Initializes the view.

Sets the standard lights, whether or not to use antialiasing and various other OpenGL states.

This method does not have to be called directly, since that is handled by the Java OpenGL system.

Specified by:
init in interface GLEventListener
See Also:
GLEventListener.init(javax.media.opengl.GLAutoDrawable)

display

public void display(GLAutoDrawable drawable)
Renders the scene into the given drawable.

This method does not have to be called directly, since that is handled by the Java OpenGL system.

Specified by:
display in interface GLEventListener
See Also:
GLEventListener.display(javax.media.opengl.GLAutoDrawable)

reshape

public void reshape(GLAutoDrawable drawable,
                    int x,
                    int y,
                    int width,
                    int height)
Adjusts camera parameters when the canvas this view renders into is resized.

This method does not have to be called directly, since that is handled by the Java OpenGL system.

Specified by:
reshape in interface GLEventListener
See Also:
GLEventListener.reshape(javax.media.opengl.GLAutoDrawable, int, int, int, int)

displayChanged

public void displayChanged(GLAutoDrawable drawable,
                           boolean modeChanged,
                           boolean deviceChanged)
Currently, this method is empty.

This method does not have to be called directly, since that is handled by the Java OpenGL system.

Specified by:
displayChanged in interface GLEventListener
See Also:
GLEventListener.displayChanged(javax.media.opengl.GLAutoDrawable, boolean, boolean)

displayGraph25D

protected void displayGraph25D(GLAutoDrawable drawable)
Renders the Graph25D that is associated with this view into the given drawable.

For rendering individual Graph2Ds, this method calls displayGraph2D(). Layers are rendered through a call to displayGraph2DLayer().


displayGraph2D

protected void displayGraph2D(GLAutoDrawable drawable,
                              Graph2D g2D)
Renders a Graph2D into the given drawable.


displayGraph2DLayer

protected void displayGraph2DLayer(GLAutoDrawable drawable,
                                   Graph2D g2D)
Renders the layer representation of the given Graph2D into the given drawable.


addViewMode25D

public void addViewMode25D(ViewMode25D vm)
Adds the given view mode to this view and makes it active.

There can only be one active view mode at a time.


getViewModes

public Iterator getViewModes()
Returns an interator to all view modes that have been added to this view.


setActiveViewMode

public void setActiveViewMode(ViewMode25D vm)
Sets the given view mode as the active view mode.

There can only be one active view mode at a time.