Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/GaugeDischargeState.java @ 3051:49727e9dcfde
Polished Gauge Discharges in computed discharge curves.
flys-artifacts/trunk@4625 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Thu, 07 Jun 2012 20:47:17 +0000 |
parents | 89731cb8c385 |
children | bb576facbe50 |
line wrap: on
line diff
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/GaugeDischargeState.java Thu Jun 07 13:13:13 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/GaugeDischargeState.java Thu Jun 07 20:47:17 2012 +0000 @@ -23,6 +23,8 @@ import de.intevation.flys.artifacts.resources.Resources; import de.intevation.flys.utils.FLYSUtils; +import de.intevation.flys.model.Gauge; + /** * The only state for an GaugeDischargeState (River and km known). @@ -35,7 +37,33 @@ public static final String I18N_DESCRIPTION = "facet.discharge.curve"; /** The logger that is used in this state. */ - private static final Logger logger = Logger.getLogger(GaugeDischargeState.class); + private static final Logger logger = + Logger.getLogger(GaugeDischargeState.class); + + + /** + * Create i18ned name for gaugedischargeFacet. + * @param artifact The artifact which has information about the gauge. + * @param meta used for i18n. + * @return localized name for gaugedischargefacet. + */ + protected String createFacetName(GaugeDischargeArtifact artifact, + CallMeta meta) { + + Gauge gauge = artifact.getGauge(); + Object[] args = new Object[] { + gauge.getName(), + gauge.getStation() + }; + + String name = Resources.getMsg( + meta, + "chart.computed.discharge.curve.gauge", + "", + args); + + return name; + } /** @@ -59,20 +87,22 @@ ) { logger.debug("GaugeDischargeState.computeInit()"); - // TODO caching, / CalculationResultusage + // TODO caching, / CalculationResultUsage GaugeDischargeFacet facet = new GaugeDischargeFacet( 0, DISCHARGE_CURVE, - DISCHARGE_CURVE); - //Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION)); + createFacetName((GaugeDischargeArtifact) artifact, meta)); + facets.add(facet); return null; } - //WINFOArtifact#getDischargeCurveData + /** + * 'Calculate' Discharge at Gauge. + */ @Override public Object computeAdvance( FLYSArtifact artifact, @@ -81,8 +111,6 @@ List<Facet> facets, Object old ) { - // TODO why are the facets null here? - //if (facets == null) facets = new List<Facet>(); if (artifact instanceof GaugeDischargeArtifact) { logger.debug("GaugeDischargeState.computeAdvance()"); GaugeDischargeArtifact dischargeArtifact = (GaugeDischargeArtifact) artifact; @@ -100,33 +128,12 @@ if (wqkms != null && facets != null) { logger.debug("GaugeDischargeState.computeAdvance(): create facets"); - // Create an i18ed name for a (w or q) duration curve facet. - Object[] args = new Object[] { - FLYSUtils.getRiver(dischargeArtifact).getName(), - FLYSUtils.getLocations(dischargeArtifact)[0] - }; - String nameW = Resources.getMsg( - context.getMeta(), - "chart.duration.curve.curve.w", - "", - args); - - String nameQ = Resources.getMsg( - context.getMeta(), - "chart.duration.curve.curve.q", - "", - args); - - /*Facet w = new DurationCurveFacet(DURATION_W, nameW); - Facet q = new DurationCurveFacet(DURATION_Q, nameQ); - - facets.add(w);*/ GaugeDischargeFacet facet = new GaugeDischargeFacet( 0, - "A"+DISCHARGE_CURVE, - "A"+DISCHARGE_CURVE); - //Resources.getMsg(meta, I18N_DESCRIPTION, I18N_DESCRIPTION)); + DISCHARGE_CURVE, + createFacetName(dischargeArtifact, context.getMeta())); + facets.add(facet); //facets.add(new DataFacet(CSV, "CSV data")); @@ -138,9 +145,9 @@ } else { if (wqkms == null) - logger.debug("GaugeDischargeState.computeAdvance(): wqkms 0"); + logger.debug("GaugeDischargeState.computeAdvance(): wqkms 0"); else - logger.debug("GaugeDischargeState.computeAdvance(): facets 0"); + logger.debug("GaugeDischargeState.computeAdvance(): facets 0"); } return res; @@ -152,6 +159,5 @@ } return null; } - } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :