diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java index 6a47ea7844..d7be459fab 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPResource.java @@ -196,6 +196,7 @@ import com.vividsolutions.jts.geom.Point; * Aug 13, 2014 3492 mapeters Updated deprecated createWireframeShape() calls. * Aug 14, 2014 3523 mapeters Updated deprecated {@link DrawableString#textStyle} * assignments. + * Sep 23, 2014 3009 njensen Overrode recycleInternal() * * * @author dhladky @@ -1110,19 +1111,6 @@ public class FFMPResource extends @Override protected void disposeInternal() { - IDisplayPaneContainer container = getResourceContainer(); - if (container != null) { - container.unregisterMouseHandler(inspectAdapter); - } - - if (font != null) { - font.dispose(); - } - - if (xfont != null) { - xfont.dispose(); - } - if (this.getName().indexOf("Table Display") > -1) { if (basinTableDlg != null) { closeDialog(); @@ -1135,25 +1123,7 @@ public class FFMPResource extends } } - // dispose of shapes - if (smallBasinOverlayShape != null) { - smallBasinOverlayShape.dispose(); - } - if (streamShadedShape != null) { - streamShadedShape.dispose(); - } - if (streamOutlineShape != null) { - streamOutlineShape.dispose(); - } - shadedShapes.dispose(); - - // clear takes care of the drawables - clear(); resetRecords(); - for (PixelCoverage px : vgbDrawables.values()) { - px.dispose(); - } - vgbDrawables.clear(); if (monitor.getResourceListenerList().size() == 1) { // free up the monitor which holds most of the memory @@ -1164,6 +1134,52 @@ public class FFMPResource extends monitor.removeResourceListener(this); } + recycleInternal(); + } + + /** + * Removes the mouse adapter and disposes of all the graphics objects. + */ + @Override + protected void recycleInternal() { + IDisplayPaneContainer container = getResourceContainer(); + if (container != null) { + container.unregisterMouseHandler(inspectAdapter); + } + + if (font != null) { + font.dispose(); + font = null; + } + + if (xfont != null) { + xfont.dispose(); + xfont = null; + } + + // dispose of shapes + if (smallBasinOverlayShape != null) { + smallBasinOverlayShape.dispose(); + smallBasinOverlayShape = null; + } + if (streamShadedShape != null) { + streamShadedShape.dispose(); + streamShadedShape = null; + } + if (streamOutlineShape != null) { + streamOutlineShape.dispose(); + streamOutlineShape = null; + } + shadedShapes.dispose(); + + // clear takes care of the drawables + clear(); + + for (PixelCoverage px : vgbDrawables.values()) { + px.dispose(); + } + vgbDrawables.clear(); + } /** @@ -1552,7 +1568,7 @@ public class FFMPResource extends public void project(CoordinateReferenceSystem mapData) throws VizException { if (shadedShapes != null) { - shadedShapes.clear(); + shadedShapes.dispose(); } if (streamShadedShape != null) { diff --git a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPShapeContainer.java b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPShapeContainer.java index 23948e25b8..5434f4340e 100644 --- a/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPShapeContainer.java +++ b/cave/com.raytheon.uf.viz.monitor.ffmp/src/com/raytheon/uf/viz/monitor/ffmp/ui/rsc/FFMPShapeContainer.java @@ -20,8 +20,8 @@ package com.raytheon.uf.viz.monitor.ffmp.ui.rsc; * further licensing information. **/ -import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; import com.raytheon.uf.viz.core.IGraphicsTarget; import com.raytheon.uf.viz.core.drawables.ext.colormap.IColormapShadedShapeExtension; @@ -38,6 +38,8 @@ import com.raytheon.uf.viz.core.map.MapDescriptor; * ------------ ---------- ----------- -------------------------- * 15 Sept, 2011 10899 dhladky Initial creation * 27 June, 2013 2152 njensen Added dispose() + * Sep 23, 2014 3009 njensen Cleaned up + * * * * @author dhladky @@ -47,21 +49,22 @@ import com.raytheon.uf.viz.core.map.MapDescriptor; public class FFMPShapeContainer { /** always the same vertexes, one for each CWA **/ - private ConcurrentHashMap> shadedShapes = null; + private ConcurrentMap> shadedShapes = null; // public constructor public FFMPShapeContainer() { - shadedShapes = new ConcurrentHashMap>(); + shadedShapes = new ConcurrentHashMap>(); } /** - * build the ones you need to draw all possible FFMP configs + * Retrieves the shaded shape if it exists, or builds and caches it if it + * does not exist * * @param cwa * @param huc * @param target * @param descriptor - * @return + * @return the shaded shape */ public IColormapShadedShape getShape(String cwa, String huc, IGraphicsTarget target, MapDescriptor descriptor) @@ -74,7 +77,7 @@ public class FFMPShapeContainer { .createColormapShadedShape(descriptor.getGridGeometry(), true); - ConcurrentHashMap cwaShapes = shadedShapes + ConcurrentMap cwaShapes = shadedShapes .get(cwa); if (cwaShapes == null) { @@ -89,43 +92,33 @@ public class FFMPShapeContainer { } /** - * return only drawable shape + * Retrieves the shaded shape from the cache * * @param cwa * @param huc - * @return + * @return the shape if it exists, otherwise null */ public IColormapShadedShape getDrawableShape(String cwa, String huc) { - IColormapShadedShape shape = null; - - try { - shape = shadedShapes.get(cwa).get(huc); - } catch (NullPointerException npe) { - // System.out.println(cwa + " " + huc + - // " Shape Not created yet!!!!"); - // do nothing + if (cwa != null) { + ConcurrentMap innerMap = shadedShapes + .get(cwa); + if (innerMap != null && huc != null) { + shape = innerMap.get(huc); + } } return shape; } /** - * clears the shapes - * - * @return + * Disposes of each of the shaded shapes and clears the maps */ - public void clear() { - shadedShapes.clear(); - } - public void dispose() { - for (String key : shadedShapes.keySet()) { - ConcurrentHashMap innerMap = shadedShapes - .get(key); - Iterator itr = innerMap.values().iterator(); - while (itr.hasNext()) { - itr.next().dispose(); + for (ConcurrentMap innerMap : shadedShapes + .values()) { + for (IColormapShadedShape shp : innerMap.values()) { + shp.dispose(); } innerMap.clear(); }