// ShapesPanel.java

import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JPanel;

public class ShapesPanel extends JPanel
{
   private ShapeBoundedBuffer shapes;

   public ShapesPanel(ShapeBoundedBuffer shapes)
   {
      if ( shapes == null )
         throw new NullPointerException("shapes null");
      this.shapes = shapes;

      setBackground(Color.BLACK);
      setForeground(Color.WHITE);
   }  // constructor

   public void paintComponent(Graphics g)
   {
      super.paintComponent(g);

      int pixelsFromLeft = 40;
      int pixelsFromTop = 40;

      for (int i = 0; i < shapes.getLengthFilled(); i++)
      {
         shapes.getShapeAt(i).draw(g,
                                   pixelsFromLeft,
                                   pixelsFromTop);
         pixelsFromLeft += 100;
      }  // for i
   }  // method paint
}  // class ShapesPanel