Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java @ 696:708b270dfd30 facets-slt
OutGenerators use now facets to fetch necessary data.
flys-artifacts/branches/facets-slt@2140 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Fri, 17 Jun 2011 09:19:43 +0000 |
parents | 45cd58a2a2bb |
children | 035c0095b427 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java Thu Jun 16 14:31:41 2011 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DischargeLongitudinalSectionGenerator.java Fri Jun 17 09:19:43 2011 +0000 @@ -16,7 +16,7 @@ import de.intevation.artifactdatabase.state.Facet; -import de.intevation.flys.artifacts.WINFOArtifact; +import de.intevation.flys.artifacts.FLYSArtifact; import de.intevation.flys.artifacts.model.WQCKms; import de.intevation.flys.artifacts.model.WQKms; @@ -33,13 +33,6 @@ Logger.getLogger(DischargeLongitudinalSectionGenerator.class); - /** The facet for Ws.*/ - public static final String FACET_W = "discharge_longitudinal_section.w"; - - /** The facet for Qs.*/ - public static final String FACET_Q = "discharge_longitudinal_section.q"; - - /** The storage for the corrected W series to be drawn in this chart.*/ protected XYSeriesCollection cw; @@ -97,69 +90,27 @@ public void doOut(Artifact artifact, Facet facet, Document attr) { logger.debug("DischargeLongitudinalSectionGenerator.doOut"); - if (facet != null && facet.equals(FACET_W)) { - doWOut(getDischargeLongitudinalSectionData(artifact)); + String name = facet != null ? facet.getName() : null; + + FLYSArtifact flys = (FLYSArtifact) artifact; + Facet f = flys.getNativeFacet(facet); + + if (name != null && name.equals(DISCHARGE_LONGITUDINAL_W)) { + doWOut((WQKms) f.getData(artifact, context)); } - else if (facet != null && facet.equals(FACET_Q)) { - doQOut(getDischargeLongitudinalSectionData(artifact)); + else if (name != null && name.equals(DISCHARGE_LONGITUDINAL_Q)) { + doQOut((WQKms) f.getData(artifact, context)); + } + else if (name != null && name.equals(DISCHARGE_LONGITUDINAL_C)) { + doCorrectedWOut((WQCKms) f.getData(artifact, context)); } else { - logger.warn("Unknown facet name: " + facet); + logger.warn("Unknown facet name: " + name); return; } } - protected WQKms[] getDischargeLongitudinalSectionData(Artifact artifact) { - WINFOArtifact winfoArtifact = (WINFOArtifact) artifact; - return winfoArtifact.getDischargeLongitudinalSectionData(); - } - - - /** - * This method adds new Series for the wqkms objects. If there are instances - * of WQCKms in this array, there is a further curve that displays the - * corrected W values. - * - * @param wqkms An array of WQKms objects to be displayed. - */ - protected void doWOut(WQKms[] wqkms) { - logger.debug("LongitudinalSectionGenerator.doWOut"); - - int idx = 0; - for (WQKms tmp: wqkms) { - if (tmp instanceof WQCKms) { - doCorrectedWOut((WQCKms) tmp); - } - - doWOut(tmp); - } - } - - - /** - * Adds a new series for the W curve. - * - * @param wqkms The object that contains the W values. - */ - protected void doWOut(WQKms wqkms) { - logger.debug("DischargeLongitudinalSectionGenerator.doWOut"); - - XYSeries series = new XYSeries(getSeriesName(wqkms, "W")); - - double[] target = new double[4]; - int size = wqkms.size(); - - for (int i = 0; i < size; i++) { - target = wqkms.get(i, target); - - series.add(target[2], target[0]); - } - - w.addSeries(series); - } - - /** * Adds a new series for the corrected W curve. *