Mercurial > dive4elements > gnv-client
view gnv-artifacts/src/main/java/de/intevation/gnv/state/profile/horizontalcrosssection/HorizontalCrossSectionMeshOutputState.java @ 416:04a242c67fe6
Added support of gap detection in horizontalcrossprofile charts.
gnv-artifacts/trunk@464 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Ingo Weinzierl <ingo.weinzierl@intevation.de> |
---|---|
date | Mon, 21 Dec 2009 13:49:49 +0000 |
parents | 2f7a28f211c7 |
children | bed9735adf84 |
line wrap: on
line source
/** * */ package de.intevation.gnv.state.profile.horizontalcrosssection; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.util.Collection; import java.util.Iterator; import java.util.Locale; import org.apache.log4j.Logger; import org.jfree.chart.ChartTheme; import au.com.bytecode.opencsv.CSVWriter; import de.intevation.gnv.chart.Chart; import de.intevation.gnv.chart.ChartLabels; import de.intevation.gnv.geobackend.base.Result; import de.intevation.gnv.state.exception.StateException; import de.intevation.gnv.state.timeseries.TimeSeriesOutputState; import de.intevation.gnv.statistics.Statistics; /** * @author Tim Englich <tim.englich@intevation.de> * */ public class HorizontalCrossSectionMeshOutputState extends TimeSeriesOutputState { private static Logger log = Logger .getLogger(HorizontalCrossSectionMeshOutputState.class); /** * The UID of this Class */ private static final long serialVersionUID = 3233620652465061860L; /** * Constructor */ public HorizontalCrossSectionMeshOutputState() { super(); super.domainLable = "chart.horizontalcrosssection.title.xaxis"; } @Override protected Chart getChart( ChartLabels chartLables, ChartTheme theme, Collection parameters, Collection measurements, Collection dates, Collection result, Locale locale, String uuid, boolean linesVisible, boolean shapesVisible ) { Chart chart = null; if (CACHE_CHART) { log.info("Try to get horizontalcrosssection chart from cache."); chart = (Chart) getChartFromCache(uuid); } if (chart != null) return chart; log.info("Chart not in cache yet."); log.warn("This sort of chart is not implemented yet."); /* TODO Implement a special chart for this sort of charts. chart = new HorizontalProfileChart( chartLables, chartTheme, parameters, measurements, result, dates, locale ); chart.generateChart(); if (CACHE_CHART) { log.info("Put chart into cache."); purifyChart(chart, uuid); } */ return chart; } /** * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#getStatisticsGenerator() */ @Override protected Statistics getStatisticsGenerator() { return null; //Statistiken werden nicht f�r diesen Out-Typ unterst�tzt. } /** * @see de.intevation.gnv.state.timeseries.TimeSeriesOutputState#createCSV(java.io.OutputStream, * java.util.Collection) */ @Override protected void createCSV(OutputStream outputStream, Collection<Result> chartResult) throws UnsupportedEncodingException, IOException, StateException { if (chartResult != null) { try { CSVWriter writer = new CSVWriter(new OutputStreamWriter( outputStream, "ISO-8859-1"), ','); // USE THIS ENCODING BECAUSE OF // PROBLEMS WITH EXCEL AND UTF-8 Iterator<Result> it = chartResult.iterator(); while (it.hasNext()) { Result result = it.next(); int i = 0; String[] entries = new String[5]; entries[i++] = result.getString("SHAPE"); entries[i++] = result.getString("YORDINATE"); entries[i++] = result.getString("IPOSITION"); entries[i++] = result.getString("JPOSITION"); entries[i++] = result.getString("KPOSITION"); writer.writeNext(entries); } writer.close(); } catch (Exception e) { log.error(e,e); throw new StateException( "Exception occured while parsing an Point from WKT."); } } else { log.error("No Data given for generating an CSV-File."); throw new StateException( "No Data given for generating an CSV-File."); } } }