com.davisor.graphics.chart
Class ComboFactory

java.lang.Object
  extended bycom.davisor.graphics.chart.ChartFactory
      extended bycom.davisor.graphics.chart.AxisFactory
          extended bycom.davisor.graphics.chart.ComboFactory
All Implemented Interfaces:
com.davisor.core.Dupable, com.davisor.core.MIMETypes, com.davisor.core.Public

public class ComboFactory
extends AxisFactory

ComboFactory implements a polymorphic axis chart that can combine different axis charts into one common coordinate system. In particular, all combo-chart sub-charts share the same core area. They may also share one or more common axes and value ranges, as sub-chart specific axis types and placement allow.

Introduction

Combo-chart creation follows the general axis chart creation process all axis charts are expected to follow. However, after sub-chart specific value and size computation has been made, and before anything has actually drawn, combo-chart browses through the sub-chart specific results collected so far, and unifiest them so that they can all be rendered into one common coordinate axis system.

After unification, combo-chart simply asks each sub-chart to continue and render itself into a given shared chart image. None of the sub-charts is aware of the precense of other combo-chart components, or even that it itself is going to be part of a combo-chart. This architecture allows future axis charts to be immediately part of combo-charts, provided that they otherwise follow the general contract expected from all axis charts.

Combo-chart control

Combo-charts are made made of one or more sub-charts, that each have their own set of data and attributes. The selection of sub-chart specific data and chart type differs however somewhat from ordinary single charts.

The basic difference between combo-charts and single-charts is, that combo-chart attributes may contain more than one set of coordinate axis attributes (ChartAxes objects}. Each coordinate axis set defines one sub-charts, and defines all sub-chart specific attributes for it. All other attributes outside the axis sets are considered top-level combo-chart attributes that affect details and structures outside the individual sub-charts (like backgroudn border and paint), and provide default values for corresponding sub-chart specific attributes (like plot area attributes).

Data control

First, sub-charts rely more than single charts on data groups and data group selection. In particular, as described by ChartData.getTypeIndexes(String,String), data grouping allows data sources to partition their streams into named groups, thus making it possible for one datasource to provide data for more than one separate chart. Sub-charts select their input data group with ChartAxes specific dataGroup attribute, accessible through ChartAxes.getDataGroup() and ChartAxes.setDataGroup(java.lang.String) methods. dataGroup attribute has also it's corresponding XML representation, as described by ChartXMLAttributes.

Type control

Combo-chart is just one chart type among other chart types (combo by default), and combo-chart type is selected like any other chart type would be (ChartFactory.getFactory(String), ChartObjectAttributes.setChartType(String), or ChartXMLAttributes for example). This does still however leave open the question about the combo-chart sub-chart types.

Sub-chart types are select by ChartAxes specific subChartType attributes, accessible through ChartAxes.getChartType() and ChartAxes.setChartType(java.lang.String) methods. The axes specific subChartType attribute has also it's corresponding XML representation, as described by ChartXMLAttributes.

Combo chart manufacturing process

Combo-charts are created with the following procedure:

Unification

Combochart unifies sub-chart parameters with the following steps:

Size allocation

Chart component size allocation works by first allocation space for each component one chart at a time, then unifying the corresponding component sizes, and finally scaling to final chart to given target size. This approach allows easy integration with any new axis chart types and chart component space allocation strategies. However, size allocation optimization becomes more difficult, as individual sub-charts have limited information about the global size allocation situation.

One particular problem occurs when a sub-chart thinks it has more than enough space, when actually this is not true on the global scale where the given same chart image space is shared between multiple sub-charts. In order to reduce this kind of wasted space, combo charts instruct their sub-components to conserve space, and never exceed their ideal sizes. If there is extra space even after all sub-charts have been combined, the final chart image is scaled up as neccessary.

Since:
JDK1.3

Nested Class Summary
 class ComboFactory.ComboContext
          Combo context contains data neccessary to create a combo chart for a particular set of sub charts.
 class ComboFactory.ComboMetrics
          Combo metrics.
 
Nested classes inherited from class com.davisor.graphics.chart.AxisFactory
AxisFactory.AxisContext, AxisFactory.AxisMetrics
 
Nested classes inherited from class com.davisor.graphics.chart.ChartFactory
ChartFactory.ChartContext, ChartFactory.ChartMetrics
 
Field Summary
 
Fields inherited from class com.davisor.graphics.chart.AxisFactory
DEFAULTLABELTYPE, FLIPX, FLIPY, MAJORMARGIN, MINORMARGIN, MINSIZE
 
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
ComboFactory()
          Default constructor.
ComboFactory(ComboFactory factory)
          Copy constructor.
 
Method Summary
 Chart createChart(ChartFactory.ChartContext chartContext, ChartFactory.ChartMetrics chartMetrics, ChartAttributes attr, Chart chart)
          Creates a multiaxis chart from multiple chart attributes.
 ChartFactory.ChartContext createContext(ChartData data, ChartAttributes attr)
          Creates a multiaxis chart from multiple chart attributes.
 ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext chartContext, ChartAttributes attr)
          Resolves combo chart size.
protected  ComboFactory.ComboMetrics createMetrics(ComboFactory.ComboContext comboContext, java.lang.Number comboWidth, java.lang.Number comboHeight)
          Computes combo metrics information.
 com.davisor.core.Dupable dup()
          Duplicates this factory.
protected  float[] getIdealSize(ChartAxes axes, int elements, int channels, float[] labelOffsets, float[][] titleSizes, float[][] labelSizes, float[][] markerSizes, float[] markerOffsets)
          Gets the ideal suggested size for this chart.
protected  DataValue[][] resolveLimits(ChartDataSummary summary)
          Computes chart factory specific axis limit values.
 
Methods inherited from class com.davisor.graphics.chart.AxisFactory
computeMinorMargin, createChart, createContext, createContext, createContext, createMetrics, createMetrics, createMetrics, drawAxis, drawChart, drawMarkers, drawTics, drawXYAxes, drawXYZAxes, fillGrid, fillMarkers, formatDouble, getIdealSize, hasGridLines, isSilent, labelAxis, labelMarkers, resolveLabels, resolveLabels, resolveMarkerSizes, resolveOverlap, titleAxis, transpose
 
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
 

Constructor Detail

ComboFactory

public ComboFactory()
Default constructor.


ComboFactory

public ComboFactory(ComboFactory factory)
Copy constructor.

Method Detail

getIdealSize

protected float[] getIdealSize(ChartAxes axes,
                               int elements,
                               int channels,
                               float[] labelOffsets,
                               float[][] titleSizes,
                               float[][] labelSizes,
                               float[][] markerSizes,
                               float[] markerOffsets)
Gets the ideal suggested size for this chart.

Combo-charts resolve their own size by consulting their sub-charts during chart generation. They itself do not have any ideal size that would depend on the arguments given for this method. This method therefore does nothing.

Overrides:
getIdealSize in class AxisFactory
Parameters:
axes - axis attributes
elements - the expected number of data element groups
channels - the expected number of data channels
labelOffsets - axis label offsets ([x,y])
titleSizes - axis title sizes ([x,y][w,h])
labelSizes - axis label sizes ([x,y][w,h])
markerSizes - axis marker sizes ([x,y][w,h])
markerOffsets - axis marker offsets ([x,y])
Returns:
null
See Also:
AxisFactory.getIdealSize(ChartAxes,float[],float[], float[][],float[][],float[][],float[]), AxisFactory.AxisMetrics

resolveLimits

protected DataValue[][] resolveLimits(ChartDataSummary summary)
Description copied from class: AxisFactory
Computes chart factory specific axis limit values. The computation is based on the chart input data limit values and/or the number of data elements, according to the nature of each particular chart factory.

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.

Specified by:
resolveLimits in class AxisFactory
Parameters:
summary - chart data summary
Returns:
array of axis minimum and maximum data values ([x,y,...][min,max])
See Also:
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[])

createContext

public ChartFactory.ChartContext createContext(ChartData data,
                                               ChartAttributes attr)
                                        throws ChartException
Creates a multiaxis chart from multiple chart attributes. A combofactory axis chart consists of one or more axis charts, all draw into a common coordinate system. Please see class description for more information.

Overrides:
createContext in class AxisFactory
Parameters:
data - chart data
attr - chart attributes
Returns:
chart context (AxisContext)
Throws:
ChartException - if chart generation fails
See Also:
ChartFactory.createChart(ChartData,ChartAttributes)

createMetrics

public ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext chartContext,
                                               ChartAttributes attr)
                                        throws ChartException
Resolves combo chart size. Uses the values in attributes and replaces missing values with value 200 mm.

Overrides:
createMetrics in class AxisFactory
Parameters:
chartContext - chart context (ComboContext)
attr - chart attributes
Returns:
an instance of ComboMetrics
Throws:
ChartException - if chart generation fails
See Also:
createMetrics(ComboFactory.ComboContext,Number,Number)

createChart

public Chart createChart(ChartFactory.ChartContext chartContext,
                         ChartFactory.ChartMetrics chartMetrics,
                         ChartAttributes attr,
                         Chart chart)
                  throws ChartException
Creates a multiaxis chart from multiple chart attributes. A combo factory axis chart consists of one or more axis charts, all draw into a common coordinate system. Please see class description for more information.

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.

Overrides:
createChart in class AxisFactory
Parameters:
chartContext - context information (ComboContext)
chartMetrics - metrics information (ComboMetrics)
attr - chart atttributes
chart - chart to render to (may be null)
Returns:
given or new chart object
Throws:
ChartException - if chart generation fails
See Also:
AxisFactory.createChart(AxisFactory.AxisContext,AxisFactory.AxisMetrics, ChartAxes,boolean,boolean,boolean,boolean,Chart)

dup

public com.davisor.core.Dupable dup()
Duplicates this factory.


createMetrics

protected ComboFactory.ComboMetrics createMetrics(ComboFactory.ComboContext comboContext,
                                                  java.lang.Number comboWidth,
                                                  java.lang.Number comboHeight)
                                           throws ChartException
Computes combo metrics information.

Parameters:
comboContext - the combo operation context
comboWidth - combo chart width constrain (may be null)
comboHeight - combo chart height constrain (may be null)
Returns:
combo metrics that meet given constrains
Throws:
ChartException - if chart generation fails
See Also:
createMetrics(ChartFactory.ChartContext,ChartAttributes)


Copyright © 2001-2004 Davisor Oy. All Rights Reserved.