comparison artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java @ 6364:eec895f6ec80 3.0.8

Fixed y axis label generation in sedimentload generator.
author Raimund Renkert <rrenkert@intevation.de>
date Tue, 18 Jun 2013 13:53:58 +0200
parents 682a73729fda
children a8a97f27ca27
comparison
equal deleted inserted replaced
6363:abed7e091762 6364:eec895f6ec80
15 import org.w3c.dom.Document; 15 import org.w3c.dom.Document;
16 16
17 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; 17 import org.dive4elements.artifactdatabase.state.ArtifactAndFacet;
18 import org.dive4elements.artifactdatabase.state.Facet; 18 import org.dive4elements.artifactdatabase.state.Facet;
19 import org.dive4elements.river.artifacts.D4EArtifact; 19 import org.dive4elements.river.artifacts.D4EArtifact;
20 import org.dive4elements.river.artifacts.MINFOArtifact;
21 import org.dive4elements.river.artifacts.access.RangeAccess; 20 import org.dive4elements.river.artifacts.access.RangeAccess;
22 import org.dive4elements.river.artifacts.access.SedimentLoadAccess; 21 import org.dive4elements.river.artifacts.access.SedimentLoadAccess;
23 import org.dive4elements.river.artifacts.model.FacetTypes; 22 import org.dive4elements.river.artifacts.model.FacetTypes;
24 import org.dive4elements.river.artifacts.model.FlowVelocityData; 23 import org.dive4elements.river.artifacts.model.FlowVelocityData;
25 import org.dive4elements.river.artifacts.model.WKms; 24 import org.dive4elements.river.artifacts.model.WKms;
69 public static final String I18N_YAXIS_LABEL_DEFAULT_1 = "[t/a]"; 68 public static final String I18N_YAXIS_LABEL_DEFAULT_1 = "[t/a]";
70 public static final String I18N_YAXIS_LABEL_DEFAULT_2 = "[m\u00b3/a]"; 69 public static final String I18N_YAXIS_LABEL_DEFAULT_2 = "[m\u00b3/a]";
71 public static final String I18N_YAXIS_D_LABEL_DEFAULT = "delta S [m]"; 70 public static final String I18N_YAXIS_D_LABEL_DEFAULT = "delta S [m]";
72 public static final String I18N_YAXIS_V_LABEL_DEFAULT = "Geschwindigkeit v [m/s]"; 71 public static final String I18N_YAXIS_V_LABEL_DEFAULT = "Geschwindigkeit v [m/s]";
73 72
74 private D4EArtifact artifact; 73 private String yLabel = "";
75 74
76 @Override 75 @Override
77 protected YAxisWalker getYAxisWalker() { 76 protected YAxisWalker getYAxisWalker() {
78 return new YAxisWalker() { 77 return new YAxisWalker() {
79 78
100 logger.error("No facet name for doOut(). No output generated!"); 99 logger.error("No facet name for doOut(). No output generated!");
101 return; 100 return;
102 } 101 }
103 102
104 Facet facet = bundle.getFacet(); 103 Facet facet = bundle.getFacet();
105 artifact = (D4EArtifact)bundle.getArtifact(); 104 D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
106 105
106 SedimentLoadAccess slaccess = new SedimentLoadAccess(artifact);
107 String unit = slaccess.getUnit();
108 if (unit != null && unit.equals("m3_per_a")) {
109 yLabel = msg(I18N_YAXIS_LABEL_2, I18N_YAXIS_LABEL_DEFAULT_2);
110 }
111 else {
112 yLabel = msg(I18N_YAXIS_LABEL_1, I18N_YAXIS_LABEL_DEFAULT_1);
113 }
107 if (facet == null) { 114 if (facet == null) {
108 return; 115 return;
109 } 116 }
110 if (getXBounds(0) != null && getDomainAxisRange() != null) { 117 if (getXBounds(0) != null && getDomainAxisRange() != null) {
111 logger.debug(Arrays.toString(getDomainAxisRangeFromRequest())); 118 logger.debug(Arrays.toString(getDomainAxisRangeFromRequest()));
117 else if (getXBounds(0) != null && getDomainAxisRange() == null) { 124 else if (getXBounds(0) != null && getDomainAxisRange() == null) {
118 context.putContextValue("startkm", getXBounds(0).getLower()); 125 context.putContextValue("startkm", getXBounds(0).getLower());
119 context.putContextValue("endkm", getXBounds(0).getUpper()); 126 context.putContextValue("endkm", getXBounds(0).getUpper());
120 } 127 }
121 else if (getXBounds(0) == null && getDomainAxisRange() == null) { 128 else if (getXBounds(0) == null && getDomainAxisRange() == null) {
122 D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
123 RangeAccess access = new RangeAccess(artifact); 129 RangeAccess access = new RangeAccess(artifact);
124 context.putContextValue("startkm", access.getFrom()); 130 context.putContextValue("startkm", access.getFrom());
125 context.putContextValue("endkm", access.getTo()); 131 context.putContextValue("endkm", access.getTo());
126 } 132 }
127 else if (getXBounds(0) == null && getDomainAxisRange() != null){ 133 else if (getXBounds(0) == null && getDomainAxisRange() != null){
128 D4EArtifact artifact = (D4EArtifact)bundle.getArtifact();
129 RangeAccess access = new RangeAccess(artifact); 134 RangeAccess access = new RangeAccess(artifact);
130 Bounds b = new DoubleBounds(access.getFrom(), access.getTo()); 135 Bounds b = new DoubleBounds(access.getFrom(), access.getTo());
131 Bounds bounds = 136 Bounds bounds =
132 calculateZoom(b, getDomainAxisRange()); 137 calculateZoom(b, getDomainAxisRange());
133 context.putContextValue("startkm", bounds.getLower()); 138 context.putContextValue("startkm", bounds.getLower());
224 } 229 }
225 230
226 @Override 231 @Override
227 protected String getDefaultYAxisLabel(int pos) { 232 protected String getDefaultYAxisLabel(int pos) {
228 String label = "default"; 233 String label = "default";
229 if (pos == YAXIS.L.idx && artifact instanceof MINFOArtifact) { 234 if (pos == YAXIS.L.idx) {
230 SedimentLoadAccess access = new SedimentLoadAccess(artifact); 235 label = yLabel;
231 if (access.getUnit().equals("m3_per_a")) {
232 label = msg(I18N_YAXIS_LABEL_2, I18N_YAXIS_LABEL_DEFAULT_2);
233 }
234 else {
235 label = msg(I18N_YAXIS_LABEL_1, I18N_YAXIS_LABEL_DEFAULT_1);
236 }
237 } 236 }
238 else if (pos == YAXIS.V.idx) { 237 else if (pos == YAXIS.V.idx) {
239 label = msg(I18N_YAXIS_V_LABEL, I18N_YAXIS_V_LABEL_DEFAULT); 238 label = msg(I18N_YAXIS_V_LABEL, I18N_YAXIS_V_LABEL_DEFAULT);
240 } 239 }
241 else if (pos == YAXIS.D.idx) { 240 else if (pos == YAXIS.D.idx) {

http://dive4elements.wald.intevation.org