001: /*
002: JOpenChart Java Charting Library and Toolkit
003: Copyright (C) 2001 Sebastian Müller
004: http://jopenchart.sourceforge.net
005:
006: This library is free software; you can redistribute it and/or
007: modify it under the terms of the GNU Lesser General Public
008: License as published by the Free Software Foundation; either
009: version 2.1 of the License, or (at your option) any later version.
010:
011: This library is distributed in the hope that it will be useful,
012: but WITHOUT ANY WARRANTY; without even the implied warranty of
013: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: Lesser General Public License for more details.
015:
016: You should have received a copy of the GNU Lesser General Public
017: License along with this library; if not, write to the Free Software
018: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
019:
020: TestChartDataModel.java
021: Created on 1. August 2001, 18:07
022: */
023:
024: package de.progra.charting.test;
025:
026: import de.progra.charting.model.*;
027: import de.progra.charting.render.*;
028: import de.progra.charting.*;
029:
030: /**
031: *
032: * @author mueller
033: * @version
034: */
035: public class TestChartDataModel {
036:
037: int[][] intval = {
038: { 1, 2, 4, 234, 45, 0, -102, Integer.MAX_VALUE },
039: { 23, 2, 45, -2000, 34, 566, 766, Integer.MIN_VALUE },
040: { 40594, 32493, -12020, 21023, 103, 3498, -1202, -12039 } };
041:
042: Number[][] numval = {
043: { new Integer(45), new Integer(0), new Integer(-102),
044: new Integer(Integer.MAX_VALUE) },
045: { new Integer(34), new Integer(566), new Integer(766),
046: new Integer(Integer.MIN_VALUE) },
047: { new Integer(103), new Integer(3498), new Integer(-1202),
048: new Integer(-12039) } };
049:
050: double[] numcolumns = { Double.MIN_VALUE, Double.MAX_VALUE,
051: Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY };
052:
053: double[] columns = { 1.0, Double.MIN_VALUE, Double.MAX_VALUE,
054: Double.POSITIVE_INFINITY, Double.NEGATIVE_INFINITY, 0.0,
055: -20.0, 9458.340 };
056:
057: Object[] objcolumns = { new Double(Double.MIN_VALUE),
058: new Double(Double.MAX_VALUE),
059: new Double(Double.POSITIVE_INFINITY),
060: new Double(Double.NEGATIVE_INFINITY) };
061:
062: String[] strcolumns = { "1.0", "" + Double.MIN_VALUE,
063: "" + Double.MAX_VALUE, "" + Double.POSITIVE_INFINITY,
064: "" + Double.NEGATIVE_INFINITY, "" + 0.0, "" + -20.0,
065: "" + 9458.340 };
066:
067: /** Creates new TestChartDataModel */
068: public TestChartDataModel() {
069: //DefaultChartDataModel model;
070: ObjectChartDataModel model;
071:
072: // Create Empty DefaultChartDataModel
073: //model = new DefaultChartDataModel();
074: model = new ObjectChartDataModel();
075: System.out.println("** Teste leeres Modell");
076: testDefaultChartDataModel(model);
077:
078: // Create Number[][] DefaultChartDataModel
079: //model = new DefaultChartDataModel(numval, numcolumns);
080: model = new ObjectChartDataModel(numval, objcolumns,
081: new String[] { "1", "2", "3", "4" });
082: System.out.println("** Teste Modell mit Number[][]");
083:
084: testDefaultChartDataModel(model);
085:
086: // Create int[][] DefaultChartDataModel
087: //model = new DefaultChartDataModel(intval, columns);
088: model = new ObjectChartDataModel(intval, strcolumns,
089: new String[] { "1", "2", "3", "4" });
090: System.out.println("** Teste Modell mit int[][]");
091: testDefaultChartDataModel(model);
092:
093: }
094:
095: public void testDefaultChartDataModel(DefaultChartDataModel m) {
096: try {
097: System.out.println("** AxisBinding von DataSet 0 = "
098: + m.getAxisBinding(0));
099: } catch (Exception e) {
100: System.out.println("** Fehler");
101: }
102:
103: try {
104: System.out.println("** ColumnValue At index 3 = "
105: + m.getColumnValueAt(3));
106: } catch (Exception e) {
107: System.out.println("** Fehler");
108: }
109:
110: try {
111: System.out.println("** ColumnValue At index 7 = "
112: + m.getColumnValueAt(7));
113: } catch (Exception e) {
114: System.out.println("** Fehler");
115: }
116:
117: try {
118: System.out.println("** Länge von DataSet 2 = "
119: + m.getDataSetLength(2));
120: } catch (Exception e) {
121: System.out.println("** Fehler");
122: }
123: try {
124: System.out.println("** Anzahl von DataSets = "
125: + m.getDataSetNumber());
126: } catch (Exception e) {
127: System.out.println("** Fehler");
128: }
129: try {
130: System.out.println("** Wert an Index 0,7 = "
131: + m.getValueAt(0, 7));
132: } catch (Exception e) {
133: System.out.println("** Fehler");
134: }
135: try {
136: System.out.println("** Wert an Index 2,2 = "
137: + m.getValueAt(2, 2));
138: } catch (Exception e) {
139: System.out.println("** Fehler");
140: }
141:
142: ChartDataModelConstraints con;
143:
144: try {
145: System.out
146: .println("** Lade ChartDataModelConstraints für CoordSystem.SECOND_YAXIS");
147: con = m
148: .getChartDataModelConstraints(CoordSystem.SECOND_YAXIS);
149: } catch (Exception e) {
150: System.out.println("** Fehler");
151: return;
152: }
153:
154: try {
155: System.out.println("** Kleinster Wert = "
156: + con.getMinimumValue());
157: } catch (Exception e) {
158: System.out.println("** Fehler");
159: }
160:
161: try {
162: System.out.println("** Größter Wert = "
163: + con.getMaximumValue());
164: } catch (Exception e) {
165: System.out.println("** Fehler");
166: }
167:
168: try {
169: System.out.println("** Kleinster Column Wert = "
170: + con.getMinimumColumnValue());
171: } catch (Exception e) {
172: System.out.println("** Fehler");
173: }
174:
175: try {
176: System.out.println("** Größter Column Wert = "
177: + con.getMaximumColumnValue());
178: } catch (Exception e) {
179: System.out.println("** Fehler");
180: }
181: }
182:
183: public void testDefaultChartDataModel(ObjectChartDataModel m) {
184: try {
185: System.out.println("** AxisBinding von DataSet 0 = "
186: + m.getAxisBinding(0));
187: } catch (Exception e) {
188: System.out.println("** Fehler");
189: }
190:
191: try {
192: System.out.println("** ColumnValue At index 3 = "
193: + m.getColumnValueAt(3));
194: } catch (Exception e) {
195: System.out.println("** Fehler");
196: }
197:
198: try {
199: System.out.println("** ColumnValue At index 7 = "
200: + m.getColumnValueAt(7));
201: } catch (Exception e) {
202: System.out.println("** Fehler");
203: }
204:
205: try {
206: System.out.println("** Länge von DataSet 2 = "
207: + m.getDataSetLength(2));
208: } catch (Exception e) {
209: System.out.println("** Fehler");
210: }
211: try {
212: System.out.println("** Anzahl von DataSets = "
213: + m.getDataSetNumber());
214: } catch (Exception e) {
215: System.out.println("** Fehler");
216: }
217: try {
218: System.out.println("** Wert an Index 0,7 = "
219: + m.getValueAt(0, 7));
220: } catch (Exception e) {
221: System.out.println("** Fehler");
222: }
223: try {
224: System.out.println("** Wert an Index 2,2 = "
225: + m.getValueAt(2, 2));
226: } catch (Exception e) {
227: System.out.println("** Fehler");
228: }
229:
230: ChartDataModelConstraints con;
231:
232: try {
233: System.out
234: .println("** Lade ChartDataModelConstraints für CoordSystem.SECOND_YAXIS");
235: con = m
236: .getChartDataModelConstraints(CoordSystem.SECOND_YAXIS);
237: } catch (Exception e) {
238: System.out.println("** Fehler");
239: return;
240: }
241:
242: try {
243: System.out.println("** Kleinster Wert = "
244: + con.getMinimumValue());
245: } catch (Exception e) {
246: System.out.println("** Fehler");
247: }
248:
249: try {
250: System.out.println("** Größter Wert = "
251: + con.getMaximumValue());
252: } catch (Exception e) {
253: System.out.println("** Fehler");
254: }
255:
256: try {
257: System.out.println("** Kleinster Column Wert = "
258: + con.getMinimumColumnValue());
259: } catch (Exception e) {
260: System.out.println("** Fehler");
261: }
262:
263: try {
264: System.out.println("** Größter Column Wert = "
265: + con.getMaximumColumnValue());
266: } catch (Exception e) {
267: System.out.println("** Fehler");
268: }
269: }
270:
271: /**
272: * @param args the command line arguments
273: */
274: public static void main(String args[]) {
275: new TestChartDataModel();
276: }
277:
278: }
|