net.sourceforge.chart2d
Class PieLabelsArea

java.lang.Object
  |
  +--net.sourceforge.chart2d.Area
        |
        +--net.sourceforge.chart2d.FontArea
              |
              +--net.sourceforge.chart2d.PieLabelsArea

class PieLabelsArea
extends FontArea

This class manages a set of labels that can be used to encircle a PieArea, labeling its pie sectors. The way it works is that you must set the size of the max size for the class and also the size that it is supposed to encircle. This provides three different labeling types. The text of the label can be the data number of that sector, the text of the label can be a percent of the total on the data number of that sector, and the text of the label can be both. The font properties can be set using the methods of this' parent class. This class can return a point centered near each label so that lines can be drawn from the labels to their corresponding pie sectors.


Field Summary
(package private) static int PERCENT
          Static variable for setLabelsType (int) method.
(package private) static int RAW
          Static variable for setLabelsType (int) method.
 
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) PieLabelsArea()
          The general constructor for this class.
 
Method Summary
(package private)  java.awt.Rectangle getInteriorBounds(java.awt.Graphics2D g2D)
          Returns a bounding rectangle of the area the labels encircle.
(package private)  boolean getLabelsPointsGapExistence()
          Returns whether the gaps between the labels and the points near each label exist.
(package private)  int getLabelsPointsGapThicknessModel()
          Returns how far from the labels, the points on each label should be.
(package private)  int getLabelsType()
          Indirectly returns the text of the labels.
(package private)  boolean getPieLabelsAreaNeedsUpdate()
          Indicates whether some property of this class has changed.
(package private)  java.awt.Point[] getPointsNearLabels(java.awt.Graphics2D g2D)
          Returns an array of points, one for each label, that are near the labels.
(package private)  int getRawLabelsPrecision()
          Returns how many significant digits are wanted.
(package private)  void paintComponent(java.awt.Graphics2D g2D)
          Paints this class.
(package private)  void resetPieLabelsAreaModel(boolean reset)
          Resets the model for this class.
(package private)  void setBetweenLabelsGapExistence(boolean existence)
          Indicates whether a gap should exist between the labels.
(package private)  void setBetweenLabelsGapThicknessModel(int thickness)
          Indicates the model thickness of the gap between each label.
(package private)  void setCustomSize(boolean customize, java.awt.Dimension size)
          Indicates the final size of the area.
(package private)  void setLabelsPointsGapExistence(boolean existence)
          Specifies whether the gaps between the labels and the points near each label exist.
(package private)  void setLabelsPointsGapThicknessModel(int thickness)
          Indicates how far from the labels, the points on each label should be.
(package private)  void setLabelsType(int type)
          Indirectly sets the text of the labels.
(package private)  void setPieArea(PieArea pie)
          Passes in the PieArea to encircle with labels.
(package private)  void setRawLabelsPrecision(int precision)
          Indicates how many significant digits are wanted.
(package private)  void updatePieLabelsArea(java.awt.Graphics2D g2D)
          Updates all this classes variables.
 
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

RAW

static final int RAW
Static variable for setLabelsType (int) method. RAW indicates that the actual number represented by the sector should be present.

PERCENT

static final int PERCENT
Static variable for setLabelsType (int) method. PERCENT indicates that the percent the number represented by the sector makes of the whole should should be present.
Constructor Detail

PieLabelsArea

PieLabelsArea()
The general constructor for this class.
Method Detail

setCustomSize

void setCustomSize(boolean customize,
                   java.awt.Dimension size)
Indicates the final size of the area. Everything is calculated using the non-custom properties. When laying out the labels, the labels are mereley laid out wider than normal to the point that their ends touch the edges of the custom size... Hence, all extra space is added to the interior size.
Parameters:
customize - If true, then the custom size will be used.
size - The custom size if used.

setPieArea

void setPieArea(PieArea pie)
Passes in the PieArea to encircle with labels.
Parameters:
pie - The PieArea.

setLabelsPointsGapExistence

void setLabelsPointsGapExistence(boolean existence)
Specifies whether the gaps between the labels and the points near each label exist.
Parameters:
existence - If true, the gaps exist.

setLabelsPointsGapThicknessModel

void setLabelsPointsGapThicknessModel(int thickness)
Indicates how far from the labels, the points on each label should be. The points are returned by the getPointsNearLabels(...) method.
Parameters:
thickness - The model thickness of the gap between the label and the point.

setRawLabelsPrecision

void setRawLabelsPrecision(int precision)
Indicates how many significant digits are wanted. For example, if you want two decimal places, then pass -2. If you want no decimal places, then pass 0. For more information see ChartArea.getPrecisionRound(...).
Parameters:
The - desired precision of the raw labels.

setBetweenLabelsGapExistence

void setBetweenLabelsGapExistence(boolean existence)
Indicates whether a gap should exist between the labels. This method overides setBetweenLabelsGapThicknessModel(...).
Parameters:
existence - If true, the gaps will exist.

setBetweenLabelsGapThicknessModel

void setBetweenLabelsGapThicknessModel(int thickness)
Indicates the model thickness of the gap between each label. This thickness is actually the minimum model thickness. If there is extra space that the labels don't need it is divided evenly between the labels, but the gap will be at least what is specified here.
Parameters:
thickness - The model minimum thickness of the gap.

setLabelsType

void setLabelsType(int type)
Indirectly sets the text of the labels. Possible values are RAW, PERCENT, and RAW + PERCENT. RAW causes the text of the label to be the actual data numbers. PERCENT causes the text to be the percent of the whole of the data. RAW + PERCENT causes the text of the label to be both, in the format of "p% - d" were p is the percent and d is the data number.
Parameters:
type - What text occurrs in each label.

getLabelsPointsGapThicknessModel

int getLabelsPointsGapThicknessModel()
Returns how far from the labels, the points on each label should be. The points are returned by the getPointsNearLabels(...) method.
Returns:
The model thickness of the gap between the label and the point.

getRawLabelsPrecision

int getRawLabelsPrecision()
Returns how many significant digits are wanted. For example, if you want two decimal places, then pass -2. If you want no decimal places, then pass 0. For more information see ChartArea.getPrecisionRound(...).
Returns:
The desired precision of the raw labels.

getLabelsType

int getLabelsType()
Indirectly returns the text of the labels. Possible values are RAW, PERCENT, and RAW + PERCENT. RAW causes the text of the label to be the actual data numbers. PERCENT causes the text to be the percent of the whole of the data. RAW + PERCENT causes the text of the label to be both, in the format of "p% - d" were p is the percent and d is the data number.
Returns:
What text occurrs in each label.

getInteriorBounds

java.awt.Rectangle getInteriorBounds(java.awt.Graphics2D g2D)
Returns a bounding rectangle of the area the labels encircle.
Returns:
The bounding rectangle of the interior.

getLabelsPointsGapExistence

boolean getLabelsPointsGapExistence()
Returns whether the gaps between the labels and the points near each label exist.
Returns:
boolean If true, the gaps exist.

getPointsNearLabels

java.awt.Point[] getPointsNearLabels(java.awt.Graphics2D g2D)
Returns an array of points, one for each label, that are near the labels. These points can be used for drawing lines from pie sectors to labels.
Returns:
Point[] The array of points.

getPieLabelsAreaNeedsUpdate

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

resetPieLabelsAreaModel

void resetPieLabelsAreaModel(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.

updatePieLabelsArea

void updatePieLabelsArea(java.awt.Graphics2D g2D)
Updates all this classes variables. First updates it's parent class, then then updates its own variables.

paintComponent

void paintComponent(java.awt.Graphics2D g2D)
Paints this class. Updates all variables, then paints its parent, since this class itself doesn't have anything to paint.
Overrides:
paintComponent in class FontArea
Parameters:
g2D - The graphics context for calculations and painting.