// ChangeBackground:

    // To change a graph's background, call the
    // BarChart's setBackground() method

       import com.sas.graphics.components.areabarchart.AreaBarChart;
       import com.sas.graphics.components.areabarchart.AreaBarChartTableDataModel;
       import com.sas.graphics.components.AnalysisVariable;
       import com.sas.graphics.components.ClassificationVariable;
       import com.sas.graphics.components.GraphConstants;
       import javax.swing.table.DefaultTableModel;
       import java.awt.BorderLayout;
       import java.awt.Color;
       import java.awt.Container;
       import java.awt.event.WindowAdapter;
       import java.awt.event.WindowEvent;
       import javax.swing.JFrame;
       import javax.swing.JPanel;

       public class ChangeBackground extends JPanel  {
         private ChangeBackground  theApp;
         public ChangeBackground () {
            setLayout(new BorderLayout());

         // Create an AreaBarChart and a data source
            AreaBarChart areaBarChart=new AreaBarChart();
            SampleData dataTable=new SampleData();

         // Set a background color
            areaBarChart.setBackground(Color.lightGray);

         // Create a data model and attach the data source
            AreaBarChartTableDataModel dataModel=
                      new AreaBarChartTableDataModel();
            dataModel.setModel(dataTable);

         // Assign variable roles to appropriate variables
            dataModel.setCategoryVariable(
                      new ClassificationVariable("Group"));

         // Create Analysis variables that calculate a mean
            AnalysisVariable h=new AnalysisVariable(
              "Height"                        // column for Height role
              ,GraphConstants.STATISTIC_MEAN    // statistic to calculate
            );
            AnalysisVariable w=new AnalysisVariable(
              "Weight"                        // column for Width role
              ,GraphConstants.STATISTIC_MEAN    // statistic to calculate
            );
         // Assign the Analysis variables to the data model
            dataModel.setHeightVariable(h);
            dataModel.setWidthVariable(w);

         // Assign the data model to the AreaBarChart
            areaBarChart.setDataModel(dataModel);

         // Set a graph title
            areaBarChart.getTitle1().setText("Change the Background");
            add(areaBarChart, BorderLayout.CENTER);
          }
       // Create the data source
          static private class SampleData extends DefaultTableModel {
            private static Class  columnClass[]={String.class, String.class,
                                                 Double.class, Double.class};
            private static String columnNames[]={"Group","Age","Height","Weight"};
              public SampleData() {
    	    super();
                Object data[][] = {
                 { "Group 1", new String("y"+13), new Double(56.5), new Double(84)    },
                 { "Group 1", new String("y"+12), new Double(50.5), new Double(98)    },
                 { "Group 1", new String("y"+11), new Double(49),   new Double(50.5)  },
                 { "Group 1", new String("y"+12), new Double(46.3), new Double(77)    },
                 { "Group 1", new String("y"+12), new Double(53),   new Double(96.5)  },
                 { "Group 2", new String("y"+14), new Double(62.8), new Double(102.5) },
                 { "Group 2", new String("y"+16), new Double(70),   new Double(140)   },
                 { "Group 2", new String("y"+14), new Double(59.5), new Double(102)   },
                 { "Group 3", new String("y"+15), new Double(62),   new Double(112.5) },
                 { "Group 2", new String("y"+14), new Double(64.3), new Double(90)    },
                 { "Group 3", new String("y"+15), new Double(66.5), new Double(112)   },
                 { "Group 1", new String("y"+12), new Double(59),   new Double(99.5)  },
                 { "Group 1", new String("y"+13), new Double(62.5), new Double(84)    },
                 { "Group 1", new String("y"+12), new Double(64.8), new Double(128)   },
                 { "Group 1", new String("y"+12), new Double(57.3), new Double(83)    },
                 { "Group 1", new String("y"+11), new Double(57.5), new Double(85)    },
                 { "Group 3", new String("y"+15), new Double(77),   new Double(133)   },
                 { "Group 3", new String("y"+15), new Double(66.5), new Double(112)   },
                 { "Group 2", new String("y"+14), new Double(63.5), new Double(102.5) },
                 { "Group 3", new String("y"+16), new Double(72),   new Double(150)   }
                };
                setDataVector(data, columnNames);
              }
              public Class getColumnClass(int column) {
    	    return columnClass[column];
    	  }
          }
          public static void main(String[] args) {
          	  JFrame frame = new JFrame("BIP Graph Sample");
          	  Container container = frame.getContentPane();
              container.setLayout(new BorderLayout());
              container.setBackground(Color.white);

              JPanel bipPanel = new JPanel();
              bipPanel.setLayout(new BorderLayout());
              ChangeBackground  bipGraphSample = new ChangeBackground ();

              bipPanel.add(bipGraphSample, BorderLayout.CENTER);
              container.add(bipPanel, BorderLayout.CENTER);

              frame.setSize(600,450);
              frame.addWindowListener(new WindowAdapter() {
                  public void windowClosing(WindowEvent e) {
                         System.exit(0);
                  }
              } );
              frame.pack();
              frame.setVisible(true);
          }
       }