net.moioli.drawables
Class Pie

java.lang.Object
  extended by TreeMap
      extended by net.moioli.drawables.Pie
All Implemented Interfaces:
DrawableI

public class Pie
extends TreeMap
implements DrawableI

A nice class to draw a pie out of a Map table of data.
It will draw a pie with the values' percentages and will use the Map keys as lables.
Attention: this class expects you use Number derived objects as the map values (like Double or Integer). Not doing so might raise ClassCastExceptions.

Version:
2005/10/5
Author:
Silvio Moioli
See Also:
Number, Map

Constructor Summary
Pie()
          Default constructor.
 
Method Summary
 void drawMe(GraphicsI g, Scale s, java.lang.Object c)
          This method is automatically called by DefaultChart to draw the objects it contains, so end users should never call drawMe directly.
 double maxY(double minX, double maxX)
          Returns the maximum y value that should be represented in the DefaultChart for this object to be drawn properly.
 double minY(double minX, double maxX)
          Returns the minimum y value that should be represented in the DefaultChart for this object to be drawn properly.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pie

public Pie()
Default constructor.

Method Detail

drawMe

public void drawMe(GraphicsI g,
                   Scale s,
                   java.lang.Object c)
Description copied from interface: DrawableI
This method is automatically called by DefaultChart to draw the objects it contains, so end users should never call drawMe directly. Inside this method there must be all the code to draw the object on a DefaultChart, and all the operations which involve scaling should be done via the passed Scale object.

Specified by:
drawMe in interface DrawableI
Parameters:
g - the surface where this object will be drawn
s - the DefaultChart's Scale object
c - the color to be used for drawing
See Also:
DrawableI.drawMe(net.moioli.chart.GraphicsI, net.moioli.chart.Scale, java.lang.Object)

minY

public double minY(double minX,
                   double maxX)
Description copied from interface: DrawableI
Returns the minimum y value that should be represented in the DefaultChart for this object to be drawn properly.
If the object will be drawn indipendently from the y values represented in the DefaultChart, this method should return Double.NaN.

Specified by:
minY in interface DrawableI
Parameters:
minX - the minimum x value represented in this DefaultChart
maxX - the maximum x value represented in this DefaultChart
Returns:
the minimum y value or NaN
See Also:
DrawableI.minY(double, double)

maxY

public double maxY(double minX,
                   double maxX)
Description copied from interface: DrawableI
Returns the maximum y value that should be represented in the DefaultChart for this object to be drawn properly.
If the object will be drawn indipendently from the y values represented in the DefaultChart, this method should return Double.NaN.

Specified by:
maxY in interface DrawableI
Parameters:
minX - the minimum x value represented in this DefaultChart
maxX - the maximum x value represented in this DefaultChart
Returns:
the maximum y value or NaN
See Also:
DrawableI.maxY(double, double)