Mercurial > dive4elements > gnv-client
diff gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java @ 171:7fb9441dd8af
Format Code to max 80 Chars per Row and Cleanup
gnv-artifacts/trunk@208 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Tim Englich <tim.englich@intevation.de> |
---|---|
date | Fri, 09 Oct 2009 07:54:48 +0000 |
parents | 820238357bab |
children | bff7bbb7c6f0 |
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java Fri Oct 09 07:49:47 2009 +0000 +++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/HorizontalProfileChartFactory.java Fri Oct 09 07:54:48 2009 +0000 @@ -28,85 +28,89 @@ /** * * @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.VERTICAL; - } + /** + * Default Logging instance + */ + private static Logger sLogger = Logger + .getLogger(HorizontalProfileChartFactory.class); + private static boolean sDebug = sLogger.isDebugEnabled(); - - /** - * - * @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()){ + public HorizontalProfileChartFactory() { + super(); + super.plotOrientation = PlotOrientation.VERTICAL; + } + + /** + * + * @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){ + 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 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){ + + 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)); - } + } 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)); + } }