com.davisor.graphics.chart
Class ChartFactory

java.lang.Object
  extended bycom.davisor.graphics.chart.ChartFactory
All Implemented Interfaces:
com.davisor.core.Dupable, com.davisor.core.MIMETypes, com.davisor.core.Public
Direct Known Subclasses:
AxisFactory, DumpFactory, LayoutFactory, LegendFactory, PieFactory, TableFactory

public abstract class ChartFactory
extends java.lang.Object
implements com.davisor.core.Dupable, com.davisor.core.MIMETypes

Chart factories.

ChartFactory represents a chart producer that can make charts out of chart data and attributes. ChartFactory is one of the three major classes that control chart generation. The two other major components are:

This documentation gives a summary description of chart factories and the process in which chart data and attributes are refined into charts. The details of the individual factories are not, however, described herein. More information about individual factories can be found in their respective reference documentations found through the links below.

Overview

Chart factories construct Chart objects from ChartData and ChartAttributes. Chart factories always attempt to interprete data and attributes in a consistent and lenient way, trying to produce meaningful results no matter what the input might be. It is therefore often possible to change the chart type without modifying the input data in any way, and still get visually significant results.

The main product that Chart objects contain is a chart image represented by a standard Java Image object, manufactured by the ImageFactory, and later drawn upon by a chart factory. The charts also provide a copy of the original chart attributes that the chart was created with, with possible changes and updates to the attribute values that the factory had to make during chart generation. The chart data that the chart was created from is NOT provided.

Chart Factory Types

The default chart factories are:

Most of the basic factories are derived from AxisFactory, which implements a base class for all charts that lay data out into two- or three-dimensional coordinate systems. The axis factory also takes care of most of the chart data and attribute processing, so its documentation is mandatory reading for all who wish to use its sub-classes.

The small number of basic chart factories must not be taken as a sign of limited chart generation options, since each of the factories support a wealth of attributes, which may be used to configure and alter the appearance of chart images in an infinite number of ways. Each of the chart factories, for example, supports a three-dimensional look, so no separate set of corresponding 3D factories is needed. Charts also support all the graphics data types defined in the com.davisor.graphics.data package, and all their features.

Chart Factory Specifications

The chart factory specific documentation describes the operations of each factory. It covers, in particular, the following factory-specific details:

Chart Factory Registry

Chart factories share a common registration service that allows them to be registered under descriptive names. An initial set of factories is always registered at class initialization time. The default factories and their names are defined by the

com/davisor/graphics/chart/factories.properties

resource bundle. The default definitions in this file correspond to the factory list given above.

Implementation Issues

The set of chart factories is meant to be expanded later by deriving new chart factories from the existing ones and their intermediate superclasses. Writing new chart factories should be straightforward enough, in particular with the following implementation issues kept in mind.

To render high-quality raster images, chart factories should avoid using scaling transformations that cause practical problems with fonts and other delicate shapes. Java 2D implementations are also often buggy, when it comes to the fine details of font size computations after any scaling transformations.

Another implementation recommendation that subclasses should honor is that chart data values and user space coordinates should always be computed with double precision scalar values. For image and device coordinates, single precision and even integer values are, however, often accurate enough.

Chart factories should also typically be strictly stateless objects, in order to safely manufacture charts, even in threaded environments. Factories may, however, contain parameters that are set at factory construction time.

Finally, chart factories should not in any way modify original chart data or attribute objects given to them. In particular, attributes attached to the Chart objects should be copies from the original attribute set. On the other hand, copying chart data should never be neccessary, and certainly it is not recommended, as the data objects potentially may be excessively large.

Since:
JDK1.2
See Also:
createChart(com.davisor.graphics.chart.ChartAttributes), AxisFactory, BarFactory, BufferedChart, Chart, ChartAttributes, ChartData, LegendFactory, LineFactory, PieFactory

Nested Class Summary
 class ChartFactory.ChartContext
          ChartContext is a base class for chart factory context information.
 class ChartFactory.ChartMetrics
          ChartMetrics provides common interface for all chart factories to store chart and chart component size information, and to resize charts.
 
Field Summary
static int ALL
          Combined array indexes (-2).
protected static int BRIGHT
          Bright paint index.
protected static int CHANNEL
          'CHANNEL' label code.
protected static int COS
          Cosine coefficient index (0).
protected static int DARK
          Dark paint index.
static float[] DOTSEQUENCE
          Default grid dot sequence (1,1).
static java.awt.Stroke DOTSTROKE
          Default grid stroke (dotted line).
static float DOTSTROKEWIDTH
          Default grid stroke width (1).
protected static java.lang.String DUMPFACTORYNAME
          Dump factory.
static com.davisor.graphics.codec.MimeInfo ENCODERINFO
          Default encoder info.
static java.awt.Font FONT
          Default font (plain 12 point (4.2 mm) Serif).
static java.awt.font.FontRenderContext FRC
          Default font render context.
protected static boolean HAS_3D
          Chart3D option pack availability.
static java.awt.geom.AffineTransform I
          Static identity transformation.
protected static int LABEL
          'LABEL' label code.
protected static java.lang.String[] LABELFIELDNAMES
          Label field names.
protected static com.davisor.core.Index LABELFIELDS
          Label field name map.
static java.lang.String MIME_DEFAULT
          Default content type (image/png).
static int NONE
          Undefined array index (-1).
protected static int NORMAL
          Base paint index.
static java.awt.Stroke NULLSTROKE
          Default null stroke (completely invisible).
protected static int PERCENT
          'PERCENT' label code.
static double PI2
          PI / 2 constant.
static java.awt.Shape SHAPE
          Default shape style (unit cross).
protected static int SIN
          Sine coefficient index (1).
static java.awt.Stroke STROKE
          Default stroke (thin, solid line).
static float STROKEWIDTH
          Default stroke width (1).
static java.awt.geom.Line2D TIC
          Default tic mark (vertical unit line).
protected static int VALUE
          'VALUE' label code.
static int X
          X axis array index (0).
static int Y
          Y axis array index (1).
static int Z
          Z axis array index (2).
 
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
ChartFactory()
          Default constructor.
ChartFactory(ChartFactory factory)
          Copy constructor.
 
Method Summary
protected static java.awt.Paint annotate(java.awt.Paint paint, TupleData tuple, long tupleIndex, int channelIndex, short contextIndex, int urlChannel, int altChannel, Type urlChannelType, java.util.Properties plotAnnotationProperties, java.util.Properties renderingAnnotationProperties, java.util.Map additionalValues, TupleType streamType)
          Annotates given paint.
static java.util.Properties combineProperties(java.util.Properties actual, java.util.Properties defaults)
          Creates a new Properties instance which contains all the properties in the two given property sets.
protected  Type createChannelType(java.net.URL context, java.awt.Color minColor, java.awt.Color maxColor, int[] channels, ChartData data)
          Deprecated.  
protected  Type createChannelType(java.net.URL context, java.awt.Color minColor, java.awt.Color maxColor, int channel, ChartData data)
          Deprecated.  
 Chart createChart(ChartAttributes attr)
          Creates a new chart instance capable of emitting the chart content using some specific content type.
 Chart createChart(ChartAttributes attr, float userWidth, float userHeight, boolean symmetric)
          Creates a new chart with an optionally constrained size aspect ratio.
 Chart createChart(ChartData data)
          Creates a new single-component chart with default attributes.
 Chart createChart(ChartData data, ChartAttributes attr)
          Creates a chart using the given data and attributes.
 Chart createChart(ChartData data, ChartAttributes attr, Chart chart)
          Creates a new chart using the given data and attributes.
abstract  Chart createChart(ChartFactory.ChartContext chartContext, ChartFactory.ChartMetrics chartMetrics, ChartAttributes attr, Chart chart)
          Draw chart using information in ChartContext and ChartMetrics.
abstract  ChartFactory.ChartContext createContext(ChartData data, ChartAttributes attr)
          Creates and initializes a chart context.
static TupleType createFormat(TupleType streamType, java.lang.String valueFormat, java.util.Map additionalValues)
          Creates a a new data stream formatter.
abstract  ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext context, ChartAttributes attr)
          Resolve final axis chart image and image component sizes.
protected  Type createPaintChannelType(java.net.URL context, java.awt.Color minColor, java.awt.Color maxColor, int[] channels, ChartData data, AbstractScale scale)
          Creates a type suitable for interpreting color and paint channel values.
protected  Type createPaintChannelType(java.net.URL context, java.awt.Color minColor, java.awt.Color maxColor, int channel, ChartData data, AbstractScale scale)
          Creates a type suitable for interpreting color and paint channel values.
protected  Type createShapeChannelType(int[] channels, ChartData data, AbstractScale scale)
          Creates a type suitable for interpreting shape channel values.
protected  Type createShapeChannelType(int channel, ChartData data, AbstractScale scale)
          Creates a type suitable for interpreting shape channel values.
protected  ChartDataSummary createSummary(ChartData data, ChartAttributes attr, ChartAxes axes, PlotRenderAttributes plot, EnumType labelType, int[] channels, boolean isometric, int[] positionChannels)
          Computes summary information over a set of ChartData value channels.
protected static void drawLabel(java.awt.Graphics2D g, java.awt.Paint color, java.awt.Paint paint, java.awt.Font font, java.lang.String label, int boundsAlignment, int textAlignment, float width, float height, float rotation, float x, float y, float ax, float ay)
          Draws a rotated multirow label into a restricted space.
 java.lang.String getContentType()
          Gets the content type preferred by this factory.
protected static java.awt.Paint getDefaultPaint()
          Gets system default paint.
static ChartFactory getFactory()
          Creates a LayoutFactory capable to produce charts with legends.
static ChartFactory getFactory(java.lang.String type)
          Gets a reference to the factory instance of given type.
static java.lang.String getGroup(Type type)
          Returns group value.
protected static float[][] getIsometricCoefficients(ChartAxes axes)
          Computes axis' cosine and sine isometric rotation coefficients for the first two axes.
 java.awt.Shape getLegendShape()
          Gets the legend symbol shape preferred by this factory.
static java.lang.String getName(Type type)
          Returns name value.
static boolean has3D()
          Tests the precense of Davisor 3D Option pack.
static boolean hasSVG()
          Tests the precense of Davisor SVG Option pack.
static boolean isClassAvailable(java.lang.String className)
          Returns true if specified class is found.
static boolean isMultiSeriesMode(ChartData data, ChartAttributes attr)
          Determines multiSeriesMode based on data and attributes.
static void main(java.lang.String[] args)
          Generic chart factory test program.
 boolean mayHaveLegend()
          Determines whether a sensible legend exists or not.
static void registerFactory(java.lang.String type, ChartFactory factory)
          Associates a factory to the given type name.
protected  DataValue[] resolveDataLimits(ChartData data, ChartAttributes attr, PlotRenderAttributes plot, int[] channels, boolean isometric, boolean[] cumulative)
          Determines global minimum and maximum data values.
protected  DataValue[] resolveDataLimits(DataValue[][] limits, boolean[] cumulative)
          Determines global minimum and maximum data values.
static void rotateSize(float[] size, float angle)
          Computes a bounding box of a rotated bounding box.
protected static java.awt.Paint[] shade(java.awt.Paint paint)
          Creates darker and brighter versions of the given paint.
static void unregisterFactory(java.lang.String type)
          De-associates a factory with the given type name.
 
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

COS

protected static final int COS
Cosine coefficient index (0).

See Also:
Constant Field Values

SIN

protected static final int SIN
Sine coefficient index (1).

See Also:
Constant Field Values

X

public static final int X
X axis array index (0).

See Also:
Constant Field Values

Y

public static final int Y
Y axis array index (1).

See Also:
Constant Field Values

Z

public static final int Z
Z axis array index (2).

See Also:
Constant Field Values

NONE

public static final int NONE
Undefined array index (-1).

See Also:
Constant Field Values

ALL

public static final int ALL
Combined array indexes (-2).

See Also:
Constant Field Values

DOTSEQUENCE

public static final float[] DOTSEQUENCE
Default grid dot sequence (1,1).


DOTSTROKE

public static final java.awt.Stroke DOTSTROKE
Default grid stroke (dotted line).


DOTSTROKEWIDTH

public static final float DOTSTROKEWIDTH
Default grid stroke width (1).

See Also:
Constant Field Values

MIME_DEFAULT

public static final java.lang.String MIME_DEFAULT
Default content type (image/png).

See Also:
Constant Field Values

ENCODERINFO

public static com.davisor.graphics.codec.MimeInfo ENCODERINFO
Default encoder info.


FRC

public static final java.awt.font.FontRenderContext FRC
Default font render context.


FONT

public static final java.awt.Font FONT
Default font (plain 12 point (4.2 mm) Serif).


I

public static final java.awt.geom.AffineTransform I
Static identity transformation.


NULLSTROKE

public static final java.awt.Stroke NULLSTROKE
Default null stroke (completely invisible).


PI2

public static final double PI2
PI / 2 constant.

See Also:
Constant Field Values

SHAPE

public static java.awt.Shape SHAPE
Default shape style (unit cross).


STROKE

public static final java.awt.Stroke STROKE
Default stroke (thin, solid line).


STROKEWIDTH

public static final float STROKEWIDTH
Default stroke width (1).

See Also:
Constant Field Values

TIC

public static final java.awt.geom.Line2D TIC
Default tic mark (vertical unit line).


HAS_3D

protected static boolean HAS_3D
Chart3D option pack availability.


DARK

protected static final int DARK
Dark paint index.

See Also:
Constant Field Values

NORMAL

protected static final int NORMAL
Base paint index.

See Also:
Constant Field Values

BRIGHT

protected static final int BRIGHT
Bright paint index.

See Also:
Constant Field Values

LABELFIELDNAMES

protected static java.lang.String[] LABELFIELDNAMES
Label field names.


CHANNEL

protected static final int CHANNEL
'CHANNEL' label code.

See Also:
Constant Field Values

LABEL

protected static final int LABEL
'LABEL' label code.

See Also:
Constant Field Values

VALUE

protected static final int VALUE
'VALUE' label code.

See Also:
Constant Field Values

PERCENT

protected static final int PERCENT
'PERCENT' label code.

See Also:
Constant Field Values

LABELFIELDS

protected static com.davisor.core.Index LABELFIELDS
Label field name map.


DUMPFACTORYNAME

protected static java.lang.String DUMPFACTORYNAME
Dump factory.

Constructor Detail

ChartFactory

public ChartFactory()
Default constructor.


ChartFactory

public ChartFactory(ChartFactory factory)
Copy constructor.

Method Detail

main

public static void main(java.lang.String[] args)
Generic chart factory test program.


createChannelType

protected Type createChannelType(java.net.URL context,
                                 java.awt.Color minColor,
                                 java.awt.Color maxColor,
                                 int channel,
                                 ChartData data)
                          throws InvalidDataException
Deprecated.  

Creates a type suitable for interpreting color and paint channel values. If color scale upper and lower values are given, a ColorScaleType is created, otherwise a PaintType.

Throws:
InvalidDataException
See Also:
createPaintChannelType(URL,Color,Color,int[],ChartData,AbstractScale)

createChannelType

protected Type createChannelType(java.net.URL context,
                                 java.awt.Color minColor,
                                 java.awt.Color maxColor,
                                 int[] channels,
                                 ChartData data)
                          throws InvalidDataException
Deprecated.  

Creates a type suitable for interpreting color and paint channel values. If color scale upper and lower values are given, a ColorScaleType is created, otherwise a PaintType.

Throws:
InvalidDataException
See Also:
createPaintChannelType(URL,Color,Color,int[],ChartData,AbstractScale)

createPaintChannelType

protected Type createPaintChannelType(java.net.URL context,
                                      java.awt.Color minColor,
                                      java.awt.Color maxColor,
                                      int channel,
                                      ChartData data,
                                      AbstractScale scale)
                               throws InvalidDataException
Creates a type suitable for interpreting color and paint channel values. If a scale is given, it is initialized for interpreting channel values and then returned. Otherwise, if color scale upper and lower values are given, a ColorScaleType is created, otherwise a PaintType.

Parameters:
context - texture location context
minColor - color scale lower color (may be null)
maxColor - color scale upper color (may be null)
channel - color or paint channel index (may be negative)
data - chart data
scale - scale for interpreting channel values (may be null)
Returns:
channel type, or null is channel index is negative
Throws:
InvalidDataException - if channel type creation fails
See Also:
createPaintChannelType(URL,Color,Color,int[],ChartData,AbstractScale), AbstractScale, ColorScaleType, PaintType

createPaintChannelType

protected Type createPaintChannelType(java.net.URL context,
                                      java.awt.Color minColor,
                                      java.awt.Color maxColor,
                                      int[] channels,
                                      ChartData data,
                                      AbstractScale scale)
                               throws InvalidDataException
Creates a type suitable for interpreting color and paint channel values. If a scale is given, it is initialized for interpreting channel values and then returned. Otherwise, if color scale upper upper and lower values are given, a ColorScaleType is created, otherwise a PaintType.

Parameters:
context - texture location context
minColor - color scale lower color (may be null)
maxColor - color scale upper color (may be null)
channels - color or paint channel indexes
data - chart data
scale - scale for interpreting channel values (may be null)
Throws:
InvalidDataException - if channel type creation fails
See Also:
createPaintChannelType(URL,Color,Color,int,ChartData,AbstractScale), 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[]), AbstractScale, ColorScaleType, PaintType

createShapeChannelType

protected Type createShapeChannelType(int channel,
                                      ChartData data,
                                      AbstractScale scale)
                               throws InvalidDataException
Creates a type suitable for interpreting shape channel values. If a scale is given, it is initialized for interpreting channel values and then returned. Otherwise, a ShapeType is returned.

Parameters:
channel - shape channel index (may be negative)
data - chart data
scale - scale for interpreting channel values (may be null)
Returns:
channel type, or null is channel index is negative
Throws:
InvalidDataException - if channel type creation fails
See Also:
createShapeChannelType(int[],ChartData,AbstractScale), 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[]), AbstractScale, ShapeType

createShapeChannelType

protected Type createShapeChannelType(int[] channels,
                                      ChartData data,
                                      AbstractScale scale)
                               throws InvalidDataException
Creates a type suitable for interpreting shape channel values. If a scale is given, it is initialized for interpreting channel values and then returned. Otherwise, a ShapeType is returned.

Parameters:
channels - shape channel indexes
data - chart data
scale - scale for interpreting channel values (may be null)
Throws:
InvalidDataException - if channel type creation fails
See Also:
createShapeChannelType(int,ChartData,AbstractScale), 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[]), AbstractScale, ShapeType

createSummary

protected ChartDataSummary createSummary(ChartData data,
                                         ChartAttributes attr,
                                         ChartAxes axes,
                                         PlotRenderAttributes plot,
                                         EnumType labelType,
                                         int[] channels,
                                         boolean isometric,
                                         int[] positionChannels)
                                  throws InvalidDataException
Computes summary information over a set of ChartData value channels. Value channel data types are expected to be mutually compatible so that the total minimum and maximum values over all the channels can be computed.

The minimum and maximum values in the returned summary are copies of the original values, so it is allowed to modify them.

Parameters:
data - chart data to be inspected
attr - chart rendering attributes
axes - the axes that control this particular chart
plot - local plot area attributes
labelType - label access type (may be null)
channels - indexes of the channels to be inspected
isometric - isometric rendering may affect how data is understood
positionChannels - channel indexes for element position value data
Throws:
java.lang.ClassCastException - if the elements are not DataValue
InvalidDataException - if data analysis fails
See Also:
ChartDataSummary

getDefaultPaint

protected static java.awt.Paint getDefaultPaint()
Gets system default paint.

If "default" paint creation fails, Color.black is returned.

Returns:
system default paint
See Also:
PaintType.createPaint(String)

getIsometricCoefficients

protected static float[][] getIsometricCoefficients(ChartAxes axes)
Computes axis' cosine and sine isometric rotation coefficients for the first two axes. The coefficients are returned in a two-dimensional table where the first index represents an axis, and the second represents the coefficients.

Axis angles are expected to be on the range [0,90] degrees, even if from a mathematical standpoint the correct Y -axis value range would be [-90,0]. This is compensated by negating the Y -axis angle before computing the Y -axis coefficients.

Returns:
axis rotation angle trigonometric coefficients, arranged into a float[0,1][COS,SIN] array
See Also:
ChartAxis.getAngle()

resolveDataLimits

protected DataValue[] resolveDataLimits(DataValue[][] limits,
                                        boolean[] cumulative)
                                 throws InvalidDataException
Determines global minimum and maximum data values. The global limit values are computed by taking the minimum and maximum values of the cumulative and channel specific limit values. In particular, cumulative limit values are computed by summing the member channel minimum and maximum values together, respectively.

Taking the sum of cumulative maximum values may yield too high and low limit values, as the data itself may not perhaps contain any such channel data value combination that would give the extream minimum or maximum values. However, the data element specific sum values are at least guaranteed to be between returned global values.

Warning! Do not modify the returned values since they may be references to the original data points.

Parameters:
limits - channel specific limit values
cumulative - precomputed channel cumulativenes values (may be null)
Returns:
global minimum and maximum values, taken over all value channels
Throws:
InvalidDataException - if chart generation fails

resolveDataLimits

protected DataValue[] resolveDataLimits(ChartData data,
                                        ChartAttributes attr,
                                        PlotRenderAttributes plot,
                                        int[] channels,
                                        boolean isometric,
                                        boolean[] cumulative)
                                 throws InvalidDataException
Determines global minimum and maximum data values.

This default implementation computes first channel specific minimum and maximum values, and then resolves their global minimum and maximum values. Data channel cumulativeness is not taken into account. Specific factories may override this method to get proper results for their purposes.

Warning! Do not modify the returned values since they may be references to the original data points.

Parameters:
data - chart data to be inspected
attr - chart rendering attributes
plot - local plot area attributes
channels - indexes of the channels to be inspected
isometric - isometric rendering may affect how data is understood
cumulative - precomputed channel cumulativenes values
Returns:
global minimum and maximum values, taken over all value channels
Throws:
InvalidDataException - if chart generation fails
See Also:
resolveDataLimits(DataValue[][],boolean[])

annotate

protected static java.awt.Paint annotate(java.awt.Paint paint,
                                         TupleData tuple,
                                         long tupleIndex,
                                         int channelIndex,
                                         short contextIndex,
                                         int urlChannel,
                                         int altChannel,
                                         Type urlChannelType,
                                         java.util.Properties plotAnnotationProperties,
                                         java.util.Properties renderingAnnotationProperties,
                                         java.util.Map additionalValues,
                                         TupleType streamType)
Annotates given paint. Annotation associates essential information to chart data, and provides a reliable way to pass that information through chart generation process. In particular, with annotation, chart and chart data post-processing systems may attach powerfull user interface functions to the graphics images chart factories produce. An example of annotation information is a describing text that is shown when a user points to a data bar.

Composing annotation information

Annotation information is searched and composed from the following sources, in the given ascending order:

Because the annotation information is composed from different sources, it possible that one information is taken from paint itself, one from alt data channel and one from rendering annotation. If any annotation information is found, the given paint is annotated (or re-annotated) and returned. If no annotation information is found, the paint is returned as it were.

Indexing information

Annotation indexing information is taken from given tupleIndex, channelIndex, and contextIndex. tupleIndex is assumed to be the running index of given tuple ("row number"). channelIndex is assumed to be the running index of the tuple member that provides the principal element value ("column number"). In particular, the tuple member index should be taken over all tuple members, not for example over only the value elements. Finally, contextIndex gives the index of the context the annotation occurs. For example, combo-chart sub-chart each have different context index, while simple chart context indexes should typically be always zero.

Parameters:
paint - the paint to be annotated
tuple - data point data
tupleIndex - tuple element index in the stream it came from
channelIndex - value channel the tuple came from
contextIndex - the sub-chart the tuple came from
urlChannel - url data channel number (may be invalid, like -1)
altChannel - alt data channel number (may be invalid, like -1)
urlChannelType - url data channel url data type (may be null)
plotAnnotationProperties - plot annotation attributes (may be null)
renderingAnnotationProperties - rendering annotation attributes (may be null)
additionalValues - additional values map to be used in format field value resolvation
streamType - description of stream data elements

drawLabel

protected static void drawLabel(java.awt.Graphics2D g,
                                java.awt.Paint color,
                                java.awt.Paint paint,
                                java.awt.Font font,
                                java.lang.String label,
                                int boundsAlignment,
                                int textAlignment,
                                float width,
                                float height,
                                float rotation,
                                float x,
                                float y,
                                float ax,
                                float ay)
Draws a rotated multirow label into a restricted space. If the final label bounding box is bigger than the given bounding box, the label font is to be scaled down to make the label fit. If the label is smaller than the given bounding box, the label will be aligned inside the box as specified by the given alignment argument.

If a label background paint is given, the label bounding box will be filled with that paint before the label itself is drawn.

Parameters:
g - the graphics context to draw into
color - label foreground color
paint - label background paint (may be null)
font - label font
label - label text
boundsAlignment - text bounding box alignment (RenderAttributes alignment code)
textAlignment - text alignment within text bounding box (RenderAttributes alignment code)
width - label maximum width in device coordinates (non-positive values impose no width restrictions)
height - label maximum height in device coordinates (non-positive values impose no height restrictions)
rotation - the rotation of labels of this axis
x - label X-position in device coordinates
y - label Y-position in device coordinates
ax - X font flipping multiplier (-1,1)
ay - Y font flipping multiplier (-1,1)
See Also:
LabelRenderer, RenderAttributes

shade

protected static java.awt.Paint[] shade(java.awt.Paint paint)
Creates darker and brighter versions of the given paint. The shades are packed into a new paint table with the elements:

The method can shade PaintData and Color instances. Other paints are not shaded, but simply returned in an array with elements that refer to the original paint.

If the argument paint is null, no shade table is created, and null is returned.


createChart

public Chart createChart(ChartAttributes attr)
Creates a new chart instance capable of emitting the chart content using some specific content type. In particular, the desired target content type is taken from given attributes with a call to the ChartAttributes.getContentType() method.

The following content types and corresponding Chart implementations are currently supported:

The supporting of a content types depends from a chart factory. For example, a content type of text/xml is not suitable content type for a ColumnBarFactory.

If content type in given chart attributes is null, content type defaults to chart factory specific default type. In particular, the target chart factory instance is first resolved with ChartAttributes.getChartType() and getFactory(String) methods, after which the factory default content type is resolved with getContentType().

If the chart factory in question is DumpFactory, the content type for a chart produced by DumpFactory is forced to text/xml.

If the above process fails for any reason, a BufferedChart with "image/png" content type is returned as the last resort.

Parameters:
attr - chart attributes
Returns:
new chart instance of appropriate type
See Also:
createChart(ChartAttributes,float,float,boolean), createChart(ChartData), createChart(ChartData,ChartAttributes), getContentType(), getFactory(String), BufferedChart, ChartAttributes.getContentType(), SVGChart, StringBufferChart

createChart

public Chart createChart(ChartAttributes attr,
                         float userWidth,
                         float userHeight,
                         boolean symmetric)
                  throws ChartException
Creates a new chart with an optionally constrained size aspect ratio. In particular, this method creates a chart with such a size that all given size and aspect ration constrains are met.

This method operates with two different size concepts. The first of the two is chart physical size that define chart canvas size in SI millimeters. The second size is chart logical size that defines the size of the same canvas in some undetermined but mutually equal units. In particular, the magnitude of the logical units has no significance, only the aspect ratio between the logical width and height values is important. That aspect ratio is then used to complete any partially declared physical size information.

Chart physical size is taken from given chart size attributes, and logical size is taken from the given size parameters.

Either, or both of the physial chart size attributes may have null or zero value, which leaves those attribute values undetermined. In this case, missing values will be resolved to match the given user units' size aspect ratio, and the resulting new concrete size will be stored in the given image chart.

If chart physical and logical sizes have been defined, but their aspect ratios do not match, and symmetric aspect ratio has been requested for, the user units' coordinate system is centered along the violating axis with an initial affine translation transformation, if possible. In particular, affine translation is possible only if the chart is an ImageChart that supports such operations.

Once the image chart device and user units' sizes have been fully resolved, a new ImageChart object is created and initialized, as described in that class documentation. Before the new image chart is returned, however, its bounds are set to match the concrete size of the image chart's drawable area. This area may be smaller than the whole chart's concrete area, due to centering and other initial transformations.

Finally, if the image chart creation fails due to an out of memory error, the image creation is retried with half of the image width and height. This is continued until the image width or height drops below 2, or if the image creation succeeds. If the creation of an image with the width or height equal to 1 still fails, the out of memory error is allowed to proceed out of this method.

Parameters:
attr - chart attributes
userWidth - the chart width in arbitrary units
userHeight - the chart height in arbitrary units
symmetric - should chart size aspect ratio be enforced
Returns:
a chart configured as described above
Throws:
ChartException - if chart generation fails
See Also:
createChart(ChartAttributes), createChart(ChartData), createChart(ChartData,ChartAttributes)

createChart

public Chart createChart(ChartData data)
                  throws ChartException
Creates a new single-component chart with default attributes. Please see class documentation for more information.

This implementation just invokes createChart(ChartData,ChartAttributes) with a null attribute argument.

Parameters:
data - chart data
Throws:
ChartException - if chart generation fails
See Also:
createChart(ChartData,ChartAttributes)

createChart

public Chart createChart(ChartData data,
                         ChartAttributes attr,
                         Chart chart)
                  throws ChartException
Creates a new chart using the given data and attributes. If a chart is not given, creates a new one. Otherwise, draws onto the graphics context of the given chart.

Creates the chart in four steps:

  1. Combine the separately given attributes with data attributes.
  2. Create ChartFactory.ChartContext by calling createContext(com.davisor.graphics.chart.ChartData, com.davisor.graphics.chart.ChartAttributes). This phase resolves the final attribute values by taking care of all kinds of defaulting mechanisms. May also calculate calculate values needed later.
  3. Create ChartFactory.ChartMetrics by calling createMetrics(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartAttributes). Reserves space for labels and plot area among others. Determines preliminatory chart size.
  4. Create the chart instance if needed and draw the chart by calling createChart(ChartFactory.ChartContext, ChartFactory.ChartMetrics,ChartAttributes,Chart).

Sub-classes may override this if they need a deeper access to the chart creation procedure. They must, however, take care that all the phases listed above will be done.

Parameters:
data - chart data
attr - chart attributes (may be null)
chart - previously created chart to be drawn onto (may be null)
Throws:
ChartException - if chart generation fails
See Also:
createContext(com.davisor.graphics.chart.ChartData, com.davisor.graphics.chart.ChartAttributes), createMetrics(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartAttributes), ChartFactory.ChartContext, ChartFactory.ChartMetrics

createChart

public Chart createChart(ChartData data,
                         ChartAttributes attr)
                  throws ChartException
Creates a chart using the given data and attributes.

Parameters:
data - chart data
attr - chart attributes (may be null)
Throws:
ChartException - if chart generation fails
See Also:
createChart(ChartData,ChartAttributes,Chart)

combineProperties

public static java.util.Properties combineProperties(java.util.Properties actual,
                                                     java.util.Properties defaults)
Creates a new Properties instance which contains all the properties in the two given property sets. If there are properties with the same name, the ones in the actual set overrides the ones in defaults.


getContentType

public java.lang.String getContentType()
Gets the content type preferred by this factory.

This default implementation returns "image/png", which is what most sub-classes will most propably want. Specific sub-classes may however want to use some other default content type, like "text/html", for example

Returns:
"image/png"

getLegendShape

public java.awt.Shape getLegendShape()
Gets the legend symbol shape preferred by this factory.

This default implementation returns "rectange" shape, which is suitable for most cases since it is capable of showing color, paint, and stroke. Returns null if shape creation fails.

Sub-classes are engouraged to override this.

Returns:
Shape instance or null

has3D

public static boolean has3D()
Tests the precense of Davisor 3D Option pack.

Returns:
if Davisor 3D Option pack is present

hasSVG

public static boolean hasSVG()
Tests the precense of Davisor SVG Option pack.

Returns:
if Davisor SVG Option pack is present

isMultiSeriesMode

public static boolean isMultiSeriesMode(ChartData data,
                                        ChartAttributes attr)
Determines multiSeriesMode based on data and attributes. In particular, if multiSeriesMode is set in attributes, that setting is used. Otherwise, the return value is determined using the amount of value channels (or groups) in the data. If no value channels are present, number of object channels is used instead.

Please note that the automatic multi series mode logic ignores the precense of any data groups, and counts only the total number of value channels. The reason for this is that all combination chart sub-charts should use multi series mode by default, even if they individually would use only one data channel, and therefore use single series mode if they would appear alone outside a combination chart. This is because combination chart legends are composed for the entire collection of sub-charts in a combination charts, and from the legend point of view, a combination chart with multiple single data channel sub-charts is a multi series chart.

Parameters:
data - chart data
attr - chart attributes
Returns:
use multi series mode or not

mayHaveLegend

public boolean mayHaveLegend()
Determines whether a sensible legend exists or not. The default value returned by this implementation is true. Chart factories are engouraged to override this when needed.


createContext

public abstract ChartFactory.ChartContext createContext(ChartData data,
                                                        ChartAttributes attr)
                                                 throws ChartException
Creates and initializes a chart context. The context will hold values neccessary to resolve chart image size. All context parameters expect data and attr will be new object instances. Sub-classes are expected to extend ChartFactory.ChartContext in order to pass forward sub-class specific context parameter.

See class documentation for more information about how axis chart generation is expected to proceed.

Parameters:
data - chart data
attr - chart attributes
Returns:
chart context, containing chart sizing information
Throws:
ChartException - if chart generation fails
See Also:
createMetrics(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartAttributes)

createMetrics

public abstract ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext context,
                                                        ChartAttributes attr)
                                                 throws ChartException
Resolve final axis chart image and image component sizes.

Parameters:
context - chart context
attr - chart attributes
Throws:
ChartException - if chart generation fails

createChart

public abstract Chart createChart(ChartFactory.ChartContext chartContext,
                                  ChartFactory.ChartMetrics chartMetrics,
                                  ChartAttributes attr,