jaron.pde
Class Graph

java.lang.Object
  extended by jaron.gui.Panel
      extended by jaron.pde.Graph

public class Graph
extends Panel

The Graph class provides a graphical component for the Processing Development Environment (PDE). It contains n graphs that are added and referenced via a unique key.
Reversing the graph's is done by swapping the high and the low signal values of the corresponding graph's signal.
The graphs usually get their current amplitudes via the EventListener mechanism as demonstrated in the example of the UAVsim.

Since:
1.0
Version:
1.2
Author:
jarontec gmail com

Field Summary
 
Fields inherited from class jaron.gui.Panel
content, frame, labelBottom, labelLeft, labelRight, labelTop
 
Constructor Summary
Graph(processing.core.PApplet applet, int left, int top)
          Creates a new Graph object for the Processing Development Environment (PDE) at a certain position.
Graph(processing.core.PApplet applet, int left, int top, int width, int height)
          Creates a new Graph object for the Processing Development Environment (PDE) at a certain position and with a certain width and height.
 
Method Summary
 void addGraph(java.lang.String label, int color)
          Adds a graph that will be drawn periodically.
 Signal createGraph(java.lang.String label, int color)
          Adds a graph that will be drawn periodically and returns its signal.
 void draw()
          Draws the whole graph component, containing all its graphs and the labels,to the screen.
 Signal getSignal(java.lang.String label)
          Returns the Signal of a certain graph.
 void setUpdateFrequency(int frequency)
          Sets the frequency on which the graphs should be updated.
 
Methods inherited from class jaron.gui.Panel
getContent, getFrame, getLabelBottom, getLabelLeft, getLabelRight, getLabelTop, setContent, setFrame, setLabelBottomHeight, setLabelLeftWidth, setLabelRightWidth, setLabelTopHeight
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Graph

public Graph(processing.core.PApplet applet,
             int left,
             int top,
             int width,
             int height)
Creates a new Graph object for the Processing Development Environment (PDE) at a certain position and with a certain width and height.

Parameters:
applet - a reference to the PDE applet that provides the drawing environment
left - the component's position from the left
top - the component's position from top
height - the component's height including the labels
width - the component's width including the labels

Graph

public Graph(processing.core.PApplet applet,
             int left,
             int top)
Creates a new Graph object for the Processing Development Environment (PDE) at a certain position.

Parameters:
applet - a reference to the PDE applet that provides the drawing environment
left - the component's position from the left
top - the component's position from top
Method Detail

addGraph

public void addGraph(java.lang.String label,
                     int color)
Adds a graph that will be drawn periodically.

Parameters:
label - a short description and unique identifier of the graph
color - the color of the graph
See Also:
Colors

createGraph

public Signal createGraph(java.lang.String label,
                          int color)
Adds a graph that will be drawn periodically and returns its signal.

Parameters:
label - a short description and unique identifier of the graph
color - the color of the graph
Returns:
the graph's signal
See Also:
Colors, Signal

draw

public void draw()
Draws the whole graph component, containing all its graphs and the labels,to the screen. This method should usually be called from the draw method of the Processing Development Environment. This ensures that the graph is updated periodically.


getSignal

public Signal getSignal(java.lang.String label)
Returns the Signal of a certain graph. The graph is identified by its label (unique key).

Parameters:
label - the label identifying the graph
Returns:
the graphs signal

setUpdateFrequency

public void setUpdateFrequency(int frequency)
Sets the frequency on which the graphs should be updated. By default the frequency is set to 20Hz.

Parameters:
frequency - the new update frequency