net.moioli.drawables
Class Histogram
java.lang.Object
java.util.AbstractMap<K,V>
java.util.HashMap
net.moioli.drawables.Histogram
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, java.util.Map, DrawableI
public class Histogram
- extends java.util.HashMap
- implements DrawableI
A nice class to draw a histogram out of a Map table of data.
It will draw a histogram with the values 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
,
Serialized Form
Constructor Summary |
Histogram()
Constructs a new, empty Histogram. |
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.util.HashMap |
clear, clone, containsKey, containsValue, entrySet, get, isEmpty, keySet, put, putAll, remove, size, values |
Methods inherited from class java.util.AbstractMap |
equals, hashCode, toString |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Methods inherited from interface java.util.Map |
equals, hashCode |
Histogram
public Histogram()
- Constructs a new, empty Histogram.
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 DefaultChartmaxX
- the maximum x value represented in this DefaultChart
- Returns:
- the minimum y value or NaN
- See Also:
TODO: find a better
strategy to do this (use keys as values in a TreeMap?)
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 DefaultChartmaxX
- the maximum x value represented in this DefaultChart
- Returns:
- the maximum y value or NaN
- See Also:
DrawableI.maxY(double, double)
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 drawns
- the DefaultChart's Scale objectc
- the color to be used for drawing- See Also:
DrawableI.drawMe(GraphicsI, Scale, Object)