|
ChartCat 1.2 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectli.netcat.chart.data.AbstractChartModelAdapter
li.netcat.chart.data.DefaultScaleModel
Default implementation of a NumericScaleModel that uses a linear scale.
This class uses a configurable divide map that defines how to divide
a range into sub ranges. The structure of the map consists of
a series of triple.
The value range of the scale is mapped into the range from 1.0 to 10.0 so that the divide map gets independent of the decimal power. The map value is initialized as follows:
setDivideMap(new double[] {
1.0, 0.2, 1,
1.2, 0.2, 1,
1.4, 0.2, 1,
1.5, 0.3, 1,
1.6, 0.2, 1,
1.8, 0.3, 1,
2.0, 0.25, 2,
2.5, 0.5, 1,
3.0, 0.5, 1,
3.5, 0.5, 1,
4.0, 0.5, 1,
5.0, 1.0, 0,
6.0, 1.0, 0,
7.0, 1.0, 0,
8.0, 1.0, 0,
});
which means: Divide a range of 1.0 by using 5 sub ranges of lenght 0.2 and use 1 decimal place.
Divide a range of 1.2 by using sub ranges of 0.2 and use 1 decimal place. ...etc...
Divide a range of 8.0 by using sub ranges of 1.0 and use no decimal places. It also
means, that a range of 10 gets divided into 5 sub ranges of lenght 2 and use 0 decimal places ...etc...
| Constructor Summary | |
DefaultScaleModel()
Constructs and initializes a new DefaultScaleModel. |
|
| Method Summary | |
double[] |
getDivideMap()
Returns a clone of the divide map of this scale model. |
float |
getLength()
Returns the length of the scale |
int |
getMarkCount()
Returns the number of marks of this scale. |
java.text.NumberFormat |
getNumberFormat(double startValue,
double stepWidth,
int decimalPlaces)
Returns the number format that is used to format the values of the scale. |
java.text.NumberFormat |
getPercentFormat(double startValue,
double stepWidth,
int decimalPlaces)
Returns the number format that is used to format the relative values of the scale. |
float |
getPosition(int markIndex)
Returns the position of the mark at the given index. |
java.lang.String |
getText(int textIndex)
Returns the text of the mark at the given index. |
double |
getValue(int markIndex)
Returns the value of the mark at the given index. |
void |
invalidate()
Invoked when the underlying model changes. |
boolean |
isCentered()
Returns false. |
boolean |
isReverted()
Returns true, if this scale model is reverted, which means that the smallest number is at the top of a horizontal scale. |
void |
setDivideMap(double[] map)
Sets a new instance of the divide map. |
void |
setLength(float length)
Sets the length of the scale. |
void |
setRange(double min,
double max,
boolean relative)
Sets the range for this scale. |
void |
setReverted(boolean flag)
Sets the reverted flag. |
float |
toPosition(double value)
Calculates the position of an arbitrary value. |
| Methods inherited from class li.netcat.chart.data.AbstractChartModelAdapter |
getChartModel, setChartModel |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface li.netcat.chart.data.ChartModelAdapter |
getChartModel, setChartModel |
| Constructor Detail |
public DefaultScaleModel()
DefaultScaleModel.
| Method Detail |
public void setDivideMap(double[] map)
map - The new divide map, valid and not null. This parameter gets cloned.public double[] getDivideMap()
setDivideMap(double[]) for a description
of the structure.
public java.text.NumberFormat getNumberFormat(double startValue,
double stepWidth,
int decimalPlaces)
startValue - The start value of the scale.stepWidth - The value of the step width.decimalPlaces - The number of preferred decimal places.
public java.text.NumberFormat getPercentFormat(double startValue,
double stepWidth,
int decimalPlaces)
startValue - The start value of the scale.stepWidth - The value of the step width.decimalPlaces - The number of preferred decimal places.public boolean isReverted()
public void setReverted(boolean flag)
flag - The reverted flag.
public void setRange(double min,
double max,
boolean relative)
NumericScaleModel
setRange in interface NumericScaleModelmin - The minimum value, it is <= max.max - The maximum value, it is >= min.relative - Flag that indicates that the values are in percent.
The value 1.0 refers to 100%.public float getLength()
ScaleModel
getLength in interface ScaleModelpublic void setLength(float length)
ScaleModel
setLength in interface ScaleModellength - The length of the scale, must be > 0.0f.public int getMarkCount()
ScaleModel
getMarkCount in interface ScaleModelpublic float getPosition(int markIndex)
ScaleModel
getPosition in interface ScaleModelmarkIndex - The index of the mark. It must be >= 0 and < getMarkCount().public double getValue(int markIndex)
ScaleModel
getValue in interface ScaleModelmarkIndex - The index of the mark. It must be >= 0 and < getMarkCount().public java.lang.String getText(int textIndex)
ScaleModel
getText in interface ScaleModeltextIndex - The index of the mark. It must be >= 0 and < getMarkCount().public float toPosition(double value)
ScaleModel
toPosition in interface ScaleModelvalue - An arbitrary value.
public boolean isCentered()
false.
isCentered in interface ScaleModelpublic void invalidate()
AbstractChartModelAdapter
invalidate in class AbstractChartModelAdapter
|
ChartCat 1.2 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||