Class Autoscaler

java.lang.Object
pl.polsl.rtsa.controller.Autoscaler

public class Autoscaler extends Object
Automatic Y-axis scaler for the oscilloscope and FFT views.

Analyses the current signal data and returns visible min/max values with a configurable padding margin so the waveform never touches the canvas edges.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final double
    Padding percentage to add above/below the signal (0.1 = 10%).
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    scaleFFT(double[] fft)
    Computes a padded magnitude ceiling for the FFT display.
    double[]
    scaleTime(double[] samples)
    Computes a padded voltage range for the time-domain display.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • PADDING_FACTOR

      private static final double PADDING_FACTOR
      Padding percentage to add above/below the signal (0.1 = 10%).
      See Also:
  • Constructor Details

    • Autoscaler

      public Autoscaler()
  • Method Details

    • scaleTime

      public double[] scaleTime(double[] samples)
      Computes a padded voltage range for the time-domain display.
      Parameters:
      samples - voltage samples (V)
      Returns:
      double[2] = { vMin, vMax } with 0.1 padding applied; defaults to [0.0, 5.0] when data is insufficient
    • scaleFFT

      public double scaleFFT(double[] fft)
      Computes a padded magnitude ceiling for the FFT display.
      Parameters:
      fft - FFT magnitude bins
      Returns:
      maximum magnitude multiplied by (1 + 0.1); defaults to 1.0 when data is insufficient