01: /*
02: * WardGraph.java
03: *
04: * Created on 27 February 2007, 15:52
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package com.xoetrope.tools;
11:
12: import com.xoetrope.swing.XGraph;
13: import java.awt.BorderLayout;
14: import java.awt.Color;
15: import javax.swing.JButton;
16: import javax.swing.JComponent;
17: import javax.swing.JFrame;
18: import net.xoetrope.xui.XPage;
19: import net.xoetrope.xui.XProjectManager;
20: import net.xoetrope.xui.data.XModel;
21:
22: /**
23: *
24: * @author kingsley.elmes
25: */
26: public class WardGraph extends XGraph {
27: private XGraph chart;
28: private double[] capacityPoints;
29: private int numSeries;
30: private String[] seriesNames = { "January", "February", "March",
31: "April", "May" };
32:
33: /**
34: * Creates a new instance of WardGraph
35: */
36: public WardGraph() {
37: setLabels(false);
38: setMarkers(false);
39: setHighlight(false);
40: setDrawBorder(true);
41: setBackground(Color.white);
42: setLegendPos(1);
43:
44: setupChart(false, false);
45: setMode(2);
46: }
47:
48: public void showChart(int chartType, String[] seriesNames,
49: boolean animate) {
50: double[] points;
51: setXScale(-45, 20, 0, "Time (GMT)", new String[] { "13:00", "",
52: "15:00", "", "17:00", "", "19:00", "", "21:00", "",
53: "23:00", "", "1:00", "", "3:00", "", "5:00" });
54: setYScale(LOGARITHMIC, "Patients Arriving");
55: points = capacityPoints;
56: setData(points, numSeries, seriesNames, animate);
57: repaint();
58: }
59:
60: protected void setupChart(boolean animate, boolean outputTable) {
61: numSeries = 5;
62: int numPoints = 14;
63: int seriesPts = numPoints * 2 * numSeries;
64: capacityPoints = new double[seriesPts];
65:
66: double te[] = { -45.0, -40.0, -35.0, -30.0, -25.0, -20.0,
67: -15.0, -10.0, -5.0, 0.0, 5.0, 10.0, 15.0, 20.0 };
68: double ts[] = { 0.01, 0.02, 0.03, 0.05, 0.05 };
69:
70: int idx = 0;
71: for (int j = 0; j < numSeries; j++) {
72: for (int i = 0; i < numPoints; i++) {
73: capacityPoints[idx++] = te[i];
74: capacityPoints[idx++] = te[i] * te[i] * ts[j];
75: }
76: }
77: showChart(1, seriesNames, animate);
78: }
79: }
|