Class AxisScalePolicyAutomaticBestFit
- All Implemented Interfaces:
IAxisScalePolicy
- Every scale tick is a minor or major tick of the corresponding axis.
- If a scale tick was found that matches a major and a minor tick it is judged as major tick.
- Every major tick is a multiple of minor ticks: It is not possible for the sum minor ticks to "skip" a major tick.
- There is no guarantee that the labels of ticks will overwrite each others.
- There is no guarantee that the major and minor ticks of the axis are chosen in a reasonable manner: You could get no labels at all if the values are too high or thousands of labels with a weird output.
- Author:
- Achim Westermann
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected double
Internally used for rounding to ticks, calculated once per paint iteration. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected List
<LabeledValue> Returns the labels for this axis.getScaleValues
(Graphics g2d, IAxis<?> axis) Returns the array of labeled values that will be used by the
to paint labels.Chart2D
void
initPaintIteration
(IAxis<?> axis) Performs expensive calculations for various values that are used by many calls throughout a paint iterations.protected LabeledValue
roundToTicks
(double value, boolean floor, boolean findMajorTick, IAxis<?> axis) Internal rounding routine.
-
Field Details
-
m_power
protected double m_powerInternally used for rounding to ticks, calculated once per paint iteration.
-
-
Constructor Details
-
AxisScalePolicyAutomaticBestFit
public AxisScalePolicyAutomaticBestFit()
-
-
Method Details
-
getScaleValues
Description copied from interface:IAxisScalePolicy
Returns the array of labeled values that will be used by the
to paint labels.Chart2D
- Specified by:
getScaleValues
in interfaceIAxisScalePolicy
- Parameters:
g2d
- Provides information about the graphic context (e.g. font metrics).axis
- the axis to work for.- Returns:
- the labeled values that will be used by the
to paint labels.Chart2D
-
initPaintIteration
Description copied from interface:IAxisScalePolicy
Performs expensive calculations for various values that are used by many calls throughout a paint iterations.These values are constant throughout a paint iteration by the contract that no point is added removed or changed in this period. Because these values are used from many methods it is impossible to calculate them at a "transparent" method that may perform this caching over a paint period without knowledge from outside. The first method called in a paint iteration is called several further times in the iteration. So this is the common hook to invoke before painting a chart.
- Specified by:
initPaintIteration
in interfaceIAxisScalePolicy
- Parameters:
axis
- the axis to read data from.- See Also:
-
getLabels
Returns the labels for this axis.The labels will have at least the given argument
resolution
as distance in the value domain of the chart.- Parameters:
resolution
- the distance in the value domain of the chart that has to be at least between to labels.- Returns:
- the labels for the axis.
-
roundToTicks
protected LabeledValue roundToTicks(double value, boolean floor, boolean findMajorTick, IAxis<?> axis) Internal rounding routine.Arguments are not chosen to be "understandable" or "usable" but optimized for performance.
The
findMajorTick
argument may be used e.g. to force labels to start from a major tick.- Parameters:
value
- the value to round.floor
- if true, rounding goes to floor else to ceiling.findMajorTick
- if true the returned value will be a major tick (which might be fare more away from the given value than the next major tick).- Returns:
- the value rounded to minor or major ticks.
-