comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java @ 719:035c0095b427

Draw correction curve again. flys-artifacts/trunk@2193 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Sascha L. Teichmann <sascha.teichmann@intevation.de>
date Tue, 21 Jun 2011 21:41:49 +0000
parents 45cd58a2a2bb
children 61c051e53f9b
comparison
equal deleted inserted replaced
718:f3fd8c9b7f51 719:035c0095b427
6 import javax.xml.xpath.XPathConstants; 6 import javax.xml.xpath.XPathConstants;
7 7
8 import org.apache.log4j.Logger; 8 import org.apache.log4j.Logger;
9 9
10 import org.w3c.dom.Document; 10 import org.w3c.dom.Document;
11 import org.w3c.dom.Node; 11 import org.w3c.dom.Element;
12 12
13 import org.jfree.data.Range; 13 import org.jfree.data.Range;
14 14
15 import de.intevation.artifacts.Artifact; 15 import de.intevation.artifacts.Artifact;
16 import de.intevation.artifacts.CallContext; 16 import de.intevation.artifacts.CallContext;
115 * getDefaultSize() if no width or height are given in the request document. 115 * getDefaultSize() if no width or height are given in the request document.
116 */ 116 */
117 protected int[] getSize() { 117 protected int[] getSize() {
118 int[] size = new int[2]; 118 int[] size = new int[2];
119 119
120 Node sizeEl = (Node) XMLUtils.xpath( 120 Element sizeEl = (Element)XMLUtils.xpath(
121 request, 121 request,
122 XPATH_CHART_SIZE, 122 XPATH_CHART_SIZE,
123 XPathConstants.NODE, 123 XPathConstants.NODE,
124 ArtifactNamespaceContext.INSTANCE); 124 ArtifactNamespaceContext.INSTANCE);
125 125
126 if (sizeEl != null) { 126 if (sizeEl != null) {
127 String w = XMLUtils.xpathString( 127 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
128 sizeEl, "@art:width", ArtifactNamespaceContext.INSTANCE); 128
129 129 String w = sizeEl.getAttributeNS(uri, "width");
130 String h = XMLUtils.xpathString( 130 String h = sizeEl.getAttributeNS(uri, "height");
131 sizeEl, "@art:height", ArtifactNamespaceContext.INSTANCE); 131
132 132 if (w.length() > 0 && h.length() > 0) {
133 if (w != null && w.length() > 0 && h != null && h.length() > 0) {
134 try { 133 try {
135 size[0] = Integer.parseInt(w); 134 size[0] = Integer.parseInt(w);
136 size[1] = Integer.parseInt(h); 135 size[1] = Integer.parseInt(h);
137 } 136 }
138 catch (NumberFormatException nfe) { 137 catch (NumberFormatException nfe) {
144 return size[0] > 0 && size[1] > 0 ? size : getDefaultSize(); 143 return size[0] > 0 && size[1] > 0 ? size : getDefaultSize();
145 } 144 }
146 145
147 146
148 protected Range getDomainAxisRange() { 147 protected Range getDomainAxisRange() {
149 Node xrange = (Node) XMLUtils.xpath( 148 Element xrange = (Element)XMLUtils.xpath(
150 request, 149 request,
151 XPATH_CHART_X_RANGE, 150 XPATH_CHART_X_RANGE,
152 XPathConstants.NODE, 151 XPathConstants.NODE,
153 ArtifactNamespaceContext.INSTANCE); 152 ArtifactNamespaceContext.INSTANCE);
154 153
155 if (xrange == null) { 154 if (xrange == null) {
156 return null; 155 return null;
157 } 156 }
158 157
159 String lower = XMLUtils.xpathString( 158 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
160 xrange, "@art:from", ArtifactNamespaceContext.INSTANCE); 159
161 160 String lower = xrange.getAttributeNS(uri, "from");
162 String upper = XMLUtils.xpathString( 161 String upper = xrange.getAttributeNS(uri, "to");
163 xrange, "@art:to", ArtifactNamespaceContext.INSTANCE);
164 162
165 logger.debug("FOUND X RANGE: " + lower + " -> " + upper); 163 logger.debug("FOUND X RANGE: " + lower + " -> " + upper);
166 164
167 if (lower != null && upper != null) { 165 if (lower.length() > 0 && upper.length() > 0) {
168 try { 166 try {
169 double from = Double.parseDouble(lower); 167 double from = Double.parseDouble(lower);
170 double to = Double.parseDouble(upper); 168 double to = Double.parseDouble(upper);
171 169
172 if (from == 0 && to == 0) { 170 if (from == 0 && to == 0) {
190 return null; 188 return null;
191 } 189 }
192 190
193 191
194 protected Range getValueAxisRange() { 192 protected Range getValueAxisRange() {
195 Node yrange = (Node) XMLUtils.xpath( 193 Element yrange = (Element)XMLUtils.xpath(
196 request, 194 request,
197 XPATH_CHART_Y_RANGE, 195 XPATH_CHART_Y_RANGE,
198 XPathConstants.NODE, 196 XPathConstants.NODE,
199 ArtifactNamespaceContext.INSTANCE); 197 ArtifactNamespaceContext.INSTANCE);
200 198
201 if (yrange == null) { 199 if (yrange == null) {
202 return null; 200 return null;
203 } 201 }
204 202
205 String lower = XMLUtils.xpathString( 203 String uri = ArtifactNamespaceContext.NAMESPACE_URI;
206 yrange, "@art:from", ArtifactNamespaceContext.INSTANCE); 204
207 205 String lower = yrange.getAttributeNS(uri, "from");
208 String upper = XMLUtils.xpathString( 206 String upper = yrange.getAttributeNS(uri, "to");
209 yrange, "@art:to", ArtifactNamespaceContext.INSTANCE); 207
210 208 if (lower.length() > 0 && upper.length() > 0) {
211 if (lower != null && upper != null) {
212 try { 209 try {
213 double from = Double.parseDouble(lower); 210 double from = Double.parseDouble(lower);
214 double to = Double.parseDouble(upper); 211 double to = Double.parseDouble(upper);
215 212
216 if (from == 0 && to == 0) { 213 if (from == 0 && to == 0) {

http://dive4elements.wald.intevation.org