com.davisor.graphics.chart
Class PieFactory

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

public class PieFactory
extends ChartFactory

PieFactory implements a pie chart producer that can make pie charts out of one-dimensional data.

Channels

Pie charts accepts data from channels of the following types:

Values

If more that one value channels are provided, only the first will be used. Any values with numeric interprerations are accepted, and at least one value must have non-zero value. Each value will generate one pie segment. Any null values will be omitted. Values may be negative or positive, and their absolute value determines the size of the corresponding pie slice.

Channel Attributes

Channel attributes are used if present.

Value Attributes

Pie slice labels and render attributes are taken from the corresponding label, color,, and paint channels. If multiple suitable channels are present, only the first one of each type is used. If there are more value entries columns than there are attribute columns of a specific type, then the remaining values use default values.

Slices can be separated from the pie by giving them non-zero value in explode channel. The explode value tells the distance from the pie center to slice as percentage of the pie radius. Values between 0 and 100 are allowed.

Pie labels will be formatted using value format attribute. If no value format has been given, no labels are generated. Color, background paint, font, alignment, and attaching line stroke for value labels are controlled by value rendering attributes. Pie color values control pie slice borderline color, while paint controls pie slice fill color. Pie color and paint will default to plot area attributes.

Other Attributes

Chart axes control bar chart 3D look. X-axis rotation determines the chart 3D look. Zero rotation gives a flat 2D chart, other angles between zero and 90 (not including) will turn the pie and expose it's front -sides. Z-axis rotation will turn the pie disk around its center axis. Y-axis rotation is ignored.

By default pie is drawn counterclockwise from three o'clock. The drawing direction can be altered by reversing Y-axis. This affects to Z-axis angle, too.

Font, background paint and pen color have their obvious meanings. The pie slices will be bordered with the plot area stroke style, which will default to a thin solid line.

Since:
JDK1.2
See Also:
createChart(com.davisor.graphics.chart.ChartFactory.ChartContext, com.davisor.graphics.chart.ChartFactory.ChartMetrics, com.davisor.graphics.chart.ChartAttributes, com.davisor.graphics.chart.Chart), ChartAttributes, ChartData

Nested Class Summary
 class PieFactory.PieContext
          Contains ready resolved values for metrics resolvation and rendering.
 class PieFactory.PieMetrics
          PieMetrics contains calculated values for size variables needed when drawing the pie.
 
Nested classes inherited from class com.davisor.graphics.chart.ChartFactory
ChartFactory.ChartContext, ChartFactory.ChartMetrics
 
Field Summary
 
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
PieFactory()
          Creates a new pie factory.
PieFactory(PieFactory factory)
          Copy constructor.
 
Method Summary
 Chart createChart(ChartFactory.ChartContext chartContext, ChartFactory.ChartMetrics chartMetrics, ChartAttributes attr, Chart chart)
          Draw pie chart using the precalculated values in context and metrics.
 ChartFactory.ChartContext createContext(ChartData data, ChartAttributes attr)
          Resolve needed values for drawing.
 ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext chartContext, ChartAttributes attr)
          Resolves pie size and label positions.
protected  PieFactory.PieMetrics createMetrics(PieFactory.PieContext pieContext, java.lang.Number pieWidth, java.lang.Number pieHeight)
          Computes pie metrics information.
protected static void drawSlice(ImageChart chart, PieFactory.PieMetrics metrics, PieFactory.PieContext context, com.davisor.graphics.chart.PieFactory.PieSlice slice, java.awt.geom.Rectangle2D pieBounds)
          Draws one pie slice.
 com.davisor.core.Dupable dup()
          Duplicates this factory.
protected static void labelSlice(ImageChart chart, com.davisor.graphics.chart.PieFactory.PieSlice slice, PieFactory.PieMetrics metrics, PieFactory.PieContext context)
          Labels one pie slice.
 
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

PieFactory

public PieFactory()
Creates a new pie factory.


PieFactory

public PieFactory(PieFactory factory)
Copy constructor.

Method Detail

createContext

public ChartFactory.ChartContext createContext(ChartData data,
                                               ChartAttributes attr)
                                        throws ChartException
Resolve needed values for drawing.

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

createChart

public Chart createChart(ChartFactory.ChartContext chartContext,
                         ChartFactory.ChartMetrics chartMetrics,
                         ChartAttributes attr,
                         Chart chart)
                  throws ChartException
Draw pie chart using the precalculated values in context and metrics.

Specified by:
createChart in class ChartFactory
Parameters:
chartContext - context information (PieContext)
chartMetrics - metrics information (PieMetrics)
attr - chart atttributes
chart - A ready made chart canvas to draw on (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.


createMetrics

protected PieFactory.PieMetrics createMetrics(PieFactory.PieContext pieContext,
                                              java.lang.Number pieWidth,
                                              java.lang.Number pieHeight)
Computes pie metrics information.

Parameters:
pieContext - the pie operation context
pieWidth - pie chart width constrain (may be null)
pieHeight - pie chart height constrain (may be null)
Returns:
pie metrics that meet given constrains
See Also:
createMetrics(ChartFactory.ChartContext,ChartAttributes)

drawSlice

protected static void drawSlice(ImageChart chart,
                                PieFactory.PieMetrics metrics,
                                PieFactory.PieContext context,
                                com.davisor.graphics.chart.PieFactory.PieSlice slice,
                                java.awt.geom.Rectangle2D pieBounds)
Draws one pie slice.

Parameters:
chart - chart to draw into
metrics - precalculated information for rendering
context - resolved attributes for rendering
slice - the pie slice to be drawn
pieBounds - rectangular bounds for the pie
See Also:
drawSlice(com.davisor.graphics.chart.ImageChart, com.davisor.graphics.chart.PieFactory.PieMetrics, com.davisor.graphics.chart.PieFactory.PieContext, com.davisor.graphics.chart.PieFactory.PieSlice, java.awt.geom.Rectangle2D), labelSlice(com.davisor.graphics.chart.ImageChart, com.davisor.graphics.chart.PieFactory.PieSlice, com.davisor.graphics.chart.PieFactory.PieMetrics, com.davisor.graphics.chart.PieFactory.PieContext)

labelSlice

protected static void labelSlice(ImageChart chart,
                                 com.davisor.graphics.chart.PieFactory.PieSlice slice,
                                 PieFactory.PieMetrics metrics,
                                 PieFactory.PieContext context)
Labels one pie slice. Draws also the line from slice to its label if needed.

Parameters:
chart - chart to draw into
slice - the pie slice to be drawn
metrics - precalculated information for rendering
context - resolved attributes for rendering
See Also:
drawSlice(com.davisor.graphics.chart.ImageChart, com.davisor.graphics.chart.PieFactory.PieMetrics, com.davisor.graphics.chart.PieFactory.PieContext, com.davisor.graphics.chart.PieFactory.PieSlice, java.awt.geom.Rectangle2D), labelSlice(com.davisor.graphics.chart.ImageChart, com.davisor.graphics.chart.PieFactory.PieSlice, com.davisor.graphics.chart.PieFactory.PieMetrics, com.davisor.graphics.chart.PieFactory.PieContext)

createMetrics

public ChartFactory.ChartMetrics createMetrics(ChartFactory.ChartContext chartContext,
                                               ChartAttributes attr)
                                        throws ChartException
Resolves pie size and label positions.

Specified by:
createMetrics in class ChartFactory
Parameters:
chartContext - chart context (PieContext)
attr - chart attributes
Returns:
pie and label size and position information as PieMetrics
Throws:
ChartException - if chart generation fails
See Also:
createMetrics(PieFactory.PieContext,Number,Number)


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