java.lang.Object
pl.polsl.rtsa.controller.GridCalculator
Utility for calculating grid line positions for plot axes.
Uses the 1–2–5 sequence so tick labels are always human-readable
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordComputed grid information. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic GridCalculator.GridInfocalculate(double min, double max, int targetDivisions) Calculate grid lines for a given visible range.static StringformatFrequency(double hz, double step) Format a frequency value with the most readable unit (Hz, kHz).static StringformatTime(double seconds, double step) Format a time value with the most readable unit (s, ms, µs).static StringformatValue(double value, double step) Format a numeric value with precision appropriate for the grid step.static doubleniceNumber(double value) Round to the nearest number in the 1–2–5 decade sequence.
-
Constructor Details
-
GridCalculator
private GridCalculator()
-
-
Method Details
-
calculate
Calculate grid lines for a given visible range.- Parameters:
min- visible minimum valuemax- visible maximum valuetargetDivisions- desired number of divisions- Returns:
- grid info with start position, step, and count of grid lines
-
niceNumber
public static double niceNumber(double value) Round to the nearest number in the 1–2–5 decade sequence. -
formatValue
Format a numeric value with precision appropriate for the grid step. Avoids displaying "-0.0" for values very close to zero. -
formatTime
Format a time value with the most readable unit (s, ms, µs). -
formatFrequency
Format a frequency value with the most readable unit (Hz, kHz).
-