The idea behind the BasicPlotter
is to provide a small fraction of the
functionality known from "R" or "GnuPlot", if you have some basic elements,
such as lines, ellipses, rectangles, you want to add to your view you can use
the BasicPlotter
.
addLine(double[] yValues, Color color, Stroke stroke) addLine(double[] xValues, double[] yValues, Color color, Stroke stroke) addRectangle(double x, double y, int width, int height, Color color, Stroke stroke, boolean filled) addEllipse(double xCenter, double yCenter, double width, double height, Color color, Stroke stroke, boolean filled)The usage of the
BasicPlotter
methods only makes sense, if the
the domain values of the elements are known but not the mapped values.
One example is a scatter plot where you want to add a regression line.
Here only the domain values of the line are known and can simply be added as a line
to the plotter with the domain values.
The BasicPlotter
will map the domain values to the drawing pane's size.
If you set preserve = true
in the AbstractPlotter
the
existing ranges of the coordinates won't be adapted. If you set preserve to false,
the ranges will be adapted if, for example, the added rectangle is larger than
the existing range of the coordinates.
Another possibility is to add a DataArray
which will be visualized
with a line connecting all values in the columns, where the row number is the
x axis and the value of the column is painted at the y axis.
addLine(DataArray data, int columnIndex, Color color, Stroke stroke)If you want to add a specific element to the
BasicPlotter
you can
extend the BasicDrawingElement
or the Basic2DDrawingElement
(described below) with
addBasicDrawingElement(BasicDrawingElement element)
BasicDrawingElement
consists of a number of domain values and the
referring mapped points, a color and a stroke. Whenever the size is changed,
the BasicPlotter
takes the domain values and maps them to the
current drawing pane size. How the BasicDrawingElement
is actually
painted (depending on the given points) is defined in the paint method which is
abstract. The Basic2DDrawingElement
extends the
BasicDrawingElement
by holding a flag, whether the form should be
filled or not.
Thus, if you want to add, for example, a triangle you have to extend the
Basic2DDrawingElement
then assert that the given points are the
left corner, the top and the right corner and define the paint method to connect
the points or fill the shape.
BasicDrawingElements
to the BasicDrawingPane
,
get them and clear the BasicDrawingElements
with the following methods:
addDrawingElement(BasicDrawingElement element) getDrawingElements() clearPlot()