Ejemplo n.º 1
0
 private void initScale(int width) {
   hertz = Settings.getMaxFrequency();
   scale = new double[hertz * hDivBy];
   scaleStr = new String[(hertz * hDivBy) + 1];
   for (int i = 0; i < hertz; i++) {
     for (int j = 0; j < hDivBy; j++) {
       scale[i * hDivBy + j] =
           10.0
               + ((width - settingsPanelWidth) * (i * hDivBy + j + 1)) / (double) (hertz * hDivBy);
       scaleStr[i * hDivBy + j] = (i + j / hDivBy) + "," + (10 / hDivBy) * (j % hDivBy);
     }
   }
   scaleStr[hertz * hDivBy] = hertz + ",0";
 }
Ejemplo n.º 2
0
 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));
 }