|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.davisor.graphics.chart.ChartFactory
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.
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.
PieFactory - pie charts
ColumnBarFactory - vertical column charts
RowBarFactory - horizontal bar charts
LineFactory - line charts for one-dimensional data
ScatterFactory - scatter charts for
two-dimensional data
LegendFactory - chart legend generator
ComboFactory - combined multiaxis chart generator
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.
com/davisor/graphics/chart/factories.properties
resource bundle. The default definitions in this file correspond to the factory list given above.
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.
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 |
protected static final int COS
protected static final int SIN
public static final int X
public static final int Y
public static final int Z
public static final int NONE
public static final int ALL
public static final float[] DOTSEQUENCE
public static final java.awt.Stroke DOTSTROKE
public static final float DOTSTROKEWIDTH
public static final java.lang.String MIME_DEFAULT
public static com.davisor.graphics.codec.MimeInfo ENCODERINFO
public static final java.awt.font.FontRenderContext FRC
public static final java.awt.Font FONT
public static final java.awt.geom.AffineTransform I
public static final java.awt.Stroke NULLSTROKE
public static final double PI2
public static java.awt.Shape SHAPE
public static final java.awt.Stroke STROKE
public static final float STROKEWIDTH
public static final java.awt.geom.Line2D TIC
protected static boolean HAS_3D
protected static final int DARK
protected static final int NORMAL
protected static final int BRIGHT
protected static java.lang.String[] LABELFIELDNAMES
protected static final int CHANNEL
protected static final int LABEL
protected static final int VALUE
protected static final int PERCENT
protected static com.davisor.core.Index LABELFIELDS
protected static java.lang.String DUMPFACTORYNAME
| Constructor Detail |
public ChartFactory()
public ChartFactory(ChartFactory factory)
| Method Detail |
public static void main(java.lang.String[] args)
protected Type createChannelType(java.net.URL context,
java.awt.Color minColor,
java.awt.Color maxColor,
int channel,
ChartData data)
throws InvalidDataException
ColorScaleType is created, otherwise a PaintType.
InvalidDataExceptioncreatePaintChannelType(URL,Color,Color,int[],ChartData,AbstractScale)
protected Type createChannelType(java.net.URL context,
java.awt.Color minColor,
java.awt.Color maxColor,
int[] channels,
ChartData data)
throws InvalidDataException
ColorScaleType is created, otherwise a PaintType.
InvalidDataExceptioncreatePaintChannelType(URL,Color,Color,int[],ChartData,AbstractScale)
protected Type createPaintChannelType(java.net.URL context,
java.awt.Color minColor,
java.awt.Color maxColor,
int channel,
ChartData data,
AbstractScale scale)
throws InvalidDataException
ColorScaleType is created,
otherwise a PaintType.
context - texture location contextminColor - 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 datascale - scale for interpreting channel values (may be null)
null is channel index is negative
InvalidDataException - if channel type creation failscreatePaintChannelType(URL,Color,Color,int[],ChartData,AbstractScale),
AbstractScale,
ColorScaleType,
PaintType
protected Type createPaintChannelType(java.net.URL context,
java.awt.Color minColor,
java.awt.Color maxColor,
int[] channels,
ChartData data,
AbstractScale scale)
throws InvalidDataException
ColorScaleType is
created, otherwise a PaintType.
context - texture location contextminColor - color scale lower color (may be null)maxColor - color scale upper color (may be null)channels - color or paint channel indexesdata - chart datascale - scale for interpreting channel values (may be null)
InvalidDataException - if channel type creation failscreatePaintChannelType(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
protected Type createShapeChannelType(int channel,
ChartData data,
AbstractScale scale)
throws InvalidDataException
ShapeType is
returned.
channel - shape channel index (may be negative)data - chart datascale - scale for interpreting channel values (may be null)
null is channel index is negative
InvalidDataException - if channel type creation failscreateShapeChannelType(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
protected Type createShapeChannelType(int[] channels,
ChartData data,
AbstractScale scale)
throws InvalidDataException
ShapeType is
returned.
channels - shape channel indexesdata - chart datascale - scale for interpreting channel values (may be null)
InvalidDataException - if channel type creation failscreateShapeChannelType(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
protected ChartDataSummary createSummary(ChartData data,
ChartAttributes attr,
ChartAxes axes,
PlotRenderAttributes plot,
EnumType labelType,
int[] channels,
boolean isometric,
int[] positionChannels)
throws InvalidDataException
The minimum and maximum values in the returned summary are copies of the original values, so it is allowed to modify them.
data - chart data to be inspectedattr - chart rendering attributesaxes - the axes that control this particular chartplot - local plot area attributeslabelType - label access type (may be null)channels - indexes of the channels to be inspectedisometric - isometric rendering may affect how data is understoodpositionChannels - channel indexes for element position value data
java.lang.ClassCastException - if the elements are not DataValue
InvalidDataException - if data analysis failsChartDataSummaryprotected static java.awt.Paint getDefaultPaint()
If "default" paint creation fails, Color.black is returned.
PaintType.createPaint(String)protected static float[][] getIsometricCoefficients(ChartAxes axes)
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.
float[0,1][COS,SIN] arrayChartAxis.getAngle()
protected DataValue[] resolveDataLimits(DataValue[][] limits,
boolean[] cumulative)
throws InvalidDataException
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.
limits - channel specific limit valuescumulative - precomputed channel cumulativenes values (may be null)
InvalidDataException - if chart generation fails
protected DataValue[] resolveDataLimits(ChartData data,
ChartAttributes attr,
PlotRenderAttributes plot,
int[] channels,
boolean isometric,
boolean[] cumulative)
throws InvalidDataException
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.
data - chart data to be inspectedattr - chart rendering attributesplot - local plot area attributeschannels - indexes of the channels to be inspectedisometric - isometric rendering may affect how data is understoodcumulative - precomputed channel cumulativenes values
InvalidDataException - if chart generation failsresolveDataLimits(DataValue[][],boolean[])
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)
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.
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.
paint - the paint to be annotatedtuple - data point datatupleIndex - tuple element index in the stream it came fromchannelIndex - value channel the tuple came fromcontextIndex - the sub-chart the tuple came fromurlChannel - 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 resolvationstreamType - description of stream data elements
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)
If a label background paint is given, the label bounding box will be filled with that paint before the label itself is drawn.
g - the graphics context to draw intocolor - label foreground colorpaint - label background paint (may be null)font - label fontlabel - label textboundsAlignment - 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 axisx - label X-position in device coordinatesy - label Y-position in device coordinatesax - X font flipping multiplier (-1,1)ay - Y font flipping multiplier (-1,1)LabelRenderer,
RenderAttributesprotected static java.awt.Paint[] shade(java.awt.Paint paint)
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.
public Chart createChart(ChartAttributes attr)
ChartAttributes.getContentType() method.
The following content types and corresponding Chart
implementations are currently supported:
SVGChart
BufferedChart
StringBufferChart
StringBufferChart
StringBufferChart
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.
attr - chart attributes
createChart(ChartAttributes,float,float,boolean),
createChart(ChartData),
createChart(ChartData,ChartAttributes),
getContentType(),
getFactory(String),
BufferedChart,
ChartAttributes.getContentType(),
SVGChart,
StringBufferChart
public Chart createChart(ChartAttributes attr,
float userWidth,
float userHeight,
boolean symmetric)
throws ChartException
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.
attr - chart attributesuserWidth - the chart width in arbitrary unitsuserHeight - the chart height in arbitrary unitssymmetric - should chart size aspect ratio be enforced
ChartException - if chart generation failscreateChart(ChartAttributes),
createChart(ChartData),
createChart(ChartData,ChartAttributes)
public Chart createChart(ChartData data)
throws ChartException
This implementation just invokes
createChart(ChartData,ChartAttributes)
with a null attribute argument.
data - chart data
ChartException - if chart generation failscreateChart(ChartData,ChartAttributes)
public Chart createChart(ChartData data,
ChartAttributes attr,
Chart chart)
throws ChartException
Creates the chart in four steps:
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.
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.
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.
data - chart dataattr - chart attributes (may be null)chart - previously created chart to be drawn onto (may be null)
ChartException - if chart generation failscreateContext(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
public Chart createChart(ChartData data,
ChartAttributes attr)
throws ChartException
data - chart dataattr - chart attributes (may be null)
ChartException - if chart generation failscreateChart(ChartData,ChartAttributes,Chart)
public static java.util.Properties combineProperties(java.util.Properties actual,
java.util.Properties defaults)
public java.lang.String getContentType()
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
public java.awt.Shape getLegendShape()
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.
nullpublic static boolean has3D()
public static boolean hasSVG()
public static boolean isMultiSeriesMode(ChartData data,
ChartAttributes attr)
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.
data - chart dataattr - chart attributes
public boolean mayHaveLegend()
true.
Chart factories are engouraged to override this when needed.
public abstract ChartFactory.ChartContext createContext(ChartData data,
ChartAttributes attr)
throws ChartException
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.
data - chart dataattr - chart attributes
ChartException - if chart generation failscreateMetrics(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartAttributes)
public abstract ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext context,
ChartAttributes attr)
throws ChartException
context - chart contextattr - chart attributes
ChartException - if chart generation fails
public abstract Chart createChart(ChartFactory.ChartContext chartContext,
ChartFactory.ChartMetrics chartMetrics,
ChartAttributes attr,