private void initAnalysisDisplay(RealSpectrum spec, SpectrumAnalysis analysis, int width) { int dominantFrequencyIndex = analysis.getDominantFrequencyIndex(); dominantFrequency = String.valueOf(Math.round(analysis.getDominantFrequency() * 100.0) / 100.0) + " Hz"; double freqX = ((double) (width - settingsPanelWidth)) * (dominantFrequencyIndex / (double) spec.length()); double freqY = calcDominantFrequencyAmplitude(dominantFrequencyIndex) - 10; dominantFrequencyLocation = new Point2D.Double(freqX, freqY); }
public SpectrumDisplayPanel(RealSpectrum spectrum, SpectrumAnalysis analysis) { this(); height = Display.getHeight(); width = Display.getWidth(); xUnit = " Hz"; hDivBy = 40 / Settings.getMaxFrequency(); name = "Spectrum"; initScale(width); double max = spectrum.calcMax(); double min = spectrum.calcMin(); double signalHeight = max - min; double baseline = (height / 2) + (min * (height / 3) / signalHeight) - 70; int numnberOfPointsToDraw = spectrum.length(); points = new Point2D[numnberOfPointsToDraw]; for (int i = 0; i < numnberOfPointsToDraw; i++) { points[i] = new Point2D.Double( 10.0 + ((double) (width - settingsPanelWidth)) * (i / (double) numnberOfPointsToDraw), -15 + baseline - (spectrum.getSample(i) * (height / 3) / signalHeight)); } initAnalysisDisplay(spectrum, analysis, width); dx = Settings.getMaxFrequency() * (1.0 / (width - settingsPanelWidth)); }