KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > progra > charting > test > TestChartDataModel


1 /*
2     JOpenChart Java Charting Library and Toolkit
3     Copyright (C) 2001 Sebastian Müller
4     http://jopenchart.sourceforge.net
5
6     This library is free software; you can redistribute it and/or
7     modify it under the terms of the GNU Lesser General Public
8     License as published by the Free Software Foundation; either
9     version 2.1 of the License, or (at your option) any later version.
10
11     This library is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14     Lesser General Public License for more details.
15
16     You should have received a copy of the GNU Lesser General Public
17     License along with this library; if not, write to the Free Software
18     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19
20     TestChartDataModel.java
21     Created on 1. August 2001, 18:07
22  */

23
24 package de.progra.charting.test;
25
26 import de.progra.charting.model.*;
27 import de.progra.charting.render.*;
28 import de.progra.charting.*;
29
30 /**
31  *
32  * @author mueller
33  * @version
34  */

35 public class TestChartDataModel {
36
37     int[][] intval = {{1, 2, 4, 234, 45, 0, -102, Integer.MAX_VALUE},
38                         {23, 2, 45, -2000, 34, 566, 766, Integer.MIN_VALUE},
39                         {40594, 32493, -12020, 21023, 103, 3498, -1202, -12039}};
40                         
41     Number JavaDoc[][] numval = {{new Integer JavaDoc(45), new Integer JavaDoc(0), new Integer JavaDoc(-102), new Integer JavaDoc(Integer.MAX_VALUE)},
42                         {new Integer JavaDoc(34), new Integer JavaDoc(566), new Integer JavaDoc(766), new Integer JavaDoc(Integer.MIN_VALUE)},
43                         {new Integer JavaDoc(103), new Integer JavaDoc(3498), new Integer JavaDoc(-1202), new Integer JavaDoc(-12039)}};
44     
45     double[] numcolumns = {Double.MIN_VALUE, Double.MAX_VALUE, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY};
46     
47     double[] columns = {1.0, Double.MIN_VALUE, Double.MAX_VALUE, Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0, -20.0, 9458.340};
48     
49     Object JavaDoc[] objcolumns = {new Double JavaDoc(Double.MIN_VALUE), new Double JavaDoc(Double.MAX_VALUE),
50                            new Double JavaDoc(Double.POSITIVE_INFINITY), new Double JavaDoc(Double.NEGATIVE_INFINITY)};
51     
52     String JavaDoc[] strcolumns = {"1.0", ""+Double.MIN_VALUE, ""+Double.MAX_VALUE,
53                            ""+Double.POSITIVE_INFINITY, ""+Double.NEGATIVE_INFINITY,
54                            ""+0.0, ""+-20.0, ""+9458.340};
55     
56                         
57     /** Creates new TestChartDataModel */
58     public TestChartDataModel() {
59         //DefaultChartDataModel model;
60
ObjectChartDataModel model;
61         
62         // Create Empty DefaultChartDataModel
63
//model = new DefaultChartDataModel();
64
model = new ObjectChartDataModel();
65         System.out.println("** Teste leeres Modell");
66         testDefaultChartDataModel(model);
67         
68         // Create Number[][] DefaultChartDataModel
69
//model = new DefaultChartDataModel(numval, numcolumns);
70
model = new ObjectChartDataModel(numval, objcolumns, new String JavaDoc[] {"1", "2", "3", "4"});
71         System.out.println("** Teste Modell mit Number[][]");
72         
73         testDefaultChartDataModel(model);
74                 
75         // Create int[][] DefaultChartDataModel
76
//model = new DefaultChartDataModel(intval, columns);
77
model = new ObjectChartDataModel(intval, strcolumns, new String JavaDoc[] {"1", "2", "3", "4"});
78         System.out.println("** Teste Modell mit int[][]");
79         testDefaultChartDataModel(model);
80         
81     }
82     
83     public void testDefaultChartDataModel(DefaultChartDataModel m) {
84         try {
85             System.out.println("** AxisBinding von DataSet 0 = "+m.getAxisBinding(0));
86         } catch(Exception JavaDoc e) {
87             System.out.println("** Fehler");
88         }
89         
90         try {
91             System.out.println("** ColumnValue At index 3 = "+m.getColumnValueAt(3));
92         } catch(Exception JavaDoc e) {
93             System.out.println("** Fehler");
94         }
95         
96         try {
97             System.out.println("** ColumnValue At index 7 = "+m.getColumnValueAt(7));
98         } catch(Exception JavaDoc e) {
99             System.out.println("** Fehler");
100         }
101         
102         try {
103             System.out.println("** Länge von DataSet 2 = "+m.getDataSetLength(2));
104         } catch(Exception JavaDoc e) {
105             System.out.println("** Fehler");
106         }
107         try {
108             System.out.println("** Anzahl von DataSets = "+m.getDataSetNumber());
109         } catch(Exception JavaDoc e) {
110             System.out.println("** Fehler");
111         }
112         try {
113             System.out.println("** Wert an Index 0,7 = "+m.getValueAt(0, 7));
114         } catch(Exception JavaDoc e) {
115             System.out.println("** Fehler");
116         }
117         try {
118             System.out.println("** Wert an Index 2,2 = "+m.getValueAt(2, 2));
119         } catch(Exception JavaDoc e) {
120             System.out.println("** Fehler");
121         }
122         
123         ChartDataModelConstraints con;
124         
125         try {
126             System.out.println("** Lade ChartDataModelConstraints für CoordSystem.SECOND_YAXIS");
127             con = m.getChartDataModelConstraints(CoordSystem.SECOND_YAXIS);
128         } catch(Exception JavaDoc e) {
129             System.out.println("** Fehler");
130             return;
131         }
132         
133         try {
134             System.out.println("** Kleinster Wert = "+con.getMinimumValue());
135         } catch(Exception JavaDoc e) {
136             System.out.println("** Fehler");
137         }
138         
139         try {
140             System.out.println("** Größter Wert = "+con.getMaximumValue());
141         } catch(Exception JavaDoc e) {
142             System.out.println("** Fehler");
143         }
144         
145         try {
146             System.out.println("** Kleinster Column Wert = "+con.getMinimumColumnValue());
147         } catch(Exception JavaDoc e) {
148             System.out.println("** Fehler");
149         }
150         
151         try {
152             System.out.println("** Größter Column Wert = "+con.getMaximumColumnValue());
153         } catch(Exception JavaDoc e) {
154             System.out.println("** Fehler");
155         }
156     }
157     
158     public void testDefaultChartDataModel(ObjectChartDataModel m) {
159         try {
160             System.out.println("** AxisBinding von DataSet 0 = "+m.getAxisBinding(0));
161         } catch(Exception JavaDoc e) {
162             System.out.println("** Fehler");
163         }
164         
165         try {
166             System.out.println("** ColumnValue At index 3 = "+m.getColumnValueAt(3));
167         } catch(Exception JavaDoc e) {
168             System.out.println("** Fehler");
169         }
170         
171         try {
172             System.out.println("** ColumnValue At index 7 = "+m.getColumnValueAt(7));
173         } catch(Exception JavaDoc e) {
174             System.out.println("** Fehler");
175         }
176         
177         try {
178             System.out.println("** Länge von DataSet 2 = "+m.getDataSetLength(2));
179         } catch(Exception JavaDoc e) {
180             System.out.println("** Fehler");
181         }
182         try {
183             System.out.println("** Anzahl von DataSets = "+m.getDataSetNumber());
184         } catch(Exception JavaDoc e) {
185             System.out.println("** Fehler");
186         }
187         try {
188             System.out.println("** Wert an Index 0,7 = "+m.getValueAt(0, 7));
189         } catch(Exception JavaDoc e) {
190             System.out.println("** Fehler");
191         }
192         try {
193             System.out.println("** Wert an Index 2,2 = "+m.getValueAt(2, 2));
194         } catch(Exception JavaDoc e) {
195             System.out.println("** Fehler");
196         }
197         
198         ChartDataModelConstraints con;
199         
200         try {
201             System.out.println("** Lade ChartDataModelConstraints für CoordSystem.SECOND_YAXIS");
202             con = m.getChartDataModelConstraints(CoordSystem.SECOND_YAXIS);
203         } catch(Exception JavaDoc e) {
204             System.out.println("** Fehler");
205             return;
206         }
207         
208         try {
209             System.out.println("** Kleinster Wert = "+con.getMinimumValue());
210         } catch(Exception JavaDoc e) {
211             System.out.println("** Fehler");
212         }
213         
214         try {
215             System.out.println("** Größter Wert = "+con.getMaximumValue());
216         } catch(Exception JavaDoc e) {
217             System.out.println("** Fehler");
218         }
219         
220         try {
221             System.out.println("** Kleinster Column Wert = "+con.getMinimumColumnValue());
222         } catch(Exception JavaDoc e) {
223             System.out.println("** Fehler");
224         }
225         
226         try {
227             System.out.println("** Größter Column Wert = "+con.getMaximumColumnValue());
228         } catch(Exception JavaDoc e) {
229             System.out.println("** Fehler");
230         }
231     }
232
233     /**
234     * @param args the command line arguments
235     */

236     public static void main (String JavaDoc args[]) {
237         new TestChartDataModel();
238     }
239
240 }
241
Popular Tags