# HG changeset patch # User Sascha L. Teichmann # Date 1340984443 0 # Node ID 750e98fc8b760190f6338fcf50bc519ab9b35e76 # Parent 3287019ad04bda72d61720f2660b3f4ea6ec0775 FixA: Tweaked the derivate diagram a bit and added chart info. flys-artifacts/trunk@4838 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 3287019ad04b -r 750e98fc8b76 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Jun 29 13:42:06 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jun 29 15:40:43 2012 +0000 @@ -1,3 +1,32 @@ +2012-06-29 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveInfoGenerator.java: + New. Added chart info companion for FixDerivedCurveGenerator. + + * doc/conf/conf.xml: Added to configuration. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java: + Code clean up. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixFunction.java: + Simplified. Not Serializable any more because its only a transient object. + + * src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveGenerator.java: + Clean up. Simplified. Removed dependency from Function2DAdapter because + we are doing our own sampling. + + * src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionInfoGenerator.java: + Removed empty last line. + + * src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java: + Small cosmetics. + + * src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionGenerator.java: + Do not notify listeners when add data series. + + * src/main/java/de/intevation/flys/jfree/Function2DAdapter.java: + Removed. Obsolete. + 2012-06-29 Sascha L. Teichmann * src/main/java/de/intevation/flys/exports/TimeseriesChartGenerator.java: @@ -6,7 +35,7 @@ 2012-06-29 Sascha L. Teichmann * src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionInfoGenerator.java: - Added chart info companion for FixLongitudinalSectionGenerator. + New. Added chart info companion for FixLongitudinalSectionGenerator. * doc/conf/conf.xml: Added to configuration. diff -r 3287019ad04b -r 750e98fc8b76 flys-artifacts/doc/conf/conf.xml --- a/flys-artifacts/doc/conf/conf.xml Fri Jun 29 13:42:06 2012 +0000 +++ b/flys-artifacts/doc/conf/conf.xml Fri Jun 29 15:40:43 2012 +0000 @@ -269,6 +269,7 @@ de.intevation.flys.exports.fixings.FixLongitudinalSectionGenerator de.intevation.flys.exports.fixings.FixLongitudinalSectionInfoGenerator de.intevation.flys.exports.fixings.FixDerivedCurveGenerator + de.intevation.flys.exports.fixings.FixDerivedCurveInfoGenerator de.intevation.flys.exports.ReportGenerator de.intevation.flys.exports.ReportGenerator diff -r 3287019ad04b -r 750e98fc8b76 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java Fri Jun 29 13:42:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixDerivateFacet.java Fri Jun 29 15:40:43 2012 +0000 @@ -60,50 +60,50 @@ */ @Override public Object getData(Artifact artifact, CallContext context) { - logger.debug("FixDerivateFacet.getData"); - if (artifact instanceof FLYSArtifact) { - FLYSArtifact flys = (FLYSArtifact)artifact; - FixationArtifactAccess access = new FixationArtifactAccess(flys); - - CalculationResult res = - (CalculationResult) flys.compute(context, - ComputeType.ADVANCE, - false); - - FixResult result = (FixResult) res.getData(); - double currentKm = - ((Double)context.getContextValue("currentKm")).doubleValue(); - - String function = access.getFunction(); - Function ff = FunctionFactory.getInstance().getFunction(function); - Function.Derivative fd = ff.getDerivative(); - Parameters params = result.getParameters(); - double maxQ = FixFacetUtils.getMaxQ(params, currentKm); - - String[] paramNames = ff.getParameterNames(); - - double[] coeffs = params.interpolate("km", currentKm, paramNames); - if(coeffs == null) { - logger.warn("getData: coeffs == null"); - return null; - } - - de.intevation.flys.artifacts.math.Function mf = - fd.instantiate(coeffs); - - FixFunction fix = new FixFunction( - "", - ff.getDescription(), - mf, - maxQ); - - return fix; - } - else { + logger.debug("FixDerivateFacet.getData"); + if (!(artifact instanceof FLYSArtifact)) { logger.debug("Not an instance of FixationArtifact."); return null; } + + FLYSArtifact flys = (FLYSArtifact)artifact; + FixationArtifactAccess access = new FixationArtifactAccess(flys); + + CalculationResult res = + (CalculationResult) flys.compute(context, + ComputeType.ADVANCE, + false); + + FixResult result = (FixResult) res.getData(); + double currentKm = + ((Double)context.getContextValue("currentKm")).doubleValue(); + + String function = access.getFunction(); + Function ff = FunctionFactory.getInstance().getFunction(function); + Function.Derivative fd = ff.getDerivative(); + + Parameters params = result.getParameters(); + double maxQ = FixFacetUtils.getMaxQ(params, currentKm); + + String[] paramNames = ff.getParameterNames(); + + double[] coeffs = params.interpolate("km", currentKm, paramNames); + if (coeffs == null) { + logger.warn("getData: coeffs == null"); + return null; + } + + de.intevation.flys.artifacts.math.Function mf = + fd.instantiate(coeffs); + + FixFunction fix = new FixFunction( + "", + fd.getDescription(), + mf, + maxQ); + + return fix; } diff -r 3287019ad04b -r 750e98fc8b76 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixFunction.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixFunction.java Fri Jun 29 13:42:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixFunction.java Fri Jun 29 15:40:43 2012 +0000 @@ -2,45 +2,39 @@ import de.intevation.flys.artifacts.math.Function; -import java.io.Serializable; - public class FixFunction -implements Serializable { - protected String name; - protected String description; - protected Function mathFunction; - protected double maxQ; - + protected String name; + protected String description; + protected Function function; + protected double maxQ; public FixFunction ( - String name, - String description, - Function f, - double maxQ) { - this.name = name; - this.description = description; - this.mathFunction = f; - this.maxQ = maxQ; + String name, + String description, + Function function, + double maxQ + ) { + this.name = name; + this.description = description; + this.function = function; + this.maxQ = maxQ; } public String getName() { - return this.name; - } - - - public String getDescription() { - return this.description; + return name; } + public String getDescription() { + return description; + } public Function getFunction() { - return this.mathFunction; + return function; } - public double getMaxQ() { - return this.maxQ; + return maxQ; } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 3287019ad04b -r 750e98fc8b76 flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveGenerator.java Fri Jun 29 13:42:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveGenerator.java Fri Jun 29 15:40:43 2012 +0000 @@ -9,14 +9,11 @@ import de.intevation.flys.exports.ChartGenerator; -import de.intevation.flys.jfree.Function2DAdapter; +import de.intevation.flys.jfree.JFreeUtil; +import de.intevation.flys.jfree.StyledXYSeries; import org.apache.log4j.Logger; -import org.jfree.data.general.DatasetUtilities; - -import org.jfree.data.xy.XYSeries; - import org.w3c.dom.Document; /** @@ -70,21 +67,22 @@ FixFunction func = (FixFunction)facet.getData( aaf.getArtifact(), context); - if(func != null) { - double maxQ = func.getMaxQ(); + if (func == null) { + logger.warn("doOut: Facet does not contain FixFunction"); + return; + } - if(maxQ > 0) { - XYSeries series = DatasetUtilities.sampleFunction2DToSeries( - new Function2DAdapter(func.getFunction()), - 0, // start - maxQ, // end - 500, // number of samples - aaf.getFacetDescription()); - addAxisSeries(series, 0, visible); - } - } - else { - logger.debug("doOut: func == null"); + double maxQ = func.getMaxQ(); + + if (maxQ > 0) { + StyledXYSeries series = JFreeUtil.sampleFunction2D( + func.getFunction(), + doc, + aaf.getFacetDescription(), + 500, // number of samples + 0.0 , // start + maxQ); // end + addAxisSeries(series, 0, visible); } } diff -r 3287019ad04b -r 750e98fc8b76 flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveInfoGenerator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixDerivedCurveInfoGenerator.java Fri Jun 29 15:40:43 2012 +0000 @@ -0,0 +1,11 @@ +package de.intevation.flys.exports.fixings; + +import de.intevation.flys.exports.ChartInfoGenerator; + +public class FixDerivedCurveInfoGenerator extends ChartInfoGenerator { + + public FixDerivedCurveInfoGenerator() { + super(new FixDerivedCurveGenerator()); + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 3287019ad04b -r 750e98fc8b76 flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionGenerator.java Fri Jun 29 13:42:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionGenerator.java Fri Jun 29 15:40:43 2012 +0000 @@ -205,8 +205,8 @@ double dev = devArray[0]; double up = dev; double lo = -dev; - upper.add(km, up); - lower.add(km, lo); + upper.add(km, up, false); + lower.add(km, lo, false); } area.addSeries(upper); area.addSeries(lower); diff -r 3287019ad04b -r 750e98fc8b76 flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionInfoGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionInfoGenerator.java Fri Jun 29 13:42:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixLongitudinalSectionInfoGenerator.java Fri Jun 29 15:40:43 2012 +0000 @@ -9,4 +9,3 @@ } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : - diff -r 3287019ad04b -r 750e98fc8b76 flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Fri Jun 29 13:42:06 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/fixings/FixWQCurveGenerator.java Fri Jun 29 15:40:43 2012 +0000 @@ -27,12 +27,11 @@ import org.jfree.data.xy.XYSeries; - import org.w3c.dom.Document; public class FixWQCurveGenerator -extends FixChartGenerator -implements FacetTypes +extends FixChartGenerator +implements FacetTypes { private static Logger logger = Logger.getLogger(FixWQCurveGenerator.class); @@ -141,14 +140,14 @@ double maxQ = func.getMaxQ(); - if(maxQ > 0) { + if (maxQ > 0) { StyledXYSeries series = JFreeUtil.sampleFunction2D( func.getFunction(), doc, aaf.getFacetDescription(), - 500, // number of samples - 0.0 , // start - func.getMaxQ()); // end + 500, // number of samples + 0.0 , // start + maxQ); // end addAxisSeries(series, 0, visible); } diff -r 3287019ad04b -r 750e98fc8b76 flys-artifacts/src/main/java/de/intevation/flys/jfree/Function2DAdapter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/Function2DAdapter.java Fri Jun 29 13:42:06 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ -package de.intevation.flys.jfree; - -import de.intevation.flys.artifacts.math.Function; - -import org.jfree.data.function.Function2D; - -public class Function2DAdapter -implements Function2D -{ - protected Function function; - - public Function2DAdapter() { - } - - public Function2DAdapter(Function function) { - this.function = function; - } - - public Function getFunction() { - return function; - } - - public void setFunction(Function function) { - this.function = function; - } - - @Override - public double getValue(double x) { - return function.value(x); - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :