// ChangeAxis:

    // A graph's display properties (axis characteristics, orientation, and
    // so on) are general properties that are defined in the graph's model.
    // Thus, to change a BarChart's axis characteristics,
    //    1) Create an AxisModel and any other objects needed to define
    //       axis characteristics (line style, tick intervals, ...)
    //    2) Use the BarChart to set the axis definitions on the chart
    // This example creates a StrokeLineStyle to define a
    // 3pt solid red line for both the Category and Response axes.
    // It creates an AxisModel to suppress the axis label and define
    // a line style and tick characteristics for the Response axis.

       import com.sas.graphics.components.barchart.BarChart;
       import com.sas.graphics.components.barchart.BarChartTableDataModel;
       import com.sas.graphics.components.AnalysisVariable;
       import com.sas.graphics.components.ClassificationVariable;
       import com.sas.graphics.components.barchart.BarChartModel;
       import com.sas.graphics.components.AxisModel;
       import com.sas.graphics.components.GraphConstants;
       import com.sas.graphics.components.StrokeLineStyle;
       import com.sas.measures.BaseLength;

       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 ChangeAxis extends JPanel  {
         private ChangeAxis  theApp;
         public ChangeAxis () {
            setLayout(new BorderLayout());

         // Create a BarChart and a data source
            BarChart barChart=new BarChart();
            SampleData dataTable=new SampleData();

         // 1) Create the objects needed to define axis characteristics.
         // A StrokeLineStyle is needed to define line characteristics
         // for both axes
            StrokeLineStyle lineStyle=new StrokeLineStyle(
              StrokeLineStyle.SASGRAPH_LINE01,
              Color.red,
              new BaseLength(3, "pt"),
              GraphConstants.TRUE);

         // An AxisModel is needed to suppress the axis label and define
         // a line style and tick characteristics for the Response axis
            AxisModel rAxis = new AxisModel();
            rAxis.setLabel("");
            rAxis.setAxisLineStyle(lineStyle);
            rAxis.setContinuousMajorTickPositionPolicy(
              GraphConstants.TICK_POSITION_INTERVAL);
            rAxis.setContinuousMajorTickInterval(40);
            rAxis.getMinorTickStyle().getLineStyle()
             .setVisibilityPolicy(GraphConstants.FALSE);

         // 2) Use the BarChart to set the axis definitions on the chart

         // Set the line color on the Category axis
            barChart.getGraphModel().getCategoryAxisModel()
             .setAxisLineStyle(lineStyle);

         // Set the AxisModel on the Response axis
            barChart.getGraphModel().setResponseAxisModel(rAxis);

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

         // Assign the Category and Response variable roles
            dataModel.setCategoryVariable(
              new ClassificationVariable("EnergyType"));
            dataModel.setResponseVariable(
              new AnalysisVariable("Produced"));

         // Assign the data model to the BarChart
            barChart.setDataModel(dataModel);

         // Set a graph title
            barChart.getTitle1().setText(
              "Energy Production and Consumption");

            add(barChart, 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[]={"EnergyType","Year","Produced","Consumed"};
              public SampleData() {
    	    super();
                Object data[][] = {
                  {"coal", "1985", new Double(19.33), new Double(17.48) },
                  {"gas", "1985", new Double(16.92), new Double(17.85) },
                  {"petro", "1985", new Double(21.23), new Double(30.92) },
                  {"hydro", "1985", new Double(2.94), new Double(3.36) },
                  {"nuclear", "1985", new Double(4.15), new Double(4.15) },
                  {"geotherm", "1985", new Double(0.20), new Double(0.20) },

                  {"coal", "1986", new Double(19.51), new Double(17.26) },
                  {"gas", "1986", new Double(16.47), new Double(16.71) },
                  {"petro", "1986", new Double(20.53), new Double(32.20) },
                  {"hydro", "1986", new Double(3.03), new Double(3.40) },
                  {"nuclear", "1986", new Double(4.47), new Double(4.47) },
                  {"geotherm", "1986", new Double(0.22), new Double(0.22) },

                  {"coal", "1987", new Double(20.14), new Double(18.01) },
                  {"gas", "1987", new Double(17.05), new Double(17.67) },
                  {"petro", "1987", new Double(19.89), new Double(32.87) },
                  {"hydro", "1987", new Double(2.59), new Double(3.07) },
                  {"nuclear", "1987", new Double(4.91), new Double(4.91) },
                  {"geotherm", "1987", new Double(0.23), new Double(0.23) },

                  {"coal", "1988", new Double(20.94), new Double(18.81) },
                  {"gas", "1988", new Double(17.19), new Double(18.60) },
                  {"petro", "1988", new Double(19.52), new Double(33.96) },
                  {"hydro", "1988", new Double(2.32), new Double(2.62) },
                  {"nuclear", "1988", new Double(5.68), new Double(5.68) },
                  {"geotherm", "1988", new Double(0.22), new Double(0.22) }
                };
                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());
              ChangeAxis  bipGraphSample = new ChangeAxis ();

              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);
          }
       }