SSJ API Documentation
Stochastic Simulation in Java
Loading...
Searching...
No Matches
YListSeriesCollection.java
1/*
2 * Class: YListSeriesCollection
3 * Description: Lists of y-coordinates of charts
4 * Environment: Java
5 * Software: SSJ
6 * Copyright (C) 2001 Pierre L'Ecuyer and Universite de Montreal
7 * Organization: DIRO, Universite de Montreal
8 * @author
9 * @since
10 *
11 *
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
23 *
24 */
25package umontreal.ssj.charts;
26
27import org.jfree.data.xy.XYSeries;
28import org.jfree.data.xy.XYSeriesCollection;
29import org.jfree.chart.renderer.xy.XYLineAndShapeRenderer;
30
39
40 private void initYListSeries(double h, double[] data, int numPoints) {
41 renderer = new XYLineAndShapeRenderer(true, false);
42 seriesCollection = new XYSeriesCollection();
43
44 XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection;
45 XYSeries serie = new XYSeries(" ");
46 for (int j = 0; j < numPoints; j++)
47 serie.add(h * (j + 1), data[j]);
48 tempSeriesCollection.addSeries(serie);
49
50 // set default colors
51 renderer.setSeriesPaint(0, getDefaultColor(0));
52
53 // set default plot style
54 plotStyle = new String[1];
55 marksType = new String[1];
56 dashPattern = new String[1];
57 marksType[0] = " ";
58 plotStyle[0] = "smooth";
59 dashPattern[0] = "solid";
60 }
61
62 private void initYListSeries(boolean flag, double[]... data) {
63 // if flag = true, h = 1; else h = 1/numPoints
64 double h;
65 renderer = new XYLineAndShapeRenderer(true, false);
66 seriesCollection = new XYSeriesCollection();
67
68 XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection;
69 for (int i = 0; i < data.length; i++) {
70 XYSeries serie = new XYSeries(" ");
71 if (flag)
72 h = 1;
73 else
74 h = 1.0 / data[i].length;
75 for (int j = 0; j < data[i].length; j++)
76 serie.add(h * (j + 1), data[i][j]);
77 tempSeriesCollection.addSeries(serie);
78 }
79
80 final int s = tempSeriesCollection.getSeriesCount();
81
82 // set default colors
83 for (int i = 0; i < s; i++) {
84 renderer.setSeriesPaint(i, getDefaultColor(i));
85 }
86
87 // set default plot style
88 plotStyle = new String[s];
89 marksType = new String[s];
90 dashPattern = new String[s];
91 for (int i = 0; i < s; i++) {
92 marksType[i] = " ";
93 plotStyle[i] = "smooth";
94 dashPattern[i] = "solid";
95 }
96 // dashPattern[s-1] = "dashed"; // for the line y = x
97 }
98
110 public YListSeriesCollection(double[]... data) {
111 initYListSeries(true, data);
112 }
113
124 public YListSeriesCollection(boolean flag, double[]... data) {
125 initYListSeries(flag, data);
126 }
127
141 public YListSeriesCollection(double[] data, int numPoints) {
142 initYListSeries(1, data, numPoints);
143 }
144
155 public YListSeriesCollection(double h, double[] data, int numPoints) {
156 initYListSeries(h, data, numPoints);
157 }
158
173 public YListSeriesCollection(double[][] data, int numPoints) {
174 renderer = new XYLineAndShapeRenderer(true, false);
175 seriesCollection = new XYSeriesCollection();
176
177 XYSeriesCollection tempSeriesCollection = (XYSeriesCollection) seriesCollection;
178 for (int i = 0; i < data.length; i++) {
179 XYSeries serie = new XYSeries(" ");
180 for (int j = 0; j < numPoints; j++)
181 serie.add(j + 1, data[i][j]);
182 tempSeriesCollection.addSeries(serie);
183 }
184
185 final int s = tempSeriesCollection.getSeriesCount();
186
187 // set default colors
188 for (int i = 0; i < s; i++) {
189 renderer.setSeriesPaint(i, getDefaultColor(i));
190 }
191
192 // set default plot style
193 plotStyle = new String[s];
194 marksType = new String[s];
195 dashPattern = new String[s];
196 for (int i = 0; i < s; i++) {
197 marksType[i] = " ";
198 plotStyle[i] = "smooth";
199 dashPattern[i] = "solid";
200 }
201 }
202}
YListSeriesCollection(double h, double[] data, int numPoints)
Similar to the constructor YListSeriesCollection(data, numPoints) above, but the points are.
YListSeriesCollection(double[]... data)
Creates a new YListSeriesCollection instance with default parameters and given data series.
YListSeriesCollection(boolean flag, double[]... data)
Similar to the constructor YListSeriesCollection(data) above, except that if flag is true,...
YListSeriesCollection(double[] data, int numPoints)
Creates a new YListSeriesCollection instance with default parameters and one data series.
YListSeriesCollection(double[][] data, int numPoints)
Creates a new YListSeriesCollection instance with default parameters and given data series.
XYListSeriesCollection()
Stores data used in a XYLineChart or in other related charts, and provides complementary tools to dra...