Mercurial > dive4elements > river
diff flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java @ 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 | 45af081061e7 |
children | 05deafdcbf39 |
line wrap: on
line diff
--- 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); }