From 2c82f5ea7a1a91fe49e507206121dd68b2b392a0 Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Wed, 23 Apr 2014 15:42:16 -0500 Subject: [PATCH] Issue #2648 Update hprof info to match grid changes in 14.3 Former-commit-id: c391a6fbb543e467030f45a494e00bc4246c6a36 --- .../uf/viz/hprof/D2DGridResourceExporter.java | 45 +++++++++++++++---- 1 file changed, 37 insertions(+), 8 deletions(-) diff --git a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/uf/viz/hprof/D2DGridResourceExporter.java b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/uf/viz/hprof/D2DGridResourceExporter.java index 493bb6d28c..06a28e7f55 100644 --- a/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/uf/viz/hprof/D2DGridResourceExporter.java +++ b/javaUtilities/com.raytheon.uf.viz.hprof/src/com/raytheon/uf/viz/hprof/D2DGridResourceExporter.java @@ -177,7 +177,6 @@ public class D2DGridResourceExporter extends RequestableResourceExporter { } catch (IllegalStateException e) { /* heap dump is from after 14.2 */ } - resource.getBoolean("reprojectedData"); int floats = entry.getValue(); int size = floats * 4 / 1024; String suffix = "KB"; @@ -216,9 +215,16 @@ public class D2DGridResourceExporter extends RequestableResourceExporter { SmartInstance gridGeometry = generalGridData.get("gridGeometry"); SmartInstance gridRange = gridGeometry.get("gridRange"); int[] index = gridRange.getIntArray("index"); - width = index[2] - index[0]; - height = index[3] - index[1]; - + if (index != null) { + /* GeneralGridEnvelope */ + this.width = index[2] - index[0]; + this.height = index[3] - index[1]; + } else { + /* GridEnvelope2D */ + this.width = gridRange.getInt("width"); + this.height = gridRange.getInt("height"); + } + SmartInstance buffer = generalGridData.get("scalarData"); scalarCapacity = getCapacity(buffer); @@ -237,11 +243,34 @@ public class D2DGridResourceExporter extends RequestableResourceExporter { if (buffer == null) { return 0; } - try { - return buffer.getInt("capacity"); - } catch (IllegalStateException e) { - return buffer.get("buffer").getInt("capacity"); + while (buffer != null) { + try { + /* + * Eventually we hope to find a FloatBuffer, before 14.3 it + * even happens on the first try. + */ + return buffer.getInt("capacity"); + } catch (IllegalStateException e1) { + /* + * This case will pull the buffer out of a + * FloatBufferWrapper + */ + + SmartInstance tmp = buffer.get("buffer"); + if (tmp == null) { + /* + * This case will pull a source out of a + * GeographicDataSource or a FilteredDataSource, + * hopefully after recursing enough we will get to a + * FloatBufferWrapper. + */ + tmp = buffer.get("wrappedSource"); + } + buffer = tmp; + } } + System.err.println("Unable to count floats in GeneralGridData."); + return 0; } public int getFloatCount() {