Mercurial > dive4elements > river
changeset 3617:05deafdcbf39
sloppy logo placement property implementation.
flys-artifacts/trunk@5284 c6561f87-3c4e-4783-a992-168aeb5c3f6f
author | Felix Wolfsteller <felix.wolfsteller@intevation.de> |
---|---|
date | Tue, 28 Aug 2012 15:53:05 +0000 |
parents | d4751be54745 |
children | b7867c03760a |
files | flys-artifacts/ChangeLog flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java |
diffstat | 5 files changed, 83 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/flys-artifacts/ChangeLog Tue Aug 28 13:21:38 2012 +0000 +++ b/flys-artifacts/ChangeLog Tue Aug 28 15:53:05 2012 +0000 @@ -1,3 +1,20 @@ +2012-08-28 Felix Wolfsteller <felix.wolfsteller@intevation.de> + + Sloppy logo placement property implementation. + + * src/main/java/de/intevation/flys/exports/ChartSettings.java: + Parse and set logo placement property value. + + * src/main/java/de/intevation/flys/exports/ChartSection.java: + Accessors for Logo placement property. + + * src/main/java/de/intevation/flys/exports/ChartGenerator.java + (logoPlace): New, get logo placement property value. + (showLogo): Default to "none". + + * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: + Sloppy interpretation of the logo placement property. + 2012-08-28 Felix Wolfsteller <felix.wolfsteller@intevation.de> * src/main/java/de/intevation/flys/exports/XYChartGenerator.java:
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Tue Aug 28 13:21:38 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartGenerator.java Tue Aug 28 15:53:05 2012 +0000 @@ -752,8 +752,8 @@ chartSection.setTitle(getChartTitle()); chartSection.setSubtitle(getChartSubtitle()); chartSection.setDisplayGrid(isGridVisible()); - // TODO default to: "none" chartSection.setDisplayLogo(showLogo()); + chartSection.setLogoPlacement(logoPlace()); return chartSection; } @@ -1030,6 +1030,18 @@ } + protected String logoPlace() { + ChartSettings chartSettings = getChartSettings(); + if (chartSettings != null) { + ChartSection cs = chartSettings.getChartSection(); + String place = cs.getLogoPlacement(); + + return place; + } + return "none"; + } + + /** Return the logo id from settings. */ protected String showLogo(ChartSettings chartSettings) { if (chartSettings != null) { @@ -1038,8 +1050,7 @@ return logo; } - // TODO "none" instead of null? - return null; + return "none"; }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java Tue Aug 28 13:21:38 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSection.java Tue Aug 28 15:53:05 2012 +0000 @@ -1,5 +1,6 @@ package de.intevation.flys.exports; +import org.apache.log4j.Logger; /** @@ -7,10 +8,13 @@ */ public class ChartSection extends TypeSection { - public static final String TITLE_ATTR = "title"; - public static final String SUBTITLE_ATTR = "subtitle"; - public static final String DISPLAYGRID_ATTR = "display-grid"; - public static final String DISPLAYLOGO_ATTR = "display-logo"; + private static Logger logger = Logger.getLogger(ChartSection.class); + + public static final String TITLE_ATTR = "title"; + public static final String SUBTITLE_ATTR = "subtitle"; + public static final String DISPLAYGRID_ATTR = "display-grid"; + public static final String DISPLAYLOGO_ATTR = "display-logo"; + public static final String LOGOPLACEMENT_ATTR = "logo-place"; public ChartSection() { @@ -38,16 +42,31 @@ } + /** Get Property-value for display-logo property. */ public String getDisplayLogo() { return getStringValue(DISPLAYLOGO_ATTR); } + /** Set Property-value for display-logo property. */ public void setDisplayLogo(String logo) { + logger.debug("Setting Display logo string."); setChoiceStringValue(DISPLAYLOGO_ATTR, logo, "logo"); } + /** Get Property-value for logo-placement property. */ + public String getLogoPlacement() { + return getStringValue(LOGOPLACEMENT_ATTR); + } + + + /** Set Property-value for logo-placement property. */ + public void setLogoPlacement(String place) { + setChoiceStringValue(LOGOPLACEMENT_ATTR, place, "place"); + } + + public void setDisplayGrid(boolean displayGrid) { setBooleanValue(DISPLAYGRID_ATTR, displayGrid); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java Tue Aug 28 13:21:38 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartSettings.java Tue Aug 28 15:53:05 2012 +0000 @@ -235,18 +235,22 @@ String sub = XMLUtils.xpathString(chart, "chart/subtitle", null); String grid = XMLUtils.xpathString(chart, "chart/display-grid", null); String logo = XMLUtils.xpathString(chart, "chart/display-logo", null); + String place = XMLUtils.xpathString(chart, "chart/logo-place", null); if (logger.isDebugEnabled()) { logger.debug("Found chart title: '" + title + "'"); logger.debug("Found chart subtitle: '" + sub + "'"); logger.debug("Found chart grid: '" + grid + "'"); logger.debug("Found chart logo: '" + logo + "'"); + logger.debug("Found chart logo place: '" + place + "'"); } chartSection.setTitle(title); chartSection.setSubtitle(sub); chartSection.setDisplayGrid(Boolean.valueOf(grid)); chartSection.setDisplayLogo(logo); + chartSection.setLogoPlacement(place); + target.setChartSection(chartSection); }
--- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Tue Aug 28 13:21:38 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Tue Aug 28 15:53:05 2012 +0000 @@ -269,9 +269,33 @@ imageIcon = new ImageIcon("/home/felix/Downloads/bfg_logo.gif"); } + double xPos = 0d, yPos = 0d; + // TODO placement should be decided by from other properties. + String place = logoPlace(); + if (place == null || place.equals("none")) { + place = "top"; + } + if (place.equals("top")) { + xPos = ((Double)getXBounds(0).getUpper() - (Double)getXBounds(0).getLower())/2d; + yPos = (Double)getYBounds(0).getUpper(); + } + else if (place.equals("bottom")) { + xPos = ((Double)getXBounds(0).getUpper() - (Double)getXBounds(0).getLower())/2d; + yPos = (Double)getYBounds(0).getLower(); + } + else if (place.equals("left")) { + xPos = (Double)getXBounds(0).getLower(); + yPos = ((Double)getYBounds(0).getLower() - (Double)getYBounds(0).getLower())/2d; + } + else if (place.equals("right")) { + xPos = (Double)getXBounds(0).getUpper(); + yPos = ((Double)getYBounds(0).getLower() - (Double)getYBounds(0).getLower())/2d; + } + logger.debug("logo position: " + xPos + "/" + yPos); + XYAnnotation xyannotation = - new XYImageAnnotation(10, 10, imageIcon.getImage()); + new XYImageAnnotation(xPos, yPos, imageIcon.getImage()); plot.getRenderer().addAnnotation(xyannotation, org.jfree.ui.Layer.BACKGROUND); }