changeset 3616:d4751be54745

Add rather faked image annotations to chart, if property is set accordingly. flys-artifacts/trunk@5282 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author Felix Wolfsteller <felix.wolfsteller@intevation.de>
date Tue, 28 Aug 2012 13:21:38 +0000
parents f84854eba0b3
children 05deafdcbf39
files flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java
diffstat 2 files changed, 53 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog	Tue Aug 28 12:47:11 2012 +0000
+++ b/flys-artifacts/ChangeLog	Tue Aug 28 13:21:38 2012 +0000
@@ -1,3 +1,26 @@
+2012-08-28	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	* src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
+	  (addLogo): New, add an image annotation to plot, very stubby,
+	             use hard-coded paths for now.
+
+2012-08-28	Felix Wolfsteller	<felix.wolfsteller@intevation.de>
+
+	Preparations for logo-inclusion in charts.
+
+	* src/main/java/de/intevation/flys/exports/ChoiceStringAttribute.java:
+	  New string attribute type to trigger different UI (selectboxes)
+	  in client.
+	  
+	* src/main/java/de/intevation/flys/exports/TypeSection.java
+	  (setChoiceStringValue): Create new ChoiceStringAttribute.
+	  
+	  
+	* src/main/java/de/intevation/flys/exports/ChartSection.java,
+	  src/main/java/de/intevation/flys/exports/ChartGenerator.java,
+	  src/main/java/de/intevation/flys/exports/ChartSettings.java:
+	  Accessors to show logo-property.
+
 2012-08-28  Raimund Renkert <raimund.renkert@intevation.de>
 
 	MINFO: Implemented UI and facet/artifact stack for bed height differences.
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue Aug 28 12:47:11 2012 +0000
+++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java	Tue Aug 28 13:21:38 2012 +0000
@@ -11,6 +11,7 @@
 
 import java.awt.Color;
 import java.awt.Font;
+import javax.swing.ImageIcon;
 
 import java.text.NumberFormat;
 
@@ -25,6 +26,8 @@
 import org.jfree.chart.JFreeChart;
 import org.jfree.chart.LegendItem;
 
+import org.jfree.chart.annotations.XYAnnotation;
+import org.jfree.chart.annotations.XYImageAnnotation;
 import org.jfree.chart.annotations.XYTextAnnotation;
 
 import org.jfree.chart.axis.NumberAxis;
@@ -240,12 +243,39 @@
         // These have to go after the autozoom.
         addAnnotationsToRenderer(plot);
 
+        // Add a logo (maybe).
+        addLogo(plot);
+
         aggregateLegendEntries(plot);
 
         return chart;
     }
 
 
+    /** Add a logo as background annotation to plot. */
+    protected void addLogo(XYPlot plot) {
+        String logo = showLogo();
+        if (logo  == null) {
+            logger.debug("No logo to show chosen");
+            return;
+        }
+
+        ImageIcon imageIcon = null; 
+        // TODO: Which logo?
+        if (logo.equals("Intevation")) {
+            imageIcon = new ImageIcon("/home/felix/Downloads/intevation_logo_120.png");
+        }
+        else {
+            imageIcon = new ImageIcon("/home/felix/Downloads/bfg_logo.gif");
+        }
+
+        // TODO placement should be decided by from other properties.
+        XYAnnotation xyannotation =
+            new XYImageAnnotation(10, 10, imageIcon.getImage()); 
+        plot.getRenderer().addAnnotation(xyannotation, org.jfree.ui.Layer.BACKGROUND); 
+    }
+
+
     protected NumberAxis createXAxis(String label) {
         return new NumberAxis(label);
     }

http://dive4elements.wald.intevation.org