# HG changeset patch # User Raimund Renkert # Date 1338984419 0 # Node ID 7db919b1bc1e1b5d8cb5769f5bb716fca581b029 # Parent 6a37a0134409a8897370f4823fd8a8c4729e188b Added new facet for analysis periods and updated facet names in fix analysis. flys-artifacts/trunk@4608 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 6a37a0134409 -r 7db919b1bc1e flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Jun 06 11:53:55 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Jun 06 12:06:59 2012 +0000 @@ -1,3 +1,19 @@ +2012-06-06 Raimund Renkert + + Added new facet for analysis periods and updated facet names. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java: + New. Facet for analysis periods. Returns the date ranges for the analysis + periods. + + * doc/conf/artifacts/fixanalysis.xml, + src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java: + Added new facet and updated facet names. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java: + Updated facet names. + 2012-06-06 Felix Wolfsteller * src/main/java/de/intevation/flys/jfree/CollisionFreeXYTextAnnotation.java: diff -r 6a37a0134409 -r 7db919b1bc1e flys-artifacts/doc/conf/artifacts/fixanalysis.xml --- a/flys-artifacts/doc/conf/artifacts/fixanalysis.xml Wed Jun 06 11:53:55 2012 +0000 +++ b/flys-artifacts/doc/conf/artifacts/fixanalysis.xml Wed Jun 06 12:06:59 2012 +0000 @@ -132,7 +132,9 @@ - + + + diff -r 6a37a0134409 -r 7db919b1bc1e flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed Jun 06 11:53:55 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/FacetTypes.java Wed Jun 06 12:06:59 2012 +0000 @@ -158,9 +158,11 @@ String RELATIVE_POINT = "relativepoint"; - String FIX_EVENTS = "fix_events"; + String FIX_ANALYSIS_EVENTS = "fix_analysis_events"; + String FIX_REFERENCE_EVENTS = "fix_reference_events"; String FIX_SECTOR_AVERAGE = "fix_sector_average"; String FIX_WQ_CURVE = "fix_wq_curve"; String FIX_OUTLIER = "fix_outlier"; + String FIX_ANALYSIS_PERIODS = "fix_analysis_periods"; } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf-8 : diff -r 6a37a0134409 -r 7db919b1bc1e flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java Wed Jun 06 11:53:55 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisEventsFacet.java Wed Jun 06 12:06:59 2012 +0000 @@ -38,7 +38,12 @@ * @param name */ public FixAnalysisEventsFacet(int index, String description) { - super(index, FIX_EVENTS, description, ComputeType.ADVANCE, null, null); + super(index, + FIX_ANALYSIS_EVENTS, + description, + ComputeType.ADVANCE, + null, + null); } diff -r 6a37a0134409 -r 7db919b1bc1e flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixAnalysisPeriodsFacet.java Wed Jun 06 12:06:59 2012 +0000 @@ -0,0 +1,105 @@ +package de.intevation.flys.artifacts.model.fixings; + +import org.apache.log4j.Logger; + +import de.intevation.artifacts.Artifact; +import de.intevation.artifacts.CallContext; + +import de.intevation.flys.utils.KMIndex; + +import de.intevation.flys.artifacts.FLYSArtifact; +import de.intevation.flys.artifacts.FixationArtifactAccess; + +import de.intevation.flys.artifacts.model.FacetTypes; +import de.intevation.flys.artifacts.model.DataFacet; +import de.intevation.flys.artifacts.model.CalculationResult; + +import de.intevation.flys.artifacts.states.DefaultState.ComputeType; + + +/** + * Facet to show W values for Q values at km for a date. + * + * @author Raimund Renkert + */ +public class FixAnalysisPeriodsFacet +extends DataFacet +implements FacetTypes { + + /** House logger. */ + private static Logger logger = Logger.getLogger(FixAnalysisPeriodsFacet.class); + + /** Trivial Constructor. */ + public FixAnalysisPeriodsFacet() { + } + + + /** + * @param name + */ + public FixAnalysisPeriodsFacet(int index, String description) { + super(index, + FIX_ANALYSIS_PERIODS, + description, + ComputeType.ADVANCE, + null, + null); + } + + + /** + * Returns the data this facet requires. + * + * @param artifact the owner artifact. + * @param context the CallContext (ignored). + * + * @return the data. + */ + @Override + public Object getData(Artifact artifact, CallContext context) { + logger.debug("FixAnalysisPeriodsFacet.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 km = access.getCurrentKm(); + + KMIndex kmPeriods = result.getAnalysisPeriods(); + AnalysisPeriod[] periods = kmPeriods.binarySearch(km).getValue(); + + if (periods == null) { + return null; + } + DateRange[] dates = new DateRange[periods.length]; + for (int i = 0; i < periods.length; i++) { + dates[i] = periods[i].getDateRange(); + } + return dates; + } + else { + logger.debug("Not an instance of FixationArtifact."); + return null; + } + } + + + /** + * Create a deep copy of this Facet. + * @return a deep copy. + */ + @Override + public FixAnalysisPeriodsFacet deepCopy() { + FixAnalysisPeriodsFacet copy = new FixAnalysisPeriodsFacet(); + copy.set(this); + return copy; + } +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 6a37a0134409 -r 7db919b1bc1e flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java Wed Jun 06 11:53:55 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/FixReferenceEventsFacet.java Wed Jun 06 12:06:59 2012 +0000 @@ -38,7 +38,12 @@ * @param name */ public FixReferenceEventsFacet(int index, String description) { - super(index, FIX_EVENTS, description, ComputeType.ADVANCE, null, null); + super(index, + FIX_REFERENCE_EVENTS, + description, + ComputeType.ADVANCE, + null, + null); }