From 8e734f917e63cd966d2b915373f34e67f804fded Mon Sep 17 00:00:00 2001 From: Nate Jensen Date: Mon, 10 Mar 2014 13:02:45 -0500 Subject: [PATCH] Issue #2832 consolidate watch and warning recycle logic Change-Id: I9d7e284bafbe8073ac99eb3ce0e7fbd81f3ff889 Former-commit-id: 8cd98e0b9fd27ed600e46c95ebb5cac7220326e5 [formerly 814d21d0a5b58c95f6339e1816788953692f5e95] Former-commit-id: 057f7671a0e0ff785bf9d52f85ff81d87c5f3700 --- .../viz/warnings/rsc/AbstractWWAResource.java | 32 +++++++++++++++++++ .../viz/warnings/rsc/WarningsResource.java | 29 ++--------------- .../viz/warnings/rsc/WatchesResource.java | 24 ++------------ 3 files changed, 38 insertions(+), 47 deletions(-) diff --git a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/AbstractWWAResource.java b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/AbstractWWAResource.java index efce152268..d8d6e83485 100644 --- a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/AbstractWWAResource.java +++ b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/AbstractWWAResource.java @@ -84,6 +84,8 @@ import com.vividsolutions.jts.geom.prep.PreparedGeometryFactory; * Sep 4, 2013 2176 jsanchez Made the polygon line width thicker and made regular text not bold. * Nov 11, 2013 2439 rferrel Changes to prevent getting future warning when in DRT mode. * Dec 3, 2013 2576 jsanchez Increased the font size of EMER. + * Mar 10, 2014 2832 njensen Moved duplicated subclass's disposeInternal() logic here + * * * * @author jsanchez @@ -695,4 +697,34 @@ public abstract class AbstractWWAResource extends } return timeRange; } + + @Override + protected void disposeInternal() { + for (WarningEntry entry : entryMap.values()) { + if (entry.shadedShape != null) { + entry.shadedShape.dispose(); + } + if (entry.wireframeShape != null) { + entry.wireframeShape.dispose(); + } + + /* + * we set this to true and keep the entries around solely in case + * this resource is being recycled + */ + entry.project = true; + } + + if (warningsFont != null) { + warningsFont.dispose(); + // set font to null for recycle safety + warningsFont = null; + } + + if (emergencyFont != null) { + emergencyFont.dispose(); + // set font to null for recylcle safety + emergencyFont = null; + } + } } diff --git a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningsResource.java b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningsResource.java index 50ed0daa0b..a415b3d6bc 100644 --- a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningsResource.java +++ b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WarningsResource.java @@ -63,8 +63,8 @@ import com.vividsolutions.jts.geom.Geometry; * Jul 24, 2013 DR16350 mgamazaychikov Fix the problem with plotting EXP warning * Sep 5, 2013 2176 jsanchez Disposed the emergency font. * Feb 19, 2014 2819 randerso Removed unnecessary .clone() call - * Mar 04, 2014 2832 njensen Set fonts to null in disposeInternal() so recycle works - * Set entry.project to true for recycle + * Mar 04, 2014 2832 njensen Moved disposeInternal() to abstract class + * * * * @author jsanchez @@ -134,30 +134,7 @@ public class WarningsResource extends AbstractWWAResource { @Override protected void disposeInternal() { cancelRefreshTask(this); - for (WarningEntry entry : entryMap.values()) { - if (entry.shadedShape != null) { - entry.shadedShape.dispose(); - } - if (entry.wireframeShape != null) { - entry.wireframeShape.dispose(); - } - - /* - * we set this to true and keep the entries around solely in case - * this resource is being recycled - */ - entry.project = true; - } - - if (warningsFont != null) { - warningsFont.dispose(); - warningsFont = null; - } - - if (emergencyFont != null) { - emergencyFont.dispose(); - emergencyFont = null; - } + super.disposeInternal(); } @Override diff --git a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java index ab95ba9951..fb04078daa 100644 --- a/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java +++ b/cave/com.raytheon.viz.warnings/src/com/raytheon/viz/warnings/rsc/WatchesResource.java @@ -53,7 +53,8 @@ import com.vividsolutions.jts.geom.GeometryFactory; * Nov 8, 2013 16758 mgamazaychikov Changed access modifier of mergeWatches to protected * so a child class can override the implementation. * Feb 19, 2014 2819 randerso Removed unnecessary .clone() call - * Mar 04, 2014 2832 njensen Set fonts to null in disposeInternal() so recycle works + * Mar 04, 2014 2832 njensen Moved disposeInternal() to abstract class + * * * * @author jsanchez @@ -131,26 +132,7 @@ public class WatchesResource extends AbstractWWAResource { @Override protected void disposeInternal() { timer.cancel(); - - for (WarningEntry entry : entryMap.values()) { - if (entry.shadedShape != null) { - entry.shadedShape.dispose(); - } - if (entry.wireframeShape != null) { - entry.wireframeShape.dispose(); - } - } - - entryMap.clear(); - if (warningsFont != null) { - warningsFont.dispose(); - warningsFont = null; - } - - if (emergencyFont != null) { - emergencyFont.dispose(); - emergencyFont = null; - } + super.disposeInternal(); } @Override