net.sourceforge.chart2d
Class ChartArea

java.lang.Object
  |
  +--net.sourceforge.chart2d.Area
        |
        +--net.sourceforge.chart2d.FontArea
              |
              +--net.sourceforge.chart2d.TitledArea
                    |
                    +--net.sourceforge.chart2d.ChartArea
Direct Known Subclasses:
GraphChartArea, PieChartArea

class ChartArea
extends TitledArea

A container containing information and components for all charts.


Field Summary
(package private) static int DEFAULT_FLOAT
          Used by setLabelsPrecisionNum (int num).
(package private) static int MAX_FLOAT
          Used by setLabelsPrecisionNum (int num).
(package private) static int MAX_INTEGER
          Used by setLabelsPrecisionNum (int num).
 
Fields inherited from class net.sourceforge.chart2d.Area
BETWEEN, BOTTOM, CENTER, CENTERED, CONTINUOUS, DASHED, DOTTED, FLOAT, HEIGHT, HORIZONTAL, INTEGER, LABELSBOTTOM, LABELSLEFT, LEFT, LEFTBOTTOM, LEFTRIGHT, LEFTTOP, LESSER, MAX, MAXMODEL, MIN, RIGHT, RIGHTBOTTOM, RIGHTTOP, TOP, TOPBOTTOM, VERTICAL, WIDTH
 
Constructor Summary
(package private) ChartArea()
          Creates a Chart Area with the default values.
 
Method Summary
(package private)  boolean getAutoColor()
          Indicates whether this chart will obtain its own colors automatically, or whether it will use the user specified colors.
(package private)  boolean getAutoSetLayoutRatios()
          Returns whether upon the next painting, the layout ratios distributing the max size of the space between the components, should be set to their ideal values based on particulars of the chart.
(package private)  boolean getBetweenChartAndLegendGapExistence()
          Returns whether the gap between the chart and the legend exists.
(package private)  int getBetweenChartAndLegendGapThicknessModel()
          Returns the thickness of the gap between the chart and the legend for the chart's model size.
(package private)  boolean getChartAreaNeedsUpdate()
          Indicates whether some property of this class has changed.
(package private)  int getColorsType()
          Gets the automatic colors type.
(package private) static float[] getDataCategoryTotals(float[][] dataSets)
          Returns the total amount of data in for each data category.
(package private)  java.awt.Color[] getDataSetColors(java.awt.Graphics2D g2D)
          Returns the colors the auto charting algorithm chose or your custom colors.
(package private)  java.awt.Color[] getDataSetColors(java.awt.Graphics2D g2D, int begin, int end)
          Returns the colors the auto charting algorithm chose or your custom colors, from the beginning index (inclusive) and to the ending index (exclusive).
(package private) static float getDataSetTotal(float[] dataSet)
          Returns the total amount of data in this set.
(package private) static java.lang.String getFloatToString(float value, int places)
          Returns a simple string representation of the float.
(package private)  int getLabelsPrecisionNum()
          Indicates how many decimal places should be in the labels of the value axis.
(package private)  LegendArea getLegend()
          Returns the legend in order to allow customization of it.
(package private)  boolean getLegendExistence()
          Returns this property in order for subclasses to have access to it.
(package private)  float getLegendToHeightRatio()
          Returns this property in order for subclasses to have access to it.
(package private)  float getLegendToWidthRatio()
          Returns this property in order for subclasses to have access to it.
(package private) static float getPrecisionCeil(float value, int precision)
          Provides a more sophisticated use of Math.ceil(double).
(package private) static float getPrecisionFloor(float value, int precision)
          Provides a more sophisticated use of Math.floor(double).
(package private) static float getPrecisionRound(float value, int precision)
          Provides a more sophisticated use of Math.round(double).
(package private)  boolean getTitleSqueeze()
          Indicates whether the title should be squeezed on top of, and near to the chart.
(package private)  void paintComponent(java.awt.Graphics2D g2D)
          Updates this parent's variables, and this' variables.
(package private)  void resetChartAreaModel(boolean reset)
          Resets the model for this class.
(package private)  void setAutoColor(boolean auto)
          Changes whether this chart should choose its own colors for the chart.
(package private)  void setAutoSetLayoutRatios(boolean auto)
          Indiates whether upon the next painting, the layout ratios distributing the max size of the space between the components, should be set to their ideal values based on particulars of the chart.
(package private)  void setBetweenChartAndLegendGapExistence(boolean existence)
          Specifies whether the gap between the chart and the legend exists.
(package private)  void setBetweenChartAndLegendGapThicknessModel(int thickness)
          Specifies the thickness of the gap between the chart and the legend for the chart's model size.
(package private)  void setDataSetColors(java.awt.Color[] colors)
          Sets the colors for the pie sectors and the legend bullets.
(package private)  void setDataSetColorsType(int type)
          Changes the automatic colors type.
(package private)  void setLabelsPrecisionNum(int num)
          Changes the number of decimal places to be displayed on the data values axis.
(package private)  void setLegendExistence(boolean existence)
          Enables or disables the legend from calculations and painting.
(package private)  void setLegendToHeightRatio(float ratio)
          Specifies how much of the maximum height less borders, gaps, and title to make availalble to the legend maximum size.
(package private)  void setLegendToWidthRatio(float ratio)
          Specifies how much of the maximum width less borders and gaps to make availalble to the legend maximum size.
(package private)  void setNumDataSets(int num)
          Specifies how many data sets this chart contains.
(package private)  void setTitleSqueeze(boolean squeeze)
          Changes whether the chart title should be squeezed near to and on top of the chart graph and legend.
(package private)  void updateChartArea(java.awt.Graphics2D g2D)
          Updates this parent's variables, and this' variables.
 
Methods inherited from class net.sourceforge.chart2d.TitledArea
getBetweenTitleAndSpaceGapThickness, getBetweenTitleAndSpaceGapThicknessModel, getMaxEntitledSpaceBounds, getTitle, getTitleAutoLocate, getTitledAreaNeedsUpdate, getTitleExistence, getTitleJustifications, getTitleSize, getTitleText, resetTitledAreaModel, setBetweenTitleAndSpaceGapExistence, setBetweenTitleAndSpaceGapThicknessModel, setTitle, setTitleAutoLocate, setTitleExistence, setTitleJustifications, setTitleLocation, setTitleRotateLeft, updateTitledArea
 
Methods inherited from class net.sourceforge.chart2d.FontArea
getFont, getFontAreaNeedsUpdate, getFontColor, getFontName, getFontPointModel, getFontStyle, resetFontAreaModel, setFontColor, setFontName, setFontPointModel, setFontStyle, updateFontArea
 
Methods inherited from class net.sourceforge.chart2d.Area
applyRatio, getAreaNeedsUpdate, getAutoSize, getBackgroundColor, getBackgroundExistence, getBorderColor, getBorderColor, getBorderExistence, getBorderExistence, getBorderThickness, getBorderThickness, getBorderThicknessModel, getBorderThicknessModel, getGapThickness, getGapThicknessModel, getJustifications, getRatio, getResetAreaModel, getSize, getSizeLocation, getSpaceSize, getSpaceSizeLocation, resetAreaModel, setAutoJustifys, setAutoSizes, setBackgroundColor, setBackgroundExistence, setBorderAssociations, setBorderColor, setBorderColors, setBorderCornerAssociations, setBorderExistence, setBorderExistences, setBorderThicknessModel, setBorderThicknessModels, setCustomRatio, setGapAssociations, setGapExistence, setGapExistences, setGapThicknessModel, setGapThicknessModels, setJustifications, setLockRatios, setSize, setSizeLocation, setSpaceSize, setSpaceSizeLocation, updateArea
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_INTEGER

static final int MAX_INTEGER
Used by setLabelsPrecisionNum (int num). The number is 8. This makes the label with the largest absolute value, have as many zeroes as possible -- up to 8.

MAX_FLOAT

static final int MAX_FLOAT
Used by setLabelsPrecisionNum (int num). The number is -8. This makes the float labels have as many significant digits as possible -- 8.

DEFAULT_FLOAT

static final int DEFAULT_FLOAT
Used by setLabelsPrecisionNum (int num). The number is -2. This makes the float labels have two significant labels.
Constructor Detail

ChartArea

ChartArea()
Creates a Chart Area with the default values.
Method Detail

setBetweenChartAndLegendGapExistence

void setBetweenChartAndLegendGapExistence(boolean existence)
Specifies whether the gap between the chart and the legend exists. If the legend doesn't exist, this gap will automatically not exist.
Parameters:
existence - If true, the gap exists.

setBetweenChartAndLegendGapThicknessModel

void setBetweenChartAndLegendGapThicknessModel(int thickness)
Specifies the thickness of the gap between the chart and the legend for the chart's model size.
Parameters:
thickness - The model thickness of the gap.

getBetweenChartAndLegendGapExistence

boolean getBetweenChartAndLegendGapExistence()
Returns whether the gap between the chart and the legend exists. If the legend doesn't exist, this gap will automatically not exist.
Returns:
boolean If true, the gap exists.

getBetweenChartAndLegendGapThicknessModel

int getBetweenChartAndLegendGapThicknessModel()
Returns the thickness of the gap between the chart and the legend for the chart's model size.
Returns:
int The model thickness of the gap.

setNumDataSets

void setNumDataSets(int num)
Specifies how many data sets this chart contains. This information is needed in order to select the colors for auto coloring.
Parameters:
The - number of data sets this chart contains.

setAutoSetLayoutRatios

void setAutoSetLayoutRatios(boolean auto)
Indiates whether upon the next painting, the layout ratios distributing the max size of the space between the components, should be set to their ideal values based on particulars of the chart.
Parameters:
auto - If true, then the ratios will be adjusted.

getAutoSetLayoutRatios

boolean getAutoSetLayoutRatios()
Returns whether upon the next painting, the layout ratios distributing the max size of the space between the components, should be set to their ideal values based on particulars of the chart.
Returns:
boolean If true, then the ratios should be adjusted.

setTitleSqueeze

void setTitleSqueeze(boolean squeeze)
Changes whether the chart title should be squeezed near to and on top of the chart graph and legend. The between title and chart gap will be respected.
Parameters:
squeeze - True if the title should be squeezed.

setAutoColor

void setAutoColor(boolean auto)
Changes whether this chart should choose its own colors for the chart. Colors for the chart are used for the legend bullets and the bars, lines, or dots.
Parameters:
auto - True if this chart should automatically color chart parts.

setDataSetColorsType

void setDataSetColorsType(int type)
Changes the automatic colors type. Possible color types are ChartColors.NATURAL and ChartColors.PASTEL. See ChartColors for a description.
Parameters:
type - The type of auto colors.

setDataSetColors

void setDataSetColors(java.awt.Color[] colors)
Sets the colors for the pie sectors and the legend bullets. The ith color in the array is the ith sector counting clockwise from degree 135 and is the ith bullet/label in the legend.
Parameters:
colors - The array of colors.

setLegendExistence

void setLegendExistence(boolean existence)
Enables or disables the legend from calculations and painting.
Parameters:
existence - The existence of the legend.

setLegendToWidthRatio

void setLegendToWidthRatio(float ratio)
Specifies how much of the maximum width less borders and gaps to make availalble to the legend maximum size.
Parameters:
ratio - The ratio to the width, to make available to the legend.

setLegendToHeightRatio

void setLegendToHeightRatio(float ratio)
Specifies how much of the maximum height less borders, gaps, and title to make availalble to the legend maximum size.
Parameters:
ratio - The ratio to the height, to make available to the legend.

setLabelsPrecisionNum

void setLabelsPrecisionNum(int num)
Changes the number of decimal places to be displayed on the data values axis. A positive int specifies how many places to the right of the decimal place should be kept (Float Labels). A non positive int specifies how many zeros to the left of the decimal should occur (Integer Labels). Use MAX_ZEROES if you want integer labels with only one non-zero number.
Parameters:
num - The number of decimal places.

getTitleSqueeze

boolean getTitleSqueeze()
Indicates whether the title should be squeezed on top of, and near to the chart. The title gap spacing will be respected.
Returns:
True if the title will be squeezed.

getAutoColor

boolean getAutoColor()
Indicates whether this chart will obtain its own colors automatically, or whether it will use the user specified colors.
Parameters:
True - if it will choose its own colors.

getColorsType

int getColorsType()
Gets the automatic colors type. Possible color types are ChartColors.NATURAL and ChartColors.PASTEL. See ChartColors for a description.
Returns:
The type of auto colors.

getDataSetTotal

static final float getDataSetTotal(float[] dataSet)
Returns the total amount of data in this set.
Parameters:
data - set. The data set to sum.
Returns:
float The sum.

getDataCategoryTotals

static final float[] getDataCategoryTotals(float[][] dataSets)
Returns the total amount of data in for each data category. Found by summing the data in each category, from each data set.
Returns:
float[] An array of the totals of each data category.

getDataSetColors

java.awt.Color[] getDataSetColors(java.awt.Graphics2D g2D)
Returns the colors the auto charting algorithm chose or your custom colors.
Returns:
The colors for the chart.

getDataSetColors

java.awt.Color[] getDataSetColors(java.awt.Graphics2D g2D,
                                  int begin,
                                  int end)
Returns the colors the auto charting algorithm chose or your custom colors, from the beginning index (inclusive) and to the ending index (exclusive).
Returns:
The colors for the chart.

getLegend

LegendArea getLegend()
Returns the legend in order to allow customization of it.
Returns:
The legend of this chart.

getLegendExistence

boolean getLegendExistence()
Returns this property in order for subclasses to have access to it.
Returns:
The specified property.

getLegendToWidthRatio

float getLegendToWidthRatio()
Returns this property in order for subclasses to have access to it.
Returns:
The specified property.

getLegendToHeightRatio

float getLegendToHeightRatio()
Returns this property in order for subclasses to have access to it.
Returns:
The specified property.

getChartAreaNeedsUpdate

boolean getChartAreaNeedsUpdate()
Indicates whether some property of this class has changed.
Returns:
True if some property has changed.

getLabelsPrecisionNum

int getLabelsPrecisionNum()
Indicates how many decimal places should be in the labels of the value axis. For integer values, choose 0. For floats, a good choice is generally 2.
Returns:
The number of decimal places in the labels.

getPrecisionCeil

static final float getPrecisionCeil(float value,
                                    int precision)
Provides a more sophisticated use of Math.ceil(double). For precision = 0, the return value is Math.ceil (value). For precision > 1, the return value is the value obtained by the following three operations: shift decimal left precision number of places, apply the resultant value in Math.ceil, shift decimal right precision number of places. For precision < 1, the return value is the value obtained by the following three operations: shift decimal right precision number of places, apply the resultant value in Math.ceil, shift decimal left precision number of places.
Parameters:
value - The value to ceil.
precision - The basically an indicator of what digit to apply ceil to.
Returns:
float The resultant value.

getPrecisionFloor

static final float getPrecisionFloor(float value,
                                     int precision)
Provides a more sophisticated use of Math.floor(double). For precision = 0, the return value is Math.floor (value). For precision > 1, the return value is the value obtained by the following three operations: shift decimal left precision number of places, apply the resultant value in Math.floor, shift decimal right precision number of places. For precision < 1, the return value is the value obtained by the following three operations: shift decimal right precision number of places, apply the resultant value in Math.floor, shift decimal left precision number of places.
Parameters:
value - The value to floor.
precision - The basically an indicator of what digit to apply floor to.
Returns:
float The resultant value.

getPrecisionRound

static final float getPrecisionRound(float value,
                                     int precision)
Provides a more sophisticated use of Math.round(double). For precision = 0, the return value is Math.round (value). For precision > 1, the return value is the value obtained by the following three operations: shift decimal left precision number of places, apply the resultant value in Math.round, shift decimal right precision number of places. For precision < 1, the return value is the value obtained by the following three operations: shift decimal right precision number of places, apply the resultant value in Math.round, shift decimal left precision number of places.
Parameters:
value - The value to round.
precision - The basically an indicator of what digit to apply round to.
Returns:
float The resultant value.

getFloatToString

static final java.lang.String getFloatToString(float value,
                                               int places)
Returns a simple string representation of the float. If places >=0, then floats will have respresentation as integers. If places < 0, then floats will have floating point representation with the number of places to the right of the decimal equal to |places|.
Parameters:
value - The value to represent.
places - Roughly, the number of decimal places in the representation.
Returns:
The representation of the value.

resetChartAreaModel

void resetChartAreaModel(boolean reset)
Resets the model for this class. The model is used for shrinking and growing of its components based on the maximum size of this class. If this method is called, then the next time the maximum size is set, this classes model maximum size will be made equal to the new maximum size. Effectively what this does is ensure that whenever this objects maximum size is equal to the one given, then all of the components will take on their default model sizes. Note: This is only useful when auto model max sizing is disabled.
Parameters:
reset - True causes the max model size to be set upon the next max sizing.

updateChartArea

void updateChartArea(java.awt.Graphics2D g2D)
Updates this parent's variables, and this' variables.
Parameters:
g2D - The graphics context to use for calculations.

paintComponent

void paintComponent(java.awt.Graphics2D g2D)
Updates this parent's variables, and this' variables.
Overrides:
paintComponent in class TitledArea
Parameters:
g2D - The graphics context to use for calculations.