|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.davisor.graphics.chart.ChartFactory
com.davisor.graphics.chart.AxisFactory
AxisFactory implements an abstract base class for charts that render data into one-, two-, or three-dimensional coordinate systems. Axis chart subclasses are expected to extend the functionality of this class to render actual graph data into the axis coordinate systems produced by this class.
createContext(com.davisor.graphics.chart.ChartData, com.davisor.graphics.chart.ChartAttributes))
createMetrics(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartAttributes))
drawChart(com.davisor.graphics.chart.AxisFactory.AxisContext, com.davisor.graphics.chart.AxisFactory.AxisMetrics, com.davisor.graphics.chart.ChartAxes, boolean, boolean, boolean, boolean, com.davisor.graphics.chart.Chart))
Any number of value channels of any type are accepted. Each channel is mapped on a single axis, as defined by sub-class implementations. Individual values are mapped on chosen axes with de-interpolation, implemented by the de-interpolation operation of channel data type. This deinterpolation requires that axis minimum and maximum values are first resolved. When minimum and maximum values and their placement on target axis are known, the placement of intermediate values can also be resolved.
If there is more than one value channel, then the respective elements sharing the same element index in different channels form element groups. Different charts may assign special meanings to the members of each group, like for example ScatterFactory does with the X and Y coordinate values. There will be as many element groups as there are elements in the longest value channel. Missing elements are considered to have null values.
ChartAxes instances. Each axes group contains axes,
modelled by ChartAxis instances. Each axis then sets up a
value range and a value step that divides the range into a number
of discrete steps.
Axis value ranges define not only the range minimum and maximum
values, but also the type of the data that is expected to be laid
out along the axis. The type may be anything supported by the
Type framework, including simple scalar values, dates,
timestamps, and enumerated values like labels. In particular, if
chart input data contains a label channel, these labels are turned
into a enumerated data type than spans a integer value range
[0,N-1], where N is the number of labels.
Axis mimum and maximum values are resolved by finding data channel
minimum and maximum values with the help of
ChartFactory.createSummary(com.davisor.graphics.chart.ChartData, com.davisor.graphics.chart.ChartAttributes, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.PlotRenderAttributes, com.davisor.data.EnumType, int[], boolean, int[]) method. Sub-class spesific
resolveLimits(com.davisor.graphics.chart.ChartDataSummary) method then assign channel limit values on
individual axes. Finally, ChartAxes.computeValues(com.davisor.data.DataValue[][]) method
resolves the axis spesific minimum and maximum values. At this time
the minimum and maximum values may also be overriden with
explicitly given values. Furthermore, if axis spesific data step
values have been given, they will be used to round the final
minimum and maximum values to even step values.
The chart axes control the axis labeling, orientation, grid and 3D look. The chart axis will be labeled only if the axis label type has been given. If so, the labels are formatted with the given type. X- and Y-axis rotation determines the chart's 3D look. Zero rotation gives a flat 2D chart and other angles between zero and 90 will turn the axels and expose the top and right sides of the bar.
Element render attributes are primarily taken from the channel attributes, and secondarily from the corresponding channels. If channels are used, the n:th attribute column of one attribute type corresponds to the n:th value column. If there are more value columns than there are attribute columns of a specific type, the remaining value columns use the attributes from the last available attribute column.
The element color attribute controls the element borderline color, while the element paint controls the element fill color. The element's color will default to the plot area color, while the element's paint will default to missing (invisible) paint.
The element shape attribute controls the shape of the data points in the factories drawing shapes such as LineFactory and ScatterFactory. If the shape for an element is not set, no shape is drawn for the element.
AxisMetrics inner class documentation for details.
The chart image size is determined from initial chart attributes. If
either or both of the width and height values are zero, the
suitable image size values are queried from the subclasses through
the getIdealSize(com.davisor.graphics.chart.ChartAxes, int, int, float[], float[][], float[][], float[][], float[]) method. If the chart size is
decreased below the point where the chart labels would not fit in
the space given to them, then the font sizes are automatically
scaled down, in order to make the labels fit.
AxisFactory.AxisContext,
AxisFactory.AxisMetrics| Nested Class Summary | |
class |
AxisFactory.AxisContext
AxisContext holds the state of one particular axis chart while it is being constructed. |
class |
AxisFactory.AxisMetrics
AxisMetrics is an AxisFactory internal info container that carries axis chart manufacturing parameters. |
| Nested classes inherited from class com.davisor.graphics.chart.ChartFactory |
ChartFactory.ChartContext, ChartFactory.ChartMetrics |
| Field Summary | |
static Type |
DEFAULTLABELTYPE
Default label type (DoubleType(null,"#")). |
protected static java.awt.geom.AffineTransform |
FLIPX
Static flip-X transformation. |
protected static java.awt.geom.AffineTransform |
FLIPY
Static flip-Y transformation. |
protected static int |
MAJORMARGIN
Index for table elements that concern major marginal size data. |
protected static int |
MINORMARGIN
Index for table elements that concern minor marginal size data. |
protected static int |
MINSIZE
The minimum element size (3). |
| Fields inherited from class com.davisor.graphics.chart.ChartFactory |
ALL, BRIGHT, CHANNEL, COS, DARK, DOTSEQUENCE, DOTSTROKE, DOTSTROKEWIDTH, DUMPFACTORYNAME, ENCODERINFO, FONT, FRC, HAS_3D, I, LABEL, LABELFIELDNAMES, LABELFIELDS, MIME_DEFAULT, NONE, NORMAL, NULLSTROKE, PERCENT, PI2, SHAPE, SIN, STROKE, STROKEWIDTH, TIC, VALUE, X, Y, Z |
| Fields inherited from interface com.davisor.core.MIMETypes |
FILETYPE_BMP, FILETYPE_CSS, FILETYPE_DOC, FILETYPE_ECMA, FILETYPE_GIF, FILETYPE_HTML, FILETYPE_HTML_CSS, FILETYPE_INDEX, FILETYPE_INDEX_DOC, FILETYPE_INDEX_HTML, FILETYPE_INDEX_HTML_CSS, FILETYPE_INDEX_PDF, FILETYPE_INDEX_PPT, FILETYPE_INDEX_SVG, FILETYPE_INDEX_XHTML, FILETYPE_INDEX_XLS, FILETYPE_INDEX_XMSE, FILETYPE_INDEX_XMSP, FILETYPE_INDEX_XMSW, FILETYPE_INDEX_XSLFO, FILETYPE_JPEG, FILETYPE_PDF, FILETYPE_PNG, FILETYPE_PNG_WBMP, FILETYPE_PPM, FILETYPE_PPT, FILETYPE_SVG, FILETYPE_TEXT, FILETYPE_WBMP, FILETYPE_XHTML, FILETYPE_XLS, FILETYPE_XML, FILETYPE_XMSE, FILETYPE_XMSP, FILETYPE_XMSW, FILETYPE_XSLFO, FILETYPE_XSLFO_CSS, MIME_BMP, MIME_CSS, MIME_DOC, MIME_ECMA, MIME_GIF, MIME_HTML, MIME_HTML_CSS, MIME_INDEX, MIME_INDEX_DOC, MIME_INDEX_HTML, MIME_INDEX_HTML_CSS, MIME_INDEX_PDF, MIME_INDEX_PPT, MIME_INDEX_SVG, MIME_INDEX_XHTML, MIME_INDEX_XLS, MIME_INDEX_XMSE, MIME_INDEX_XMSP, MIME_INDEX_XMSW, MIME_INDEX_XSLFO, MIME_JPEG, MIME_OTHER, MIME_PDF, MIME_PNG, MIME_PNG_WBMP, MIME_PPM, MIME_PPT, MIME_SVG, MIME_TEXT, MIME_WBMP, MIME_XHTML, MIME_XLS, MIME_XML, MIME_XMSE, MIME_XMSP, MIME_XMSW, MIME_XSLFO, MIME_XSLFO_CSS |
| Constructor Summary | |
AxisFactory()
Default constructor. |
|
AxisFactory(AxisFactory factory)
Copy constructor. |
|
| Method Summary | |
protected float |
computeMinorMargin(int dim,
float[][] labelSizes)
Computes label minor margin size. |
protected Chart |
createChart(AxisFactory.AxisContext context,
AxisFactory.AxisMetrics metrics,
ChartAxes axes,
boolean fillGrid,
boolean drawAxes,
boolean drawLabel,
boolean drawGrid,
Chart chart)
Creates and renders an axis chart. |
Chart |
createChart(ChartFactory.ChartContext chartContext,
ChartFactory.ChartMetrics chartMetrics,
ChartAttributes attr,
Chart chart)
Draw chart. |
ChartFactory.ChartContext |
createContext(ChartData data,
ChartAttributes attr)
Creates axis chart context. |
protected AxisFactory.AxisContext |
createContext(ChartData data,
ChartAttributes attr,
ChartAxes axes,
short index)
Creates and initializes an axis chart context. |
protected AxisFactory.AxisContext |
createContext(ChartData data,
ChartAttributes attr,
PlotRenderAttributes plot,
ChartDataSummary summary,
java.awt.Font[] labelFont,
java.awt.Font[] titleFont,
Type[] colorChannelTypes,
int lastPlotColorChannel,
Type[] paintChannelTypes,
int lastPlotPaintChannel,
Type urlChannelType,
EnumType labelType,
int[] valueChannels,
int[] colorChannels,
int[] paintChannels,
int[] urlChannels,
int[] altChannels,
int[] positionChannels,
float[] labelOffsets,
float[] markerOffsets,
float[][] titleSizes,
boolean isometric,
short index)
Creates a new axis context. |
protected AxisFactory.AxisContext |
createContext(ChartData data,
ChartAttributes attr,
PlotRenderAttributes plot,
ChartDataSummary summary,
java.awt.Font[] labelFont,
java.awt.Font[] titleFont,
Type colorChannelType,
Type paintChannelType,
Type urlChannelType,
EnumType labelType,
int[] valueChannels,
int[] colorChannels,
int[] paintChannels,
int[] urlChannels,
int[] altChannels,
int[] positionChannels,
float[] labelOffsets,
float[] markerOffsets,
float[][] titleSizes,
boolean isometric,
short index)
Deprecated. |
protected AxisFactory.AxisMetrics |
createMetrics(ChartAxes axes,
AxisFactory.AxisContext context,
boolean scaleMargins,
boolean conserveSpace)
Resolve final axis chart image and image component sizes. |
protected AxisFactory.AxisMetrics |
createMetrics(ChartAxes axes,
float chartWidth,
float chartHeight,
float[] titleSize,
float[] labelSize,
float[] markerSize,
float[] labelOffset,
float[] markerOffset,
float[] majorEdge,
float[] minorEdge,
float[] zLabel)
Defines metrics for three-dimensional chart. |
protected AxisFactory.AxisMetrics |
createMetrics(ChartAxes axes,
float width,
float height,
float[] titleSize,
float[] labelSize,
float[] markerSize,
float[] axisOffset,
float[] labelOffset,
float[] markerOffset,
float[] symbolOffset,
float[] majorEdge,
float[] minorEdge)
Defines metrics for two-dimensional chart. |
ChartFactory.ChartMetrics |
createMetrics(ChartFactory.ChartContext context,
ChartAttributes attr)
Creates axis chart metrics. |
protected void |
drawAxis(ChartAxis axis,
java.awt.Graphics2D g,
AxisFactory.AxisMetrics metrics,
boolean transpose,
float zeroPosition,
float offset,
boolean drawAxis,
boolean drawGrid,
boolean down)
Draws an axis inside the back area. |
protected Chart |
drawChart(AxisFactory.AxisContext context,
AxisFactory.AxisMetrics metrics,
ChartAxes axes,
boolean fillGrid,
boolean drawAxes,
boolean drawLabel,
boolean drawGrid,
Chart chart)
Renders an axis chart. |
protected void |
drawMarkers(java.awt.Graphics2D g,
ChartAxes axes,
AxisFactory.AxisMetrics metrics)
Draws marker lines and fills areas between them. |
protected static void |
drawTics(java.awt.Graphics2D g,
java.awt.Shape ticShape,
java.awt.Stroke ticStroke,
java.awt.Paint ticColor,
java.awt.Stroke gridStroke,
java.awt.Paint gridColor,
int ticLevel,
float width,
float height,
float zeroPosition,
DataValue min,
DataValue max,
DataValue step,
java.util.ArrayList markers)
Draws tic marks and grid lines along the axis. |
protected AxisFactory.AxisMetrics |
drawXYAxes(java.awt.Graphics2D g,
ChartAxes axes,
AxisFactory.AxisMetrics metrics,
boolean fillGrid,
boolean drawAxes,
boolean drawLabel,
boolean drawGrid)
Draws a two-dimensional XY-axis. |
protected float[] |
drawXYZAxes(java.awt.Graphics2D g,
ChartAxes axes,
AxisFactory.AxisMetrics metrics,
boolean fillGrid,
boolean drawAxes,
boolean drawLabel,
boolean drawGrid)
Draws a three-dimensional XYZ-axis. |
protected void |
fillGrid(ChartAxis axis,
java.awt.Graphics2D g,
AxisFactory.AxisMetrics metrics,
boolean transpose)
Fills the axis' face with back paint. |
protected void |
fillMarkers(ChartAxis axis,
java.awt.Graphics2D g,
AxisFactory.AxisMetrics metrics,
boolean transpose)
Fills the areas defined by markers. |
protected static java.lang.String |
formatDouble(Type type,
double value)
Returns the correct locale formatted string received by formatting a float value. |
protected static float[] |
getIdealSize(ChartAxes axes,
float[] steps,
float[] labelOffsets,
float[][] titleSizes,
float[][] labelSizes,
float[][] markerSizes,
float[] markerOffsets)
Computes generic ideal suggested size for a chart. |
protected float[] |
getIdealSize(ChartAxes axes,
int elements,
int channels,
float[] labelOffsets,
float[][] titleSizes,
float[][] labelSizes,
float[][] markerSizes,
float[] markerOffsets)
Computes the ideal, suggested image size for this chart. |
protected boolean |
hasGridLines(ChartAxis axis)
Tests if axis has grid lines in chart factory spesific way. |
protected boolean |
isSilent(ChartAxis axis)
Tests axis silency in chart factory spesific way. |
protected void |
labelAxis(ChartAxis axis,
java.awt.Graphics2D g,
float renderWidth,
float renderHeight,
float offsetWidth,
float edgeWidth,
float labelHeight,
float axisHeight,
float rotation,
boolean gaps,
boolean down,
boolean above,
boolean flipx,
boolean flipy)
Labels an axis with tic labels. |
protected void |
labelMarkers(ChartAxis axis,
java.awt.Graphics2D g,
AxisFactory.AxisMetrics metrics,
float plotOffsetWidth,
float renderWidth,
float renderHeight,
float coreWidth,
float markerHeight,
float markerOffsetHeight,
float labelHeight,
float labelOffsetHeight,
float axisHeight,
boolean down,
boolean above,
boolean flipx,
boolean flipy)
Label markers. |
protected float[][] |
resolveLabels(ChartAxes axes,
AxisFactory.AxisContext context)
Computes ideal axis label sizes. |
protected java.awt.geom.Rectangle2D |
resolveLabels(ChartAxis axis,
java.awt.Font font)
Measures axis label maximum size. |
protected abstract DataValue[][] |
resolveLimits(ChartDataSummary summary)
Computes chart factory specific axis limit values. |
protected float[][] |
resolveMarkerSizes(ChartAxes axes)
Loops through the markers associated to X and Y axes. |
protected static void |
resolveOverlap(AxisFactory.AxisContext context,
float[][] labelSizes)
Configures axis label offsets to ensure that axis labels do not overlap at the axis junction, or exceed chart bounds. |
protected static void |
titleAxis(ChartAxis axis,
java.awt.Graphics2D g,
float renderWidth,
float renderHeight,
float titleHeight,
float titleOffset,
float markerHeight,
float markerOffset,
float labelHeight,
float axisHeight,
boolean down,
boolean above,
boolean flipx,
boolean flipy)
Labels an axis with a title. |
protected static float[] |
transpose(float[] size)
Transposes size array width/height elements, and returns them in a new array. |
| Methods inherited from class com.davisor.graphics.chart.ChartFactory |
annotate, combineProperties, createChannelType, createChannelType, createChart, createChart, createChart, createChart, createChart, createFormat, createPaintChannelType, createPaintChannelType, createShapeChannelType, createShapeChannelType, createSummary, drawLabel, getContentType, getDefaultPaint, getFactory, getFactory, getGroup, getIsometricCoefficients, getLegendShape, getName, has3D, hasSVG, isClassAvailable, isMultiSeriesMode, main, mayHaveLegend, registerFactory, resolveDataLimits, resolveDataLimits, rotateSize, shade, unregisterFactory |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface com.davisor.core.Dupable |
dup |
| Field Detail |
public static final Type DEFAULTLABELTYPE
protected static final int MAJORMARGIN
protected static final int MINORMARGIN
protected static final int MINSIZE
protected static final java.awt.geom.AffineTransform FLIPX
protected static final java.awt.geom.AffineTransform FLIPY
| Constructor Detail |
public AxisFactory()
public AxisFactory(AxisFactory factory)
| Method Detail |
protected abstract DataValue[][] resolveLimits(ChartDataSummary summary)
This method will be called once before actual chart rendering
begins. This gives each chart factory type a chance to control
the range of values to be displayed. The result will be passed to
ChartAxes.computeValues(com.davisor.data.DataValue[][]) method, which configures chart
axes.
summary - chart data summary
ChartAxis.computeValues(com.davisor.data.DataValue[]),
ChartFactory.createSummary(com.davisor.graphics.chart.ChartData, com.davisor.graphics.chart.ChartAttributes, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.PlotRenderAttributes, com.davisor.data.EnumType, int[], boolean, int[])
public ChartFactory.ChartContext createContext(ChartData data,
ChartAttributes attr)
throws ChartException
createContext in class ChartFactorydata - chart dataattr - chart attributes
ChartException - if chart generation failscreateContext(ChartData,ChartAttributes,ChartAxes,short),
createMetrics(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartAttributes),
AxisFactory.AxisContext,
ChartFactory.ChartContext
public ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext context,
ChartAttributes attr)
throws ChartException
createMetrics in class ChartFactorycontext - chart context (must be AxisFactory.AxisContext)attr - chart attributes
ChartException - if chart generation failscreateMetrics(ChartAxes,AxisFactory.AxisContext,boolean,boolean),
AxisFactory.AxisContext,
AxisFactory.AxisMetrics
public Chart createChart(ChartFactory.ChartContext chartContext,
ChartFactory.ChartMetrics chartMetrics,
ChartAttributes attr,
Chart chart)
throws ChartException
createChart in class ChartFactorychartContext - pre-calculated context information (AxisContext)chartMetrics - pre-calculated size information used in drawing
(instance of AxisMetrics)attr - chart attributeschart - previously created chart to be drawn onto (may be null)
ChartException - if chart generation failscreateChart(AxisFactory.AxisContext,AxisFactory.AxisMetrics,
ChartAxes,boolean,boolean,boolean,boolean,Chart)
protected float computeMinorMargin(int dim,
float[][] labelSizes)
X #
| X | XX = edgemost label text
| |
| | # = minor margin space
##+------## X +------
XX XX X #
Labels are typically rendered centered at axis end, in which
case the label minor margin is equal to half the label width or
heigh, depending on la,
chartbel orientation. This is also the value
this method returns by default. Sub-classes may override this
as neccessary.
dim - dimension index (X or Y)labelSizes - label width and height ([x,y][w,h])
resolveLabels(com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisContext)
protected Chart createChart(AxisFactory.AxisContext context,
AxisFactory.AxisMetrics metrics,
ChartAxes axes,
boolean fillGrid,
boolean drawAxes,
boolean drawLabel,
boolean drawGrid,
Chart chart)
throws ChartException
The chart object the chart is rendered into depends on given
chart parameter. If no chart object is given, a new
one is created with ChartFactory.createChart(ChartAttributes,float,float,boolean). If the given
chart is an ImageChart instance, the chart is rendered
into it. In any other case the chart is deemed incompatible, and
no chart is rendered.
context - chart contextmetrics - chart metricsaxes - chart axesfillGrid - enables or disables axis background fillingdrawAxes - determine which axes may be drawndrawLabel - determine if default labeling is to be applieddrawGrid - determine if axis grid is to be drawnchart - chart to render to (may be null)
ChartException - if chart generation fails
protected AxisFactory.AxisContext createContext(ChartData data,
ChartAttributes attr,
ChartAxes axes,
short index)
throws ChartException
data and attr will be
new object instances. Sub-classes are expected to extend
AxisFactory.AxisContext in order to pass forward sub-class spesific context
parameter.
See class documentation for more information about how axis chart generation is expected to proceed.
data - chart dataattr - chart attributesaxes - chart axesindex - context index among other contexts
ChartException - if chart generation failscreateMetrics(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartAttributes)
protected AxisFactory.AxisContext createContext(ChartData data,
ChartAttributes attr,
PlotRenderAttributes plot,
ChartDataSummary summary,
java.awt.Font[] labelFont,
java.awt.Font[] titleFont,
Type colorChannelType,
Type paintChannelType,
Type urlChannelType,
EnumType labelType,
int[] valueChannels,
int[] colorChannels,
int[] paintChannels,
int[] urlChannels,
int[] altChannels,
int[] positionChannels,
float[] labelOffsets,
float[] markerOffsets,
float[][] titleSizes,
boolean isometric,
short index)
createContext(ChartData,ChartAttributes,PlotRenderAttributes,
ChartDataSummary,Font[],Font[],Type[],int,Type[],int,Type,EnumType,
int[],int[],int[],int[],int[],int[],float[],float[],float[][],
boolean,short)
protected AxisFactory.AxisContext createContext(ChartData data,
ChartAttributes attr,
PlotRenderAttributes plot,
ChartDataSummary summary,
java.awt.Font[] labelFont,
java.awt.Font[] titleFont,
Type[] colorChannelTypes,
int lastPlotColorChannel,
Type[] paintChannelTypes,
int lastPlotPaintChannel,
Type urlChannelType,
EnumType labelType,
int[] valueChannels,
int[] colorChannels,
int[] paintChannels,
int[] urlChannels,
int[] altChannels,
int[] positionChannels,
float[] labelOffsets,
float[] markerOffsets,
float[][] titleSizes,
boolean isometric,
short index)
data - chart dataattr - chart attributesplot - local plot area attributessummary - chart data summarylabelFont - axis label fonts [X,Y,Z,...]titleFont - axis title fonts [X,Y,Z,...]colorChannelTypes - color data channel types for each value channellastPlotColorChannel - last color channel for plotpaintChannelTypes - paint data channel type for each value channellastPlotPaintChannel - last paint channel for ploturlChannelType - annotation URL address data channel typelabelType - label channel access type (may be null)valueChannels - value data channel indexescolorChannels - color data channel indexespaintChannels - paint data channel indexesurlChannels - annotation URL address data channel indexesaltChannels - annotation description text data channel indexespositionChannels - category position value data channel indexeslabelOffsets - axis label offsets ([x,y,z])titleSizes - axis title sizes ([x,y][w,h])isometric - isometric mode indicatorindex - context index among other contexts
protected AxisFactory.AxisMetrics createMetrics(ChartAxes axes,
AxisFactory.AxisContext context,
boolean scaleMargins,
boolean conserveSpace)
throws ChartException
resolveLabels(com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisContext) method. Sub-class spesific ideal chart
size is computed next by invoking getIdealSize(com.davisor.graphics.chart.ChartAxes, int, int, float[], float[][], float[][], float[][], float[]) methods.
Finally, and conflicts between chart ideal size and given size
constrains are resolved. The results are then collected into an
AxisFactory.AxisMetrics instance, which is returned.
Conflict resolution between chart ideal and given size scales ideal size components to fit into given size. If size is not explisitly set, the ideal size is used. If size is greater than ideal size, all chart components are scaled up evenly. If size is smaller than ideal size, more complex chart component size optimization is carried out.
First, an attempt to reduce the number of steps on the relevant
axis is made by calling ChartAxis.reduceSteps(float). A new
ideal size is then computed by using the reduced number of steps.
If this yields enough or more than space, chart components are
scaled evenly up to the new ideal size.
axes - the axes that control this particular chartcontext - axis chart contextscaleMargins - if true, scales only the margins and plot areaconserveSpace - if true, does not scale beyoun ideal size
ChartException - if chart generation failscreateContext(com.davisor.graphics.chart.ChartData, com.davisor.graphics.chart.ChartAttributes),
resolveLabels(com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisContext)
protected AxisFactory.AxisMetrics createMetrics(ChartAxes axes,
float width,
float height,
float[] titleSize,
float[] labelSize,
float[] markerSize,
float[] axisOffset,
float[] labelOffset,
float[] markerOffset,
float[] symbolOffset,
float[] majorEdge,
float[] minorEdge)
throws ChartException
AxisMetrics class documentation. When determining
the axis marginal's width and height, the corresponding axis
stroke widths are taken into account.
This method will compute and create a new axis metrix object that
describes the sizes of all axis areas. Please see
AxisFactory.AxisMetrics documentation for into what kind of areas the
coordinate systems is divided.
axes - chart axeswidth - chart widthheight - chart heighttitleSize - title sizelabelSize - label sizemarkerSize - marker sizeaxisOffset - axis line offsetlabelOffset - label offsetmarkerOffset - marker offsetsymbolOffset - symbol line offsetmajorEdge - major edge sizeminorEdge - minor edge size
ChartException - if chart generation failsdrawXYAxes(java.awt.Graphics2D, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, boolean, boolean, boolean),
AxisFactory.AxisMetrics
protected AxisFactory.AxisMetrics createMetrics(ChartAxes axes,
float chartWidth,
float chartHeight,
float[] titleSize,
float[] labelSize,
float[] markerSize,
float[] labelOffset,
float[] markerOffset,
float[] majorEdge,
float[] minorEdge,
float[] zLabel)
throws ChartException
AxisMetrics class documentation.
A isometric shearing space is merged with the marginal space, when possible. This makes better use of the available chart area, while still ensuring the requested marginal space for the labels.
axes - chart axeschartWidth - chart width, stricly within chart borderschartHeight - chart height, stricly within chart borderstitleSize - title sizelabelSize - label sizemarkerSize - label sizelabelOffset - label offsetmarkerOffset - label offsetmajorEdge - major edge sizeminorEdge - minor edge sizezLabel - Z -axis label information
ChartException - if chart generation failscreateMetrics(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartAttributes),
drawXYZAxes(java.awt.Graphics2D, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, boolean, boolean, boolean),
AxisFactory.AxisMetrics
protected void drawAxis(ChartAxis axis,
java.awt.Graphics2D g,
AxisFactory.AxisMetrics metrics,
boolean transpose,
float zeroPosition,
float offset,
boolean drawAxis,
boolean drawGrid,
boolean down)
throws InvalidDataException
zeroPosition height. The
grid lines are drawn across the whole height of the back area
at even axis unit steps values. Axis line is also moved by
vertical plot offset, and grid lines are moved horizontally
by horizontal plot offset.
h----------- 0 origo | -:-:-:- | w back width | | : : : | | h back height |o| : : : | | z zero position | | : : : | | o plot offset |===+=+=+===| z = axis line | | : : : | | : grid line | -:-:-:- | : grid line 0-----------w + tic markIf the axis is reversed, the axis and tic marks are mirrored horizontally (left becomes right, and vice versa). Axis opposite side status has no effect on how the axis is drawn.
When drawing an Y -axis, the given graphics context is assumed to
have been rotated +90 degrees so that the Y -axis and the
graphics context X -axis are parallel. In this case the
transpose argument
axis - the axis to be drawng - the graphics context that the axis is to be drawn tometrics - axis metricstranspose - invert width/height or notzeroPosition - zero value position along the vertical axisoffset - horizontal label offset along axisdrawAxis - determine if axis line and tic marks are to be drawndrawGrid - determine if axis grid lines are to be drawndown - true if grid lines extend to the -Y direction
InvalidDataException - if data is invalid for axis drawingdrawTics(java.awt.Graphics2D, java.awt.Shape, java.awt.Stroke, java.awt.Paint, java.awt.Stroke, java.awt.Paint, int, float, float, float, com.davisor.data.DataValue, com.davisor.data.DataValue, com.davisor.data.DataValue, java.util.ArrayList),
drawXYAxes(java.awt.Graphics2D, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, boolean, boolean, boolean),
drawXYZAxes(java.awt.Graphics2D, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, boolean, boolean, boolean)
protected Chart drawChart(AxisFactory.AxisContext context,
AxisFactory.AxisMetrics metrics,
ChartAxes axes,
boolean fillGrid,
boolean drawAxes,
boolean drawLabel,
boolean drawGrid,
Chart chart)
throws InvalidDataException
Before doing anything else, this method will move the given chart graphics context origo upwards and left so that title, label, and axis areas will lie left and below coordinate axes. The actual drawing area will lie above and right from coordinate axes, followed by top and right margin areas. In order for this to work, this method assumes that the old origo was located at target area bottom left corner, and X- and Y-axes positive directions were left and up, respectively.
context - chart contextmetrics - chart metricsaxes - chart axesfillGrid - enables or disables axis background fillingdrawAxes - determine which axes may be drawndrawLabel - determine if default labeling is to be applieddrawGrid - determine if axis grid is to be drawnchart - chart to draw into
InvalidDataException - if data is invalid for chart drawing
protected void drawMarkers(java.awt.Graphics2D g,
ChartAxes axes,
AxisFactory.AxisMetrics metrics)
throws InvalidDataException
InvalidDataException - if data is invalid for marker drawing
protected static void drawTics(java.awt.Graphics2D g,
java.awt.Shape ticShape,
java.awt.Stroke ticStroke,
java.awt.Paint ticColor,
java.awt.Stroke gridStroke,
java.awt.Paint gridColor,
int ticLevel,
float width,
float height,
float zeroPosition,
DataValue min,
DataValue max,
DataValue step,
java.util.ArrayList markers)
throws InvalidDataException
ticShape is not
null. Grid lines are drawn only if given
ticStroke is not null. Furthermore, if
min, max, or step is
null, or ticLevel is not positive,
nothing is drawn.
Tic marks and grid lines are rendered along the axis, starting
the distance offsetWidth from the origo, and
continuing stepwise onwards. The exact label horizontal positions
along the axis are deinterpolated with DataValue.deinterpolate(com.davisor.data.DataValue, com.davisor.data.DataValue), using axis minimum and maximum values
as interpolation range, and axis step value as unit increment. If
axis minimum and maximum values are equal, a single tic mark and
grid line are draw at the center of the axis.
g - the graphics context for tic marksticShape - tic shape (may be null)ticStroke - tic line stroke (may be null if tic shape is)ticColor - tic line color (may be null if tic shape is)gridStroke - grid line stroke (may be null)gridColor - grid line color (may be null if grid stroke is)ticLevel - tic recursion level (decreases until reaches 0)width - grid widthheight - grid heightzeroPosition - grid line offsetmin - grid minimum valuemax - grid maximum valuestep - grid unit step
InvalidDataException - if data is invalid for tic drawinglabelAxis(com.davisor.graphics.chart.ChartAxis, java.awt.Graphics2D, float, float, float, float, float, float, float, boolean, boolean, boolean, boolean, boolean)
protected AxisFactory.AxisMetrics drawXYAxes(java.awt.Graphics2D g,
ChartAxes axes,
AxisFactory.AxisMetrics metrics,
boolean fillGrid,
boolean drawAxes,
boolean drawLabel,
boolean drawGrid)
throws InvalidDataException
The axis' position will depend on user coordinate space bounds, computed from the chart info minimum values and value ranges. The X- and Y-axis will be, respectively, positioned to:
The axis' position does not depend on the other axis, so any up/down/left/righ combination is possible.
g - graphics context to draw intoaxes - axes to drawmetrics - chart metricsfillGrid - determine if grid filling is to be enableddrawAxes - determine which axes may be drawndrawLabel - determine if default labeling is to be applieddrawGrid - determine if grid drawing is to be enabled
InvalidDataException - if data is invalid for axes drawingcreateMetrics(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartAttributes),
drawAxis(com.davisor.graphics.chart.ChartAxis, java.awt.Graphics2D, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, float, float, boolean, boolean, boolean),
fillGrid(com.davisor.graphics.chart.ChartAxis, java.awt.Graphics2D, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean),
labelAxis(com.davisor.graphics.chart.ChartAxis, java.awt.Graphics2D, float, float, float, float, float, float, float, boolean, boolean, boolean, boolean, boolean)
protected float[] drawXYZAxes(java.awt.Graphics2D g,
ChartAxes axes,
AxisFactory.AxisMetrics metrics,
boolean fillGrid,
boolean drawAxes,
boolean drawLabel,
boolean drawGrid)
throws InvalidDataException
g - graphics context to draw intoaxes - chart axes to drawmetrics - axis area measurementsfillGrid - enables or disables axis background fillingdrawAxes - determine which axes may be drawndrawLabel - determine if default labeling is to be applieddrawGrid - determine if axis grid is to be drawn
InvalidDataException - if data is invalid for axes drawingcreateMetrics(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartAttributes),
drawAxis(com.davisor.graphics.chart.ChartAxis, java.awt.Graphics2D, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, float, float, boolean, boolean, boolean),
drawXYAxes(java.awt.Graphics2D, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, boolean, boolean, boolean),
labelAxis(com.davisor.graphics.chart.ChartAxis, java.awt.Graphics2D, float, float, float, float, float, float, float, boolean, boolean, boolean, boolean, boolean)
protected void fillGrid(ChartAxis axis,
java.awt.Graphics2D g,
AxisFactory.AxisMetrics metrics,
boolean transpose)
drawXYAxes(java.awt.Graphics2D, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, boolean, boolean, boolean) and
drawXYZAxes(java.awt.Graphics2D, com.davisor.graphics.chart.ChartAxes, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, boolean, boolean, boolean) call this method to fill the axes backfaces
before anything else is draw on them.
axis - the axis to be drawng - the graphics context that the axis is to be drawn tometrics - chart metricstranspose - invert width/height or notdrawAxis(com.davisor.graphics.chart.ChartAxis, java.awt.Graphics2D, com.davisor.graphics.chart.AxisFactory.AxisMetrics, boolean, float, float, boolean, boolean, boolean)
protected void fillMarkers(ChartAxis axis,
java.awt.Graphics2D g,
AxisFactory.AxisMetrics metrics,
boolean transpose)
throws