com.davisor.graphics.chart
Class LabelLegendFactory

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

public class LabelLegendFactory
extends LegendFactory

LabelLegendFactory implements a chart legend producer that can make legend charts out of one- or multidimensional data. Legend entries are generated from data series, or from individual data point values. Individual data point values are used if there is only one value channel, or there is explicitly given multiseriesMode="false" attribute. If there are several channels or multiseriesMode="true", series names are used.

Legend factory supports also combination charts, where one chart contains more than one sub-charts, each with different data channel group. Legend factory iterates over all sub-charts, and concatenates the output from each. In particular, if a channel appears multiple times in multiple data groups, it will be included as many times, too.

Legend charts expect data from channels of the following types. The channel types are taken from the corresponding tuple data stream type names:

Furhermore, the following attribute channel types will be recognized and utilized, but only in the "single series mode":

For each series, one series legend entry is generated. The series entry displays the series name and a legend symbol. If the series defines a line paint, the symbol will be a rectangle, filled with the the fill paint, and surrounded with a borderline, drawn with series line color and stroke. If the series does not define a fill paint, the symbol will be horizontal line, drawn with series line color and stroke. In either case, if the the series defines also a point shape, the shape is drawn on top of the rectange or line, drawn and filled with series point color, paint, shape, and stroke. Missing series names are replaced with text "Series #num", where #num is ascending order number.

In the case of "single series mode" legend factory produces one legend entry for each data point, regardless of the number of channels. Each data point entry displays a data point label and a horizontal line symbol. The label text is taken from the label channel, if available. Missing values are replaced with text &quo;Value #num". If there are channel attibutes in the first value channel, those are used not depending on the number of actual value channels (usually there is only one). Then the specific attribute channels for color, paint, shape, and stroke are looked. For still unresolved attributes the plot attributes or system defaults will be used.

If shape is given, pointColor and pointPaint are used instead of lineColor and linePaint when determining the color and paint for legend symbol.

The legend image size is determined from initial chart attributes. If either or both of the width and height values are zero, suitable image size values are computed and substituted. If the chart size is decreased below the point where the chart labels would not fit in the space given, the font sizes are automatically scaled down to make the labels fit.

The legend symbol size is relative to the label height. It can be adjusted by changing the legend gap (which defaults to x-axis gap which defaults to axes gap setting). The default gap is 20(%). If the gap is not given or it cannot be resolved due to different values in separate axes groups, then the global default is used. Valid value range for gap is 0-100.

Legend factory supports annotated paints, but again only withint the limitations of legend factory data displaying capabilities. In particular, legend factory can not display detailed annotation information associated to multiple channels, since a legend typically shows just one series label for an entire data series, containing many points. And even when data point labels are shown, there will be only one label channel, regardless of the number of value channels.

Legend charts do not currently support any 3D look.

Since:
JDK1.2
See Also:
LegendFactory, ChartAttributes, ChartData

Nested Class Summary
 class LabelLegendFactory.LabelLegendContext
          Context information for legend size calculation and drawing.
protected  class LabelLegendFactory.LabelLegendEntry
          LabelLegendEntry stores information about a legend entry to be rendered.
 class LabelLegendFactory.LabelLegendMetrics
          Legend metrics contain the legend sizing information.
 
Nested classes inherited from class com.davisor.graphics.chart.ChartFactory
ChartFactory.ChartContext, ChartFactory.ChartMetrics
 
Field Summary
static int DEFAULT_GAP
          Default symbol gap (20).
static java.lang.String LABEL_NAME
          Default label name without order number.
static java.lang.String SERIES_NAME
          Default series name without order number.
 
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
LabelLegendFactory()
          Default constructor.
LabelLegendFactory(LabelLegendFactory factory)
          Copy constructor.
 
Method Summary
 Chart createChart(ChartFactory.ChartContext chartContext, ChartFactory.ChartMetrics chartMetrics, ChartAttributes attr, Chart chart)
          Create and draw the legend chart.
 ChartFactory.ChartContext createContext(ChartData data, ChartAttributes attr)
          Resolve rendering attributes.
 ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext chartContext, ChartAttributes attr)
          Resolve number of rows and cols.
 com.davisor.core.Dupable dup()
          Duplicates this factory.
 
Methods inherited from class com.davisor.graphics.chart.LegendFactory
getLabelBackgroundPaint, mayHaveLegend
 
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, registerFactory, resolveDataLimits, resolveDataLimits, rotateSize, shade, unregisterFactory
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_GAP

public static final int DEFAULT_GAP
Default symbol gap (20).

See Also:
Constant Field Values

SERIES_NAME

public static final java.lang.String SERIES_NAME
Default series name without order number.

See Also:
Constant Field Values

LABEL_NAME

public static final java.lang.String LABEL_NAME
Default label name without order number.

See Also:
Constant Field Values
Constructor Detail

LabelLegendFactory

public LabelLegendFactory()
Default constructor.


LabelLegendFactory

public LabelLegendFactory(LabelLegendFactory factory)
Copy constructor.

Method Detail

createContext

public ChartFactory.ChartContext createContext(ChartData data,
                                               ChartAttributes attr)
                                        throws ChartException
Resolve rendering attributes. Create context.

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

createMetrics

public ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext chartContext,
                                               ChartAttributes attr)
                                        throws ChartException
Resolve number of rows and cols. Create legend metrics.

Specified by:
createMetrics in class ChartFactory
Parameters:
chartContext - chart context
attr - chart attributes
Throws:
ChartException - if chart generation fails

createChart

public Chart createChart(ChartFactory.ChartContext chartContext,
                         ChartFactory.ChartMetrics chartMetrics,
                         ChartAttributes attr,
                         Chart chart)
                  throws ChartException
Create and draw the legend chart.

Specified by:
createChart in class ChartFactory
Parameters:
chartContext - pre-calculated context information (LabelLegendContext)
chartMetrics - pre-calculated size information used in drawing (LegendMetrics)
attr - chart attributes
chart - previously created chart to be drawn onto (may be null)
Returns:
the given chart instance or a new one if none was given
Throws:
ChartException - if chart generation fails

dup

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



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