Package de.erichseifert.gral.plots.axes
Axes, and the projection between data values and pixels.
The responsibility is split in two. An
Axis is a plain value object: it
holds the minimum and maximum of the displayed range, whether that range is
scaled automatically, and a list of listeners. It knows nothing about
drawing. An AxisRenderer owns
everything else — the shape the axis follows, the tick marks and their
labels, and, most importantly, the coordinate transform:
AxisRenderer rendererX = plot.getAxisRenderer(XYPlot.AXIS_X); Axis axisX = plot.getAxis(XYPlot.AXIS_X); // Where does the data value 4.2 end up on screen? double pixels = rendererX.worldToView(axisX, 4.2, false); // And the other way round, e.g. to turn a mouse position into a value. Number value = rendererX.viewToWorld(axisX, pixels, false);
The extrapolate flag decides what happens outside the axis range:
with false the result is clamped to the ends of the axis, with
true the transform is continued beyond them.
Because the scale lives in the renderer, changing from a linear to a logarithmic axis is a matter of substituting one object:
plot.setAxisRenderer(XYPlot.AXIS_X, new LogarithmicRenderer2D());
AbstractAxisRenderer2D implements
the two-dimensional case and is the class to extend for a custom scale; the
two shipped subclasses are
LinearRenderer2D and
LogarithmicRenderer2D. Ticks are
produced as Tick objects and come in
three flavors (major, minor and custom); custom ticks are supplied as a map
from value to label text.
-
KlasseBeschreibungBase class for
AxisRendererimplementations in two dimensions.The value range that is currently displayed along one axis of a plot.Receives a notification whenever the value range of anAxischanges.Everything about an axis except its value range: how it is drawn, where its ticks are, and — most importantly — how a data value becomes a position on screen.AnAxisRendererwith a linear scale: equal differences in value take equal distances on screen.AnAxisRendererwith a base-10 logarithmic scale: each decade takes the same distance on screen, which is what makes data spanning several orders of magnitude readable.One tick mark of an axis, as produced byAxisRenderer.getTicks(Axis): where it sits, which way it points, what it looks like, and the text of its label.Type of tick mark.