Mercurial > dive4elements > gnv-client
changeset 113:a16f5267803e
Added Basic-Support for HorizontalProfiles
gnv-artifacts/trunk@163 c6561f87-3c4e-4783-a992-168aeb5c3f6f
line wrap: on
line diff
--- a/gnv-artifacts/Changelog Wed Sep 30 06:00:21 2009 +0000 +++ b/gnv-artifacts/Changelog Wed Sep 30 13:42:51 2009 +0000 @@ -1,3 +1,23 @@ +2009-09-30 Tim Englich <tim.englich@intevation.de> + + * src/main/java/de/intevation/gnv/utils/InputValidator.java (isInputValid) Edited: + Added the Validation for Double-Values. + * src/main/java/de/intevation/gnv/transition/profile/vertical/VerticalProfileOutputTransition.java (createChart) Edited: + The Name of the Method for generaing Charts has changed. + * src/main/java/de/intevation/gnv/transition/profile/horizontal/HorizontalProfileOutputTransition.java Added: + New outputTransition for HorizontalProfiles + * src/main/java/de/intevation/gnv/statistics/HorizontalProfileStatistics.java Added: + Class which calculates the Statistics for Horizontal Profiles. + * src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileInstantaneousPointArtifact.java Added, + * src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileArtifact.java Added: + Classes which represents HorizontalProfileArtifacts + * src/main/java/de/intevation/gnv/chart/VerticalProfileChartFactory.java (plotOrientation) Edited: + Added Member for the representation of the Plotorientation to overwrite it in + extende Classes + Rename Method for generatim the Charts in a common Name. + * src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java Added: + Class for drawing Horzontal Profiles + 2009-09-30 Sascha L. Teichmann <sascha.teichmann@intevation.de> * src/test/ressources/conf.xml: s@test/xml@text/xml@g
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java Wed Sep 30 13:42:51 2009 +0000 @@ -0,0 +1,112 @@ +/** + * Title: ChartFactory, $Header: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/chart/ChartFactory.java,v 1.8 2007/12/21 12:31:15 blume Exp $ + * Source: $Source: /share/gdi/SDI-Suite/Repository/projekte/BSH-GDI/genericViewer/src/main/java/de/conterra/bsh/gdi/gnviewer/output/chart/ChartFactory.java,v $ + * created by: Stefan Blume (blume) + * erstellt am: 06.12.2007 + * Copyright: con terra GmbH, 2005 + * + * modified by: $Author: blume $ + * modified on: $Date: 2007/12/21 12:31:15 $ + * Version: $Revision: 1.8 $ + * TAG: $Name: $ + * locked from: $Locker: $ + * CVS State: $State: Exp $ + * Project: $ProjectName$ + */ +package de.intevation.gnv.chart; + +import java.util.Collection; +import java.util.Iterator; + +import org.apache.log4j.Logger; +import org.jfree.chart.plot.PlotOrientation; +import org.jfree.data.xy.XYSeries; + +import de.intevation.gnv.chart.exception.TechnicalChartException; +import de.intevation.gnv.geobackend.base.Result; + +/** + * + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public class HorizontalProfileChartFactory extends VerticalProfileChartFactory { + + /** + * Default Logging instance + */ + private static Logger sLogger = Logger.getLogger(HorizontalProfileChartFactory.class); + private static boolean sDebug = sLogger.isDebugEnabled(); + + + public HorizontalProfileChartFactory(){ + super(); + super.plotOrientation = PlotOrientation.HORIZONTAL; + } + + + /** + * + * @param seriesName + * @param resultSet + * @param lUpperCut + * @param lLowerCut + * @param pStart + * @param pEnd + * @return + * @throws TechnicalChartException + */ + @Override + protected XYSeries createXYSeries(String seriesName, Collection<Result> resultSet, + int lUpperCut, int lLowerCut,int pStart,int pEnd) throws TechnicalChartException{ + if (sDebug) + sLogger.debug("createXYSeries()"); + XYSeries series = new XYSeries(seriesName); + try { + double xValue=0; + double yValue=0; + double xStartCoord = 0; + double yStartCoord = 0; + int i = 0; + Iterator<Result> resultIterator = resultSet.iterator(); + while (resultIterator.hasNext()){ + Result lRow = resultIterator.next(); + if (i >= pStart && i <= pEnd ){ + if (xStartCoord == 0 && yStartCoord == 0){ + xStartCoord = lRow.getDouble("XORDINATE_XCOORD"); + yStartCoord = lRow.getDouble("XORDINATE_YCOORD"); + } + + double currentXCoord = lRow.getDouble("XORDINATE_XCOORD");; + double currentYCoord = lRow.getDouble("XORDINATE_YCOORD"); + + xValue = this.calculateDistance(xStartCoord, yStartCoord, currentXCoord, currentYCoord); + + yValue = lRow.getDouble("YORDINATE"); + series.add(xValue, yValue); + sLogger.debug(seriesName+" Added Value "+xValue+" / "+yValue); + + }else if (i > pEnd){ + return series; + } + i++; + } + } catch (OutOfMemoryError e) { + sLogger.error(e.getMessage(), e); + return series; + + } catch (Exception e) { //TechnicalChartException + sLogger.error(e.getMessage(), e); + } + finally { + } + + return series; + } + + private double calculateDistance(double xStartCoord, double yStartCoord, double currentXCoord, double currentYCoord){ + double dx = xStartCoord - currentXCoord; + double dy = yStartCoord - currentYCoord; + return Math.sqrt((dx*dx)+(dy*dy)); + } +}
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChartFactory.java Wed Sep 30 06:00:21 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/VerticalProfileChartFactory.java Wed Sep 30 13:42:51 2009 +0000 @@ -54,9 +54,9 @@ */ private static Logger sLogger = Logger.getLogger(VerticalProfileChartFactory.class); private static boolean sDebug = sLogger.isDebugEnabled(); + protected PlotOrientation plotOrientation = PlotOrientation.HORIZONTAL; - - public synchronized void createSimpleVerticalProfileChart(ChartLabels pLabels, ChartStyle pStyle, Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements, OutputStream outputStream, Collection<Result> resultSet) throws IOException, TechnicalChartException { + public synchronized void createProfileChart(ChartLabels pLabels, ChartStyle pStyle, Collection<KeyValueDescibeData> parameters, Collection<KeyValueDescibeData> measurements, OutputStream outputStream, Collection<Result> resultSet) throws IOException, TechnicalChartException { if (sDebug) sLogger.debug("createSimpleTimeSeriesChart()"); int lLowerLevel = Integer.MIN_VALUE; @@ -82,7 +82,7 @@ XYPlot plot = new XYPlot(); //Global settings - plot.setOrientation(PlotOrientation.HORIZONTAL); + plot.setOrientation(plotOrientation); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white);
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileArtifact.java Wed Sep 30 13:42:51 2009 +0000 @@ -0,0 +1,54 @@ +/** + * + */ +package de.intevation.gnv.profile.horizontal; + +import org.apache.log4j.Logger; +import org.w3c.dom.Document; + +import de.intevation.artifacts.ArtifactFactory; +import de.intevation.artifacts.CallContext; +import de.intevation.gnv.artifacts.GNVArtifactBase; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public class HorizontalProfileArtifact extends GNVArtifactBase { + + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(HorizontalProfileArtifact.class); + /** + * + */ + private static final long serialVersionUID = -721831166719594662L; + + /** + * Constructor + */ + public HorizontalProfileArtifact(){ + super(); + log.debug("HorizontalProfileArtifact.Constructor"); + this.name = "horizontalProfile"; + } + + /** + * @see de.intevation.artifactdatabase.DefaultArtifact#describe(java.lang.Object) + */ + @Override + public Document describe(CallContext context) { + log.debug("HorizontalProfileArtifact.describe"); + return super.createDescibeOutput(); + } + + /** + * @see de.intevation.gnv.artifacts.GNVArtifactBase#setup(java.lang.String, de.intevation.artifacts.ArtifactFactory, java.lang.Object) + */ + @Override + public void setup(String identifier, ArtifactFactory factory, Object context) { + log.debug("HorizontalProfileArtifact.setup"); + super.setup(identifier,factory,context); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/profile/horizontal/HorizontalProfileInstantaneousPointArtifact.java Wed Sep 30 13:42:51 2009 +0000 @@ -0,0 +1,31 @@ +/** + * + */ +package de.intevation.gnv.profile.horizontal; + +import org.apache.log4j.Logger; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public class HorizontalProfileInstantaneousPointArtifact extends HorizontalProfileArtifact { + /** + * the logger, used to log exceptions and additonaly information + */ + private static Logger log = Logger.getLogger(HorizontalProfileInstantaneousPointArtifact.class); + + /** + * The UID of this Class. + */ + private static final long serialVersionUID = -6700816287500004553L; + + /** + * Constructor + */ + public HorizontalProfileInstantaneousPointArtifact(){ + super(); + log.debug("HorizontalProfileInstantaneousPointArtifact.Constructor"); + super.name = super.name+ "InstantaneousPoint"; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/statistics/HorizontalProfileStatistics.java Wed Sep 30 13:42:51 2009 +0000 @@ -0,0 +1,27 @@ +/** + * + */ +package de.intevation.gnv.statistics; + +import java.sql.SQLException; + +import de.intevation.gnv.geobackend.base.Result; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public class HorizontalProfileStatistics extends TimeseriesStatistics { + + /** + * Constructor + */ + public HorizontalProfileStatistics() { + super(); + } + + @Override + protected double calculateXOrdinateValue(Result row) throws SQLException { + return row.getDouble("XORDINATE_XCOORD"); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/horizontal/HorizontalProfileOutputTransition.java Wed Sep 30 13:42:51 2009 +0000 @@ -0,0 +1,69 @@ +/** + * + */ +package de.intevation.gnv.transition.profile.horizontal; + +import java.io.IOException; +import java.io.OutputStream; +import java.util.Collection; + +import de.intevation.gnv.chart.ChartLabels; +import de.intevation.gnv.chart.ChartStyle; +import de.intevation.gnv.chart.HorizontalProfileChartFactory; +import de.intevation.gnv.chart.exception.TechnicalChartException; +import de.intevation.gnv.statistics.HorizontalProfileStatistics; +import de.intevation.gnv.statistics.Statistics; +import de.intevation.gnv.transition.describedata.KeyValueDescibeData; +import de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition; + +/** + * @author Tim Englich <tim.englich@intevation.de> + * + */ +public class HorizontalProfileOutputTransition extends TimeSeriesOutputTransition { + /** + * The UID of this class + */ + private static final long serialVersionUID = 4401516087492028840L; + + /** + * Constructor + */ + public HorizontalProfileOutputTransition() { + super(); + super.domainLable = "Tiefe"; + } + + /** + * @see de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition#getMeasurements() + */ + @Override + protected Collection<KeyValueDescibeData> getMeasurements() { + String collectionName = "dateid"; + return this.getCollection(collectionName); + } + + /** + * @see de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition#createChart(java.io.OutputStream, java.util.Collection, java.util.Collection, java.lang.String, de.intevation.gnv.chart.ChartStyle, de.intevation.gnv.chart.ChartLabels) + */ + @Override + protected void createChart(OutputStream outputStream, + Collection<KeyValueDescibeData> parameters, + Collection<KeyValueDescibeData> measurements, + ChartStyle chartStyle, ChartLabels chartLables,String uuid) throws IOException, TechnicalChartException { + HorizontalProfileChartFactory chartFactory = new HorizontalProfileChartFactory(); + chartFactory.createProfileChart(chartLables, chartStyle, + parameters, measurements, + outputStream, this.getChartResult(uuid)); + } + + /** + * @see de.intevation.gnv.transition.timeseries.TimeSeriesOutputTransition#getStatisticsGenerator() + */ + @Override + protected Statistics getStatisticsGenerator() { + return new HorizontalProfileStatistics(); + } + + +}
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/vertical/VerticalProfileOutputTransition.java Wed Sep 30 06:00:21 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/transition/profile/vertical/VerticalProfileOutputTransition.java Wed Sep 30 13:42:51 2009 +0000 @@ -53,7 +53,7 @@ Collection<KeyValueDescibeData> measurements, ChartStyle chartStyle, ChartLabels chartLables,String uuid) throws IOException, TechnicalChartException { VerticalProfileChartFactory chartFactory = new VerticalProfileChartFactory(); - chartFactory.createSimpleVerticalProfileChart(chartLables, chartStyle, + chartFactory.createProfileChart(chartLables, chartStyle, parameters, measurements, outputStream, this.getChartResult(uuid)); }
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java Wed Sep 30 06:00:21 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/utils/InputValidator.java Wed Sep 30 13:42:51 2009 +0000 @@ -32,6 +32,8 @@ boolean valid; if ("Integer".equalsIgnoreCase(type)){ valid = org.apache.commons.validator.GenericValidator.isInt(values[i].trim()); + }else if ("Double".equalsIgnoreCase(type)){ + valid = org.apache.commons.validator.GenericValidator.isDouble(values[i].trim()); }else if ("String".equalsIgnoreCase(type)){ valid = org.apache.commons.validator.GenericValidator.matchRegexp(values[i], "[a-zA-Z0-9]"); // TODO: FIXME: VALIDATE REGEXP }else if ("Date".equalsIgnoreCase(type)){