diff gnv-artifacts/src/main/java/de/intevation/gnv/chart/XMLChartTheme.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 3d13fa281a7e
children 9a828e5a2390
line wrap: on
line diff
--- a/gnv-artifacts/src/main/java/de/intevation/gnv/chart/XMLChartTheme.java	Tue Mar 23 14:11:51 2010 +0000
+++ b/gnv-artifacts/src/main/java/de/intevation/gnv/chart/XMLChartTheme.java	Wed Mar 24 14:48:55 2010 +0000
@@ -22,61 +22,138 @@
 import de.intevation.artifactdatabase.Config;
 
 /**
- * @author Ingo Weinzierl <ingo.weinzierl@intevation.de>
+ * Implementation of JFreeChart's default implementation
+ * <code>StandardChartTheme</code>. This class takes an xml document with a
+ * bunch of parameters and turns it into a <code>ChartTheme</code> to change 
+ * the appearance of charts.
+ *
+ * @author <a href="mailto:ingo.weinzierl@intevation.de">Ingo Weinzierl</a>
  */
 public class XMLChartTheme
 extends      StandardChartTheme
 {
+    /**
+     * Default color.
+     */
     private static final Color DEFAULT_COLOR = Color.BLACK;
 
+    /**
+     * Logger used for logging with log4j.
+     */
     private Logger log = Logger.getLogger(XMLChartTheme.class);
 
+    /**
+     * Field storing the visibility of the domain crosshair
+     */
     protected boolean domainCrosshairVisible;
+
+    /**
+     * Field storing the visibility of the range crosshair
+     */
     protected boolean rangeCrosshairVisible;
+    
+    /**
+     * Field storing the visiblity of lines.
+     */
     protected boolean renderLines;
+
+    /**
+     * Field storing the visibility of data points
+     */
     protected boolean renderShapes;
 
+    /**
+     * Field storing the width of a data point
+     */
     protected int pointWidth;
+
+    /**
+     * Field storing the height of a data point.
+     */
     protected int pointHeight;
 
+    /**
+     * Field storing the base color of a bin in a histogram chart
+     */
     protected Paint histogramBasePaint;
 
 
+    /**
+     * Constructor
+     *
+     * @param name Name for this theme.
+     */
     public XMLChartTheme(String name) {
         super(name);
     }
 
 
+    /**
+     * Setter method for the visibility of the domain crosshair.
+     *
+     * @param visible True, if domain crosshair should be visible
+     */
     public void setDomainCrosshairVisible(boolean visible) {
         this.domainCrosshairVisible = visible;
     }
 
 
+    /**
+     * Getter method for retrieving the visibility of the domain crosshair.
+     *
+     * @return Visibility of the domain crosshair.
+     */
     public boolean getDomainCrosshairVisible() {
         return domainCrosshairVisible;
     }
 
 
+    /**
+     * Getter method for retrieving the visibility of the range crosshair.
+     *
+     * @return Visibility of the range crosshair.
+     */
     public boolean getRangeCrosshairVisible() {
         return rangeCrosshairVisible;
     }
 
 
+    /**
+     * Setter method for the visibility of the range crosshair.
+     *
+     * @param visible True, if range crosshair should be visible
+     */
     public void setRangeCrosshairVisible(boolean visible) {
         this.rangeCrosshairVisible = visible;
     }
 
 
+    /**
+     * Method to set the bin color of histograms.
+     *
+     * @param c Bin color
+     */
     public void setHistogramBasePaint(Color c) {
         this.histogramBasePaint = c;
     }
 
 
+    /**
+     * Getter method for retrieving the bin color.
+     *
+     * @return Bin color
+     */
     public Paint getHistogramBasePaint() {
         return histogramBasePaint;
     }
 
 
+    /**
+     * Take a given xml document and read the configuration of a chart
+     * appearance.
+     *
+     * @param document XML document
+     */
     public void applyXMLConfiguration(Document document) {
         log.debug("create XMLChartTheme");
 
@@ -84,6 +161,11 @@
     }
 
 
+    /**
+     * Start parsing the different settings from <code>document</code>.
+     *
+     * @param document XML document
+     */
     private void init(Document document) {
         log.debug("init XMLChartTheme parameters");
 
@@ -98,6 +180,11 @@
     }
 
 
+    /**
+     * Read parameters configuring the title of a chart.
+     *
+     * @param document XML document
+     */
     private void initTitleParameters(Document document) {
         log.debug("init title parameters.");
 
@@ -114,6 +201,11 @@
     }
 
 
+    /**
+     * Read parameters configuring the subtitle of a chart.
+     *
+     * @param document XML document
+     */
     private void initSubtitleParameters(Document document) {
         log.debug("init title parameters.");
 
@@ -128,6 +220,11 @@
     }
 
 
+    /**
+     * Read parameters configuring the background color of a chart.
+     *
+     * @param document XML document
+     */
     private void initChartParameters(Document document) {
         log.debug("init chart parameters.");
 
@@ -138,6 +235,11 @@
     }
 
 
+    /**
+     * Read parameters configuring the plot of a chart.
+     *
+     * @param document XML document
+     */
     private void initPlotParameters(Document document) {
         log.debug("init plot parameters.");
 
@@ -181,6 +283,11 @@
     }
 
 
+    /**
+     * Read parameters configuring the axes of a plot.
+     *
+     * @param document XML document
+     */
     private void initAxisParameters(Document document) {
         log.debug("init axis parameters.");
 
@@ -197,6 +304,11 @@
     }
 
 
+    /**
+     * Read parameters configuring the legend of a chart.
+     *
+     * @param document XML document
+     */
     private void initLegendParameters(Document document) {
         log.debug("init legend parameters.");
 
@@ -213,6 +325,11 @@
     }
 
 
+    /**
+     * Read parameters configuring the renderer of a plot.
+     *
+     * @param document XML document
+     */
     private void initRenderer(Document document) {
         log.debug("init renderer parameters.");
 
@@ -229,6 +346,11 @@
     }
 
 
+    /**
+     * Read base color of bins in histogram charts.
+     *
+     * @param document XML document
+     */
     private void initHistogramColor(Document document) {
         log.debug("init histogram color");
         String tmp = getString(document, "theme/histogram/bar/color/@value");
@@ -239,11 +361,28 @@
     }
 
 
+    /**
+     * Read a xpath expression and return the matched string.
+     *
+     * @param document Document
+     * @param xpath XPath expression
+     *
+     * @return Matched string
+     */
     private static String getString(Document document, String xpath) {
         return Config.getStringXPath(document, xpath);
     }
 
 
+    /**
+     * Read a xpath and turn it into an integer.
+     *
+     * @param document Document
+     * @param xpath XPath expression
+     *
+     * @return Matched string as integer representation. Return 0 if no integer
+     * have been found at <code>xpath</code>.
+     */
     private static int getInt(Document document, String xpath) {
         String tmp = getString(document, xpath);
 
@@ -254,6 +393,15 @@
     }
 
 
+    /**
+     * Read a xpath and turn it into a boolean.
+     *
+     * @param document Document
+     * @param xpath XPath expression
+     *
+     * @return Matched string as boolean representation. Return false if no
+     * boolean have been found at <code>xpath</code>.
+     */
     private static boolean getBool(Document document, String xpath) {
         String tmp = getString(document, xpath);
 
@@ -264,6 +412,13 @@
     }
 
 
+    /**
+     * Turns a string into a color using {@link java.awt.Color}.
+     *
+     * @param Color as string
+     *
+     * @return Color
+     */
     protected Color decodeColor(String color) {
         try {
             if (color == null)
@@ -279,6 +434,15 @@
     }
 
 
+    /**
+     * Create a font with the given parameters.
+     *
+     * @param type Font type
+     * @param size Font size
+     * @param bold Font weight
+     *
+     * @return Font
+     */
     protected Font createFont(String type, int size, boolean bold) {
         Font font = null;
         if (bold)
@@ -290,6 +454,12 @@
     }
 
 
+    /**
+     * Apply settings of this <code>ChartTheme</code> to the given
+     * <code>XYPlot</code>.
+     *
+     * @param plot XYPlot
+     */
     protected void applyToXYPlot(XYPlot plot) {
         log.debug("apply theme parameter to XYPlot");
 
@@ -308,6 +478,12 @@
     }
 
 
+    /**
+     * Apply settings of this <code>ChartTheme</code> to the
+     * <code>XYLineAndShapeRenderer</code> of the given <code>XYPlot</code>.
+     *
+     * @param plot XYPlot
+     */
     protected void applyToXYLineAndShapeRenderer(XYPlot plot) {
         if (plot == null)
             return;
@@ -327,6 +503,12 @@
     }
 
 
+    /**
+     * Apply settings of this <code>ChartTheme</code> to the
+     * <code>XYBarRenderer</code> of the given <code>XYPlot</code>.
+     *
+     * @param plot XYPlot
+     */
     protected void applyToXYBarRenderer(XYPlot plot) {
         if (plot == null)
             return;

http://dive4elements.wald.intevation.org