org.ujac.chart
Class Base2DScaleChart

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

public abstract class Base2DScaleChart
extends BaseChart

Name: Base2DScaleChart
Description: Base class for 2D scale charts like bar and line charts.

Author:
lauerc

Field Summary
static int ARROWHEAD_STYLE_FILLED
          The arrowhead style for filled arrows.
static int ARROWHEAD_STYLE_OPEN
          The arrowhead style for open arrows.
static int DEFAULT_ARROWHEAD_STYLE
          The default arrowhead style.
static float DEFAULT_DESCRIPTION_ITEM_SPACING
          The default description item spacing.
static float DEFAULT_DESCRIPTION_LINE_SPACING
          The default description line spacing.
static Color DEFAULT_GRID_BACKGROUND_COLOR
          The default grid background color.
static Color DEFAULT_GRID_COLOR
          The default grid color.
static float DEFAULT_LINE_WIDTH
          The default line width.
static float DEFAULT_SCALE_ARROWHEAD_LENGTH
          The default scale arrowhead length.
static String DEFAULT_SCALE_ARROWHEAD_STYLE
          The default scale arrowhead style.
static float DEFAULT_SCALE_MARK_LENGTH
          The default line width.
static int DEFAULT_SEGMENT_MARK_STYLE
          The default segment mark style.
protected  Rectangle effectiveViewport
          The effective viewport (is determined whenever draw scale is called).
protected  float horizontalOffset
          The horizontal offset for the chart.
protected  float[] horizontalPositions
          The horizontal positions for the values.
protected  float horizontalScale
          The horizontal scale for the chart.
protected  double max
          The maximum value.
protected  double min
          The minimum value.
protected  double range
          The value range.
protected  Font scaleFont
          The Font to use for the grid.
static int SEGMENT_MARK_STYLE_BORDER
          The segment mark style for border lines.
static int SEGMENT_MARK_STYLE_CENTER
          The segment mark style for centered lines.
protected  float verticalAnchor
          The vertical anchor from which to draw the chart.
protected  float verticalMaximum
          The maximum vertical position.
protected  float verticalMinimum
          The minimum vertical position.
protected  float verticalScale
          The vertical scale for the chart values.
protected  float verticalZero
          The vertical position of the zero coordinate.
 
Fields inherited from class org.ujac.chart.BaseChart
attributes, DEFAULT_BORDER_WIDTH, DEFAULT_DESCRIPTION_COLOR, DEFAULT_DESCRIPTION_FONT, DEFAULT_DESCRIPTION_LINE_WIDTH, DEFAULT_DESCRIPTION_PATTERN, 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
Base2DScaleChart()
           
 
Method Summary
protected  float calculateBaseLinePosition()
          Calculates the base scale line position for the chart.
protected  float calculateVerticalExtent(double value)
          Calculates the vertical extent for the given value.
protected  float calculateVerticalPosition(double value)
          Calculates the vertical position for the given value.
protected  Rectangle calcViewport(Rectangle2D viewport, Graphics2D graphics)
          Calculates the viewport.
protected  void drawLegend(Rectangle2D viewport, Graphics2D graphics)
          Draws the legend.
protected  void drawScale(Rectangle2D viewport, Rectangle2D effectiveViewport, Graphics2D graphics)
          Draws the scale.
 String formatScaleValue(double number, double stepSize)
          Format a number for scale value output.
 Color getGridBackgroundColor()
          Gets the grid background color.
 Color getGridColor()
          Gets the grid color.
protected  int getInnerPadding()
          Gets the inner padding.
 float getLineWidth()
          Gets the line width.
 float getScaleArrowheadLength()
          Gets the scale arrowhead length.
 int getScaleArrowheadStyle()
          Gets the scale arrowhead style.
 float getScaleArrowheadWidth()
          Gets the scale arrowhead width.
 float getScaleMarkLength()
          Gets the scale mark length.
 NumberFormat getScaleValueFormat()
          Gets the number format for scale value output.
 int getSegmentMarkStyle()
          Gets the segment mark style.
protected  TextChartItem getSegmentScaleDescription()
          Gets the segment scale description.
protected  TextChartItem getValueScaleDescription()
          Gets the value scale description.
 float getValueStepSize(double descriptionHeight)
          Gets the value step size according to the attribute ATTR_VALUE_STEP_SIZE or calculates if it's not specified.
 boolean isViewGrid()
          Gets the 'view-grid' flag.
 boolean isViewLegend()
          Gets the 'view-legend' flag.
 boolean isViewScaleArrows()
          Gets the 'view-scale-arrows' flag.
 
Methods inherited from class org.ujac.chart.BaseChart
addAttributeDefinition, draw, 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, supportsNegativeValues
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SEGMENT_MARK_STYLE_CENTER

public static final int SEGMENT_MARK_STYLE_CENTER
The segment mark style for centered lines.

See Also:
Constant Field Values

SEGMENT_MARK_STYLE_BORDER

public static final int SEGMENT_MARK_STYLE_BORDER
The segment mark style for border lines.

See Also:
Constant Field Values

DEFAULT_SEGMENT_MARK_STYLE

public static final int DEFAULT_SEGMENT_MARK_STYLE
The default segment mark style.

See Also:
Constant Field Values

ARROWHEAD_STYLE_OPEN

public static final int ARROWHEAD_STYLE_OPEN
The arrowhead style for open arrows.

See Also:
Constant Field Values

ARROWHEAD_STYLE_FILLED

public static final int ARROWHEAD_STYLE_FILLED
The arrowhead style for filled arrows.

See Also:
Constant Field Values

DEFAULT_ARROWHEAD_STYLE

public static final int DEFAULT_ARROWHEAD_STYLE
The default arrowhead style.

See Also:
Constant Field Values

DEFAULT_LINE_WIDTH

public static final float DEFAULT_LINE_WIDTH
The default line width.

See Also:
Constant Field Values

DEFAULT_SCALE_MARK_LENGTH

public static final float DEFAULT_SCALE_MARK_LENGTH
The default line width.

See Also:
Constant Field Values

DEFAULT_SCALE_ARROWHEAD_LENGTH

public static final float DEFAULT_SCALE_ARROWHEAD_LENGTH
The default scale arrowhead length.

See Also:
Constant Field Values

DEFAULT_SCALE_ARROWHEAD_STYLE

public static final String DEFAULT_SCALE_ARROWHEAD_STYLE
The default scale arrowhead style.

See Also:
Constant Field Values

DEFAULT_GRID_COLOR

public static final Color DEFAULT_GRID_COLOR
The default grid color.


DEFAULT_GRID_BACKGROUND_COLOR

public static final Color DEFAULT_GRID_BACKGROUND_COLOR
The default grid background color.


DEFAULT_DESCRIPTION_ITEM_SPACING

public static final float DEFAULT_DESCRIPTION_ITEM_SPACING
The default description item spacing.

See Also:
Constant Field Values

DEFAULT_DESCRIPTION_LINE_SPACING

public static final float DEFAULT_DESCRIPTION_LINE_SPACING
The default description line spacing.

See Also:
Constant Field Values

scaleFont

protected Font scaleFont
The Font to use for the grid.


effectiveViewport

protected Rectangle effectiveViewport
The effective viewport (is determined whenever draw scale is called).


verticalAnchor

protected float verticalAnchor
The vertical anchor from which to draw the chart.


verticalMinimum

protected float verticalMinimum
The minimum vertical position.


verticalMaximum

protected float verticalMaximum
The maximum vertical position.


verticalZero

protected float verticalZero
The vertical position of the zero coordinate.


max

protected double max
The maximum value.


min

protected double min
The minimum value.


range

protected double range
The value range.


horizontalOffset

protected float horizontalOffset
The horizontal offset for the chart.


horizontalScale

protected float horizontalScale
The horizontal scale for the chart.


verticalScale

protected float verticalScale
The vertical scale for the chart values.


horizontalPositions

protected float[] horizontalPositions
The horizontal positions for the values.

Constructor Detail

Base2DScaleChart

public Base2DScaleChart()
Method Detail

getLineWidth

public float getLineWidth()
Gets the line width.

Returns:
The line width according to the attribute ATTR_LINE_WIDTH.

getScaleMarkLength

public float getScaleMarkLength()
Gets the scale mark length.

Returns:
The length of the scale mark lines according to the attribute ATTR_SCALE_MARK_LENGTH.

getValueStepSize

public float getValueStepSize(double descriptionHeight)
Gets the value step size according to the attribute ATTR_VALUE_STEP_SIZE or calculates if it's not specified.

Parameters:
descriptionHeight - The description height.
Returns:
The value step size.

isViewLegend

public boolean isViewLegend()
Gets the 'view-legend' flag.

Returns:
The 'view-legend' flag according to the attribute ATTR_VIEW_LEGEND.

isViewScaleArrows

public boolean isViewScaleArrows()
Gets the 'view-scale-arrows' flag.

Returns:
The 'view-grid' flag according to the attribute ATTR_VIEW_SCALE_ARROWS.

getScaleArrowheadLength

public float getScaleArrowheadLength()
Gets the scale arrowhead length.

Returns:
The length of the scale arrowhead according to the attribute ATTR_SCALE_ARROWHEAD_LENGTH.

getScaleArrowheadWidth

public float getScaleArrowheadWidth()
Gets the scale arrowhead width.

Returns:
The width of the scale arrowhead according to the attribute ATTR_SCALE_ARROWHEAD_WIDTH.

getScaleArrowheadStyle

public int getScaleArrowheadStyle()
Gets the scale arrowhead style.

Returns:
The style of the scale arrowhead according to the attribute ATTR_SCALE_ARROWHEAD_STYLE.

getScaleValueFormat

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

Returns:
The scale value format.

formatScaleValue

public String formatScaleValue(double number,
                               double stepSize)
Format a number for scale value output.

Parameters:
number - The number to format.
stepSize - The step size to use.
Returns:
The string value of given number.

getSegmentMarkStyle

public int getSegmentMarkStyle()
Gets the segment mark style.

Returns:
The style of the segment mark lines according to the attribute ATTR_SEGMENT_MARK_STYLE.

isViewGrid

public boolean isViewGrid()
Gets the 'view-grid' flag.

Returns:
The 'view-grid' flag according to the attribute ATTR_VIEW_GRID.

getGridColor

public Color getGridColor()
Gets the grid color.

Returns:
The current grid color.

getGridBackgroundColor

public Color getGridBackgroundColor()
Gets the grid background color.

Returns:
The current grid background color.

getInnerPadding

protected int getInnerPadding()
Gets the inner padding.

Returns:
The inner padding.

getValueScaleDescription

protected TextChartItem getValueScaleDescription()
Gets the value scale description.

Returns:
The ialue scale description text.

getSegmentScaleDescription

protected TextChartItem getSegmentScaleDescription()
Gets the segment scale description.

Returns:
The ialue scale description text.

drawScale

protected void drawScale(Rectangle2D viewport,
                         Rectangle2D effectiveViewport,
                         Graphics2D graphics)
Draws the scale.

Parameters:
viewport - The viewport.
effectiveViewport - The effective viewport for the scale.
graphics - The graphics object to use.

drawLegend

protected void drawLegend(Rectangle2D viewport,
                          Graphics2D graphics)
Draws the legend.

Parameters:
viewport - The viewport.
graphics - The graphics object to use.

calcViewport

protected Rectangle calcViewport(Rectangle2D viewport,
                                 Graphics2D graphics)
Calculates the viewport.

Parameters:
viewport - The original viewport.
graphics - The graphics interface needed for font metrics calculation.
Returns:
The determined effective viewport.

calculateVerticalPosition

protected float calculateVerticalPosition(double value)
Calculates the vertical position for the given value.

Parameters:
value - The value we are interrested in the vertical position for
Returns:
The vertical position.

calculateVerticalExtent

protected float calculateVerticalExtent(double value)
Calculates the vertical extent for the given value.

Parameters:
value - The value we are interrested in the vertical position for
Returns:
The vertical extent.

calculateBaseLinePosition

protected float calculateBaseLinePosition()
Calculates the base scale line position for the chart.

Returns:
The vertical position of the base line.


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