# HG changeset patch # User Felix Wolfsteller # Date 1346251406 0 # Node ID 6772e9f9b65f7f4a90fcd9a16dc4627ff54494c1 # Parent 1cd6114603d99db28e82c779a5e47e421c0c22e8 Deal with inverted axes in longitudinal charts and logos. flys-artifacts/trunk@5297 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 1cd6114603d9 -r 6772e9f9b65f flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Wed Aug 29 14:33:48 2012 +0000 +++ b/flys-artifacts/ChangeLog Wed Aug 29 14:43:26 2012 +0000 @@ -1,3 +1,10 @@ +2012-08-29 Felix Wolfsteller + + * src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java, + src/main/java/de/intevation/flys/exports/XYChartGenerator.java: + (getLeftX, getRightX): New and overridden to deal with inverted axis + for logo placement in longitudinalsection charts. + 2012-08-29 Felix Wolfsteller * src/main/java/de/intevation/flys/exports/XYChartGenerator.java: diff -r 1cd6114603d9 -r 6772e9f9b65f flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Wed Aug 29 14:33:48 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/LongitudinalSectionGenerator.java Wed Aug 29 14:43:26 2012 +0000 @@ -116,15 +116,42 @@ } + /** True if x axis has been inverted. */ public boolean isInverted() { return inverted; } + /** Set to true if x axis has been inverted. */ public void setInverted(boolean inverted) { this.inverted = inverted; } + /** + * Return left most data points x value (on first axis). + * Overridden because axis could be inverted. + */ + @Override + protected double getLeftX() { + if (isInverted()) { + return (Double)getXBounds(0).getUpper(); + } + return (Double)getXBounds(0).getLower(); + } + + + /** + * Return right most data points x value (on first axis). + * Overridden because axis could be inverted. + */ + @Override + protected double getRightX() { + if (isInverted()) { + return (Double)getXBounds(0).getLower(); + } + return (Double)getXBounds(0).getUpper(); + } + /** * Returns the default title for this chart. diff -r 1cd6114603d9 -r 6772e9f9b65f flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Wed Aug 29 14:33:48 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/XYChartGenerator.java Wed Aug 29 14:43:26 2012 +0000 @@ -252,6 +252,26 @@ } + /** + * Return left most data points x value (on first axis). + * Shortcut, especially to be overridden in (LS) charts where + * axis could be inverted. + */ + protected double getLeftX() { + return (Double)getXBounds(0).getLower(); + } + + + /** + * Return right most data points x value (on first axis). + * Shortcut, especially to be overridden in (LS) charts where + * axis could be inverted. + */ + protected double getRightX() { + return (Double)getXBounds(0).getUpper(); + } + + /** Add a logo as background annotation to plot. */ protected void addLogo(XYPlot plot) { String logo = showLogo(); @@ -296,10 +316,10 @@ placeh = "center"; } if (placeh.equals("left")) { - xPos = (Double)getXBounds(0).getLower(); + xPos = getLeftX(); } else if (placeh.equals("right")) { - xPos = (Double)getXBounds(0).getUpper(); + xPos = getRightX(); } else if (placeh.equals("center")) { xPos = ((Double)getXBounds(0).getUpper() + (Double)getXBounds(0).getLower())/2d;