Mercurial > dive4elements > river
changeset 6431:fab4abd00ef2
merge
author | Tom Gottfried <tom@intevation.de> |
---|---|
date | Wed, 26 Jun 2013 12:45:05 +0200 |
parents | e32b166c881b (diff) 641fd5bd6965 (current diff) |
children | 666f503787b3 |
files | |
diffstat | 16 files changed, 313 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java Wed Jun 26 12:38:43 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ChartGenerator.java Wed Jun 26 12:45:05 2013 +0200 @@ -717,6 +717,15 @@ } + /** + * Gets the master artifact. + * @return the master artifact. + */ + public Artifact getMaster() { + return master; + } + + /** Sets the collection. */ @Override public void setCollection(D4EArtifactCollection collection) {
--- a/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveGenerator.java Wed Jun 26 12:38:43 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/ComputedDischargeCurveGenerator.java Wed Jun 26 12:45:05 2013 +0200 @@ -20,13 +20,21 @@ import org.dive4elements.river.jfree.StickyAxisAnnotation; import org.dive4elements.river.jfree.StyledXYSeries; +import org.dive4elements.river.model.Gauge; import org.dive4elements.river.utils.RiverUtils; +import org.dive4elements.artifacts.Artifact; + +import java.awt.Font; + import java.util.ArrayList; import java.util.List; +import org.jfree.chart.axis.NumberAxis; +import org.jfree.data.xy.XYSeries; + import org.apache.log4j.Logger; -import org.jfree.data.xy.XYSeries; + import org.w3c.dom.Document; @@ -57,6 +65,7 @@ public static final String I18N_MAINVALUES_Q_LABEL = "Q (Haupt- und Extremwerte)"; public static final String I18N_MAINVALUES_W_LABEL = "W (Haupt- und Extremwerte)"; + protected NumberAxis firstYAxis; /** Trivial Constructor. */ public ComputedDischargeCurveGenerator () { @@ -83,6 +92,20 @@ } + /** + * Returns the PNP (Datum) of gauge, if at gauge, 0 otherwise. + */ + protected int atGaugeSubtractPNP() { + // Code borrowed from FixATWriter. + Gauge gauge = RiverUtils.getGauge((D4EArtifact) getMaster()); + int subtractPNP = 0; + if (Math.abs(getRange()[0] - gauge.getStation().doubleValue()) < 1e-4) { + subtractPNP = (int) Math.round(gauge.getDatum().doubleValue() /** 100*/); + } + return subtractPNP; + } + + @Override protected String getDefaultYAxisLabel(int pos) { D4EArtifact flys = (D4EArtifact) master; @@ -94,6 +117,36 @@ /** + * Create Y (range) axis for given index. + * Shall be overriden by subclasses. + */ + protected NumberAxis createYAxis(int index) { + if (index == 0) { + firstYAxis = super.createYAxis(0); + return firstYAxis; + } + YAxisWalker walker = getYAxisWalker(); + + Font labelFont = new Font( + DEFAULT_FONT_NAME, + Font.BOLD, + getYAxisFontSize(index)); + + SyncNumberAxis axis = new SyncNumberAxis( + walker.getId(index), + getYAxisLabel(index), + firstYAxis); + + axis.setAutoRangeIncludesZero(false); + axis.setLabelFont(labelFont); + axis.setTickLabelFont(labelFont); + axis.setShift((double)-atGaugeSubtractPNP()); + + return axis; + } + + + /** * Process data, build up plot. */ @Override @@ -114,7 +167,7 @@ //XXX DEAD CODE // Facet facet = artifactFacet.getFacet(); if (name.equals(COMPUTED_DISCHARGE_Q)) { - doQOut((WQKms) artifactFacet.getData(context), artifactFacet, attr, visible); + doDischargeQOut((WQKms) artifactFacet.getData(context), artifactFacet, attr, visible); } else if (name.equals(STATIC_WQ)) { doWQOut(artifactFacet.getData(context), artifactFacet, attr, visible); @@ -189,6 +242,38 @@ /** + * Add discharge Q-Series to plot, scale if at gauge. + * @param wqkms actual data + * @param theme theme to use. + */ + protected void doDischargeQOut( + WQKms wqkms, + ArtifactAndFacet aaf, + Document theme, + boolean visible + ) { + logger.debug("ComputedDischargeCurveGenerator: doDischargeQOut"); + XYSeries series = new StyledXYSeries(aaf.getFacetDescription(), theme); + + int subtractPNP = atGaugeSubtractPNP(); + + if (subtractPNP == 0) { + StyledSeriesBuilder.addPointsQW(series, wqkms); + addAxisSeries(series, YAXIS.W.idx, visible); + } + else { + XYSeries series2 = new StyledXYSeries(aaf.getFacetDescription(), theme); + StyledSeriesBuilder.addPointsQW(series2, wqkms); + addAxisSeries(series2, YAXIS.W.idx, false); + + // Use second axis... + StyledSeriesBuilder.addPointsQW(series, wqkms, -subtractPNP, 100d); + addAxisSeries(series, YAXIS.WCm.idx, visible); + } + } + + + /** * Add Q-Series to plot. * @param wqkms actual data * @param theme theme to use.
--- a/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Wed Jun 26 12:38:43 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/DischargeCurveGenerator.java Wed Jun 26 12:45:05 2013 +0200 @@ -37,7 +37,8 @@ implements FacetTypes { public static enum YAXIS { - W(0); + W(0), + WCm(1); protected int idx; private YAXIS(int c) { idx = c;
--- a/artifacts/src/main/java/org/dive4elements/river/exports/IdentifiableNumberAxis.java Wed Jun 26 12:38:43 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/IdentifiableNumberAxis.java Wed Jun 26 12:45:05 2013 +0200 @@ -10,7 +10,7 @@ import org.jfree.chart.axis.NumberAxis; - +/** Axis of which label and key differs. */ public class IdentifiableNumberAxis extends NumberAxis {
--- a/artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java Wed Jun 26 12:38:43 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/StyledSeriesBuilder.java Wed Jun 26 12:45:05 2013 +0200 @@ -214,6 +214,26 @@ } } + /** + * Add points to series (q to 1st dim, w to 2nd dim), adding wTrans to the + * W values and scaling it with wScale. + * + * @param series Series to add points to. + * @param wqkms WQKms to add to series. + * @param wAdd Value to add to each Q while adding to series. + * @param wScale multiply with + */ + public static void addPointsQW(XYSeries series, WQKms wqkms, double wTrans, double wScale) { + if (wqkms == null) { + return; + } + + int size = wqkms.size(); + + for (int i = 0; i < size; i++) { + series.add(wqkms.getQ(i), wScale * (wqkms.getW(i) + wTrans), false); + } + } /** * Add points to series (q to 1st dim, w to 2nd dim).
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/SyncNumberAxis.java Wed Jun 26 12:45:05 2013 +0200 @@ -0,0 +1,131 @@ +/* Copyright (C) 2011, 2012, 2013 by Bundesanstalt für Gewässerkunde + * Software engineering by Intevation GmbH + * + * This file is Free Software under the GNU AGPL (>=v3) + * and comes with ABSOLUTELY NO WARRANTY! Check out the + * documentation coming with Dive4Elements River for details. + */ + +package org.dive4elements.river.exports; + +import org.jfree.chart.axis.NumberAxis; +import org.jfree.chart.event.AxisChangeEvent; +import org.jfree.chart.event.AxisChangeListener; +import org.jfree.data.Range; + +import org.apache.log4j.Logger; + +/** + * Axis which is to be registered with other axis and tries + * to clone its range. The cloned range is transformed. + */ +public class SyncNumberAxis extends IdentifiableNumberAxis + implements AxisChangeListener +{ + /** The logger used in this generator. */ + private static Logger logger = + Logger.getLogger(SyncNumberAxis.class); + + /** The other axis to clone range from. */ + protected NumberAxis proxyAxis; + + /** Value to translate range by. */ + protected double shift; + + + protected SyncNumberAxis(String key, String label, NumberAxis n) { + super(key, label); + this.proxyAxis = n; + } + + + /** Range of other axis changed, adjust own range. */ + @Override + public void axisChanged(AxisChangeEvent event) { + logger.debug("SyncNumberAxis: axischange event"); + this.setRange( + transRange(((NumberAxis)event.getAxis()).getRange())); + } + + /** Set value by which to translate the range. */ + protected void setShift(double shift) { + this.shift = shift; + } + + + /** Set other axis to relate to, register listener. */ + public void setProxyAxis(NumberAxis ax) { + proxyAxis = ax; + proxyAxis.addChangeListener(this); + } + + /** Translate range by shift, scale by 100. */ + protected Range transRange(Range r) { + return new Range(100d*(r.getLowerBound()+shift), + 100d*(r.getUpperBound()+shift)); + } + + /** Set Range. */ + @Override + public void setRange(Range r) { + super.setRange(r); + logger.debug("SyncAxis: setRange"); + } + + + /* + @Override + public Range getRange() { + Range r = new Range(100d*(proxyAxis.getRange().getLowerBound()+shift), + 100d*(proxyAxis.getRange().getUpperBound()+shift)); + return r; + } + + @Override + public void setLowerBound(double max) { + } + + @Override + public void setLowerMargin(double margin) { + } + + @Override + public void setUpperBound(double max) { + } + + @Override + public void setUpperMargin(double margin) { + } + + @Override + public void setRange(double a, double b) { + } + + @Override + public void setRange(Range range, boolean turnOffAutoRange, boolean notify){ + } + + @Override + public void setRangeAboutValue(double value, double length) {} + + @Override + public void setRangeWithMargins(double lower, double upper) {} + + @Override + public void setRangeWithMargins(Range range) {} + + @Override + public void pan(double percent) {} + + @Override + public void resizeRange(double p){} + + @Override + public void resizeRange(double p, double a){} + + @Override + public void resizeRange2(double p, double a){} + + */ +} +// vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8 :
--- a/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java Wed Jun 26 12:38:43 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/fixings/FixWQCurveGenerator.java Wed Jun 26 12:45:05 2013 +0200 @@ -120,7 +120,7 @@ public boolean prepareChartData(ArtifactAndFacet aaf, Document doc, boolean visible) { String name = aaf.getFacetName(); - this.artifact = (D4EArtifact)aaf.getArtifact(); + this.artifact = (D4EArtifact) aaf.getArtifact(); if(name.startsWith(FIX_SECTOR_AVERAGE_WQ)) { doSectorAverageOut(aaf, doc, visible); @@ -184,7 +184,7 @@ } - /** Add sector average points to chart */ + /** Add sector average points to chart. */ protected void doSectorAverageOut(ArtifactAndFacet aaf, Document doc, boolean visible) { logger.debug("doSectorAverageOut"); @@ -199,7 +199,7 @@ } } - /** Add analysis event points to chart */ + /** Add analysis event points to chart. */ protected void doAnalysisEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) { logger.debug("doAnalysisEventsOut"); @@ -232,7 +232,7 @@ } - /** Add reference event points to chart */ + /** Add reference event points to chart. */ protected void doReferenceEventsOut(ArtifactAndFacet aaf, Document doc, boolean visible) { logger.debug("doReferenceEventsOut");
--- a/contrib/make_flys_release/make_release.sh Wed Jun 26 12:38:43 2013 +0200 +++ b/contrib/make_flys_release/make_release.sh Wed Jun 26 12:45:05 2013 +0200 @@ -196,6 +196,9 @@ -e "s@http://localhost:8888@http://localhost:$TOMCAT_PORT@g" \ $FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/WEB-INF/web.xml +sed -i -e "s@https://flys3-devel.bafg.de/wiki@${WIKI_URL}@g" \ + $FLYS_SOURCE_DIR/river/gwt-client/src/main/java/org/dive4elements/river/client/client/config.xm + sed -i -e "s@/tmp/flys-client.log@${LOG_DIR}/client-${VERSION}.log@g" \ $FLYS_SOURCE_DIR/river/gwt-client/src/main/webapp/WEB-INF/log4j.properties
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/Config.java Wed Jun 26 12:38:43 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/Config.java Wed Jun 26 12:45:05 2013 +0200 @@ -9,7 +9,6 @@ package org.dive4elements.river.client.client; import com.google.gwt.i18n.client.LocaleInfo; - import com.google.gwt.xml.client.Document; import com.google.gwt.xml.client.Node; @@ -81,6 +80,17 @@ /** + * Returns the URL of the FLYS/d4e-Wiki. + * + * @return wiki base URL + */ + public String getWikiUrl() { + Node server = config.getElementsByTagName("wiki").item(0); + return server.getFirstChild().getNodeValue(); + } + + + /** * Returns the name of the current locale. * * @return the name of the current locale.
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Wed Jun 26 12:38:43 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants.properties Wed Jun 26 12:45:05 2013 +0200 @@ -632,8 +632,8 @@ gauge_q_unit = m\u00b3/s gauge_river_info_link = Riverinfo gauge_info_link = Gaugeinfo -gauge_url = https://flys-intern.intevation.de/PegelInfo/ -gauge_river_url = https://flys-intern.intevation.de/GewaesserInfo/ +gauge_url = /PegelInfo/ +gauge_river_url = /GewaesserInfo/ gauge_curve_link = Dischargecurve/-table discharge_timeranges = DC-Timeranges discharge_chart = W/Q-Preview
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Wed Jun 26 12:38:43 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_de.properties Wed Jun 26 12:45:05 2013 +0200 @@ -631,8 +631,8 @@ gauge_q_unit = m\u00b3/s gauge_river_info_link = Gew\u00e4sserinfo gauge_info_link = Pegelinfo -gauge_url = https://flys-intern.intevation.de/PegelInfo/ -gauge_river_url = https://flys-intern.intevation.de/GewaesserInfo/ +gauge_url = /PegelInfo/ +gauge_river_url = /GewaesserInfo/ gauge_curve_link = Abflusskurve/-tafel discharge_timeranges = AK-Zeitr\u00e4ume discharge_chart = W/Q-Vorschau @@ -640,7 +640,7 @@ measurement_station_type = Messstellenart measurement_station_operator = Betreiber measurement_station_start_time = Beginn der Aufzeichnung -measurement_station_url = https://flys-intern.intevation.de/MessstellenInfo/ +measurement_station_url = /MessstellenInfo/ measurement_station_info_link = Messstelleninfo measurement_station_gauge_name = hydrologischer Bezugspegel
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties Wed Jun 26 12:38:43 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/FLYSConstants_en.properties Wed Jun 26 12:45:05 2013 +0200 @@ -606,8 +606,8 @@ gauge_q_unit = m\u00b3/s gauge_river_info_link = Riverinfo gauge_info_link = Gaugeinfo -gauge_url = https://flys-intern.intevation.de/PegelInfo/ -gauge_river_url = https://flys-intern.intevation.de/GewaesserInfo/ +gauge_url = /PegelInfo/ +gauge_river_url = /GewaesserInfo/ gauge_curve_link = Dischargecurve/-table discharge_timeranges = DC-Timeranges discharge_chart = W/Q-Preview @@ -615,7 +615,7 @@ measurement_station_type = Type of Measurement Station measurement_station_operator = Operator measurement_station_start_time = Observation Start Time -measurement_station_url = https://flys-intern.intevation.de/MessstellenInfo/ +measurement_station_url = /MessstellenInfo/ measurement_station_info_link = Measurement Station Info measurement_station_gauge_name = Reference Gauge
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/config.xml Wed Jun 26 12:38:43 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/config.xml Wed Jun 26 12:45:05 2013 +0200 @@ -1,5 +1,7 @@ <config> <server>http://localhost:8181</server> + + <wiki>https://flys3-devel.bafg.de/wiki</wiki> <projectlist> <!-- The interval to update the user's projects (in ms) -->
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java Wed Jun 26 12:38:43 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/RiverInfoPanel.java Wed Jun 26 12:45:05 2013 +0200 @@ -8,12 +8,6 @@ package org.dive4elements.river.client.client.ui; -import java.util.Iterator; - -import org.dive4elements.river.client.client.FLYS; -import org.dive4elements.river.client.client.FLYSConstants; -import org.dive4elements.river.client.shared.model.RiverInfo; - import com.google.gwt.core.client.GWT; import com.google.gwt.i18n.client.NumberFormat; import com.google.gwt.user.client.ui.HorizontalPanel; @@ -22,6 +16,13 @@ import com.smartgwt.client.widgets.form.DynamicForm; import com.smartgwt.client.widgets.form.fields.LinkItem; +import java.util.Iterator; + +import org.dive4elements.river.client.client.Config; +import org.dive4elements.river.client.client.FLYS; +import org.dive4elements.river.client.client.FLYSConstants; +import org.dive4elements.river.client.shared.model.RiverInfo; + /** * Panel to display information about a river. * @author <a href="mailto:bjoern.ricks@intevation.de">Björn Ricks</a> @@ -97,7 +98,8 @@ String url = number != null ? MSG.gauge_river_url() + number : MSG.gauge_river_url(); - DynamicForm infoLink = WikiLinks.linkHTML(this.flys, url, + String wikiBaseUrl = Config.getInstance().getWikiUrl(); + DynamicForm infoLink = WikiLinks.linkHTML(this.flys, wikiBaseUrl + url, MSG.gauge_river_info_link()); infoLink.setTop(5); LinkItem item = (LinkItem)infoLink.getField("saml");
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeRecord.java Wed Jun 26 12:38:43 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/GaugeRecord.java Wed Jun 26 12:45:05 2013 +0200 @@ -11,6 +11,7 @@ import com.google.gwt.core.client.GWT; import com.smartgwt.client.widgets.grid.ListGridRecord; +import org.dive4elements.river.client.client.Config; import org.dive4elements.river.client.client.FLYSConstants; import org.dive4elements.river.client.shared.model.GaugeInfo; @@ -20,15 +21,17 @@ public class GaugeRecord extends ListGridRecord implements GaugeInfo { /** The message class that provides i18n strings.*/ - private FLYSConstants MSG = GWT.create(FLYSConstants.class); + private final FLYSConstants MSG = GWT.create(FLYSConstants.class); public GaugeRecord(GaugeInfo gauge) { + String wikiBaseUrl = Config.getInstance().getWikiUrl(); + setCanExpand(true); Long number = gauge.getOfficialNumber(); String url = number != null ? MSG.gauge_url() + number : MSG.gauge_url(); - setLink(url); + setLink(wikiBaseUrl + url); setLinkText(MSG.gauge_info_link()); setName(gauge.getName()); setKmStart(gauge.getKmStart()); @@ -59,6 +62,7 @@ return this.getAttributeAsString("link"); } + @Override public String getName() { return this.getAttributeAsString("name"); } @@ -67,6 +71,7 @@ this.setAttribute("name", value); } + @Override public Double getKmStart() { return this.getAttributeAsDouble("kmstart"); } @@ -75,6 +80,7 @@ this.setAttribute("kmstart", value); } + @Override public Double getKmEnd() { return this.getAttributeAsDouble("kmend"); } @@ -83,6 +89,7 @@ this.setAttribute("kmend", value); } + @Override public Double getMinQ() { return this.getAttributeAsDouble("minq"); } @@ -91,6 +98,7 @@ this.setAttribute("minq", value); } + @Override public Double getMaxQ() { return this.getAttributeAsDouble("maxq"); } @@ -99,6 +107,7 @@ this.setAttribute("maxq", value); } + @Override public Double getMinW() { return this.getAttributeAsDouble("minw"); } @@ -107,6 +116,7 @@ this.setAttribute("minw", value); } + @Override public Double getMaxW() { return this.getAttributeAsDouble("maxw"); } @@ -115,6 +125,7 @@ this.setAttribute("maxw", value); } + @Override public Double getDatum() { return this.getAttributeAsDouble("datum"); } @@ -123,6 +134,7 @@ this.setAttribute("datum", value); } + @Override public Double getAeo() { return this.getAttributeAsDouble("aeo"); } @@ -131,6 +143,7 @@ this.setAttribute("aeo", value); } + @Override public boolean isKmUp() { return this.getAttributeAsBoolean("kmup"); } @@ -139,6 +152,7 @@ this.setAttribute("kmup", value); } + @Override public Double getStation() { return this.getAttributeAsDouble("station"); } @@ -147,6 +161,7 @@ this.setAttribute("station", value); } + @Override public String getWstUnit() { return this.getAttributeAsString("wstunit"); } @@ -155,6 +170,7 @@ this.setAttribute("wstunit", value); } + @Override public Long getOfficialNumber() { return this.getAttributeAsLong("officialnumber"); } @@ -163,6 +179,7 @@ this.setAttribute("officialnumber", number); } + @Override public String getRiverName() { return this.getAttributeAsString("rivername"); }
--- a/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationRecord.java Wed Jun 26 12:38:43 2013 +0200 +++ b/gwt-client/src/main/java/org/dive4elements/river/client/client/ui/stationinfo/MeasurementStationRecord.java Wed Jun 26 12:45:05 2013 +0200 @@ -8,11 +8,12 @@ package org.dive4elements.river.client.client.ui.stationinfo; -import java.util.Date; - import com.google.gwt.core.client.GWT; import com.smartgwt.client.widgets.grid.ListGridRecord; +import java.util.Date; + +import org.dive4elements.river.client.client.Config; import org.dive4elements.river.client.client.FLYSConstants; import org.dive4elements.river.client.shared.model.MeasurementStation; @@ -24,16 +25,18 @@ implements MeasurementStation { /** The message class that provides i18n strings.*/ - private FLYSConstants MSG = GWT.create(FLYSConstants.class); + private final FLYSConstants MSG = GWT.create(FLYSConstants.class); public MeasurementStationRecord(MeasurementStation station) { this.setCanExpand(true); + String wikiBaseUrl = Config.getInstance().getWikiUrl(); + Integer number = station.getID(); String stationName = station.getName(); String stationIdent = stationName.replaceAll("\\W", ""); String stationType = station.getMeasurementType(); - String link = MSG.measurement_station_url() + + String link = wikiBaseUrl + MSG.measurement_station_url() + stationIdent + stationType; this.setLink(link); this.setLinkText(MSG.measurement_station_info_link());