Mercurial > dive4elements > river
comparison flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java @ 2398:5d8d24984819
New abstract methods in ChartGenerator and moved a method from ChartGenerator to XYChartGenerator.
flys-artifacts/trunk@4024 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 10 Feb 2012 10:24:33 +0000 |
parents | cd4fb19ab892 |
children | dce0cc856357 |
comparison
equal
deleted
inserted
replaced
2397:c38063bf99da | 2398:5d8d24984819 |
---|---|
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>. |
1025 | 1034 |
1026 return new String[] { lower, upper }; | 1035 return new String[] { lower, upper }; |
1027 } | 1036 } |
1028 | 1037 |
1029 | 1038 |
1030 protected Range getValueAxisRange() { | 1039 protected String[] getValueAxisRangeFromRequest() { |
1031 Element yrange = (Element)XMLUtils.xpath( | 1040 Element yrange = (Element)XMLUtils.xpath( |
1032 request, | 1041 request, |
1033 XPATH_CHART_Y_RANGE, | 1042 XPATH_CHART_Y_RANGE, |
1034 XPathConstants.NODE, | 1043 XPathConstants.NODE, |
1035 ArtifactNamespaceContext.INSTANCE); | 1044 ArtifactNamespaceContext.INSTANCE); |
1039 } | 1048 } |
1040 | 1049 |
1041 | 1050 |
1042 String uri = ArtifactNamespaceContext.NAMESPACE_URI; | 1051 String uri = ArtifactNamespaceContext.NAMESPACE_URI; |
1043 | 1052 |
1044 | |
1045 String lower = yrange.getAttributeNS(uri, "from"); | 1053 String lower = yrange.getAttributeNS(uri, "from"); |
1046 String upper = yrange.getAttributeNS(uri, "to"); | 1054 String upper = yrange.getAttributeNS(uri, "to"); |
1047 | 1055 |
1048 if (lower.length() > 0 && upper.length() > 0) { | 1056 return new String[] { lower, upper }; |
1049 try { | |
1050 double from = Double.parseDouble(lower); | |
1051 double to = Double.parseDouble(upper); | |
1052 | |
1053 if (from == 0 && to == 0) { | |
1054 logger.debug("No range specified. Lower and upper Y == 0"); | |
1055 return null; | |
1056 } | |
1057 | |
1058 return from > to | |
1059 ? new Range(to, from) | |
1060 : new Range(from, to); | |
1061 } | |
1062 catch (NumberFormatException nfe) { | |
1063 logger.warn("Wrong values for value axis range."); | |
1064 } | |
1065 } | |
1066 | |
1067 return null; | |
1068 } | 1057 } |
1069 | 1058 |
1070 | 1059 |
1071 /** | 1060 /** |
1072 * Returns the default size of a chart export as array. | 1061 * Returns the default size of a chart export as array. |