# HG changeset patch # User Sascha L. Teichmann # Date 1338913551 0 # Node ID 65b6e27c6f25ec7002c2c88c641c7732bc0c6a8f # Parent 5d286d7e54cd04ad6be2eadd3bff2a0e15c5d85b FixA: Use new data structures in Delta W(t) exporter. Removed obsolete code. flys-artifacts/trunk@4593 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 5d286d7e54cd -r 65b6e27c6f25 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Tue Jun 05 15:37:38 2012 +0000 +++ b/flys-artifacts/ChangeLog Tue Jun 05 16:25:51 2012 +0000 @@ -1,3 +1,18 @@ +2012-06-05 Sascha L. Teichmann + + * src/main/java/de/intevation/flys/exports/DeltaWtExporter.java: + Use new data structures for export. + + * src/main/java/de/intevation/flys/utils/KMIndex.java: + Implements java.lang.Iterable now. + + * src/main/java/de/intevation/flys/artifacts/model/fixings/DeltaWT.java, + src/main/java/de/intevation/flys/artifacts/model/fixings/DeltaWTsKM.java: + Removed. Obsolete. + + * src/main/java/de/intevation/flys/jfree/CollisionFreeXYTextAnnotation.java: + Removed superfluous import. + 2012-06-05 Sascha L. Teichmann * src/main/java/de/intevation/flys/artifacts/FixationArtifactAccess.java: @@ -486,7 +501,7 @@ * src/main/java/de/intevation/flys/jfree/StickyAxisAnnotation.java, src/main/java/de/intevation/flys/jfree/FLYSAnnotation.java: - (flipStickyAxis): Allow easy change of sticky axes. + (flipStickyAxis): Allow easy change of sticky axes. 2012-05-24 Felix Wolfsteller diff -r 5d286d7e54cd -r 65b6e27c6f25 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/DeltaWT.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/DeltaWT.java Tue Jun 05 15:37:38 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,47 +0,0 @@ -package de.intevation.flys.artifacts.model.fixings; - -import java.io.Serializable; - -import java.util.Date; - -public class DeltaWT -implements Serializable -{ - protected double deltaW; - protected Date date; - protected String description; - - public DeltaWT() { - } - - public DeltaWT(double deltaW, Date date, String description) { - this.deltaW = deltaW; - this.date = date; - this.description = description; - } - - public double getDeltaW() { - return deltaW; - } - - public void setDeltaW(double deltaW) { - this.deltaW = deltaW; - } - - public Date getDate() { - return date; - } - - public void setDate(Date date) { - this.date = date; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 5d286d7e54cd -r 65b6e27c6f25 flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/DeltaWTsKM.java --- a/flys-artifacts/src/main/java/de/intevation/flys/artifacts/model/fixings/DeltaWTsKM.java Tue Jun 05 15:37:38 2012 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,90 +0,0 @@ -package de.intevation.flys.artifacts.model.fixings; - -import java.io.Serializable; - -import java.util.List; -import java.util.ArrayList; -import java.util.Collections; - -public class DeltaWTsKM -implements Serializable -{ - public static final double EPSILON = 1e-5; - - public static class KM - implements Serializable, Comparable - { - protected double km; - - protected List deltaWTs; - - public KM() { - deltaWTs = new ArrayList(); - } - - public KM(double km) { - this(); - this.km = km; - } - - public double getKm() { - return km; - } - - public void setKm(double km) { - this.km = km; - } - - public List getDeltaWTs() { - return deltaWTs; - } - - public void setDeltaWTs(List deltaWTs) { - this.deltaWTs = deltaWTs; - } - - public void add(DeltaWT deltaWT) { - deltaWTs.add(deltaWT); - } - - public int size() { - return deltaWTs.size(); - } - - @Override - public int compareTo(KM other) { - double d = km - other.km; - if (d < -EPSILON) return -1; - if (d > EPSILON) return +1; - return 0; - } - } // class KM - - protected List kms; - - public DeltaWTsKM() { - this(10); - } - - public DeltaWTsKM(int capacity) { - kms = new ArrayList(capacity); - } - - public void add(KM km) { - kms.add(km); - } - - public void sort() { - Collections.sort(kms); - } - - public KM findByKm(double km) { - int idx = Collections.binarySearch(kms, new KM(km)); - return idx >= 0 ? kms.get(idx) : null; - } - - public List getKms() { - return kms; - } -} -// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 : diff -r 5d286d7e54cd -r 65b6e27c6f25 flys-artifacts/src/main/java/de/intevation/flys/exports/DeltaWtExporter.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/DeltaWtExporter.java Tue Jun 05 15:37:38 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/DeltaWtExporter.java Tue Jun 05 16:25:51 2012 +0000 @@ -7,13 +7,14 @@ import de.intevation.flys.artifacts.model.CalculationResult; -import de.intevation.flys.artifacts.model.fixings.DeltaWT; -import de.intevation.flys.artifacts.model.fixings.DeltaWTsKM; import de.intevation.flys.artifacts.model.fixings.FixResult; +import de.intevation.flys.artifacts.model.fixings.AnalysisPeriod; +import de.intevation.flys.artifacts.model.fixings.QWD; import de.intevation.flys.artifacts.resources.Resources; import de.intevation.flys.utils.Formatter; +import de.intevation.flys.utils.KMIndex; import java.io.IOException; import java.io.OutputStream; @@ -55,13 +56,13 @@ public static final String DEFAULT_CSV_T_DESC_HEADER = "Beschreibung"; - protected List deltaWTsKMs; + protected List> analysisPeriods; @Override public void init(Document request, OutputStream out, CallContext context) { log.debug("DeltaWtExporter.init"); super.init(request, out, context); - deltaWTsKMs = new ArrayList(); + analysisPeriods = new ArrayList>(); } @Override @@ -94,8 +95,7 @@ log.warn("Invalid data stored in result."); } FixResult result = (FixResult)data; - // TODO: replace old code - //deltaWTsKMs.add(result.getDeltaWTsKM()); + analysisPeriods.add(result.getAnalysisPeriods()); } @Override @@ -113,34 +113,33 @@ DateFormat dF = DateFormat.getDateInstance(DateFormat.SHORT, locale); if (debug) { - log.debug("DeltaWTsKMs: " + deltaWTsKMs.size()); + log.debug("AnalysisPeriods: " + analysisPeriods.size()); } - for (DeltaWTsKM deltaWTsKM: deltaWTsKMs) { - List dkms = deltaWTsKM.getKms(); - if (debug) { - log.debug("DeltaWTsKM.KM: " + dkms.size()); - } - for (DeltaWTsKM.KM dkm: dkms) { - double km = dkm.getKm(); - String kmS = kmF.format(km); - List deltaWTs = dkm.getDeltaWTs(); - if (debug) { - log.debug("deltaWTs: " + deltaWTs.size()); - } - for (DeltaWT dwt: deltaWTs) { - double deltaW = dwt.getDeltaW(); - Date date = dwt.getDate(); - String desc = dwt.getDescription(); + for (KMIndex periods: analysisPeriods) { - String deltaWS = dwF.format(deltaW); - String dateS = dF.format(date); + for (KMIndex.Entry kmEntry: periods) { - writer.writeNext(new String[] { - kmS, - deltaWS, - dateS, - desc != null ? desc : "" }); + String kmS = kmF.format(kmEntry.getKm()); + + for (AnalysisPeriod period: kmEntry.getValue()) { + QWD [] qwds = period.getQWDs(); + if (qwds != null) { + for (QWD qwd: qwds) { + double deltaW = qwd.getDeltaW(); + Date date = qwd.getDate(); + String desc = qwd.getDescription(); + + String deltaWS = dwF.format(deltaW); + String dateS = dF.format(date); + + writer.writeNext(new String[] { + kmS, + deltaWS, + dateS, + desc != null ? desc : "" }); + } + } } } } diff -r 5d286d7e54cd -r 65b6e27c6f25 flys-artifacts/src/main/java/de/intevation/flys/jfree/CollisionFreeXYTextAnnotation.java --- a/flys-artifacts/src/main/java/de/intevation/flys/jfree/CollisionFreeXYTextAnnotation.java Tue Jun 05 15:37:38 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/jfree/CollisionFreeXYTextAnnotation.java Tue Jun 05 16:25:51 2012 +0000 @@ -2,8 +2,6 @@ import org.apache.log4j.Logger; -import java.util.Iterator; - import java.awt.Shape; import java.awt.geom.Rectangle2D; diff -r 5d286d7e54cd -r 65b6e27c6f25 flys-artifacts/src/main/java/de/intevation/flys/utils/KMIndex.java --- a/flys-artifacts/src/main/java/de/intevation/flys/utils/KMIndex.java Tue Jun 05 15:37:38 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/utils/KMIndex.java Tue Jun 05 16:25:51 2012 +0000 @@ -3,11 +3,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; +import java.util.Iterator; import java.io.Serializable; public class KMIndex -implements Serializable +implements Serializable, Iterable> { public static final double EPSILON = 1e-4; @@ -83,5 +84,9 @@ int index = Collections.binarySearch(entries, new Entry(km)); return index >= 0 ? entries.get(index) : null; } + + public Iterator> iterator() { + return entries.iterator(); + } } // vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :