Mercurial > dive4elements > river
changeset 2215:ebbb18ed78c4
Added new classes and stubs used to calculate data for historical discharge curve charts.
flys-artifacts/trunk@3854 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Wed, 01 Feb 2012 11:14:24 +0000 |
parents | 4cd0eb2ebb3b |
children | 31fa7cae0f35 |
files | flys-artifacts/ChangeLog flys-artifacts/doc/conf/artifacts/winfo.xml flys-artifacts/doc/conf/conf.xml flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HistoricalDischargeFacet.java flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java |
diffstat | 9 files changed, 324 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Wed Feb 01 11:07:22 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Feb 01 11:14:24 2012 +0000 @@ -1,3 +1,31 @@ +2012-02-01 Ingo Weinzierl <ingo@intevation.de> + + * doc/conf/artifacts/winfo.xml: Registered new facet type + 'historical_discharge.historicalq' to the 'historical_discharge' output. + + * doc/conf/conf.xml: Registered new HistoricalDischargeCurveGenerator for + output type 'historical_discharge'. + + * src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: Added + new facet type for HISTORICAL_DISCHARGE_Q. + + * src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java: + New. This ChartGenerator is used to generate new charts for historical + discharge curves. WORK IN PROGRESS! + + * src/main/java/de/intevation/flys/artifacts/model/Calculation6.java: New. + This class should 'compute' the historical discharge curves. WORK IN + PROGRESS! + + * src/main/java/de/intevation/flys/artifacts/model/HistoricalDischargeFacet.java: + New. This Facet is used during the calculation of historical discharge + curves. + + * src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java, + src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java: Added stubs + to trigger the calculation of data used for generating historical + discharge curve charts. + 2012-02-01 Ingo Weinzierl <ingo@intevation.de> * src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java,
--- a/flys-artifacts/doc/conf/artifacts/winfo.xml Wed Feb 01 11:07:22 2012 +0000 +++ b/flys-artifacts/doc/conf/artifacts/winfo.xml Wed Feb 01 11:14:24 2012 +0000 @@ -475,7 +475,7 @@ <outputmodes> <outputmode name="historical_discharge" description="output.historical_discharge.description" mime-type="image/png" type="chart"> <facets> - <!-- TODO ADD FACETS --> + <facet name="historical_discharge.historicalq"/> </facets> </outputmode> <outputmode name="historical_discharge_report" description="output.historical_discharge_report" mime-type="text/xml" type="report">
--- a/flys-artifacts/doc/conf/conf.xml Wed Feb 01 11:07:22 2012 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Wed Feb 01 11:14:24 2012 +0000 @@ -177,6 +177,7 @@ <output-generator name="w_differences_export">de.intevation.flys.exports.WDifferencesExporter</output-generator> <output-generator name="floodmap">de.intevation.flys.exports.MapGenerator</output-generator> <output-generator name="map">de.intevation.flys.exports.MapGenerator</output-generator> + <output-generator name="historical_discharge">de.intevation.flys.exports.HistoricalDischargeCurveGenerator</output-generator> <!-- Error report generators. --> <output-generator name="discharge_longitudinal_section_report">de.intevation.flys.exports.ReportGenerator</output-generator> <output-generator name="waterlevel_report">de.intevation.flys.exports.ReportGenerator</output-generator>
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Wed Feb 01 11:07:22 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/WINFOArtifact.java Wed Feb 01 11:14:24 2012 +0000 @@ -27,6 +27,7 @@ import de.intevation.flys.artifacts.model.Calculation3; import de.intevation.flys.artifacts.model.Calculation4; import de.intevation.flys.artifacts.model.Calculation5; +import de.intevation.flys.artifacts.model.Calculation6; import de.intevation.flys.artifacts.model.Calculation; import de.intevation.flys.artifacts.model.CalculationMessage; import de.intevation.flys.artifacts.model.CalculationResult; @@ -735,6 +736,12 @@ return endKms.toNativeArray(); } + + public CalculationResult getHistoricalDischargeData() { + return new Calculation6().calculate(); + } + + public List<Segment> getSegments() { StateData wqValues = getData("wq_values"); if (wqValues == null) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/Calculation6.java Wed Feb 01 11:14:24 2012 +0000 @@ -0,0 +1,23 @@ +package de.intevation.flys.artifacts.model; + +import org.apache.log4j.Logger; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class Calculation6 extends Calculation { + + private static final Logger logger = Logger.getLogger(Calculation6.class); + + + public Calculation6() { + } + + + public CalculationResult calculate() { + logger.warn("TODO: IMPLEMENT ME"); + return null; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed Feb 01 11:07:22 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed Feb 01 11:14:24 2012 +0000 @@ -120,5 +120,7 @@ String PDF = "pdf"; String REPORT = "report"; + + String HISTORICAL_DISCHARGE_Q = "historical_discharge.historicalq"; } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/HistoricalDischargeFacet.java Wed Feb 01 11:14:24 2012 +0000 @@ -0,0 +1,74 @@ +package de.intevation.flys.artifacts.model; + +import org.apache.log4j.Logger; + +import de.intevation.artifacts.Artifact; +import de.intevation.artifacts.CallContext; + +import de.intevation.artifactdatabase.state.Facet; + +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.states.DefaultState.ComputeType; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class HistoricalDischargeFacet extends DataFacet { + + private static final Logger logger = + Logger.getLogger(HistoricalDischargeFacet.class); + + + public HistoricalDischargeFacet() { + } + + + public HistoricalDischargeFacet(int index, String name, String desc) { + super(index, name, desc, ComputeType.ADVANCE, null, null); + } + + + public HistoricalDischargeFacet( + int index, + String name, + String description, + ComputeType type, + String stateID, + String hash + + ) { + super(index, name, description, type, hash, stateID); + } + + + @Override + public Facet deepCopy() { + WaterlevelFacet copy = new WaterlevelFacet(); + copy.set(this); + copy.type = type; + copy.hash = hash; + copy.stateId = stateId; + return copy; + } + + + @Override + public Object getData(Artifact artifact, CallContext context) { + if (logger.isDebugEnabled()) { + logger.debug("Get data for historical discharge curves at index: " + + index + " / stateId: " + stateId); + } + + FLYSArtifact flys = (FLYSArtifact) artifact; + + CalculationResult res = (CalculationResult) + flys.compute(context, hash, stateId, type, false); + + // TODO IMPLEMENT ME + + int[] data = new int[] {3, 4}; + return data; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java Wed Feb 01 11:07:22 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/states/HistoricalDischargeComputeState.java Wed Feb 01 11:14:24 2012 +0000 @@ -1,24 +1,36 @@ package de.intevation.flys.artifacts.states; +import java.util.List; import org.w3c.dom.Element; +import org.apache.log4j.Logger; + import de.intevation.artifacts.Artifact; import de.intevation.artifacts.CallContext; import de.intevation.artifacts.common.utils.XMLUtils.ElementCreator; - +import de.intevation.artifactdatabase.state.Facet; - - - +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.WINFOArtifact; +import de.intevation.flys.artifacts.model.CalculationResult; +import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.model.HistoricalDischargeFacet; /** * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> */ -public class HistoricalDischargeComputeState extends DefaultState { +public class HistoricalDischargeComputeState +extends DefaultState +implements FacetTypes +{ + + private static final Logger logger = + Logger.getLogger(HistoricalDischargeComputeState.class); + @Override protected void appendItems( @@ -30,5 +42,36 @@ ) { // TODO IMPLEMENT ME } + + + @Override + public Object computeAdvance( + FLYSArtifact artifact, + String hash, + CallContext context, + List<Facet> facets, + Object old + ) { + logger.debug("HistoricalDischargeComputeState.computeAdvance"); + + WINFOArtifact winfo = (WINFOArtifact) artifact; + + CalculationResult res = old instanceof CalculationResult + ? (CalculationResult) old + : winfo.getHistoricalDischargeData(); + + if (facets == null) { + return res; + } + + logger.debug("TODO: IMPLEMENT ME!"); + + HistoricalDischargeFacet facet = new HistoricalDischargeFacet( + 0, HISTORICAL_DISCHARGE_Q, "THE NEW HIST Q FACET DESC"); + + facets.add(facet); + + return res; + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/HistoricalDischargeCurveGenerator.java Wed Feb 01 11:14:24 2012 +0000 @@ -0,0 +1,140 @@ +package de.intevation.flys.exports; + +import java.awt.Font; + +import org.w3c.dom.Document; + +import org.apache.log4j.Logger; + +import org.jfree.chart.JFreeChart; +import org.jfree.chart.axis.NumberAxis; + +import de.intevation.artifactdatabase.state.ArtifactAndFacet; + +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.model.FacetTypes; + + +/** + * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a> + */ +public class HistoricalDischargeCurveGenerator +extends XYChartGenerator +implements FacetTypes +{ + private static Logger logger = + Logger.getLogger(HistoricalDischargeCurveGenerator.class); + + + public static enum YAXIS { + Q(0); + protected int idx; + private YAXIS(int c) { + idx = c; + } + } + + + @Override + protected YAxisWalker getYAxisWalker() { + return new YAxisWalker() { + @Override + public int length() { + return YAXIS.values().length; + } + + @Override + public String getId(int idx) { + YAXIS[] yaxes = YAXIS.values(); + return yaxes[idx].toString(); + } + }; + } + + + @Override + protected String getDefaultChartTitle() { + return "TODO: CHART TITLE"; + } + + + /** + * Empty (suppress subtitle). + */ + @Override + protected void addSubtitles(JFreeChart chart) { + // this chart has no subtitle + } + + + @Override + protected String getDefaultXAxisLabel() { + return "TODO: DEFAULT X AXIS LABEL"; + } + + @Override + protected String getDefaultYAxisLabel(int pos) { + return "TODO: DEFAULT Y AXIS LABEL FOR: " + pos; + } + + + /** + * Creates a new Y-Axis. + * + * @param index the index of the Y axis. + * + * @return an new NumberAxis with label from <i>getYAxisLabel()</i>. + */ + @Override + protected NumberAxis createYAxis(int index) { + Font labelFont = new Font("Tahoma", Font.BOLD, 14); + String label = "default"; + + if (index == YAXIS.Q.idx) { + label = getYAxisLabel(0); + } + + NumberAxis axis = createNumberAxis(index, label); + axis.setLabelFont(labelFont); + axis.setAutoRangeIncludesZero(false); + + return axis; + } + + + public void doOut( + ArtifactAndFacet artifactFacet, + Document theme, + boolean visible + ) { + String name = artifactFacet.getFacetName(); + logger.debug("HistoricalDischargeCurveGenerator.doOut: " + name); + + + if (name.equals(HISTORICAL_DISCHARGE_Q)) { + doHistoricalDischargeOut( + (FLYSArtifact) artifactFacet.getArtifact(), + artifactFacet.getData(context), + artifactFacet.getFacetDescription(), + theme, + visible); + } + else { + logger.warn("doOut(): unknown facet name: " + name); + return; + } + } + + + protected void doHistoricalDischargeOut( + FLYSArtifact artifact, + Object data, + String desc, + Document theme, + boolean visible) + { + logger.debug("doHistoricalDischargeOut(): description = " + desc); + logger.warn("TODO IMPLEMENT ME"); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 :