comparison gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChart.java @ 364:2413273f1c13

Workarround: Store lower and upper bounds of data while iterating over all data and set the max range of axes with these information. JFreeCharts method NumberAxis.setAutoRange(true) doesn't seem to work properly. gnv-artifacts/trunk@439 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 16 Dec 2009 11:58:44 +0000
parents 07a64cfafdf1
children 061355435075
comparison
equal deleted inserted replaced
363:22229249e9fc 364:2413273f1c13
54 this.locale = locale; 54 this.locale = locale;
55 this.PLOT_ORIENTATION = PlotOrientation.HORIZONTAL; 55 this.PLOT_ORIENTATION = PlotOrientation.HORIZONTAL;
56 this.linesVisible = linesVisible; 56 this.linesVisible = linesVisible;
57 this.shapesVisible = shapesVisible; 57 this.shapesVisible = shapesVisible;
58 this.datasets = new HashMap(); 58 this.datasets = new HashMap();
59 this.ranges = new HashMap();
59 } 60 }
60 61
61 62
62 protected void initData() { 63 protected void initData() {
63 log.debug("init data for VerticalProfileChart"); 64 log.debug("init data for VerticalProfileChart");
67 String breakPoint3 = null; 68 String breakPoint3 = null;
68 69
69 Iterator iter = resultSet.iterator(); 70 Iterator iter = resultSet.iterator();
70 Result row = null; 71 Result row = null;
71 String seriesName = null; 72 String seriesName = null;
73 String parameter = null;
72 XYSeries series = null; 74 XYSeries series = null;
73 75
74 int idx = 0; 76 int idx = 0;
75 int startPos = 0; 77 int startPos = 0;
76 int endPos = 0; 78 int endPos = 0;
90 ) { 92 ) {
91 log.debug("prepare data/plot for next dataset"); 93 log.debug("prepare data/plot for next dataset");
92 94
93 if(series != null) { 95 if(series != null) {
94 gapDetection(results, series, startPos, endPos); 96 gapDetection(results, series, startPos, endPos);
95 addSeries(series, seriesName, idx); 97 addSeries(series, parameter, idx);
96 98
97 startPos = endPos +1; 99 startPos = endPos +1;
98 } 100 }
99 101
100 // prepare variables for next plot 102 // prepare variables for next plot
105 seriesName = createSeriesName( 107 seriesName = createSeriesName(
106 breakPoint1, 108 breakPoint1,
107 breakPoint2, 109 breakPoint2,
108 breakPoint3 110 breakPoint3
109 ); 111 );
112 parameter = findParameter(seriesName);
110 113
111 log.debug("next dataset is '" + seriesName + "'"); 114 log.debug("next dataset is '" + seriesName + "'");
112 series = new XYSeries(seriesName); 115 series = new XYSeries(seriesName);
113 } 116 }
114 117
115 addValue(row, series); 118 addValue(row, series);
119 storeMaxRange(row.getDouble("YORDINATE"), parameter);
116 endPos++; 120 endPos++;
117 } 121 }
118 122
119 if (results.length == 0) 123 if (results.length == 0)
120 return; 124 return;
121 125
122 gapDetection(results, series, startPos, endPos); 126 gapDetection(results, series, startPos, endPos);
123 addSeries(series, seriesName, idx); 127 addSeries(series, parameter, idx);
124 128
125 addDatasets(); 129 addDatasets();
126 } 130 }
127 131
128 132
147 row.getDouble("YORDINATE") 151 row.getDouble("YORDINATE")
148 ); 152 );
149 } 153 }
150 154
151 155
152 protected void addSeries(Series series, String label, int idx) { 156 protected void addSeries(Series series, String parameter, int idx) {
153 log.debug("add series (" + label + ")to chart"); 157 log.debug("add series (" + parameter + ")to chart");
154 158
155 if (series == null) { 159 if (series == null) {
156 log.warn("no data to add"); 160 log.warn("no data to add");
157 return; 161 return;
158 } 162 }
159 163
160 XYSeriesCollection xysc = null; 164 XYSeriesCollection xysc = null;
161 String parameter = findParameter(label);
162 165
163 if (datasets.containsKey(parameter)) 166 if (datasets.containsKey(parameter))
164 xysc = (XYSeriesCollection) datasets.get(parameter); 167 xysc = (XYSeriesCollection) datasets.get(parameter);
165 else 168 else
166 xysc = new XYSeriesCollection(); 169 xysc = new XYSeriesCollection();

http://dive4elements.wald.intevation.org