|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objecteu.webtoolkit.jwt.chart.WChart2DRenderer
public class WChart2DRenderer
Helper class for rendering a cartesian chart.
This class is used by WCartesianChart during
rendering, and normally, you will not need to use this class directly. You
may want to specialize this class if you want to override particular aspects
of how the chart is renderered. In that case, you will want to instantiate
the specialized class in
WCartesianChart#createRenderer().
To simplify the simulatenous handling of Horizontal and Vertical charts, the
renderer makes abstraction of the orientation of the chart: regardless of the
chart orientation, the getWidth()
corresponds to the length along the X axis, and
getHeight() corresponds to the length
along the Y axis. Similarly, calcChartArea() and getChartArea()
return a rectangle where the bottom side corresponds to the lowest displayed
Y values, and the left side corresponds to the lowest displayed X values. To
map these "chart coordinates" to painter coordinates, use one of
the hv() methods.
Note, this class is part of the internal charting API, and may be subject of changes and refactorings.
| Nested Class Summary | |
|---|---|
static class |
WChart2DRenderer.AxisProperty
Enumeration that specifies a property of the axes. |
| Field Summary | |
|---|---|
protected AxisValue[] |
location_
The computed axis locations. |
| Constructor Summary | |
|---|---|
WChart2DRenderer(WCartesianChart chart,
WPainter painter,
WRectF rectangle)
Creates a renderer. |
|
| Method Summary | |
|---|---|
void |
calcChartArea()
Calculates the main plotting area rectangle. |
WRectF |
chartSegmentArea(WAxis yAxis,
int xSegment,
int ySegment)
Returns the segment area for a combination of X and Y segments. |
protected int |
getCalcNumBarGroups()
Calculates the total number of bar groups. |
WCartesianChart |
getChart()
Returns the corresponding chart. |
WRectF |
getChartArea()
Returns the main plotting area rectangle. |
protected int |
getHeight()
Returns the height along the Y axis (as if orientation is Vertical). |
WPainter |
getPainter()
Returns a reference to the painter. |
protected int |
getSegmentMargin()
Returns the segment margin. |
protected int |
getWidth()
Returns the width along the X axis (as if orientation is Vertical). |
WPointF |
hv(double x,
double y)
Conversion between chart and painter coordinates. |
WPointF |
hv(WPointF p)
Conversion between chart and painter coordinates. |
WRectF |
hv(WRectF r)
Conversion between chart and painter coordinates. |
void |
initLayout()
Initializes the layout. |
protected void |
iterateSeries(SeriesIterator iterator)
Iterates over the series using an iterator. |
protected void |
iterateSeries(SeriesIterator iterator,
boolean reverseStacked)
Iterates over the series using an iterator. |
WPointF |
map(double xValue,
double yValue)
Maps a (X, Y) point to chart coordinates. |
WPointF |
map(double xValue,
double yValue,
Axis axis)
Maps a (X, Y) point to chart coordinates. |
WPointF |
map(double xValue,
double yValue,
Axis axis,
int currentXSegment)
Maps a (X, Y) point to chart coordinates. |
WPointF |
map(double xValue,
double yValue,
Axis axis,
int currentXSegment,
int currentYSegment)
Maps a (X, Y) point to chart coordinates. |
protected void |
prepareAxes()
Prepares the axes for rendering. |
void |
render()
Renders the chart. |
protected void |
renderAxes(java.util.EnumSet<WChart2DRenderer.AxisProperty> properties)
Renders one or more properties of the axes. |
protected void |
renderAxes(WChart2DRenderer.AxisProperty propertie,
WChart2DRenderer.AxisProperty... properties)
Renders one or more properties of the axes. |
protected void |
renderAxis(WAxis axis,
java.util.EnumSet<WChart2DRenderer.AxisProperty> properties)
Renders properties of one axis. |
protected void |
renderAxis(WAxis axis,
WChart2DRenderer.AxisProperty propertie,
WChart2DRenderer.AxisProperty... properties)
Renders properties of one axis. |
protected void |
renderBackground()
Renders the background. |
void |
renderLabel(java.lang.CharSequence text,
WPointF p,
WColor color,
java.util.EnumSet<AlignmentFlag> flags,
double angle,
int margin)
Utility function for rendering text. |
protected void |
renderLegend()
Renders the (default) legend and chart titles. |
protected void |
renderSeries()
Renders all series data, including value labels. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected AxisValue[] location_
prepareAxes()| Constructor Detail |
|---|
public WChart2DRenderer(WCartesianChart chart,
WPainter painter,
WRectF rectangle)
Creates a renderer for the cartesian chart chart, for rendering in the specified rectangle of the painter.
| Method Detail |
|---|
public WCartesianChart getChart()
public WPainter getPainter()
public WRectF getChartArea()
This area is calculated and cached by
calcChartArea().
public void calcChartArea()
This method calculates the main plotting area, and stores it in the member chartArea_. The default implementation simply removes the plot area padding from the entire painting rectangle.
WAbstractChart.getPlotAreaPadding(Side side)public void initLayout()
This computes the chart plotting area dimensions, and intializes the axes so that they provide a suitable mapping from logical coordinates to device coordinates.
public void render()
This method renders the chart. The default implementation does the following:
calcChartArea(); // sets chartArea_
prepareAxes(); // provides logical dimensions to the axes
renderBackground(); // render the background
renderAxes(Grid); // render the grid
renderSeries(); // render the data series
renderAxes(AxisProperty.Line, AxisProperty.Labels); // render the axes (lines & labels)
renderLegend(); // render legend and titles
You may want to reimplement this method to change the sequence of steps for rendering the chart.
public WPointF map(double xValue,
double yValue,
Axis axis,
int currentXSegment,
int currentYSegment)
This method maps the point with given (xValue, yValue) to chart coordinates. The y value is mapped by one of the Y axes indicated by axis.
Note that chart coordinates may not be the same as painter coordinates,
because of the chart orientation. To map from chart coordinates to
painter coordinates, use hv().
The currentXSegment and currentYSegment specify the axis segments in which you wish to map the point.
public final WPointF map(double xValue,
double yValue)
Returns
map(xValue, yValue, Axis.OrdinateAxis, 0, 0)
public final WPointF map(double xValue,
double yValue,
Axis axis)
Returns
map(xValue, yValue, axis, 0, 0)
public final WPointF map(double xValue,
double yValue,
Axis axis,
int currentXSegment)
Returns
map(xValue, yValue, axis, currentXSegment, 0)
public void renderLabel(java.lang.CharSequence text,
WPointF p,
WColor color,
java.util.EnumSet<AlignmentFlag> flags,
double angle,
int margin)
This method renders text on the chart position pos, with a
particular alignment flags. These are both specified in chart
coordinates. The position is converted to painter coordinates using
hv(), and the alignment
flags are changed accordingly. The rotation, indicated by angle is
specified in painter coordinates and thus an angle of 0 always indicates
horizontal text, regardless of the chart orientation.
public WPointF hv(double x,
double y)
Converts from chart coordinates to painter coordinates, taking into account the chart orientation.
public WPointF hv(WPointF p)
Converts from chart coordinates to painter coordinates, taking into account the chart orientation.
public WRectF hv(WRectF r)
Converts from chart coordinates to painter coordinates, taking into account the chart orientation.
public WRectF chartSegmentArea(WAxis yAxis,
int xSegment,
int ySegment)
This segment area is used for clipping when rendering in a particular segment.
protected void prepareAxes()
Computes axis properties such as the range (if not manually specified), label interval (if not manually specified) and axis locations. These properties are stored within the axes (we may want to change that later to allow for reentrant rendering by multiple renderers ?).
protected void renderBackground()
protected void renderAxes(java.util.EnumSet<WChart2DRenderer.AxisProperty> properties)
protected final void renderAxes(WChart2DRenderer.AxisProperty propertie,
WChart2DRenderer.AxisProperty... properties)
Calls renderAxes(EnumSet.of(propertie, properties))
protected void renderSeries()
protected void renderLegend()
protected int getWidth()
protected int getHeight()
protected int getSegmentMargin()
This is the separation between segments, and defaults to 40 pixels.
protected void renderAxis(WAxis axis,
java.util.EnumSet<WChart2DRenderer.AxisProperty> properties)
renderAxes(EnumSet properties)
protected final void renderAxis(WAxis axis,
WChart2DRenderer.AxisProperty propertie,
WChart2DRenderer.AxisProperty... properties)
Calls renderAxis(axis,
EnumSet.of(propertie, properties))
protected int getCalcNumBarGroups()
protected void iterateSeries(SeriesIterator iterator,
boolean reverseStacked)
protected final void iterateSeries(SeriesIterator iterator)
Calls
iterateSeries(iterator, false)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||