diff gnv-artifacts/src/main/java/de/intevation/gnv/chart/TimeSeriesChart.java @ 767:79401c871da4

Added and repaired javadoc in de.intevation.gnv.chart package. gnv-artifacts/trunk@823 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Ingo Weinzierl <ingo.weinzierl@intevation.de>
date Wed, 24 Mar 2010 14:48:55 +0000
parents b98d1adee7a6
children 9a828e5a2390
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/TimeSeriesChart.java	Tue Mar 23 14:11:51 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/TimeSeriesChart.java	Wed Mar 24 14:48:55 2010 +0000
@@ -41,22 +41,54 @@
 import org.jfree.data.time.TimeSeriesCollection;
 
 /**
- * @author Ingo Weinzierl (ingo.weinzierl@intevation.de)
+ * This class is used to create timeseries charts. The domain axis contains
+ * multiple date/time objects.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class TimeSeriesChart
 extends      AbstractXYLineChart
 {
 
-    private static final String DATE_FORMAT = "chart.timeseries.date.format";
-
+    /**
+     * Constant format which can be useful to format date items. Value is
+     * {@value}.
+     */
     public static final String DEFAULT_DATE_FORMAT = "dd-MMM-yyyy";
 
+    /**
+     * Constant field used if no gap detection should be done here. This field
+     * is used in @see #getTimeGapValue. Value is {@value}.
+     */
     public static final long   NO_TIME_GAP = Long.MAX_VALUE - 1000;
+
+    /**
+     * Percentage used for gap detection. Its value is {@value}.
+     */
     public static final int    GAP_SIZE    = 5; // in percent
 
+    /**
+     * Logger used for logging with log4j.
+     */
     private static Logger log = Logger.getLogger(TimeSeriesChart.class);
 
 
+    /**
+     * Constructor used to create <code>TimeSeries</code> charts.
+     *
+     * @param labels Labels used to be displayed in title, subtitle and so on.
+     * @param theme ChartTheme used to adjust the rendering of this chart.
+     * @param parameters Collection containing a bunch of parameters.
+     * @param measurements Collection containing a bunch of measurements.
+     * @param dates Collection containing a bunch of date objects.
+     * @param result Collection containing a bunch of <code>Result</code>
+     * objects which contain the actual data items to be displayed.
+     * @param timeGaps Collection with timegap definitions.
+     * @param locale Locale used to specify the format of labels, numbers, ...
+     * @param linesVisible Render lines between data points if true, otherwise
+     * not.
+     * @param shapesVisible Render vertices as points if true, otherwise not.
+     */
     public TimeSeriesChart(
         ChartLabels labels,
         ChartTheme  theme,
@@ -85,6 +117,9 @@
     }
 
 
+    /**
+     * see de.intevation.gnv.chart.AbstractXYLineChart#initChart()
+     */
     protected void initChart() {
         chart = ChartFactory.createTimeSeriesChart(
             labels.getTitle(),
@@ -102,6 +137,9 @@
     }
 
 
+    /**
+     * @see de.intevation.gnv.chart.AbstractXYLineChart#initData()
+     */
     protected void initData() {
         log.debug("init data for timeseries chart");
 
@@ -177,6 +215,9 @@
     }
 
 
+    /**
+     * @see de.intevation.gnv.chart.AbstractXYLineChart#addValue(Result, Series)
+     */
     protected void addValue(Result row, Series series) {
         ((TimeSeries) series).addOrUpdate(
             new Minute(row.getDate("XORDINATE")),
@@ -185,6 +226,10 @@
     }
 
 
+    /**
+     * @see de.intevation.gnv.chart.AbstractXYLineChart#addSeries(Series,
+     * String, int)
+     */
     protected void addSeries(Series series, String parameter, int idx) {
         log.debug("add series (" + parameter + ")to timeseries chart");
 
@@ -205,6 +250,10 @@
     }
 
 
+    /**
+     * Method to add processed datasets to plot. Each dataset is adjusted using
+     * <code>prepareAxis</code> and <code>adjustRenderer</code> methods.
+     */
     protected void addDatasets() {
         Iterator   iter = parameters.iterator();
         XYPlot     plot = chart.getXYPlot();
@@ -233,6 +282,10 @@
     }
 
 
+    /**
+     * @see de.intevation.gnv.chart.AbstractXYLineChart#localizeDomainAxis(Axis,
+     * Locale)
+     */
     protected void localizeDomainAxis(Axis axis, Locale locale) {
         ((ValueAxis)axis).setStandardTickUnits(createStandardDateTickUnits(
             TimeZone.getDefault(),
@@ -240,6 +293,10 @@
     }
 
 
+    /**
+     * @see org.jfree.chart.axis.DateAxis#createStandardDateTickUnits(TimeZone,
+     * Locale)
+     */
     public static TickUnitSource createStandardDateTickUnits(
         TimeZone zone,
         Locale locale)
@@ -370,11 +427,23 @@
     }
 
 
+    /**
+     * Method to get a message from resource bundle.
+     *
+     * @param Locale Locale used to specify the resource bundle.
+     * @param def Key to specify the required message.
+     *
+     * @return Message
+     */
     protected String getMessage(Locale locale, String key, String def) {
         return RessourceFactory.getInstance().getRessource(locale, key, def);
     }
 
 
+    /**
+     * @see de.intevation.gnv.chart.AbstractXYLineChart#createSeriesName(String,
+     * String, String)
+     */
     protected String createSeriesName(
         String breakPoint1,
         String breakPoint2,
@@ -388,6 +457,17 @@
     }
 
 
+    /**
+     * Method to add gaps between two data points. The max valid space between 
+     * two data points is calculated by <code>calculateGapSize</code>.
+     *
+     * @param results All data points in this dataset.
+     * @param series Series to be processed.
+     * @param startDate Date item where the scan for gaps should begin.
+     * @param endDate Date item where the scan should end.
+     * @param startPos Start position of this series in <code>results</code>.
+     * @param endPos End position of a series in <code>results</code>
+     */
     protected void addGaps(
         Result[] results,
         Series   series,
@@ -435,6 +515,19 @@
     }
 
 
+    /**
+     * Method to calculate the max space between two data points.
+     *
+     * @param start First date
+     * @param end Last date
+     * @param startPos Start position of the current series in the collection
+     * containing the bunch of series.
+     * @param endPos End position of the current series in the collection
+     * containing the bunch of series.
+     * @param gapID Gap id used to specify the time intervals.
+     *
+     * @return Min size of a gap.
+     */
     protected long calculateGapSize(
         Date start,
         Date end,
@@ -452,6 +545,19 @@
     }
 
 
+    /**
+     * Determine the interval size between two data points.
+     *
+     * @param dStart Start date
+     * @param dEnd End date
+     * @param pStart Index of start point in series used to specify the total 
+     * amount of date items.
+     * @param pEnd Index of end point in series used to specify the total amount
+     * of date items.
+     * @param gapID Gap id used to determine gaps configured in a xml document.
+     *
+     * @return Interval size between two data points.
+     */
     protected long getTimeGapValue(
         Date dStart,
         Date dEnd,

http://dive4elements.wald.intevation.org