/**********************************************************************
# Copyright (c) EWA Systems Inc. 1998 - 2005 All Rights Reserved
#               No part of this program may be photocopied, reproduced,
#               or translated to another programming language without
#               the prior written consent of EWA Systems.
**********************************************************************/

package com.ewasystems.chart.test;

import java.awt.Color;
import com.ewasystems.chart.AxesXY;
import com.ewasystems.chart.Chart;
import com.ewasystems.chart.JFrameChart;
import com.ewasystems.chart.JPanelChart;
import com.ewasystems.chart.box.ChartBoxPlot;

/**
 * <p>Title: Example Box Plot #1</p>
 * <p>Copyright: (c) 1998 - 2005</p>
 * <p>Company: EWA Systems, Inc.</p>
 * @author Lincoln Evans-Beauchamp
 * @version 1.0
 */

public class BoxPlotEx1 extends javax.swing.JApplet
{
  public void init()
  {
    Chart chart = new Chart(this);
    JPanelChart panel = new JPanelChart(chart);
    getContentPane().add(panel, java.awt.BorderLayout.CENTER);
    setup(chart);
  }

  static private void setup(Chart chart)
  {
    double obs[][]={{66.0, 52.0, 49.0, 64.0, 68.0, 26.0, 86.0, 52.0,
      43.0, 75.0, 87.0, 188.0, 118.0, 103.0, 82.0,
      71.0, 103.0, 240.0, 31.0, 40.0, 47.0, 51.0, 31.0,
      47.0, 14.0, 71.0},

      {61.0, 47.0, 196.0, 131.0, 173.0, 37.0, 47.0,
      215.0, 230.0, 69.0, 98.0, 125.0, 94.0, 72.0,
      72.0, 125.0, 143.0, 192.0, 122.0, 32.0, 114.0,
      32.0, 23.0, 71.0, 38.0, 136.0, 169.0},

      {152.0, 201.0, 134.0, 206.0, 92.0, 101.0, 119.0,
      124.0, 133.0, 83.0, 60.0, 124.0, 142.0, 124.0, 64.0,
      75.0, 103.0, 46.0, 68.0, 87.0, 27.0,
      73.0, 59.0, 119.0, 64.0, 111.0},

      {80.0, 68.0, 24.0, 24.0, 82.0, 100.0, 55.0, 91.0,
      87.0, 64.0, 170.0, 86.0, 202.0, 71.0, 85.0, 122.0,
      155.0, 80.0, 71.0, 28.0, 212.0, 80.0, 24.0,
      80.0, 169.0, 174.0, 141.0, 202.0},

      {113.0, 38.0, 38.0, 28.0, 52.0, 14.0, 38.0, 94.0,
      89.0, 99.0, 150.0, 146.0, 113.0, 38.0, 66.0, 38.0,
      80.0, 80.0, 99.0, 71.0, 42.0, 52.0, 33.0, 38.0,
      24.0, 61.0, 108.0, 38.0, 28.0}
    };
    double x[] = {1.0, 2.0, 3.0, 4.0, 5.0};
    String xLabels[] = { "May" ,"June" ,"July" ,"August" ,"September" };

    //   Create an instance of a BoxPlot Chart
    AxesXY axes = new AxesXY(chart);
    ChartBoxPlot boxPlot = new ChartBoxPlot(axes, obs);
    boxPlot.setLabels(xLabels);
    // Customize the fill color and the outside and far markers
    boxPlot.getBody().setFillColor(Color.blue);
    boxPlot.getOutsideMarker().setMarkerType(boxPlot.MARKER_TYPE_HOLLOW_CIRCLE);
    boxPlot.getOutsideMarker().setMarkerColor(Color.orange);
    boxPlot.getFarMarker().setMarkerType(boxPlot.MARKER_TYPE_ASTERISK);
    boxPlot.getFarMarker().setMarkerColor(Color.red); // Set titles
    chart.getChartTitle().setTitle( "Ozone Levels in Stanford by Month" );
    axes.getAxisX().getAxisTitle().setTitle( "Month" );
    axes.getAxisY().getAxisTitle().setTitle( "Ozone Level" );
  }

  public static void main(String argv[])
  {
    JFrameChart frame = new JFrameChart();
    BoxPlotEx1.setup(frame.getChart());
    frame.show();
  }
}
