org.ujac.chart
Class BaseChart

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

public abstract class BaseChart
extends Object
implements Chart

Name: BaseChart
Description: Base Chart implementation.

Author:
lauerc

Field Summary
protected  ChartAttributes attributes
          The chart attributes.
static float DEFAULT_BORDER_WIDTH
          The default border width.
static Color DEFAULT_DESCRIPTION_COLOR
          The default description color.
static Font DEFAULT_DESCRIPTION_FONT
          The default description font.
static float DEFAULT_DESCRIPTION_LINE_WIDTH
          The default description line width.
static String DEFAULT_DESCRIPTION_PATTERN
          The default description pattern.
static float DEFAULT_PADDING
          The default padding.
static Color DEFAULT_SHADOW_COLOR
          The default grid color.
static float DEFAULT_SHADOW_OFFSET
          The default shadow offset.
static Font DEFAULT_TITLE_FONT
          The default title font.
 NumberFormat defaultPercentFormat
          The default percent format.
 NumberFormat defaultValueFormat
          The default value format.
protected  ChartModel model
          The chart 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
BaseChart()
           
 
Method Summary
protected  void addAttributeDefinition(List attributeDefinitions, String name, int type, boolean list, boolean optional)
          Adds an attribute definition to the list of supported attributes for the chart.
 Rectangle2D draw(Rectangle2D viewport, Graphics2D graphics)
          Draws the chart to the given chart output.
protected  void fillSupportedAttributes(List attrDefs)
          Fills the list of supported attributes for the chart.
 String[] getAreaLabels()
          Gets the area labels.
 ChartAttributes getAttributes()
          Gets the chart attributes.
 Color getBackgroundColor()
          Gets the background color.
 float getBorderWidth()
          Gets the border width.
 float getBottomPadding()
          Gets the top padding.
 Color getDescriptionColor()
          Gets the description line color.
 Font getDescriptionFont()
          Gets the description font.
 float getDescriptionLineWidth()
          Gets the description line width.
 String getDescriptionPattern()
          Gets the description pattern.
 float getLeftPadding()
          Gets the left padding.
protected  double getMaxValue()
          Gets the maximum value from the chart data.
protected  double getMinValue()
          Gets the minimum value from the chart data.
 ChartModel getModel()
          Gets the chart model.
 NumberFormat getPercentFormat()
          Gets the number format for percent output.
 float getRightPadding()
          Gets the right padding.
 String[] getSegmentLabels()
          Gets the segment labels.
 Color getShadowColor()
          Computes the fill color for value area.
 float getShadowLength()
          Gets the shadow length.
 List getSupportedAttributes()
          Gets a list of supported attributes for the chart.
 Font getTitleFont()
          Gets the title font.
 float getTopPadding()
          Gets the top padding.
 NumberFormat getValueFormat()
          Gets the number format for value output.
 void setAttributes(ChartAttributes attributes)
          Sets the chart attributes.
 void setModel(ChartModel model)
          Sets the chart model.
 boolean supportsNegativeValues()
          Tells, whether the chart supports negative values or not.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_BORDER_WIDTH

public static final float DEFAULT_BORDER_WIDTH
The default border width.

See Also:
Constant Field Values

DEFAULT_PADDING

public static final float DEFAULT_PADDING
The default padding.

See Also:
Constant Field Values

DEFAULT_TITLE_FONT

public static final Font DEFAULT_TITLE_FONT
The default title font.


DEFAULT_DESCRIPTION_LINE_WIDTH

public static final float DEFAULT_DESCRIPTION_LINE_WIDTH
The default description line width.

See Also:
Constant Field Values

DEFAULT_DESCRIPTION_COLOR

public static final Color DEFAULT_DESCRIPTION_COLOR
The default description color.


DEFAULT_DESCRIPTION_PATTERN

public static final String DEFAULT_DESCRIPTION_PATTERN
The default description pattern.

See Also:
Constant Field Values

DEFAULT_SHADOW_COLOR

public static final Color DEFAULT_SHADOW_COLOR
The default grid color.


DEFAULT_SHADOW_OFFSET

public static final float DEFAULT_SHADOW_OFFSET
The default shadow offset.

See Also:
Constant Field Values

DEFAULT_DESCRIPTION_FONT

public static final Font DEFAULT_DESCRIPTION_FONT
The default description font.


defaultValueFormat

public transient NumberFormat defaultValueFormat
The default value format.


defaultPercentFormat

public transient NumberFormat defaultPercentFormat
The default percent format.


model

protected ChartModel model
The chart model.


attributes

protected ChartAttributes attributes
The chart attributes.

Constructor Detail

BaseChart

public BaseChart()
Method Detail

getSupportedAttributes

public List getSupportedAttributes()
Gets a list of supported attributes for the chart.

Specified by:
getSupportedAttributes in interface Chart
Returns:
The list of supported attributes for the chart.

addAttributeDefinition

protected void addAttributeDefinition(List attributeDefinitions,
                                      String name,
                                      int type,
                                      boolean list,
                                      boolean optional)
Adds an attribute definition to the list of supported attributes for the chart.

Parameters:
attributeDefinitions - The list of supported attributes for the chart to fill.
name - The name of the attribute definition.
type - The attribute type.
list - The list flag.
optional - The optional flag.

fillSupportedAttributes

protected void fillSupportedAttributes(List attrDefs)
Fills the list of supported attributes for the chart.

Parameters:
attrDefs - The list of supported attributes for the chart to fill.

getAttributes

public ChartAttributes getAttributes()
Gets the chart attributes.

Specified by:
getAttributes in interface Chart
Returns:
The current border width.

setAttributes

public void setAttributes(ChartAttributes attributes)
Sets the chart attributes.

Specified by:
setAttributes in interface Chart
Parameters:
attributes - The chart attributes to set.

getBackgroundColor

public Color getBackgroundColor()
Gets the background color.

Returns:
The current background color.

getBorderWidth

public float getBorderWidth()
Gets the border width.

Returns:
The current border width.

getDescriptionLineWidth

public float getDescriptionLineWidth()
Gets the description line width.

Returns:
The current description line width.

getDescriptionColor

public Color getDescriptionColor()
Gets the description line color.

Returns:
The current description line color.

getDescriptionPattern

public String getDescriptionPattern()
Gets the description pattern.

Returns:
The description pattern.

getShadowColor

public Color getShadowColor()
Computes the fill color for value area.

Returns:
The transformed color.

getShadowLength

public float getShadowLength()
Gets the shadow length.

Returns:
The length of the shadow to draw according to the attribute ATTR_SHADOW_OFFSET.

getValueFormat

public NumberFormat getValueFormat()
Gets the number format for value output.

Returns:
The value format.

getPercentFormat

public NumberFormat getPercentFormat()
Gets the number format for percent output.

Returns:
The percent format.

getLeftPadding

public float getLeftPadding()
Gets the left padding.

Returns:
The current left padding.

getRightPadding

public float getRightPadding()
Gets the right padding.

Returns:
The current right padding.

getTopPadding

public float getTopPadding()
Gets the top padding.

Returns:
The current top padding.

getBottomPadding

public float getBottomPadding()
Gets the top padding.

Returns:
The current top padding.

getTitleFont

public Font getTitleFont()
Gets the title font.

Returns:
The current title font.

getDescriptionFont

public Font getDescriptionFont()
Gets the description font.

Returns:
The current description font.

getSegmentLabels

public String[] getSegmentLabels()
Gets the segment labels.

Returns:
The current segment labels.

getAreaLabels

public String[] getAreaLabels()
Gets the area labels.

Returns:
The current area labels.

getModel

public ChartModel getModel()
Gets the chart model.

Specified by:
getModel in interface Chart
Returns:
The chart model.

setModel

public void setModel(ChartModel model)
              throws ChartException
Sets the chart model.

Specified by:
setModel in interface Chart
Parameters:
model - The chart model to set.
Throws:
ChartException - In case the model contained invalid data for the chart.

supportsNegativeValues

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

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

getMinValue

protected double getMinValue()
Gets the minimum value from the chart data.

Returns:
The minimum chart data value.

getMaxValue

protected double getMaxValue()
Gets the maximum value from the chart data.

Returns:
The maximum chart data value.

draw

public Rectangle2D draw(Rectangle2D viewport,
                        Graphics2D graphics)
                 throws ChartException
Draws the chart to the given chart output.

Specified by:
draw in interface Chart
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.


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