public void paintComponent(Graphics g)
    {
      Rectangle rectToPaint = g.getClipBounds();
      
      if(DEBUG)
      {
        System.out.println("Repainting: " + rectToPaint);
        System.out.println("\tSampleWidth: " + sampleWidth);
        System.out.println("\tframesPerPixel: " + framesPerPixel);
        System.out.println("\tSample panel size: " + getSize());
        System.out.println("\tSamplePanel Width: " + getWidth());
        System.out.println("\tSamplePanel Height: " + getHeight());
      }
      
      //clear out the image
      Graphics2D g2 = (Graphics2D)g;
      g2.setBackground(backgroundColor);
      g2.clearRect((int)rectToPaint.getX(), (int)rectToPaint.getY(), 
                   (int)rectToPaint.getWidth(), (int)rectToPaint.getHeight());
      
      //draw the selection if it exists
      if(selectionStart!=-1 && selectionStop!=-1)
      {
        g2.setBackground(selectionColor);
        g2.clearRect(selectionStart, 0, 
                     selectionStop-selectionStart+1, sampleHeight);
      }
      
      //draw the lines
      g2.setColor(waveColor);
      for(int i = (int)rectToPaint.getX(); 
          i < (rectToPaint.getX() + rectToPaint.getWidth() -1); i++)
      {
        g2.draw(new 
                  Line2D.Float((Point2D.Float)points.elementAt(i),
                               (Point2D.Float)points.elementAt(i+1)));
      }
      
      //draw the center line
      g2.setColor(barColor);
      g2.setStroke(new BasicStroke(1));
      g2.draw(new Line2D.Double(rectToPaint.getX(), 
                                Math.floor(sampleHeight/2), 
                                rectToPaint.getX()+rectToPaint.getWidth()-1,
                                Math.floor(sampleHeight/2)));
       
      //draw the current position
      if (rectToPaint.getX()<currentPixelPosition && 
          currentPixelPosition<(rectToPaint.getX()+rectToPaint.getWidth()-1))
      {
        g2.setColor(barColor);
        g2.setStroke(new BasicStroke(1));
        g2.draw(new Line2D.Double(currentPixelPosition, 0, 
                                  currentPixelPosition, sampleHeight));  
      }
    }//paint(g)