com.odesys.chart.piechart
Class PieChartView

java.lang.Object
  |
  +--com.odesys.chart.ChartView
        |
        +--com.odesys.chart.piechart.PieChartView

public class PieChartView
extends ChartView

PieChartView draws a Pie Chart in the Graphics context provided by its parent Chart Component.


Fields inherited from class com.odesys.chart.ChartView
m_chart
 
Constructor Summary
PieChartView(Chart chart)
          Creates a new PieChartView instance for the specified Chart.
 
Method Summary
 float angleFromPoint(java.awt.Point p)
          Gets the angle at the specified Point.
 float getChartHeight()
          Gets the height of the chart side.
 float getChartRatio()
          Gets the ratio between the two radiuses of the chart ellipse.
 float getDirection()
          Gets the orientation of the chart in radians.
 float getExplodeRatio()
          Gets the distance between the slices and the chart when exploded.
 float getHeightRatio()
          Gets the ratio between the two height of the chart side and the main radius of the chart's ellipse.
 float getLabelsRatio()
          Gets the distance between the labels and the chart.
 PieChartModel getModel()
           
 float getPrecision()
          Gets the rendering precision for the ellipse.
 int getRadius()
          Gets the main radius of this PieChartView's ellipse.
 float getRelativeValue(float value)
          Calculates the ratio of the specified value and the total value.
 void paint(java.awt.Graphics g)
          Draws the Pie Chart in the specified Graphics context.
 java.awt.Point pointFromAngle(float angle)
          Gets the Point at the periphery of the chart at the specified angle.
 java.awt.Point pointFromAngle(float angle, int radius, float ratio)
           
 float radiusFromPoint(java.awt.Point p)
          Gets the radius at the specified Point.
protected  void resizeToFit(java.awt.FontMetrics fm)
          Resizes the Pie Chart to use all the available area.
 void setChartHeight(int height)
          Sets the height of the chart side (height >= 0).
 void setChartRatio(float ratio)
          Sets the ratio between the two radiuses of the chart ellipse (0.1 - 1.0).
 void setDirection(float direction)
          Sets the orientation of the chart in radians.
 void setExplodeRatio(float explodeRatio)
          Sets the distance between the slices and the chart when exploded.
 void setHeightRatio(float heightRatio)
          Sets the ratio between the height of the chart and the main radius of the chart's ellipse.
 void setLabelsRatio(float labelsRatio)
          Sets the distance between the labels and the chart.
 void setModel(ChartModel model)
          Sets the data Model of this ChartView.
 void setPrecision(float precision)
          Sets the rendering precision for the ellipse [0.01 - 0.2].
 void setRadius(int radius)
          Sets the main radius of this PieChartView's ellipse (radius >= 1).
 SliceData sliceDataFromPoint(java.awt.Point point)
          Determines the SliceData instance (if any) associated with the specified Point.
 void updateAggregates()
          Calculates the total value of this PieChartView's model.
 void updateDrawables()
          Used internally to update the DrawableSlices and the DrawableLabels of this PieChartView.
 
Methods inherited from class com.odesys.chart.ChartView
getBackground, getFont, getForeground, getPreferredSize, isAutoScaleToFit, isContoursVisible, isLabelsVisible, location, repaint, reshape, setAutoScaleToFit, setBackground, setContoursVisible, setFont, setForeground, setLabelsVisible, size
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PieChartView

public PieChartView(Chart chart)
Creates a new PieChartView instance for the specified Chart.
Method Detail

paint

public void paint(java.awt.Graphics g)
Draws the Pie Chart in the specified Graphics context.
Overrides:
paint in class ChartView

resizeToFit

protected void resizeToFit(java.awt.FontMetrics fm)
Resizes the Pie Chart to use all the available area.

updateDrawables

public void updateDrawables()
Used internally to update the DrawableSlices and the DrawableLabels of this PieChartView.
Overrides:
updateDrawables in class ChartView

updateAggregates

public void updateAggregates()
Calculates the total value of this PieChartView's model.
Overrides:
updateAggregates in class ChartView

getRelativeValue

public float getRelativeValue(float value)
Calculates the ratio of the specified value and the total value.

setModel

public void setModel(ChartModel model)
              throws java.lang.IllegalArgumentException
Description copied from class: ChartView
Sets the data Model of this ChartView. Throws IllegalArgumentException if the ChartModel passed as a parameter is not appropriate for this ChartView instance.
Overrides:
setModel in class ChartView

getModel

public PieChartModel getModel()

sliceDataFromPoint

public SliceData sliceDataFromPoint(java.awt.Point point)
Determines the SliceData instance (if any) associated with the specified Point.
Returns:
The SliceData instance associated with the specified Point.

radiusFromPoint

public float radiusFromPoint(java.awt.Point p)
Gets the radius at the specified Point. Point is relative to the Component. (0, 0) is the upper left corner of the component.
Returns:
The radius at the specified Point.

angleFromPoint

public float angleFromPoint(java.awt.Point p)
Gets the angle at the specified Point. Point is relative to the Component. (0, 0) is the upper left corner of the component.
Returns:
The angle at the specified Point.

pointFromAngle

public java.awt.Point pointFromAngle(float angle)
Gets the Point at the periphery of the chart at the specified angle.
Returns:
The Point at the periphery of the chart at the specified angle.

pointFromAngle

public java.awt.Point pointFromAngle(float angle,
                                     int radius,
                                     float ratio)

setRadius

public void setRadius(int radius)
Sets the main radius of this PieChartView's ellipse (radius >= 1).
Parameters:
radius - The main radius of the chart ellipse.

getRadius

public int getRadius()
Gets the main radius of this PieChartView's ellipse.
Returns:
The main radius of this PieChartView's ellipse.

setChartRatio

public void setChartRatio(float ratio)
Sets the ratio between the two radiuses of the chart ellipse (0.1 - 1.0).
Parameters:
ratio - The ratio between the two radiuses of the chart ellipse.

getChartRatio

public float getChartRatio()
Gets the ratio between the two radiuses of the chart ellipse.
Returns:
The ratio between the two radiuses of the chart ellipse.

setChartHeight

public void setChartHeight(int height)
Sets the height of the chart side (height >= 0).
Parameters:
height - The height of the chart side.

getChartHeight

public float getChartHeight()
Gets the height of the chart side.
Returns:
The height of the chart side.

setHeightRatio

public void setHeightRatio(float heightRatio)
Sets the ratio between the height of the chart and the main radius of the chart's ellipse.
Parameters:
heightRatio - The ratio between the height of the chart and the main radius of the chart's ellipse [0.0, 1.0].

getHeightRatio

public float getHeightRatio()
Gets the ratio between the two height of the chart side and the main radius of the chart's ellipse.

setDirection

public void setDirection(float direction)
Sets the orientation of the chart in radians.
Parameters:
direction - The orientation of the chart in radians.

getDirection

public float getDirection()
Gets the orientation of the chart in radians.
Returns:
The orientation of the chart in radians.

setExplodeRatio

public void setExplodeRatio(float explodeRatio)
Sets the distance between the slices and the chart when exploded. The distance is specified relatively to the main radius.
Parameters:
explodeRatio - How far from the char should the slices detach [1.0 - 1.5].

getExplodeRatio

public float getExplodeRatio()
Gets the distance between the slices and the chart when exploded. The distance is specified relatively to the main radius [1.0 - 1.5].

setPrecision

public void setPrecision(float precision)
Sets the rendering precision for the ellipse [0.01 - 0.2].
Parameters:
precision - The rendering precision for the ellipse.

getPrecision

public float getPrecision()
Gets the rendering precision for the ellipse.
Returns:
The rendering precision for the ellipse.

setLabelsRatio

public void setLabelsRatio(float labelsRatio)
Sets the distance between the labels and the chart. The distance is specified relatively to the main radius.
Parameters:
labelsRatio - How far from the chart should the labels be [1.0 - 2.0].

getLabelsRatio

public float getLabelsRatio()
Gets the distance between the labels and the chart.