Mercurial > dive4elements > river
changeset 6051:e56f0d618f96
Add instanceof guard around boundary handling
Otherwise there could be a class cast exception when the class
was an annotation object
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Tue, 21 May 2013 10:12:25 +0200 |
parents | 06450ef553cc |
children | 799af7909e8d |
files | artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java |
diffstat | 1 files changed, 24 insertions(+), 22 deletions(-) [+] |
line wrap: on
line diff
--- a/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java Tue May 21 16:30:14 2013 +0200 +++ b/artifacts/src/main/java/org/dive4elements/river/exports/minfo/BedDiffHeightYearGenerator.java Tue May 21 10:12:25 2013 +0200 @@ -90,28 +90,30 @@ return; } - if (getXBounds(0) != null && getDomainAxisRange() != null) { - Bounds bounds = - calculateZoom(getXBounds(0), getDomainAxisRange()); - context.putContextValue("startkm", bounds.getLower()); - context.putContextValue("endkm", bounds.getUpper()); - } - else if (getXBounds(0) != null && getDomainAxisRange() == null) { - context.putContextValue("startkm", getXBounds(0).getLower()); - context.putContextValue("endkm", getXBounds(0).getUpper()); - } - else if (getXBounds(0) == null && getDomainAxisRange() == null) { - BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); - context.putContextValue("startkm", data.getKms().min()); - context.putContextValue("endkm", data.getKms().max()); - } - else if (getXBounds(0) == null && getDomainAxisRange() != null){ - BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); - Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max()); - Bounds bounds = - calculateZoom(b, getDomainAxisRange()); - context.putContextValue("startkm", bounds.getLower()); - context.putContextValue("endkm", bounds.getUpper()); + if (bundle.getData(context) instanceof BedDifferencesResult) { + if (getXBounds(0) != null && getDomainAxisRange() != null) { + Bounds bounds = + calculateZoom(getXBounds(0), getDomainAxisRange()); + context.putContextValue("startkm", bounds.getLower()); + context.putContextValue("endkm", bounds.getUpper()); + } + else if (getXBounds(0) != null && getDomainAxisRange() == null) { + context.putContextValue("startkm", getXBounds(0).getLower()); + context.putContextValue("endkm", getXBounds(0).getUpper()); + } + else if (getXBounds(0) == null && getDomainAxisRange() == null) { + BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); + context.putContextValue("startkm", data.getKms().min()); + context.putContextValue("endkm", data.getKms().max()); + } + else if (getXBounds(0) == null && getDomainAxisRange() != null){ + BedDifferencesResult data = (BedDifferencesResult)bundle.getData(context); + Bounds b = new DoubleBounds(data.getKms().min(), data.getKms().max()); + Bounds bounds = + calculateZoom(b, getDomainAxisRange()); + context.putContextValue("startkm", bounds.getLower()); + context.putContextValue("endkm", bounds.getUpper()); + } } Processor processor = new KMIndexProcessor(); if (name.equals(BED_DIFFERENCE_HEIGHT_YEAR)) {