# HG changeset patch # User Raimund Renkert # Date 1371556438 -7200 # Node ID eec895f6ec801a7faaed96e9f01721e1143e7bb8 # Parent abed7e0917620a045758bdc0affadf5d129acec3 Fixed y axis label generation in sedimentload generator. diff -r abed7e091762 -r eec895f6ec80 artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java --- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java Tue Jun 18 13:25:52 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/SedimentLoadLSGenerator.java Tue Jun 18 13:53:58 2013 +0200 @@ -17,7 +17,6 @@ import org.dive4elements.artifactdatabase.state.ArtifactAndFacet; import org.dive4elements.artifactdatabase.state.Facet; import org.dive4elements.river.artifacts.D4EArtifact; -import org.dive4elements.river.artifacts.MINFOArtifact; import org.dive4elements.river.artifacts.access.RangeAccess; import org.dive4elements.river.artifacts.access.SedimentLoadAccess; import org.dive4elements.river.artifacts.model.FacetTypes; @@ -71,7 +70,7 @@ public static final String I18N_YAXIS_D_LABEL_DEFAULT = "delta S [m]"; public static final String I18N_YAXIS_V_LABEL_DEFAULT = "Geschwindigkeit v [m/s]"; - private D4EArtifact artifact; + private String yLabel = ""; @Override protected YAxisWalker getYAxisWalker() { @@ -102,8 +101,16 @@ } Facet facet = bundle.getFacet(); - artifact = (D4EArtifact)bundle.getArtifact(); + D4EArtifact artifact = (D4EArtifact)bundle.getArtifact(); + SedimentLoadAccess slaccess = new SedimentLoadAccess(artifact); + String unit = slaccess.getUnit(); + if (unit != null && unit.equals("m3_per_a")) { + yLabel = msg(I18N_YAXIS_LABEL_2, I18N_YAXIS_LABEL_DEFAULT_2); + } + else { + yLabel = msg(I18N_YAXIS_LABEL_1, I18N_YAXIS_LABEL_DEFAULT_1); + } if (facet == null) { return; } @@ -119,13 +126,11 @@ context.putContextValue("endkm", getXBounds(0).getUpper()); } else if (getXBounds(0) == null && getDomainAxisRange() == null) { - D4EArtifact artifact = (D4EArtifact)bundle.getArtifact(); RangeAccess access = new RangeAccess(artifact); context.putContextValue("startkm", access.getFrom()); context.putContextValue("endkm", access.getTo()); } else if (getXBounds(0) == null && getDomainAxisRange() != null){ - D4EArtifact artifact = (D4EArtifact)bundle.getArtifact(); RangeAccess access = new RangeAccess(artifact); Bounds b = new DoubleBounds(access.getFrom(), access.getTo()); Bounds bounds = @@ -226,14 +231,8 @@ @Override protected String getDefaultYAxisLabel(int pos) { String label = "default"; - if (pos == YAXIS.L.idx && artifact instanceof MINFOArtifact) { - SedimentLoadAccess access = new SedimentLoadAccess(artifact); - if (access.getUnit().equals("m3_per_a")) { - label = msg(I18N_YAXIS_LABEL_2, I18N_YAXIS_LABEL_DEFAULT_2); - } - else { - label = msg(I18N_YAXIS_LABEL_1, I18N_YAXIS_LABEL_DEFAULT_1); - } + if (pos == YAXIS.L.idx) { + label = yLabel; } else if (pos == YAXIS.V.idx) { label = msg(I18N_YAXIS_V_LABEL, I18N_YAXIS_V_LABEL_DEFAULT);