All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class ControlBeans.CPlotter

java.lang.Object
   |
   +----java.awt.Component
           |
           +----java.awt.Container
                   |
                   +----com.sun.java.swing.JComponent
                           |
                           +----com.sun.java.swing.JPanel
                                   |
                                   +----ControlBeans.CPlotter

public class CPlotter
extends JPanel
implements ComponentInterface, Runnable
This class implements a simple plotter. Its purpose it to provide the user with a visual graph indicator. This is a passive component, meaning that it will never itself send any values to the communicator. It can contain several curves with varying colors being drawn over a user defined range.
It has been implemented as a Javabean, meaning that it is well suited to use within visual programming tools such as NetBeans or JBuilder.

See Also:
AbstractCommunicator

Constructor Index

 o CPlotter()
Constructs a new CPlotter.

Method Index

 o addComponentListener(ComponentListener)
Registers a ComponentListener.
 o drawCurves(Graphics)
This methods draws the curves, axis and ticks.
 o getCapacity()
Gets how many values each curve in this plotter will store.
 o getColors()
Gets the color for each of the plottable curves in this plotter.
 o getDrawAxis()
Gets whether or not the x-axis and y-axis will be drawn.
 o getDrawTicks()
Gets whether or not the ticks will be drawn on the x-axis and y-axis.
 o getIsReceiver()
Gets whether or not this component will receive values.
 o getIsSender()
Gets whether or not this component will send values.
 o getMajorXTickSpacing()
Gets the number of units between each of the larger lines (ticks) on the scale on the x-axis.
 o getMajorYTickSpacing()
Gets the number of units between each of the larger lines (ticks) on the scale on the y-axis.
 o getMinorXTickSpacing()
Gets the number of units between each of the smaller lines (ticks) on the scale on the x-axis.
 o getMinorYTickSpacing()
Gets the number of units between each of the smaller lines (ticks) on the scale on the y-axis.
 o getRefreshrate()
Gets how often this plotter will refresh itself.
 o getTags()
Returns an array of integers containing all tags for which this plotter will draw curves.
 o getXRange()
Gets the range of the x-axis for this plotter.
 o getYOffset()
Gets the minimum plottable value on the y-axis for this plotter.
 o getYRange()
Gets the range of the y-axis for this plotter.
 o paint(Graphics)
This methods draws the curves, axis and ticks.
 o putValue(double, int, double, int)
Sets the value of this component.
 o putValue(int, int, double, int)
Sets the value of this component.
 o putValue(String, int, double, int)
Sets the value for this component.
 o registerCommunicator(AbstractCommunicator, int)
The communicator uses this method to alert this component of its presence.
 o removeComponentListener(ComponentListener)
Deregisters the ComponentListener.
 o requestValues()
Called by the communicator to make this component send its value(s).
 o run()
Starts the automatic refreshing of this plotter.
 o setCapacity(int)
Sets how many values each curve will store.
 o setColors(Color[])
Sets the color for each of the plottable curves in this plotter.
 o setDrawAxis(boolean)
Sets whether or not the x-axis and y-axis will be drawn.
 o setDrawTicks(boolean)
Sets whether or not the ticks will be drawn on the x-axis and y-axis.
 o setIsReceiver(boolean)
Sets whether or not this component should receive values.
 o setIsSender(boolean)
Sets whether or not this component should send values.
 o setMajorXTickSpacing(double)
Sets the number of units between each of the larger lines (ticks) on the scale on the x-axis.
 o setMajorYTickSpacing(double)
Sets the number of units between each of the larger lines (ticks) on the scale on the y-axis.
 o setMinorXTickSpacing(double)
Sets the number of units between each of the smaller lines (ticks) on the scale on the x-axis.
 o setMinorYTickSpacing(double)
Sets the number of units between each of the smaller lines (ticks) on the scale on the y-axis.
 o setRefreshrate(int)
Sets how often this plotter will refresh itself.
 o setTags(int[])
Sets the tags for which this plotter will draw curves.
 o setXRange(double)
Sets the range of the x-axis for this plotter.
 o setYOffset(double)
Sets the minimum plottable value on the y-axis for this plotter.
 o setYRange(double)
Sets the range of the y-axis for this plotter.
 o update(Graphics)
This methods draws the curves, axis and ticks.

Constructors

 o CPlotter
 public CPlotter()
Constructs a new CPlotter.

Methods

 o run
 public void run()
Starts the automatic refreshing of this plotter. This method is invoked in the registerCommunicator method and should therefore not be called directly by the user.

See Also:
registerCommunicator
 o getDrawAxis
 public boolean getDrawAxis()
Gets whether or not the x-axis and y-axis will be drawn.

Returns:
true if the two axis will be drawn, false otherwise.
 o setDrawAxis
 public void setDrawAxis(boolean value)
Sets whether or not the x-axis and y-axis will be drawn.

Parameters:
value - true if this component should draw the two axis, false otherwise.
 o getDrawTicks
 public boolean getDrawTicks()
Gets whether or not the ticks will be drawn on the x-axis and y-axis.

Returns:
true if the ticks will be drawn, false otherwise.
See Also:
getMajorXTickSpacing, getMajorYTickSpacing, getMinorXTickSpacing, getMinorYTickSpacing
 o setDrawTicks
 public void setDrawTicks(boolean value)
Sets whether or not the ticks will be drawn on the x-axis and y-axis.

Parameters:
value - true if the ticks should be drawn, false otherwise.
 o getIsReceiver
 public boolean getIsReceiver()
Gets whether or not this component will receive values.

Returns:
true if this component will receive values from the communicator; false otherwise.
 o setIsReceiver
 public void setIsReceiver(boolean value)
Sets whether or not this component should receive values.

Parameters:
value - true if this component should receive values from the communicator; false otherwise.
 o getIsSender
 public boolean getIsSender()
Gets whether or not this component will send values.
NOTE: Implemented for compatibility reasons only. This component cannot send values, hence this method will always return false.

Returns:
true if this component will send values to the communicator; false otherwise.
 o setIsSender
 public void setIsSender(boolean value)
Sets whether or not this component should send values.
NOTE: Implemented for compatibility reasons only. This component cannot send values, hence calling this method will have no effect.

Parameters:
value - true if this component should send values to the communicator; false otherwise.
 o getCapacity
 public int getCapacity()
Gets how many values each curve in this plotter will store.

Returns:
the capacity of the curves
 o setCapacity
 public void setCapacity(int value)
Sets how many values each curve will store. Larger numbers will make the curves longer or more detailed (depending on how often values are added to the curve). This may affect the time spent on redrawing.

Parameters:
value - the desired capacity of the curves
 o getRefreshrate
 public int getRefreshrate()
Gets how often this plotter will refresh itself.

Returns:
the time between each refresh in milliseconds
 o setRefreshrate
 public void setRefreshrate(int value)
Sets how often this plotter will refresh itself. Please note that even if additions to the curve(s) will not be shown until next refresh, they will not be lost. The plotter will only refresh itself if needed. Too high refreshrate might slow the program.

Parameters:
value - the desired time between each refresh in milliseconds
 o getTags
 public int[] getTags()
Returns an array of integers containing all tags for which this plotter will draw curves.

Returns:
all tags used by this component
See Also:
getColors
 o setTags
 public void setTags(int value[])
Sets the tags for which this plotter will draw curves.

Parameters:
value - an integer array containing the tags for this component
 o getMajorXTickSpacing
 public double getMajorXTickSpacing()
Gets the number of units between each of the larger lines (ticks) on the scale on the x-axis.

Returns:
the spacing between the larger lines on the x-axis
 o setMajorXTickSpacing
 public void setMajorXTickSpacing(double value)
Sets the number of units between each of the larger lines (ticks) on the scale on the x-axis. These ticks will also have a number by them.

Parameters:
value - the desired spacing between the larger lines on the x-axis
 o getMajorYTickSpacing
 public double getMajorYTickSpacing()
Gets the number of units between each of the larger lines (ticks) on the scale on the y-axis.

Returns:
the spacing between the larger lines on the y-axis
 o setMajorYTickSpacing
 public void setMajorYTickSpacing(double value)
Sets the number of units between each of the larger lines (ticks) on the scale on the y-axis. These ticks will also have a number by them.

Parameters:
value - the desired spacing between the larger lines on the y-axis
 o getMinorXTickSpacing
 public double getMinorXTickSpacing()
Gets the number of units between each of the smaller lines (ticks) on the scale on the x-axis.

Returns:
the spacing between the smaller lines on the x-axis
 o setMinorXTickSpacing
 public void setMinorXTickSpacing(double value)
Sets the number of units between each of the smaller lines (ticks) on the scale on the x-axis.

Parameters:
value - the desired spacing between the smaller lines on the x-axis
 o getMinorYTickSpacing
 public double getMinorYTickSpacing()
Gets the number of units between each of the smaller lines (ticks) on the scale on the y-axis.

Returns:
the spacing between the smaller lines on the y-axis
 o setMinorYTickSpacing
 public void setMinorYTickSpacing(double value)
Sets the number of units between each of the smaller lines (ticks) on the scale on the y-axis.

Parameters:
value - the desired spacing between the smaller lines on the y-axis
 o getXRange
 public double getXRange()
Gets the range of the x-axis for this plotter.

Returns:
the number of units on the x-axis over which this plotter plots values
 o setXRange
 public void setXRange(double value)
Sets the range of the x-axis for this plotter.

Parameters:
value - the desired number of units on the x-axis over which this plotter should plot values
 o getYOffset
 public double getYOffset()
Gets the minimum plottable value on the y-axis for this plotter.

Returns:
the minimum value of the y-axis for this plotter
 o setYOffset
 public void setYOffset(double value)
Sets the minimum plottable value on the y-axis for this plotter.

Parameters:
value - the desired minimum value of the y-axis for this plotter
 o getYRange
 public double getYRange()
Gets the range of the y-axis for this plotter.

Returns:
the number of units on the y-axis over which this plotter plots values
 o setYRange
 public void setYRange(double value)
Sets the range of the y-axis for this plotter.

Parameters:
value - the desired number of units on the y-axis over which this plotter should plot values
 o getColors
 public Color[] getColors()
Gets the color for each of the plottable curves in this plotter. Each color stored on a certain index will correspond to the tag on stored on the same index.

Returns:
an array of Colors
See Also:
getTags
 o setColors
 public void setColors(Color value[])
Sets the color for each of the plottable curves in this plotter.

Parameters:
value - an array of Colors where value[0] will correspond to the curve whose index is stored in tags[0], value[1] to tags[1], and so on.
See Also:
setTags
 o addComponentListener
 public void addComponentListener(ComponentListener l)
Registers a ComponentListener. By doing so the ComponentListener can receive component events from this component.
NOTE: This component can only hold one ComponentListener.

Parameters:
l - the ComponentListener to register.
 o removeComponentListener
 public void removeComponentListener(ComponentListener l)
Deregisters the ComponentListener.

Parameters:
l - the ComponentListener to remove.
 o registerCommunicator
 public void registerCommunicator(AbstractCommunicator c,
                                  int ID)
The communicator uses this method to alert this component of its presence.
NOTE: This method is invoked by AbstractCommunicator and should therefore never be called directly by the user.
NOTE: This method starts the automatic refreshing of this plotter by calling the run method.

Parameters:
c - the communicator in question
ID - the ID number assigned to this component and is stored in myID
See Also:
run, putValue, putValue, putValue
 o putValue
 public void putValue(int value,
                      int aTag,
                      double time,
                      int ID)
Sets the value of this component.

Parameters:
value - the value to be set
aTag - the tag of the component
time - a time tag for the value
ID - the ID of the component
See Also:
registerCommunicator
 o putValue
 public void putValue(double value,
                      int aTag,
                      double time,
                      int ID)
Sets the value of this component.

Parameters:
value - the value to be set
aTag - the tag of the component
time - a time tag for the value
ID - the ID of the component
See Also:
registerCommunicator
 o putValue
 public void putValue(String value,
                      int aTag,
                      double time,
                      int ID)
Sets the value for this component.
NOTE: Implemented for compatibility reasons only. This component cannot receive string values, hence calling this method will have no effect.

Parameters:
value - the value to be set
aTag - the tag of the component
time - a time tag for the value
ID - the ID of the component
See Also:
registerCommunicator
 o drawCurves
 public void drawCurves(Graphics g)
This methods draws the curves, axis and ticks. The drawing of axes and ticks may be supressed by calling drawAxis and drawTicks.
NOTE: The user should never invoke this method directly but instead call paint(Graphics g).

Parameters:
g - the graphics context of this plotter, typically obtained by calling getGraphics()
See Also:
getDrawAxis, getDrawTicks, paint
 o paint
 public void paint(Graphics g)
This methods draws the curves, axis and ticks. The drawing of axes and ticks may be supressed by calling drawAxis and drawTicks.

Parameters:
g - the graphics context of this plotter, typically obtained by calling getGraphics()
Overrides:
paint in class JComponent
See Also:
getDrawAxis, getDrawTicks
 o update
 public void update(Graphics g)
This methods draws the curves, axis and ticks. The drawing of axes and ticks may be supressed by calling drawAxis and drawTicks.
NOTE: The user should never invoke this method directly but instead call paint(Graphics g).

Parameters:
g - the graphics context of this plotter, typically obtained by calling getGraphics()
Overrides:
update in class JComponent
See Also:
getDrawAxis, getDrawTicks, paint
 o requestValues
 public void requestValues()
Called by the communicator to make this component send its value(s). This can be used for initialization.
NOTE: Implemented for compatibility reasons only. This component does not send values, hence calling this method will have no effect,


All Packages  Class Hierarchy  This Package  Previous  Next  Index