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

Variable Index

 o ALL
style for inscribing ticks: mark each tick
 o axisColor
color, in which axis, ticks and caption are drawn
 o axisFont
font used for caption
 o currentHeight
width this SWING component
 o currentWidth
height this SWING component
 o FIT
adjust {x|y}min and {x|y}max so the values fit in the graph
 o MAXIMA
style for inscribing ticks: just mark the maxima at both axises
 o MAXIMA_ZERO
style for inscribing ticks: same as MAXIMA, but zero position as well
 o NONE
used, when signaling "ignore something"
 o OBJECT
style for inscribing ticks: pass every tick value to an object and let this object mark the tick.
 o plots
collection of IDataSeries', which have to be plotted
 o SCROLL
adjust xmin and xmax so older values are scrolled to the left
 o ticksAsDottedLines
it possible to draw dotted lines instead of ticks.
 o xAxisBehaviour
how to behave when a value is larger than xmax or smaller than xmin.
 o xmax
logical dimension of the graph: maximal x-value
 o xmin
logical dimension of the graph: minimal x-value
 o xTicksCaptionObject
if xTicksCaptionStyle equals to OBJECT then this variable contains a reference to the caption object
 o xTicksCaptionStyle
style with which the x-axis is marked
 o xTicksDistance
each xTicksDistance a tick is drawn on the axis
 o yAxisBehaviour
how to behave when a value is larger than ymax or smaller than ymin.
 o ymax
logical dimension of the graph: maximal y-value
 o ymin
logical dimension of the graph: minimal y-value
 o yTicksCaptionObject
if yTicksCaptionStyle equals to OBJECT then this variable contains a reference to the caption object
 o yTicksCaptionStyle
style with which the y-axis is marked
 o yTicksDistance
each yTicksDistance a tick is drawn axis

Constructor Index

 o Plotter()
 o Plotter(double, double, double, double, double, double)

Method Index

 o addPlot(IDataSeries)
Add a new collection of data and plot it.
 o drawPlots(Graphics)
plot the data of all registered plots.
 o drawXaxis(Graphics)
draw x-axis.
 o drawYaxis(Graphics)
draw x-axis.
 o getMinimumSize()
 o getPreferredSize()
 o getSize()
 o getTicksAsDottedLines()
get, wether ticks are drawn as dotted lines spawning the component's background
 o getXaxisBehaviour()
get , how the x-axis behaves when we attempt to plot a value
 o getXMax()
get logical x-dimension (maximum)
 o getXMin()
get logical x-dimension (minimum)
 o getXticksCaptionObject()
return the caption object for the x-axis.
 o getXticksCaptionStyle()
get, how x axis is marked.
 o getXticksDistance()
get the distance between to ticks on x-axis
 o getYaxisBehaviour()
get , how the y-axis behaves when we attempt to plot a value
 o getYMax()
get logical y-dimension (maximum)
 o getYMin()
get logical y-dimension (minimum)
 o getYticksCaptionObject()
return the caption object for the y-axis.
 o getYticksCaptionStyle()
get, how y axis is marked.
 o getYticksDistance()
get the distance between to ticks on y-axis
 o paintComponent(Graphics)
 o setBounds(Rectangle)
 o setSize(Dimension)
 o setSize(int, int)
 o setTicksAsDottedLines(boolean)
set, wether ticks are drawn as dotted lines spawning the component's background or as short lines crossing an axis.
 o setXaxisBehaviour(int)
set, how the x-axis behaves when we attempt to plot a value which is larger or smaller than xmax resp.
 o setXMax(double)
set logical x-dimension (maximum)
 o setXMin(double)
set logical x-dimension (minimum)
 o setXticksCaptionObject(ITickCaption)
Mark the x-axis using an object.
 o setXticksCaptionStyle(int)
set, how x axis is marked.
 o setXticksDistance(double)
Set the distance between to ticks on x-axis
 o setYaxisBehaviour(int)
set, how the y-axis behaves when we attempt to plot a value which is larger or smaller than ymax resp.
 o setYMax(double)
set logical y-dimension (maximum)
 o setYMin(double)
set logical y-dimension (minimum)
 o setYticksCaptionObject(ITickCaption)
Mark the y-axis using an object.
 o setYticksCaptionStyle(int)
set, how y axis is marked.
 o setYticksDistance(double)
Set the distance between to ticks on y-axis
 o translateX(double)
map values in [xmin, xmax] to [0, currentWidth]
 o translateY(double)
map values in [ymin, ymax] to [0, currentHeight]
 o update(Observable, Object)
 o updateUI()

Variables

 o plots
 private Vector plots
collection of IDataSeries', which have to be plotted

 o xmin
 private double xmin
logical dimension of the graph: minimal x-value

 o xmax
 private double xmax
logical dimension of the graph: maximal x-value

 o ymin
 private double ymin
logical dimension of the graph: minimal y-value

 o ymax
 private double ymax
logical dimension of the graph: maximal y-value

 o xTicksDistance
 private double xTicksDistance
each xTicksDistance a tick is drawn on the axis

 o yTicksDistance
 private double yTicksDistance
each yTicksDistance a tick is drawn axis

 o ticksAsDottedLines
 private boolean ticksAsDottedLines
it possible to draw dotted lines instead of ticks. Some might say, it looks better (i.e, me)..

 o axisColor
 private Color axisColor
color, in which axis, ticks and caption are drawn

 o axisFont
 private Font axisFont
font used for caption

 o NONE
 public static final int NONE
used, when signaling "ignore something"

 o MAXIMA
 public static final int MAXIMA
style for inscribing ticks: just mark the maxima at both axises

 o MAXIMA_ZERO
 public static final int MAXIMA_ZERO
style for inscribing ticks: same as MAXIMA, but zero position as well

 o ALL
 public static final int ALL
style for inscribing ticks: mark each tick

 o 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.

 o xTicksCaptionStyle
 private int xTicksCaptionStyle
style with which the x-axis is marked

 o yTicksCaptionStyle
 private int yTicksCaptionStyle
style with which the y-axis is marked

 o xTicksCaptionObject
 private ITickCaption xTicksCaptionObject
if xTicksCaptionStyle equals to OBJECT then this variable contains a reference to the caption object

 o yTicksCaptionObject
 private ITickCaption yTicksCaptionObject
if yTicksCaptionStyle equals to OBJECT then this variable contains a reference to the caption object

 o FIT
 public static final int FIT
adjust {x|y}min and {x|y}max so the values fit in the graph

 o SCROLL
 public static final int SCROLL
adjust xmin and xmax so older values are scrolled to the left

 o xAxisBehaviour
 private int xAxisBehaviour
how to behave when a value is larger than xmax or smaller than xmin. Accepted values: NONE, FIT, SCROLL.

 o yAxisBehaviour
 private int yAxisBehaviour
how to behave when a value is larger than ymax or smaller than ymin. Accepted values: NONE, FIT.

 o currentWidth
 private int currentWidth
height this SWING component

 o currentHeight
 private int currentHeight
width this SWING component

Constructors

 o Plotter
 public Plotter()
 o Plotter
 public Plotter(double xmin,
                double xmax,
                double ymin,
                double ymax,
                double xTicksDistance,
                double yTicksDistance)

Methods

 o 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.).

 o setXMin
 public final void setXMin(double xmin)
set logical x-dimension (minimum)

 o getXMin
 public final double getXMin()
get logical x-dimension (minimum)

 o setXMax
 public final void setXMax(double xmax)
set logical x-dimension (maximum)

 o getXMax
 public final double getXMax()
get logical x-dimension (maximum)

 o setXticksDistance
 public final void setXticksDistance(double xTicksDistance)
Set the distance between to ticks on x-axis

 o getXticksDistance
 public final double getXticksDistance()
get the distance between to ticks on x-axis

 o setYMin
 public final void setYMin(double ymin)
set logical y-dimension (minimum)

 o getYMin
 public final double getYMin()
get logical y-dimension (minimum)

 o setYMax
 public final void setYMax(double ymax)
set logical y-dimension (maximum)

 o getYMax
 public final double getYMax()
get logical y-dimension (maximum)

 o setYticksDistance
 public final void setYticksDistance(double yTicksDistance)
Set the distance between to ticks on y-axis

 o getYticksDistance
 public final double getYticksDistance()
get the distance between to ticks on y-axis

 o 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
 o getTicksAsDottedLines
 public final boolean getTicksAsDottedLines()
get, wether ticks are drawn as dotted lines spawning the component's background

 o setXticksCaptionStyle
 public final void setXticksCaptionStyle(int style) throws IllegalArgumentException
set, how x axis is marked.

Parameters:
style: - NONE, ALL, MAXIMA, MAXIMA_ZERO, OBJECT
 o getXticksCaptionStyle
 public final int getXticksCaptionStyle()
get, how x axis is marked.

 o setYticksCaptionStyle
 public final void setYticksCaptionStyle(int style) throws IllegalArgumentException
set, how y axis is marked.

Parameters:
style: - NONE, ALL, MAXIMA, MAXIMA_ZERO, OBJECT
 o getYticksCaptionStyle
 public final int getYticksCaptionStyle()
get, how y axis is marked.

 o 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.

 o getXticksCaptionObject
 public final ITickCaption getXticksCaptionObject()
return the caption object for the x-axis. Undefined behaviour, if xTicksCaptionStyle != OBJECT.

 o 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.

 o getYticksCaptionObject
 public final ITickCaption getYticksCaptionObject()
return the caption object for the y-axis. Undefined behaviour, if yTicksCaptionStyle != OBJECT.

 o 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
 o getXaxisBehaviour
 public final int getXaxisBehaviour()
get , how the x-axis behaves when we attempt to plot a value

 o 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
 o getYaxisBehaviour
 public final int getYaxisBehaviour()
get , how the y-axis behaves when we attempt to plot a value

 o translateX
 private int translateX(double d)
map values in [xmin, xmax] to [0, currentWidth]

 o translateY
 private int translateY(double d)
map values in [ymin, ymax] to [0, currentHeight]

 o update
 public void update(Observable o,
                    Object arg)
 o paintComponent
 public void paintComponent(Graphics gc)
Overrides:
paintComponent in class JComponent
 o drawXaxis
 private void drawXaxis(Graphics gc)
draw x-axis. respects xTicksCaptionStyle

 o drawYaxis
 private void drawYaxis(Graphics gc)
draw x-axis. respects xTicksCaptionStyle

 o drawPlots
 private void drawPlots(Graphics gc)
plot the data of all registered plots. Respects {x|y}AxisBehaviour.

 o updateUI
 public void updateUI()
Overrides:
updateUI in class JPanel
 o getMinimumSize
 public Dimension getMinimumSize()
Overrides:
getMinimumSize in class JComponent
 o getPreferredSize
 public Dimension getPreferredSize()
Overrides:
getPreferredSize in class JComponent
 o getSize
 public Dimension getSize()
Overrides:
getSize in class Component
 o setSize
 public void setSize(Dimension d)
Overrides:
setSize in class Component
 o setSize
 public void setSize(int width,
                     int height)
Overrides:
setSize in class Component
 o setBounds
 public void setBounds(Rectangle r)
Overrides:
setBounds in class Component

All Packages  Class Hierarchy  This Package  Previous  Next  Index