org.ujac.chart
Class BasePieChart

java.lang.Object
  extended by org.ujac.chart.BaseChart
      extended by org.ujac.chart.BasePieChart
All Implemented Interfaces:
Chart
Direct Known Subclasses:
BasePieChart3D, PieChart2D

public abstract class BasePieChart
extends BaseChart

Name: BasePieChart
Description: A base class for the rendering of pie charts.

Author:
lauerc

Field Summary
protected  double[] angleDiffs
          The array holding the arc differences.
static String DEFAULT_DESCRIPTION_PATTERN
          The default description pattern.
static float DEFAULT_PIE_DESCRIPTION_ANCHOR_RATIO
          The default pie description anchor ratio.
static float DEFAULT_PIE_DESCRIPTION_BASELINE_RATIO
          The default pie description anchor ratio.
static int DEFAULT_PIE_DESCRIPTION_LAYOUT
          The default pie description layout mode.
protected  Line2D.Double[] descriptionLines
          The description line definitions.
protected  double[] endAngles
          The array holding the end angles.
protected  double[] endArcs
          The array holding the end angles.
protected  double halfPieHeight
          The half pie height.
protected  double halfPieWidth
          The half pie width.
protected  AffineTransform moveDescriptionLine
          Moves the given description line to its correct position.
protected  AffineTransform moveToCenter
          Moves the given object to the center of the pie.
protected  double[] percentages
          The array holding the percentages for the slices.
static int PIE_DESCRIPTION_LAYOUT_BORDER
          Constant for border aligned pie description layout mode.
static int PIE_DESCRIPTION_LAYOUT_ROUND
          Constant for round pie description layout mode.
protected  double[] startAngles
          The array holding the start angles.
protected  double[] startArcs
          The array holding the start angles.
 
Fields inherited from class org.ujac.chart.BaseChart
attributes, DEFAULT_BORDER_WIDTH, DEFAULT_DESCRIPTION_COLOR, DEFAULT_DESCRIPTION_FONT, DEFAULT_DESCRIPTION_LINE_WIDTH, DEFAULT_PADDING, DEFAULT_SHADOW_COLOR, DEFAULT_SHADOW_OFFSET, DEFAULT_TITLE_FONT, defaultPercentFormat, defaultValueFormat, model
 
Fields inherited from interface org.ujac.chart.Chart
ATTR_AREA_LABELS, ATTR_BACKGROUND_COLOR, ATTR_BORDER_WIDTH, ATTR_DESCRIPTION_COLOR, ATTR_DESCRIPTION_FONT, ATTR_DESCRIPTION_LINE_WIDTH, ATTR_DESCRIPTION_PATTERN, ATTR_FILL_AREA, ATTR_GRID_BACKGROUND_COLOR, ATTR_GRID_COLOR, ATTR_LINE_WIDTH, ATTR_PADDING, ATTR_PADDING_BOTTOM, ATTR_PADDING_LEFT, ATTR_PADDING_RIGHT, ATTR_PADDING_TOP, ATTR_PERCENT_FORMAT, ATTR_PIE_DESCRIPTION_ANCHOR_RATIO, ATTR_PIE_DESCRIPTION_BASELINE_RATIO, ATTR_PIE_DESCRIPTION_LAYOUT, ATTR_PIE_HEIGHT, ATTR_SCALE_ARROWHEAD_LENGTH, ATTR_SCALE_ARROWHEAD_STYLE, ATTR_SCALE_ARROWHEAD_WIDTH, ATTR_SCALE_MARK_LENGTH, ATTR_SCALE_VALUE_FORMAT, ATTR_SEGMENT_COLORS, ATTR_SEGMENT_LABELS, ATTR_SEGMENT_MARK_STYLE, ATTR_SEGMENT_SCALE_DESCRIPTION, ATTR_SHADOW_COLOR, ATTR_SHADOW_OFFSET, ATTR_TITLE_FONT, ATTR_VALUE_FORMAT, ATTR_VALUE_SCALE_DESCRIPTION, ATTR_VALUE_STEP_SIZE, ATTR_VIEW_GRID, ATTR_VIEW_LEGEND, ATTR_VIEW_SCALE_ARROWS
 
Constructor Summary
BasePieChart()
           
 
Method Summary
protected  void calculateSliceMetrics(int sliceIdx, double startAngle, double endAngle)
          Calculates the metrics for the given slice
 Rectangle2D draw(Rectangle2D viewport, Graphics2D graphics)
          Draws the chart to the given chart output.
 void drawDescription(Rectangle2D viewport, Graphics2D graphics)
          Draws the chart description.
protected abstract  void drawSlice(Graphics2D graphics, Color color, int sliceIdx, int stepIdx)
          Draws a pie slice.
protected abstract  void drawSliceShadow(Graphics2D graphics, Color color, int sliceIdx)
          Draws the shadow of a pie slice.
protected  double getDeltaY()
          Gets the vertical delta factor for the pie height.
protected  int getDescriptionDrawingStep()
          Gets the index of the step before which to draw the chart description.
protected abstract  int getNumDrawingSteps()
          Gets the number of drawing steps to perform to draw the slices.
protected  Point getPieCenter()
          Gets the pie center.
 float getPieDescriptionAnchorRatio()
          Gets the border width.
 float getPieDescriptionBaselineRatio()
          Gets the border width.
 int getPieDescriptionLayout()
          Gets the number format for value output.
protected  Dimension getPieSize()
          Gets the pie size.
protected  int getSliceHeight()
          Gets the height of the slices.
protected  void init(int numSegments)
          Initializes the data structures for the chart metrics.
 boolean supportsNegativeValues()
          Tells, whether the chart supports negative values or not.
 
Methods inherited from class org.ujac.chart.BaseChart
addAttributeDefinition, fillSupportedAttributes, getAreaLabels, getAttributes, getBackgroundColor, getBorderWidth, getBottomPadding, getDescriptionColor, getDescriptionFont, getDescriptionLineWidth, getDescriptionPattern, getLeftPadding, getMaxValue, getMinValue, getModel, getPercentFormat, getRightPadding, getSegmentLabels, getShadowColor, getShadowLength, getSupportedAttributes, getTitleFont, getTopPadding, getValueFormat, setAttributes, setModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_DESCRIPTION_PATTERN

public static final String DEFAULT_DESCRIPTION_PATTERN
The default description pattern.

See Also:
Constant Field Values

PIE_DESCRIPTION_LAYOUT_BORDER

public static final int PIE_DESCRIPTION_LAYOUT_BORDER
Constant for border aligned pie description layout mode.

See Also:
Constant Field Values

PIE_DESCRIPTION_LAYOUT_ROUND

public static final int PIE_DESCRIPTION_LAYOUT_ROUND
Constant for round pie description layout mode.

See Also:
Constant Field Values

DEFAULT_PIE_DESCRIPTION_LAYOUT

public static final int DEFAULT_PIE_DESCRIPTION_LAYOUT
The default pie description layout mode.

See Also:
Constant Field Values

DEFAULT_PIE_DESCRIPTION_ANCHOR_RATIO

public static final float DEFAULT_PIE_DESCRIPTION_ANCHOR_RATIO
The default pie description anchor ratio.

See Also:
Constant Field Values

DEFAULT_PIE_DESCRIPTION_BASELINE_RATIO

public static final float DEFAULT_PIE_DESCRIPTION_BASELINE_RATIO
The default pie description anchor ratio.

See Also:
Constant Field Values

halfPieWidth

protected double halfPieWidth
The half pie width.


halfPieHeight

protected double halfPieHeight
The half pie height.


percentages

protected double[] percentages
The array holding the percentages for the slices.


startAngles

protected double[] startAngles
The array holding the start angles.


endAngles

protected double[] endAngles
The array holding the end angles.


angleDiffs

protected double[] angleDiffs
The array holding the arc differences.


startArcs

protected double[] startArcs
The array holding the start angles.


endArcs

protected double[] endArcs
The array holding the end angles.


moveToCenter

protected AffineTransform moveToCenter
Moves the given object to the center of the pie.


moveDescriptionLine

protected AffineTransform moveDescriptionLine
Moves the given description line to its correct position.


descriptionLines

protected Line2D.Double[] descriptionLines
The description line definitions.

Constructor Detail

BasePieChart

public BasePieChart()
Method Detail

supportsNegativeValues

public boolean supportsNegativeValues()
Tells, whether the chart supports negative values or not.

Specified by:
supportsNegativeValues in interface Chart
Overrides:
supportsNegativeValues in class BaseChart
Returns:
true, in case the chart supports negative values else false.

getPieDescriptionLayout

public int getPieDescriptionLayout()
Gets the number format for value output.

Returns:
The value format.

getPieDescriptionAnchorRatio

public float getPieDescriptionAnchorRatio()
Gets the border width.

Returns:
The current border width.

getPieDescriptionBaselineRatio

public float getPieDescriptionBaselineRatio()
Gets the border width.

Returns:
The current border width.

getPieCenter

protected Point getPieCenter()
Gets the pie center.

Returns:
The pie center, specified by the method draw.

getPieSize

protected Dimension getPieSize()
Gets the pie size.

Returns:
The pie size.

getDeltaY

protected double getDeltaY()
Gets the vertical delta factor for the pie height.

Returns:
The vertival delta factor for the pie size.

getSliceHeight

protected int getSliceHeight()
Gets the height of the slices.

Returns:
The height of the slices.

draw

public Rectangle2D draw(Rectangle2D viewport,
                        Graphics2D graphics)
                 throws ChartException
Description copied from class: BaseChart
Draws the chart to the given chart output.

Specified by:
draw in interface Chart
Overrides:
draw in class BaseChart
Parameters:
viewport - The viewport for chart output.
graphics - The graphics object used for chart output.
Returns:
The effective drawing area for the chart.
Throws:
ChartException - In case the rendering failed.
See Also:
BaseChart.draw(java.awt.geom.Rectangle2D, java.awt.Graphics2D)

init

protected void init(int numSegments)
Initializes the data structures for the chart metrics.

Parameters:
numSegments - The number of metrics for which to

calculateSliceMetrics

protected void calculateSliceMetrics(int sliceIdx,
                                     double startAngle,
                                     double endAngle)
Calculates the metrics for the given slice

Parameters:
sliceIdx - The index of the slice to calculate.
startAngle - The start angle in degrees.
endAngle - The end angle in degrees.

getNumDrawingSteps

protected abstract int getNumDrawingSteps()
Gets the number of drawing steps to perform to draw the slices.

Returns:
The number of drawing steps.

getDescriptionDrawingStep

protected int getDescriptionDrawingStep()
Gets the index of the step before which to draw the chart description.

Returns:
The index of the step before which to draw the description.

drawSlice

protected abstract void drawSlice(Graphics2D graphics,
                                  Color color,
                                  int sliceIdx,
                                  int stepIdx)
Draws a pie slice.

Parameters:
graphics - The graphics object to draw width.
color - The slice's color.
sliceIdx - The index of the slice to draw.
stepIdx - The index of the drawing step to perform.

drawSliceShadow

protected abstract void drawSliceShadow(Graphics2D graphics,
                                        Color color,
                                        int sliceIdx)
Draws the shadow of a pie slice.

Parameters:
graphics - The graphics object to draw width.
color - The slice's color.
sliceIdx - The index of the slice to draw.

drawDescription

public void drawDescription(Rectangle2D viewport,
                            Graphics2D graphics)
                     throws ChartException
Draws the chart description.

Parameters:
viewport - The viewport for chart output.
graphics - The graphics object used for chart output.
Throws:
ChartException - In case the rendering failed.


Copyright © 2003-2004 UJAC.org. All Rights Reserved.