graph3d
Class GraphView

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--graph3d.GraphView
All Implemented Interfaces:
javax.accessibility.Accessible, java.awt.event.ComponentListener, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseMotionListener, java.io.Serializable

public class GraphView
extends java.awt.Canvas
implements java.awt.event.ComponentListener, java.awt.event.MouseMotionListener

A graph view. This class is threadsafe, ie. one can send all kind of state setter methods in the context of any thread. Note: this explicitly excludes paint() and listener methods, which are not meant to be invoked immediately anyway.

See Also:
Serialized Form

Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent
 
Field Summary
static int AXES
          Mode bit: indicates usage of x,y,z axis display.
static int CONTOURS
          Mode bit: draw contour colors.
static int LIGHTS
          Mode bit: indicates usage of lighting.
static int LINES
          Mode bit: indicates graph shading as lines.
static int POINTS
          Mode bit: indicates graph shading as point set.
static int SMOOTH
          Mode bit: indicates smooth shading of graph.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
GraphView(Function function)
          Create a graph from a function.
 
Method Summary
 void componentHidden(java.awt.event.ComponentEvent event)
          Not used.
 void componentMoved(java.awt.event.ComponentEvent event)
          Not used.
 void componentResized(java.awt.event.ComponentEvent event)
          Invokes a reshape.
 void componentShown(java.awt.event.ComponentEvent event)
          Not used.
 void finalize()
           
 float getLightBlueValue(int n)
          Returns the blue component of light #n color.
 float getLightGreenValue(int n)
          Returns the green component of light #n color.
 float getLightRedValue(int n)
          Returns the red component of light #n color.
 double getRangeX0()
          Returns the X range low boundary.
 double getRangeX1()
          Returns the X range high boundary.
 double getRangeY0()
          Returns the Y range low boundary.
 double getRangeY1()
          Returns the Y range high boundary.
 boolean hasZ()
          Checks, if this is a f(x,y,z)-style function.
 int mode(int m)
          Checks mode bits.
 void mouseClicked(java.awt.event.MouseEvent event)
          Not used.
 void mouseDragged(java.awt.event.MouseEvent event)
          Reacts on mouse drags.
 void mouseMoved(java.awt.event.MouseEvent event)
          Not used.
 void paint(java.awt.Graphics g)
          Paint the view.
 void rotateX(double ax)
          Rotate scene around X axis.
 void rotateY(double ay)
          Rotate scene around Y axis.
 void rotateZ(double az)
          Rotate scene around Z axis.
 void setDefaultMode(int mode)
          Set default rendering mode.
 void setLightColor(int n, float r, float g, float b)
          Set light #n color.
 void setMode(int mode)
          Set rendering mode.
 void setRangeX(double x0, double x1)
          Set plot range of X axis.
 void setRangeY(double y0, double y1)
          Set plot range of Y axis.
 void setZ(double z)
          Set Z value for a f(x,y,z)-style function.
 void unsetMode(int mode)
          Unset a rendering mode bit.
 void zoom(double tz)
          Zooms the graph in or out.
 
Methods inherited from class java.awt.Canvas
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getName, getParent, getPeer, getPreferredSize, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isFocusTraversable, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

POINTS

public static final int POINTS
Mode bit: indicates graph shading as point set.

LINES

public static final int LINES
Mode bit: indicates graph shading as lines.

SMOOTH

public static final int SMOOTH
Mode bit: indicates smooth shading of graph.

LIGHTS

public static final int LIGHTS
Mode bit: indicates usage of lighting.

AXES

public static final int AXES
Mode bit: indicates usage of x,y,z axis display.

CONTOURS

public static final int CONTOURS
Mode bit: draw contour colors.
Constructor Detail

GraphView

public GraphView(Function function)
          throws java.lang.IllegalArgumentException,
                 RuntimeException,
                 TypeMismatchException
Create a graph from a function.
Parameters:
function - the function to graph
Throws:
IllegalArgumentException, - if the function is not plottable RuntimeException, if the function causes a stack machine error
Method Detail

componentHidden

public void componentHidden(java.awt.event.ComponentEvent event)
Not used.
Specified by:
componentHidden in interface java.awt.event.ComponentListener

componentMoved

public void componentMoved(java.awt.event.ComponentEvent event)
Not used.
Specified by:
componentMoved in interface java.awt.event.ComponentListener

componentResized

public void componentResized(java.awt.event.ComponentEvent event)
Invokes a reshape. This method must not be called from outside the event thread.
Specified by:
componentResized in interface java.awt.event.ComponentListener

componentShown

public void componentShown(java.awt.event.ComponentEvent event)
Not used.
Specified by:
componentShown in interface java.awt.event.ComponentListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent event)
Not used.

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent event)
Reacts on mouse drags. Used to compute scene rotation.
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent event)
Not used.
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

paint

public void paint(java.awt.Graphics g)
Paint the view. This method must not be called from outside the event thread.
Overrides:
paint in class java.awt.Canvas
Parameters:
g - the Graphics object
Throws:
IllegalArgumentException, - if invoked from another thread

getLightRedValue

public float getLightRedValue(int n)
Returns the red component of light #n color.
Returns:
red component of color of light #n
Throws:
IllegalArgumentException, - if n does not match a valid light

getLightGreenValue

public float getLightGreenValue(int n)
Returns the green component of light #n color.
Returns:
green component of color of light #n
Throws:
IllegalArgumentException, - if n does not match a valid light

getLightBlueValue

public float getLightBlueValue(int n)
Returns the blue component of light #n color.
Returns:
blue component of color of light #n
Throws:
IllegalArgumentException, - if n does not match a valid light

getRangeX0

public double getRangeX0()
Returns the X range low boundary.
Returns:
low boundary on X axis

getRangeX1

public double getRangeX1()
Returns the X range high boundary.
Returns:
high boundary on X axis

getRangeY0

public double getRangeY0()
Returns the Y range low boundary.
Returns:
low boundary on Y axis

getRangeY1

public double getRangeY1()
Returns the Y range high boundary.
Returns:
high boundary on Y axis

hasZ

public boolean hasZ()
Checks, if this is a f(x,y,z)-style function.
Returns:
true, if this graph allows z value setting

mode

public int mode(int m)
Checks mode bits.
Parameters:
m - the mode bit(s) to check for.
Returns:
the mode bits matched

rotateX

public void rotateX(double ax)
Rotate scene around X axis.
Parameters:
ax - angle to apply

rotateY

public void rotateY(double ay)
Rotate scene around Y axis.
Parameters:
ay - angle to apply

rotateZ

public void rotateZ(double az)
Rotate scene around Z axis.
Parameters:
az - angle to apply

setLightColor

public void setLightColor(int n,
                          float r,
                          float g,
                          float b)
                   throws java.lang.IllegalArgumentException
Set light #n color.
Parameters:
n - number of light
r - red value of color
g - green value of color
b - blue value of color
Throws:
IllegalArgumentException, - if n is not a valid light

setDefaultMode

public void setDefaultMode(int mode)
Set default rendering mode. Only the POINTS flag will be set, and the corresponding drawing mode be used.

setMode

public void setMode(int mode)
Set rendering mode.
Parameters:
mode - POINTS: draws the grid as a point set LINES : draws the grid as a wireframe mesh SMOOTH: applies smooth shading on the grid LIGHTS: uses lighting AXES : draws x,y,z axes

setRangeX

public void setRangeX(double x0,
                      double x1)
               throws java.lang.IllegalArgumentException
Set plot range of X axis.
Parameters:
x0 - low bound of X range
x1 - high bound of X range
Throws:
IllegalArgumentException, - if y0 >= y1

setRangeY

public void setRangeY(double y0,
                      double y1)
               throws java.lang.IllegalArgumentException
Set plot range of Y axis.
Parameters:
y0 - low bound of Y range
y1 - high bound of Y range
Throws:
IllegalArgumentException, - if y0 >= y1

setZ

public void setZ(double z)
Set Z value for a f(x,y,z)-style function. This can be used to animate a plot.
Parameters:
z - Z value to use for f(x,y,z)

unsetMode

public void unsetMode(int mode)
Unset a rendering mode bit.
Parameters:
mode - POINTS: draws the grid as a point set LINES : draws the grid as a wireframe mesh SMOOTH: applies smooth shading on the grid LIGHTS: uses lighting AXES : draws x,y,z axes

zoom

public void zoom(double tz)
Zooms the graph in or out.
Parameters:
tz - - values larger 0 zoom out values less than 0 zoom in

finalize

public void finalize()
Overrides:
finalize in class java.lang.Object