# HG changeset patch # User Felix Wolfsteller # Date 1341567363 0 # Node ID 638b1da85450d893476051b38f561f2dfb9d2ab6 # Parent 229e9b27ce1589679a9c5420f27e173e73fd30ef New ChartHelper method to expand bounds added. flys-artifacts/trunk@4880 c6561f87-3c4e-4783-a992-168aeb5c3f6f diff -r 229e9b27ce15 -r 638b1da85450 flys-artifacts/ChangeLog --- a/flys-artifacts/ChangeLog Fri Jul 06 09:34:51 2012 +0000 +++ b/flys-artifacts/ChangeLog Fri Jul 06 09:36:03 2012 +0000 @@ -1,3 +1,8 @@ +2012-07-07 Felix Wolfsteller + + * src/main/java/de/intevation/flys/exports/ChartHelper.java + (expandBounds): New, expand bounds by given percentage. + 2012-07-07 Felix Wolfsteller * src/main/java/de/intevation/flys/artifacts/math/Distance.java: diff -r 229e9b27ce15 -r 638b1da85450 flys-artifacts/src/main/java/de/intevation/flys/exports/ChartHelper.java --- a/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartHelper.java Fri Jul 06 09:34:51 2012 +0000 +++ b/flys-artifacts/src/main/java/de/intevation/flys/exports/ChartHelper.java Fri Jul 06 09:36:03 2012 +0000 @@ -155,12 +155,34 @@ /** + * Expand bounds by percent. + * + * @param bounds The bounds to expand. + * @param percent The percentage to expand. + * + * @param a new, expanded bounds. + */ + public static Bounds expandBounds(Bounds bounds, double percent) { + if (bounds == null) { + return null; + } + + double value = (Double) bounds.getLower(); + double expand = Math.abs(value / 100 * percent); + + return expand != 0 + ? new DoubleBounds(value-expand, value+expand) + : new DoubleBounds(-0.01 * percent, 0.01 * percent); + } + + + /** * Expand range by percent. * * @param range The range to expand. * @param percent The percentage to expand. * - * @param an expanded range. + * @param a new, expanded range. */ public static Range expandRange(Range range, double percent) { if (range == null) {