All Packages Class Hierarchy This Package Previous Next Index
Class jsz.Plotter.Plotter
java.lang.Object
|
+----java.awt.Component
|
+----java.awt.Container
|
+----javax.swing.JComponent
|
+----javax.swing.JPanel
|
+----jsz.Plotter.Plotter
- public class Plotter
- extends JPanel
- implements Observer
An object of this class implements a plotter, which is used
for visualizing data. This plotter class has some neat
properties. It is possible to specify, how a plotter behaves,
when data is larger then the coordinate system (ignore it, so
this datum isn't drawn, expand x and/or y dimension, so
everything fits in, or scroll, so older values scroll to the
left). There are different modes for drawing the caption
(mark every tick, mark just the maxima and mark
maxima and zero). However, it is possible to specify a class,
which does caption, so arbitrary captions can be
programmed.This class respects the current look-and-feel and
reacts on l&f changes.
- Version:
- $Revision: 1.7 $
- Author:
- Janek Schwarz
-
ALL
- style for inscribing ticks: mark each tick
-
axisColor
- color, in which axis, ticks and caption are drawn
-
axisFont
- font used for caption
-
currentHeight
- width this SWING component
-
currentWidth
- height this SWING component
-
FIT
- adjust {x|y}min and {x|y}max so the values fit in the graph
-
MAXIMA
- style for inscribing ticks: just mark the maxima at both axises
-
MAXIMA_ZERO
- style for inscribing ticks: same as MAXIMA, but zero position as well
-
NONE
- used, when signaling "ignore something"
-
OBJECT
- style for inscribing ticks: pass every tick value to an object
and let this object mark the tick.
-
plots
- collection of IDataSeries', which have to be plotted
-
SCROLL
- adjust xmin and xmax so older values are scrolled to the left
-
ticksAsDottedLines
- it possible to draw dotted lines instead of ticks.
-
xAxisBehaviour
- how to behave when a value is larger than xmax or smaller than
xmin.
-
xmax
- logical dimension of the graph: maximal x-value
-
xmin
- logical dimension of the graph: minimal x-value
-
xTicksCaptionObject
- if
xTicksCaptionStyle
equals to
OBJECT
then this variable contains a reference to
the caption object
-
xTicksCaptionStyle
- style with which the x-axis is marked
-
xTicksDistance
- each xTicksDistance a tick is drawn on the axis
-
yAxisBehaviour
- how to behave when a value is larger than ymax or smaller than
ymin.
-
ymax
- logical dimension of the graph: maximal y-value
-
ymin
- logical dimension of the graph: minimal y-value
-
yTicksCaptionObject
- if
yTicksCaptionStyle
equals to
OBJECT
then this variable contains a reference to
the caption object
-
yTicksCaptionStyle
- style with which the y-axis is marked
-
yTicksDistance
- each yTicksDistance a tick is drawn axis
-
Plotter()
-
-
Plotter(double, double, double, double, double, double)
-
-
addPlot(IDataSeries)
- Add a new collection of data and plot it.
-
drawPlots(Graphics)
- plot the data of all registered plots.
-
drawXaxis(Graphics)
- draw x-axis.
-
drawYaxis(Graphics)
- draw x-axis.
-
getMinimumSize()
-
-
getPreferredSize()
-
-
getSize()
-
-
getTicksAsDottedLines()
- get, wether ticks are drawn as dotted lines spawning the
component's background
-
getXaxisBehaviour()
- get , how the x-axis behaves when we attempt to plot a value
-
getXMax()
- get logical x-dimension (maximum)
-
getXMin()
- get logical x-dimension (minimum)
-
getXticksCaptionObject()
- return the caption object for the x-axis.
-
getXticksCaptionStyle()
- get, how x axis is marked.
-
getXticksDistance()
- get the distance between to ticks on x-axis
-
getYaxisBehaviour()
- get , how the y-axis behaves when we attempt to plot a value
-
getYMax()
- get logical y-dimension (maximum)
-
getYMin()
- get logical y-dimension (minimum)
-
getYticksCaptionObject()
- return the caption object for the y-axis.
-
getYticksCaptionStyle()
- get, how y axis is marked.
-
getYticksDistance()
- get the distance between to ticks on y-axis
-
paintComponent(Graphics)
-
-
setBounds(Rectangle)
-
-
setSize(Dimension)
-
-
setSize(int, int)
-
-
setTicksAsDottedLines(boolean)
- set, wether ticks are drawn as dotted lines spawning the
component's background or as short lines crossing an axis.
-
setXaxisBehaviour(int)
- set, how the x-axis behaves when we attempt to plot a value
which is larger or smaller than xmax resp.
-
setXMax(double)
- set logical x-dimension (maximum)
-
setXMin(double)
- set logical x-dimension (minimum)
-
setXticksCaptionObject(ITickCaption)
- Mark the x-axis using an object.
-
setXticksCaptionStyle(int)
- set, how x axis is marked.
-
setXticksDistance(double)
- Set the distance between to ticks on x-axis
-
setYaxisBehaviour(int)
- set, how the y-axis behaves when we attempt to plot a value
which is larger or smaller than ymax resp.
-
setYMax(double)
- set logical y-dimension (maximum)
-
setYMin(double)
- set logical y-dimension (minimum)
-
setYticksCaptionObject(ITickCaption)
- Mark the y-axis using an object.
-
setYticksCaptionStyle(int)
- set, how y axis is marked.
-
setYticksDistance(double)
- Set the distance between to ticks on y-axis
-
translateX(double)
- map values in [xmin, xmax] to [0, currentWidth]
-
translateY(double)
- map values in [ymin, ymax] to [0, currentHeight]
-
update(Observable, Object)
-
-
updateUI()
-
plots
private Vector plots
- collection of IDataSeries', which have to be plotted
xmin
private double xmin
- logical dimension of the graph: minimal x-value
xmax
private double xmax
- logical dimension of the graph: maximal x-value
ymin
private double ymin
- logical dimension of the graph: minimal y-value
ymax
private double ymax
- logical dimension of the graph: maximal y-value
xTicksDistance
private double xTicksDistance
- each xTicksDistance a tick is drawn on the axis
yTicksDistance
private double yTicksDistance
- each yTicksDistance a tick is drawn axis
ticksAsDottedLines
private boolean ticksAsDottedLines
- it possible to draw dotted lines instead of ticks. Some might say, it looks
better (i.e, me)..
axisColor
private Color axisColor
- color, in which axis, ticks and caption are drawn
axisFont
private Font axisFont
- font used for caption
NONE
public static final int NONE
- used, when signaling "ignore something"
MAXIMA
public static final int MAXIMA
- style for inscribing ticks: just mark the maxima at both axises
MAXIMA_ZERO
public static final int MAXIMA_ZERO
- style for inscribing ticks: same as MAXIMA, but zero position as well
ALL
public static final int ALL
- style for inscribing ticks: mark each tick
OBJECT
public static final int OBJECT
- style for inscribing ticks: pass every tick value to an object
and let this object mark the tick. Could be used to map
values to words.
xTicksCaptionStyle
private int xTicksCaptionStyle
- style with which the x-axis is marked
yTicksCaptionStyle
private int yTicksCaptionStyle
- style with which the y-axis is marked
xTicksCaptionObject
private ITickCaption xTicksCaptionObject
- if
xTicksCaptionStyle
equals to
OBJECT
then this variable contains a reference to
the caption object
yTicksCaptionObject
private ITickCaption yTicksCaptionObject
- if
yTicksCaptionStyle
equals to
OBJECT
then this variable contains a reference to
the caption object
FIT
public static final int FIT
- adjust {x|y}min and {x|y}max so the values fit in the graph
SCROLL
public static final int SCROLL
- adjust xmin and xmax so older values are scrolled to the left
xAxisBehaviour
private int xAxisBehaviour
- how to behave when a value is larger than xmax or smaller than
xmin. Accepted values: NONE, FIT, SCROLL.
yAxisBehaviour
private int yAxisBehaviour
- how to behave when a value is larger than ymax or smaller than
ymin. Accepted values: NONE, FIT.
currentWidth
private int currentWidth
- height this SWING component
currentHeight
private int currentHeight
- width this SWING component
Plotter
public Plotter()
Plotter
public Plotter(double xmin,
double xmax,
double ymin,
double ymax,
double xTicksDistance,
double yTicksDistance)
addPlot
public Plotter addPlot(IDataSeries ds)
- Add a new collection of data and plot it. The plotter adds
itself to the list of observers of ds, so it is notified about
changes of ds (adding data, changing color, legend etc.).
setXMin
public final void setXMin(double xmin)
- set logical x-dimension (minimum)
getXMin
public final double getXMin()
- get logical x-dimension (minimum)
setXMax
public final void setXMax(double xmax)
- set logical x-dimension (maximum)
getXMax
public final double getXMax()
- get logical x-dimension (maximum)
setXticksDistance
public final void setXticksDistance(double xTicksDistance)
- Set the distance between to ticks on x-axis
getXticksDistance
public final double getXticksDistance()
- get the distance between to ticks on x-axis
setYMin
public final void setYMin(double ymin)
- set logical y-dimension (minimum)
getYMin
public final double getYMin()
- get logical y-dimension (minimum)
setYMax
public final void setYMax(double ymax)
- set logical y-dimension (maximum)
getYMax
public final double getYMax()
- get logical y-dimension (maximum)
setYticksDistance
public final void setYticksDistance(double yTicksDistance)
- Set the distance between to ticks on y-axis
getYticksDistance
public final double getYticksDistance()
- get the distance between to ticks on y-axis
setTicksAsDottedLines
public final void setTicksAsDottedLines(boolean ticksAsDottedLines)
- set, wether ticks are drawn as dotted lines spawning the
component's background or as short lines crossing an axis.
- Parameters:
- ticksAsDottedLines - true: draw dotted lines
getTicksAsDottedLines
public final boolean getTicksAsDottedLines()
- get, wether ticks are drawn as dotted lines spawning the
component's background
setXticksCaptionStyle
public final void setXticksCaptionStyle(int style) throws IllegalArgumentException
- set, how x axis is marked.
- Parameters:
- style: - NONE, ALL, MAXIMA, MAXIMA_ZERO, OBJECT
getXticksCaptionStyle
public final int getXticksCaptionStyle()
- get, how x axis is marked.
setYticksCaptionStyle
public final void setYticksCaptionStyle(int style) throws IllegalArgumentException
- set, how y axis is marked.
- Parameters:
- style: - NONE, ALL, MAXIMA, MAXIMA_ZERO, OBJECT
getYticksCaptionStyle
public final int getYticksCaptionStyle()
- get, how y axis is marked.
setXticksCaptionObject
public final void setXticksCaptionObject(ITickCaption object)
- Mark the x-axis using an object. See the example provided
in {@link jsz.Plotter.ITickCaption}. This
method also changes
xTicksCaptionStyle
to
OBJECT
.
getXticksCaptionObject
public final ITickCaption getXticksCaptionObject()
- return the caption object for the x-axis. Undefined
behaviour, if
xTicksCaptionStyle != OBJECT
.
setYticksCaptionObject
public final void setYticksCaptionObject(ITickCaption object)
- Mark the y-axis using an object. See the example provided
in {@link jsz.Plotter.ITickCaption}. This
method also changes
yTicksCaptionStyle
to
OBJECT
.
getYticksCaptionObject
public final ITickCaption getYticksCaptionObject()
- return the caption object for the y-axis. Undefined
behaviour, if
yTicksCaptionStyle != OBJECT
.
setXaxisBehaviour
public final void setXaxisBehaviour(int behaviour) throws IllegalArgumentException
- set, how the x-axis behaves when we attempt to plot a value
which is larger or smaller than xmax resp. xmin.
- Parameters:
- behaviour: - NONE, FIT, SCROLL are excepted
- Throws: IllegalArgumentException
- otherwise
getXaxisBehaviour
public final int getXaxisBehaviour()
- get , how the x-axis behaves when we attempt to plot a value
setYaxisBehaviour
public final void setYaxisBehaviour(int behaviour)
- set, how the y-axis behaves when we attempt to plot a value
which is larger or smaller than ymax resp. ymin.
- Parameters:
- behaviour: - NONE, FIT are excepted
- Throws: IllegalArgumentException
- otherwise
getYaxisBehaviour
public final int getYaxisBehaviour()
- get , how the y-axis behaves when we attempt to plot a value
translateX
private int translateX(double d)
- map values in [xmin, xmax] to [0, currentWidth]
translateY
private int translateY(double d)
- map values in [ymin, ymax] to [0, currentHeight]
update
public void update(Observable o,
Object arg)
paintComponent
public void paintComponent(Graphics gc)
- Overrides:
- paintComponent in class JComponent
drawXaxis
private void drawXaxis(Graphics gc)
- draw x-axis. respects
xTicksCaptionStyle
drawYaxis
private void drawYaxis(Graphics gc)
- draw x-axis. respects
xTicksCaptionStyle
drawPlots
private void drawPlots(Graphics gc)
- plot the data of all registered plots. Respects {x|y}AxisBehaviour.
updateUI
public void updateUI()
- Overrides:
- updateUI in class JPanel
getMinimumSize
public Dimension getMinimumSize()
- Overrides:
- getMinimumSize in class JComponent
getPreferredSize
public Dimension getPreferredSize()
- Overrides:
- getPreferredSize in class JComponent
getSize
public Dimension getSize()
- Overrides:
- getSize in class Component
setSize
public void setSize(Dimension d)
- Overrides:
- setSize in class Component
setSize
public void setSize(int width,
int height)
- Overrides:
- setSize in class Component
setBounds
public void setBounds(Rectangle r)
- Overrides:
- setBounds in class Component
All Packages Class Hierarchy This Package Previous Next Index