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