java.lang.Object
org.rrd4j.graph.ValueScaler
Utility class for scaling values with appropriate units in RRD graphs. Handles automatic unit selection and value scaling for optimal display.
Nested Class Summary
Nested ClassesModifier and TypeClassDescription(package private) static classRepresents a scaled value with its corresponding unit.Field Summary
Constructor Summary
ConstructorsMethod Summary
Private MethodsModifier and TypeMethodDescriptionprivate ValueScaler.Scaledrescale(double value) Picks a scale that keeps the value readable.(package private) ValueScaler.Scaledscale(double value, boolean mustRescale) Scales a value with appropriate unit selection.
Field Details
base
private final double baseValues are scaled to multiples of this.magfact
private double magfactThe scale factor applied, -1 before the first scaling.unit
Unit suffix chosen by the scaling.
Constructor Details
ValueScaler
ValueScaler(double base) Creates a new value scaler with the specified base.- Parameters:
base- the base for unit scaling (typically 1000 for SI units)
Method Details
scale
Scales a value with appropriate unit selection.- Parameters:
value- the value to scalemustRescale- if true, forces recalculation of scaling factors- Returns:
- scaled value with unit
rescale
Picks a scale that keeps the value readable.- Parameters:
value- the value to scale- Returns:
- the scaled value and its unit