// BasicRequirements:


// Basic requirements for creating a Gantt chart:
//   1) Create a data source, usually a Java TableModel
//   2) Create a data model that uses the data source
//   3) Assign the Task variable role and the Start and
//      Finish roles for dates you are tracking
//   4) Construct a GanttChart that uses the data model. You
//      can use the constructor to apply the of the STYLE_GANTTCHART
//      graph style to the chart. STYLE_GANTTCHART was specifically
//      designed for Gantt charts.
// To set a title or footnote, get the appropriate GanttChart
// title or footnote, and then set the returned object's text

   import com.sas.graphics.components.ganttchart.GanttChart;
   import com.sas.graphics.components.ganttchart.GanttChartTableDataModel;
   import com.sas.graphics.components.Variable;
   import com.sas.graphics.components.GraphStyle;
   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 BasicRequirements extends JPanel  {
     private BasicRequirements  theApp;
     public BasicRequirements () {
        setLayout(new BorderLayout());

     // 1) Create a data source 
        ScheduleData dataTable=new ScheduleData();  // defined below

     // 2) Construct a data model that uses the data source
        GanttChartTableDataModel dataModel=
          new GanttChartTableDataModel(dataTable);

     // 3) Assign the Task and date variable roles to the data model
        String format = "DATE5.";
        String informat = "DATE5.";         	
        dataModel.setTaskVariable(new Variable("Task"));
        dataModel.setEarlyStartVariable(new Variable("EarlyStart", format, informat, "Early Start"));
        dataModel.setEarlyFinishVariable(new Variable("EarlyFinish", format, informat, "Early Finish"));
        dataModel.setLateStartVariable(new Variable("LateStart", format, informat, "Late Start"));
        dataModel.setLateFinishVariable(new Variable("LateFinish", format, informat, "Late Finish"));

     // 4) Construct a GanttChart using the data model and assigning the GANTTCHART graph style
        GanttChart ganttChart=new GanttChart(dataModel, new GraphStyle(GraphStyle.STYLE_GANTTCHART));

     // Set a graph title
        ganttChart.getTitle1().setText("Preliminary Schedule");
        add(ganttChart, BorderLayout.CENTER);
      }
  // Create the data source
     static private class ScheduleData extends DefaultTableModel {
       private static Class  columnClass[]={
                   String.class, String.class, String.class, String.class, String.class};
       private static String columnNames[]={
                  "Task", "EarlyStart", "LateStart", "EarlyFinish", "LateFinish"};
         public ScheduleData() {
	   super();
           Object data[][] = {
             {new String("Project Summary")   , new String("01NOV"), new String("02NOV"), new String("09NOV"), new String("11NOV") }, 
             {new String("Manufacturer Demos"), new String("03NOV"), new String("05NOV"), new String("12NOV"), new String("12NOV") }, 
             {new String("Needs Assessment")  , new String("06NOV"), new String("08NOV"), new String("07NOV"), new String("11NOV") }, 
             {new String("Market Survey")     , new String("04NOV"), new String("06NOV"), new String("08NOV"), new String("11NOV") }, 
             {new String("Determine Users")   , new String("02NOV"), new String("06NOV"), new String("07NOV"), new String("09NOV") }
           };
           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());
          BasicRequirements  bipGraphSample = new BasicRequirements ();

          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.setVisible(true);
       }
     }