private void drawSpectrum(Graphics2D graphics){
  Dimension size=getSize();
  Rectangle background=new Rectangle(0,0,size.width,size.height);
  graphics.setColor(mColorSpectrumBackground);
  graphics.draw(background);
  graphics.fill(background);
  GradientPaint gradient=new GradientPaint(0,(getSize().height - mSpectrumInset) / 2,mColorSpectrumGradientTop,0,getSize().height,mColorSpectrumGradientBottom);
  graphics.setBackground(mColorSpectrumBackground);
  GeneralPath spectrumShape=new GeneralPath();
  spectrumShape.moveTo(size.getWidth(),size.getHeight() - mSpectrumInset);
  spectrumShape.lineTo(0,size.getHeight() - mSpectrumInset);
  float[] bins=getBins();
  if (bins != null) {
    float insideHeight=size.height - mSpectrumInset;
    float scalor=insideHeight / -mDBScale;
    float binSize=(float)size.width / ((float)(bins.length));
    for (int x=0; x < bins.length; x++) {
      float height;
      height=bins[x] * scalor;
      if (height > insideHeight) {
        height=insideHeight;
      }
      if (height < 0) {
        height=0;
      }
      float xAxis=(float)x * binSize;
      spectrumShape.lineTo(xAxis,height);
    }
  }
 else {
    graphics.setPaint(gradient);
    spectrumShape.lineTo(0,size.getHeight() - mSpectrumInset);
    spectrumShape.lineTo(size.getWidth(),size.getHeight() - mSpectrumInset);
  }
  spectrumShape.lineTo(size.getWidth(),size.getHeight() - mSpectrumInset);
  graphics.setPaint(gradient);
  graphics.draw(spectrumShape);
  graphics.fill(spectrumShape);
  graphics.setPaint(mColorSpectrumLine);
  graphics.draw(new Line2D.Float(0,size.height - mSpectrumInset,size.width,size.height - mSpectrumInset));
}

private void drawSpectrum ( Graphics2D graphics ) { Dimension size = getSize ( ) ; Rectangle background = new Rectangle ( 0 , 0 , size . width , size . height ) ; graphics . setColor ( mColorSpectrumBackground ) ; graphics . draw ( background ) ; graphics . fill ( background ) ; GradientPaint gradient = new GradientPaint ( 0 , ( getSize ( ) . height - mSpectrumInset ) / 2 , mColorSpectrumGradientTop , 0 , getSize ( ) . height , mColorSpectrumGradientBottom ) ; graphics . setBackground ( mColorSpectrumBackground ) ; GeneralPath spectrumShape = new GeneralPath ( ) ; spectrumShape . moveTo ( size . getWidth ( ) , size . getHeight ( ) - mSpectrumInset ) ; spectrumShape . lineTo ( 0 , size . getHeight ( ) - mSpectrumInset ) ; float [ ] bins = getBins ( ) ; if ( bins != null ) { float insideHeight = size . height - mSpectrumInset ; float scalor = insideHeight / - mDBScale ; float binSize = ( float ) size . width / ( ( float ) ( bins . length ) ) ; for ( int x = 0 ; x < bins . length ; x ++ ) { float height ; height = bins [ x ] * scalor ; if ( height > insideHeight ) { height = insideHeight ; } if ( height < 0 ) { height = 0 ; } float xAxis = ( float ) x * binSize ; spectrumShape . lineTo ( xAxis , height ) ; } } else { graphics . setPaint ( gradient ) ; spectrumShape . lineTo ( 0 , size . getHeight ( ) - mSpectrumInset ) ; spectrumShape . lineTo ( size . getWidth ( ) , size . getHeight ( ) - mSpectrumInset ) ; } spectrumShape . lineTo ( size . getWidth ( ) , size . getHeight ( ) - mSpectrumInset ) ; graphics . setPaint ( gradient ) ; graphics . draw ( spectrumShape ) ; graphics . fill ( spectrumShape ) ; graphics . setPaint ( mColorSpectrumLine ) ; graphics . draw ( new Line2D . Float ( 0 , size . height - mSpectrumInset , size . width , size . height - mSpectrumInset ) ) ; }
draws the current fft spectrum with a line and a gradient fill .
