java.lang.Object
pl.polsl.rtsa.controller.FFTDomainRen
Renders the FFT magnitude spectrum with:
- Grid lines at "nice" frequency and magnitude intervals
- Frequency (X) and magnitude (Y) axis labels
- Zoom-aware rendering via explicit visible-range parameters
- Correct bin→Hz mapping: f = bin × (sampleRate / (2 × N))
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final javafx.scene.paint.Colorprivate static final javafx.scene.paint.Colorprivate static final javafx.scene.paint.Colorprivate static final intprivate static final javafx.scene.paint.Colorprivate static final intprivate static final doubleprivate static final doubleprivate static final doubleprivate static final doubleprivate booleanprivate static final javafx.scene.paint.Colorprivate static final javafx.scene.paint.Colorprivate final double[]private final double[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static doubleclamp(double v, double lo, double hi) Clampsvto the range [lo,hi].voiddraw(javafx.scene.canvas.GraphicsContext gc, double[] fft, double magMin, double magMax, double freqStart, double freqEnd, double sampleRate, double w, double h) Draw the FFT magnitude spectrum.private voiddrawBorder(javafx.scene.canvas.GraphicsContext gc, double pw, double ph) Draws the plot-area border rectangle.voiddrawEmpty(javafx.scene.canvas.GraphicsContext gc, double w, double h) Draw empty canvas with default grid and placeholder.private voiddrawGrid(javafx.scene.canvas.GraphicsContext gc, double magMin, double magMax, double freqStart, double freqEnd, double pw, double ph) Draws magnitude (Y) and frequency (X) grid lines with labels.private voiddrawPlaceholder(javafx.scene.canvas.GraphicsContext gc, double pw, double ph, String text) Draws centred placeholder text when no FFT data is available.private voiddrawSpectrum(javafx.scene.canvas.GraphicsContext gc, double[] fft, double magMin, double magMax, double freqStart, double freqEnd, double sampleRate, double pw, double ph) Render the FFT magnitude trace.voidsetShowGrid(boolean show) Toggles grid-line rendering.
-
Field Details
-
ML
private static final double ML- See Also:
-
MR
private static final double MR- See Also:
-
MT
private static final double MT- See Also:
-
MB
private static final double MB- See Also:
-
MAX_POINTS
private static final int MAX_POINTS- See Also:
-
GRID_DIVISIONS
private static final int GRID_DIVISIONS- See Also:
-
BG_COLOR
private static final javafx.scene.paint.Color BG_COLOR -
GRID_COLOR
private static final javafx.scene.paint.Color GRID_COLOR -
AXIS_COLOR
private static final javafx.scene.paint.Color AXIS_COLOR -
LABEL_COLOR
private static final javafx.scene.paint.Color LABEL_COLOR -
SIGNAL_COLOR
private static final javafx.scene.paint.Color SIGNAL_COLOR -
TITLE_COLOR
private static final javafx.scene.paint.Color TITLE_COLOR -
xBuf
private final double[] xBuf -
yBuf
private final double[] yBuf -
showGrid
private boolean showGrid
-
-
Constructor Details
-
FFTDomainRen
public FFTDomainRen()
-
-
Method Details
-
setShowGrid
public void setShowGrid(boolean show) Toggles grid-line rendering.- Parameters:
show-trueto draw grid lines,falseto hide them
-
draw
public void draw(javafx.scene.canvas.GraphicsContext gc, double[] fft, double magMin, double magMax, double freqStart, double freqEnd, double sampleRate, double w, double h) Draw the FFT magnitude spectrum.- Parameters:
gc- canvas graphics contextfft- magnitude values (half-spectrum, N/2 bins, positive freqs)magMin- visible magnitude minimum (usually 0)magMax- visible magnitude maximumfreqStart- visible frequency start (Hz)freqEnd- visible frequency end (Hz)sampleRate- sampling rate (Hz) — needed for bin→Hz mappingw- canvas width (px)h- canvas height (px)
-
drawEmpty
public void drawEmpty(javafx.scene.canvas.GraphicsContext gc, double w, double h) Draw empty canvas with default grid and placeholder. -
drawGrid
private void drawGrid(javafx.scene.canvas.GraphicsContext gc, double magMin, double magMax, double freqStart, double freqEnd, double pw, double ph) Draws magnitude (Y) and frequency (X) grid lines with labels. -
drawBorder
private void drawBorder(javafx.scene.canvas.GraphicsContext gc, double pw, double ph) Draws the plot-area border rectangle. -
drawSpectrum
private void drawSpectrum(javafx.scene.canvas.GraphicsContext gc, double[] fft, double magMin, double magMax, double freqStart, double freqEnd, double sampleRate, double pw, double ph) Render the FFT magnitude trace.Bin-to-frequency mapping:
freq(bin) = bin × freqResolutionwherefreqResolution = sampleRate / (2 × fft.length)becausefft[]is the half-spectrum (N/2 bins from an N-point FFT). -
drawPlaceholder
private void drawPlaceholder(javafx.scene.canvas.GraphicsContext gc, double pw, double ph, String text) Draws centred placeholder text when no FFT data is available.- Parameters:
gc- graphics contextpw- plot width (px)ph- plot height (px)text- the message to display
-
clamp
private static double clamp(double v, double lo, double hi) Clampsvto the range [lo,hi].
-