org.corpstein.image
Class ChartMetrics

java.lang.Object
  extended by org.corpstein.image.ChartMetrics

public class ChartMetrics
extends java.lang.Object

Encapsulates the various metrics used to create chart images using ChartFactory.

Version:
$Revision: 1.4 $ $Date: 2005/04/24 20:47:48 $
Author:
David Corpstein

Field Summary
static int BACKDROP_HEIGHT
           
static int BACKDROP_PLACEMENT_X
           
static int BACKDROP_PLACEMENT_Y
           
static int BACKDROP_WIDTH
           
static int COORD_BACKDROP_X
           
static int COORD_BACKDROP_Y
           
static int DIAGONAL_KEY_LINE_CHART_MAX_LABEL_WIDTH
           
static int DIAGONAL_KEY_MAX_LABEL_WIDTH
           
static int HORIZONTAL_KEY_OFFSET_Y
           
static int KEY_HEIGHT
           
static int MAX_Z_INDEX
           
static int METRIC_BAR_DEPTH
           
static int METRIC_BAR_INTERVAL
           
static int METRIC_BAR_WIDTH
           
static int METRIC_BASE_BAR_OFFSET
           
static int METRIC_DEPTH_OFFSET
           
static int METRIC_DIAGONAL_X
           
static int METRIC_DIAGONAL_Y
           
static int METRIC_HORIZONTAL_KEY_OFFSET_X
           
static int METRIC_KEY_COLUMNS
           
static int METRIC_KEY_OFFSET_X
           
static int METRIC_KEY_OFFSET_Y
           
static int METRIC_KEY_ROWS
           
static int METRIC_KEY_WIDTH
           
static int METRIC_LABEL_DIAGONAL
           
static int METRIC_LABEL_INTERVAL
           
static int METRIC_LABEL_SIGNIFICANT_FIGURES
           
static int METRIC_MAX_LABEL_WIDTH
           
static int METRIC_TITLE_SHADOW_Y
           
static int METRIC_TITLE_Y
           
static int METRIC_Y_AXIS_LABELS
           
static int MIN_Z_INDEX
           
static int PIE_DEPTH
           
static float PIE_ROTATION_ANGLE
           
static int Z_INDEX_AXIS_LABEL
           
static int Z_INDEX_BACKDROP
           
static int Z_INDEX_BACKGROUND
           
static int Z_INDEX_BARS
           
static int Z_INDEX_BORDER
           
static int Z_INDEX_KEY
           
static int Z_INDEX_LINES
           
static int Z_INDEX_SCALE
           
static int Z_INDEX_SLICES
           
static int Z_INDEX_TITLE
           
 
Constructor Summary
ChartMetrics(ChartData data, ChartStyle style)
          Sole constructor
 
Method Summary
 int get(int index)
          Returns the named metric
 int getCoordinate(int array, int index)
          Returns the coordinate for the named array and the specified index
 int getMaxLabelWidth(ChartData data, ChartStyle style)
          Returns the maximum width allowed for a label given the specified ChartData and ChartStyle
 double getPixelInterval()
          Return the number of pixels of bar/line height that equate to one data unit for a given chart.
 int getTotalCoordinates(int array)
          Returns the total coordinates stored in the given array
 void initializeMetrics(ChartData data)
          Initializes the metrics based on the maximum value stored in the ChartData object.
 void prepareMetrics(ChartData data)
          Adjusts the metrics based on the maximum value stored in the ChartData object.
 void set(int index, int value)
          Sets the named metric
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

METRIC_BASE_BAR_OFFSET

public static final int METRIC_BASE_BAR_OFFSET
See Also:
Constant Field Values

METRIC_BAR_INTERVAL

public static final int METRIC_BAR_INTERVAL
See Also:
Constant Field Values

METRIC_BAR_WIDTH

public static final int METRIC_BAR_WIDTH
See Also:
Constant Field Values

METRIC_KEY_WIDTH

public static final int METRIC_KEY_WIDTH
See Also:
Constant Field Values

METRIC_KEY_OFFSET_X

public static final int METRIC_KEY_OFFSET_X
See Also:
Constant Field Values

METRIC_KEY_OFFSET_Y

public static final int METRIC_KEY_OFFSET_Y
See Also:
Constant Field Values

METRIC_KEY_COLUMNS

public static final int METRIC_KEY_COLUMNS
See Also:
Constant Field Values

METRIC_KEY_ROWS

public static final int METRIC_KEY_ROWS
See Also:
Constant Field Values

METRIC_MAX_LABEL_WIDTH

public static final int METRIC_MAX_LABEL_WIDTH
See Also:
Constant Field Values

METRIC_LABEL_DIAGONAL

public static final int METRIC_LABEL_DIAGONAL
See Also:
Constant Field Values

METRIC_DIAGONAL_X

public static final int METRIC_DIAGONAL_X
See Also:
Constant Field Values

METRIC_DIAGONAL_Y

public static final int METRIC_DIAGONAL_Y
See Also:
Constant Field Values

METRIC_DEPTH_OFFSET

public static final int METRIC_DEPTH_OFFSET
See Also:
Constant Field Values

METRIC_BAR_DEPTH

public static final int METRIC_BAR_DEPTH
See Also:
Constant Field Values

METRIC_LABEL_INTERVAL

public static final int METRIC_LABEL_INTERVAL
See Also:
Constant Field Values

METRIC_LABEL_SIGNIFICANT_FIGURES

public static final int METRIC_LABEL_SIGNIFICANT_FIGURES
See Also:
Constant Field Values

METRIC_Y_AXIS_LABELS

public static final int METRIC_Y_AXIS_LABELS
See Also:
Constant Field Values

METRIC_TITLE_Y

public static final int METRIC_TITLE_Y
See Also:
Constant Field Values

METRIC_TITLE_SHADOW_Y

public static final int METRIC_TITLE_SHADOW_Y
See Also:
Constant Field Values

METRIC_HORIZONTAL_KEY_OFFSET_X

public static final int METRIC_HORIZONTAL_KEY_OFFSET_X
See Also:
Constant Field Values

COORD_BACKDROP_X

public static final int COORD_BACKDROP_X
See Also:
Constant Field Values

COORD_BACKDROP_Y

public static final int COORD_BACKDROP_Y
See Also:
Constant Field Values

KEY_HEIGHT

public static final int KEY_HEIGHT
See Also:
Constant Field Values

HORIZONTAL_KEY_OFFSET_Y

public static final int HORIZONTAL_KEY_OFFSET_Y
See Also:
Constant Field Values

DIAGONAL_KEY_MAX_LABEL_WIDTH

public static final int DIAGONAL_KEY_MAX_LABEL_WIDTH
See Also:
Constant Field Values

DIAGONAL_KEY_LINE_CHART_MAX_LABEL_WIDTH

public static final int DIAGONAL_KEY_LINE_CHART_MAX_LABEL_WIDTH
See Also:
Constant Field Values

BACKDROP_PLACEMENT_X

public static final int BACKDROP_PLACEMENT_X
See Also:
Constant Field Values

BACKDROP_PLACEMENT_Y

public static final int BACKDROP_PLACEMENT_Y
See Also:
Constant Field Values

BACKDROP_WIDTH

public static final int BACKDROP_WIDTH
See Also:
Constant Field Values

BACKDROP_HEIGHT

public static final int BACKDROP_HEIGHT
See Also:
Constant Field Values

PIE_DEPTH

public static final int PIE_DEPTH
See Also:
Constant Field Values

PIE_ROTATION_ANGLE

public static final float PIE_ROTATION_ANGLE
See Also:
Constant Field Values

Z_INDEX_BACKGROUND

public static final int Z_INDEX_BACKGROUND
See Also:
Constant Field Values

Z_INDEX_BORDER

public static final int Z_INDEX_BORDER
See Also:
Constant Field Values

Z_INDEX_BACKDROP

public static final int Z_INDEX_BACKDROP
See Also:
Constant Field Values

Z_INDEX_SCALE

public static final int Z_INDEX_SCALE
See Also:
Constant Field Values

Z_INDEX_BARS

public static final int Z_INDEX_BARS
See Also:
Constant Field Values

Z_INDEX_SLICES

public static final int Z_INDEX_SLICES
See Also:
Constant Field Values

Z_INDEX_LINES

public static final int Z_INDEX_LINES
See Also:
Constant Field Values

Z_INDEX_AXIS_LABEL

public static final int Z_INDEX_AXIS_LABEL
See Also:
Constant Field Values

Z_INDEX_KEY

public static final int Z_INDEX_KEY
See Also:
Constant Field Values

Z_INDEX_TITLE

public static final int Z_INDEX_TITLE
See Also:
Constant Field Values

MIN_Z_INDEX

public static final int MIN_Z_INDEX
See Also:
Constant Field Values

MAX_Z_INDEX

public static final int MAX_Z_INDEX
See Also:
Constant Field Values
Constructor Detail

ChartMetrics

public ChartMetrics(ChartData data,
                    ChartStyle style)
Sole constructor

Parameters:
data - The ChartData object containing the data points that will affect the metrics
style - The ChartStyle object containing the chart type, key type, and other parameters that determine the metrics
Method Detail

get

public int get(int index)
Returns the named metric

Parameters:
index - The metric to return
Throws:
java.lang.IllegalArgumentException - if the index is out of bounds

getCoordinate

public int getCoordinate(int array,
                         int index)
Returns the coordinate for the named array and the specified index

Parameters:
array - The array (COORD_BACKDROP_X or COORD_BACKDROP_Y)
index - The index into the array of the coordinate we are looking for
Returns:
the coordinate for the named array and the specified index
Throws:
java.lang.IllegalArgumentException - If the array is invalid or the index is out of bounds

getMaxLabelWidth

public int getMaxLabelWidth(ChartData data,
                            ChartStyle style)
Returns the maximum width allowed for a label given the specified ChartData and ChartStyle

Parameters:
data - The ChartData object used to determine the total columns and total values per column, given the CharStyle chart type and key type
style - The ChartStyle object used to determine the key type, chart type
Returns:
the maximum label width allowed for a label

getPixelInterval

public double getPixelInterval()
Return the number of pixels of bar/line height that equate to one data unit for a given chart. For example, suppose a chart contains bars between 0 and 10,000 units and getPixelInterval returns 0.02. Therefore each pixel of bar height will represent 50 units and the highest bar will be 200 pixels high.

Returns:
the number of data units that equates to one pixel of bar/line height

getTotalCoordinates

public int getTotalCoordinates(int array)
Returns the total coordinates stored in the given array

Parameters:
array - The array to measure
Throws:
java.lang.IllegalArgumentException - if the specified array does not exist

initializeMetrics

public void initializeMetrics(ChartData data)
Initializes the metrics based on the maximum value stored in the ChartData object.


prepareMetrics

public void prepareMetrics(ChartData data)
Adjusts the metrics based on the maximum value stored in the ChartData object.


set

public void set(int index,
                int value)
Sets the named metric

Parameters:
index - The metric to set
value - The value to set the metric to
Throws:
java.lang.IllegalArgumentException - if the index is out of bounds


Last update: 20050424 1651