Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java @ 2330:594885703687
Picked changes r4015:4026 from trunk.
flys-artifacts/tags/2.6@4028 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 10 Feb 2012 11:18:27 +0000 |
parents | 991e4a5df323 |
children | 2f6d4f92d628 |
comparison
equal
deleted
inserted
replaced
2329:d999062c20e6 | 2330:594885703687 |
---|---|
47 | 47 |
48 import de.intevation.flys.model.River; | 48 import de.intevation.flys.model.River; |
49 | 49 |
50 import de.intevation.flys.artifacts.FLYSArtifact; | 50 import de.intevation.flys.artifacts.FLYSArtifact; |
51 import de.intevation.flys.artifacts.resources.Resources; | 51 import de.intevation.flys.artifacts.resources.Resources; |
52 import de.intevation.flys.jfree.Bounds; | |
52 import de.intevation.flys.jfree.EnhancedLineAndShapeRenderer; | 53 import de.intevation.flys.jfree.EnhancedLineAndShapeRenderer; |
53 import de.intevation.flys.jfree.StableXYDifferenceRenderer; | 54 import de.intevation.flys.jfree.StableXYDifferenceRenderer; |
54 import de.intevation.flys.jfree.StyledAreaSeriesCollection; | 55 import de.intevation.flys.jfree.StyledAreaSeriesCollection; |
55 import de.intevation.flys.jfree.Style; | 56 import de.intevation.flys.jfree.Style; |
56 import de.intevation.flys.jfree.StyledSeries; | 57 import de.intevation.flys.jfree.StyledSeries; |
245 * @param index The index of the axes at the plot. | 246 * @param index The index of the axes at the plot. |
246 * | 247 * |
247 * @return a Range[] with [xrange, yrange]; | 248 * @return a Range[] with [xrange, yrange]; |
248 */ | 249 */ |
249 public abstract Range[] getRangesForAxis(int index); | 250 public abstract Range[] getRangesForAxis(int index); |
251 | |
252 public abstract Bounds getXBounds(int axis); | |
253 | |
254 protected abstract void setXBounds(int axis, Bounds bounds); | |
255 | |
256 public abstract Bounds getYBounds(int axis); | |
257 | |
258 protected abstract void setYBounds(int axis, Bounds bounds); | |
250 | 259 |
251 | 260 |
252 /** | 261 /** |
253 * This method should be used by concrete subclasses to add subtitle to | 262 * This method should be used by concrete subclasses to add subtitle to |
254 * <i>chart</i>. <b>The method in this implementation is empty</b>. | 263 * <i>chart</i>. <b>The method in this implementation is empty</b>. |
1001 : format; | 1010 : format; |
1002 } | 1011 } |
1003 | 1012 |
1004 | 1013 |
1005 /** | 1014 /** |
1006 * Get Range of Domain ("X"-) Axis from request. | 1015 * Returns the X-Axis range as String array from request document. |
1007 */ | 1016 * |
1008 protected Range getDomainAxisRange() { | 1017 * @return a String array with [lower, upper]. |
1018 */ | |
1019 protected String[] getDomainAxisRangeFromRequest() { | |
1009 Element xrange = (Element)XMLUtils.xpath( | 1020 Element xrange = (Element)XMLUtils.xpath( |
1010 request, | 1021 request, |
1011 XPATH_CHART_X_RANGE, | 1022 XPATH_CHART_X_RANGE, |
1012 XPathConstants.NODE, | 1023 XPathConstants.NODE, |
1013 ArtifactNamespaceContext.INSTANCE); | 1024 ArtifactNamespaceContext.INSTANCE); |
1019 String uri = ArtifactNamespaceContext.NAMESPACE_URI; | 1030 String uri = ArtifactNamespaceContext.NAMESPACE_URI; |
1020 | 1031 |
1021 String lower = xrange.getAttributeNS(uri, "from"); | 1032 String lower = xrange.getAttributeNS(uri, "from"); |
1022 String upper = xrange.getAttributeNS(uri, "to"); | 1033 String upper = xrange.getAttributeNS(uri, "to"); |
1023 | 1034 |
1024 if (lower.length() > 0 && upper.length() > 0) { | 1035 return new String[] { lower, upper }; |
1025 try { | 1036 } |
1026 double from = Double.parseDouble(lower); | 1037 |
1027 double to = Double.parseDouble(upper); | 1038 |
1028 | 1039 protected String[] getValueAxisRangeFromRequest() { |
1029 if (from == 0 && to == 0) { | |
1030 logger.debug("No range specified. Lower and upper X == 0"); | |
1031 return null; | |
1032 } | |
1033 | |
1034 if (from > to) { | |
1035 double tmp = to; | |
1036 to = from; | |
1037 from = tmp; | |
1038 } | |
1039 | |
1040 return new Range(from, to); | |
1041 } | |
1042 catch (NumberFormatException nfe) { | |
1043 logger.warn("Wrong values for domain axis range."); | |
1044 } | |
1045 } | |
1046 | |
1047 return null; | |
1048 } | |
1049 | |
1050 | |
1051 protected Range getValueAxisRange() { | |
1052 Element yrange = (Element)XMLUtils.xpath( | 1040 Element yrange = (Element)XMLUtils.xpath( |
1053 request, | 1041 request, |
1054 XPATH_CHART_Y_RANGE, | 1042 XPATH_CHART_Y_RANGE, |
1055 XPathConstants.NODE, | 1043 XPathConstants.NODE, |
1056 ArtifactNamespaceContext.INSTANCE); | 1044 ArtifactNamespaceContext.INSTANCE); |
1060 } | 1048 } |
1061 | 1049 |
1062 | 1050 |
1063 String uri = ArtifactNamespaceContext.NAMESPACE_URI; | 1051 String uri = ArtifactNamespaceContext.NAMESPACE_URI; |
1064 | 1052 |
1065 | |
1066 String lower = yrange.getAttributeNS(uri, "from"); | 1053 String lower = yrange.getAttributeNS(uri, "from"); |
1067 String upper = yrange.getAttributeNS(uri, "to"); | 1054 String upper = yrange.getAttributeNS(uri, "to"); |
1068 | 1055 |
1069 if (lower.length() > 0 && upper.length() > 0) { | 1056 return new String[] { lower, upper }; |
1070 try { | |
1071 double from = Double.parseDouble(lower); | |
1072 double to = Double.parseDouble(upper); | |
1073 | |
1074 if (from == 0 && to == 0) { | |
1075 logger.debug("No range specified. Lower and upper Y == 0"); | |
1076 return null; | |
1077 } | |
1078 | |
1079 return from > to | |
1080 ? new Range(to, from) | |
1081 : new Range(from, to); | |
1082 } | |
1083 catch (NumberFormatException nfe) { | |
1084 logger.warn("Wrong values for value axis range."); | |
1085 } | |
1086 } | |
1087 | |
1088 return null; | |
1089 } | 1057 } |
1090 | 1058 |
1091 | 1059 |
1092 /** | 1060 /** |
1093 * Returns the default size of a chart export as array. | 1061 * Returns the default size of a chart export as array. |