From da46b6efc02ef860dd2f2016cd29f50ca8e3e46a Mon Sep 17 00:00:00 2001 From: Max Schenkelberg Date: Tue, 22 May 2012 09:56:27 -0500 Subject: [PATCH] Issue #239 Moved initialization code in GFE resources so recycle() works properly Change-Id: I3a4e1f18a7246af504a6d1ce791bd94ab1f721d5 Former-commit-id: 4c0a18894c396236ea7dfe445598f24d19185fde [formerly e81a9ee93541994069dfe7d60050feea9774d494] [formerly 52a78af98c986e878162d0685a242a91d1ac4c7c [formerly 1f092691e6e43bd8f6d10c2b8fab0a68eca38992]] Former-commit-id: 52a78af98c986e878162d0685a242a91d1ac4c7c Former-commit-id: 7b7e708092ac5dfd86d08b80660ecfb0b59045fb --- .../ui/rsc/CollaborationResource.java | 5 ++++ .../events/strings/DrawStringEvent.java | 22 +++++++++++++++ .../raytheon/viz/core/gl/internal/GLFont.java | 1 + .../com/raytheon/viz/gfe/rsc/GFEResource.java | 28 +++++++++---------- .../viz/gfe/rsc/GFESystemResource.java | 7 ++--- .../gfe/rsc/colorbar/GFEColorbarResource.java | 23 ++++----------- 6 files changed, 50 insertions(+), 36 deletions(-) diff --git a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/rsc/CollaborationResource.java b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/rsc/CollaborationResource.java index e937666ab3..96e3dd9555 100644 --- a/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/rsc/CollaborationResource.java +++ b/cave/com.raytheon.uf.viz.collaboration.ui/src/com/raytheon/uf/viz/collaboration/ui/rsc/CollaborationResource.java @@ -291,6 +291,11 @@ public class CollaborationResource extends @Subscribe public void renderFrameEvent(RenderFrameEvent event) { + if (dataManager == null) { + // Haven't initialized yet, don't process + return; + } + if (event instanceof UpdateRenderFrameEvent == false) { // Not an update event, new frame int objectId = event.getObjectId(); diff --git a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/events/strings/DrawStringEvent.java b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/events/strings/DrawStringEvent.java index ae318e109b..1bfcc7921d 100644 --- a/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/events/strings/DrawStringEvent.java +++ b/cave/com.raytheon.uf.viz.remote.graphics/src/com/raytheon/uf/viz/remote/graphics/events/strings/DrawStringEvent.java @@ -77,6 +77,9 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent { @DynamicSerializeElement private RGB boxColor; + @DynamicSerializeElement + private RGB shadowColor; + @DynamicSerializeElement private double magnification = 1.0f; @@ -103,6 +106,7 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent { DrawStringEvent diffObject = new DrawStringEvent(); diffObject.alpha = diffEvent.alpha; diffObject.boxColor = diffEvent.boxColor; + diffObject.shadowColor = diffEvent.shadowColor; diffObject.xOrColors = diffEvent.xOrColors; diffObject.fontId = diffEvent.fontId; diffObject.magnification = diffEvent.magnification; @@ -140,6 +144,7 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent { DrawStringEvent diffObject = (DrawStringEvent) diffEvent; alpha = diffObject.alpha; boxColor = diffObject.boxColor; + shadowColor = diffObject.shadowColor; xOrColors = diffObject.xOrColors; if (diffObject.colors != null) { colors = diffObject.colors; @@ -169,6 +174,7 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent { this.colors = string.getColors(); this.alpha = string.basics.alpha; this.boxColor = string.boxColor; + this.shadowColor = string.shadowColor; this.xOrColors = string.basics.xOrColors; this.horizontalAlignment = string.horizontalAlignment; this.verticalAlignment = string.verticallAlignment; @@ -187,6 +193,7 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent { ds.basics.alpha = alpha; ds.basics.xOrColors = xOrColors; ds.boxColor = boxColor; + ds.shadowColor = shadowColor; ds.horizontalAlignment = horizontalAlignment; ds.verticallAlignment = verticalAlignment; ds.textStyle = textStyle; @@ -316,6 +323,21 @@ public class DrawStringEvent extends AbstractRemoteGraphicsRenderEvent { this.boxColor = boxColor; } + /** + * @return the shadowColor + */ + public RGB getShadowColor() { + return shadowColor; + } + + /** + * @param shadowColor + * the shadowColor to set + */ + public void setShadowColor(RGB shadowColor) { + this.shadowColor = shadowColor; + } + /** * @return the magnification */ diff --git a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLFont.java b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLFont.java index d5723118fd..eb3e26ef49 100644 --- a/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLFont.java +++ b/cave/com.raytheon.viz.core.gl/src/com/raytheon/viz/core/gl/internal/GLFont.java @@ -73,6 +73,7 @@ public class GLFont implements IGLFont { public GLFont(File font, float fontSize, Style[] styles) { try { + this.fontName = font.getName(); this.font = Font.createFont(Font.TRUETYPE_FONT, font).deriveFont( fontSize); this.currentFontSize = this.fontSize = fontSize; diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResource.java index 2fe706a6c9..8dbd7de1b5 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResource.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFEResource.java @@ -287,7 +287,6 @@ public class GFEResource extends * @param dataManager * the datamanager responsible for it */ - @SuppressWarnings("unchecked") public GFEResource(Parm parm, DataManager dataManager) { super(new GFEResourceData(), new LoadProperties()); this.resourceData.addChangeListener(this); @@ -312,11 +311,6 @@ public class GFEResource extends GridParmInfo info = this.parm.getGridInfo(); this.gridGeometry = MapUtil.getGridGeometry(info.getGridLoc()); - parm.getListeners().addGridChangedListener(this.gridChanged); - parm.getListeners().addParmInventoryChangedListener( - this.parmInventoryChanged); - parm.getListeners().addParmIDChangedListener(this.parmIdChanged); - lastIscMode = dataManager.getParmManager().iscMode(); updateRightClickMenu(); @@ -338,10 +332,6 @@ public class GFEResource extends } } }; - - dataManager.getNotificationRouter().addObserver(notificationObserver); - - Message.registerInterest(this, ShowISCGridsMsg.class); } public void reset() { @@ -393,6 +383,7 @@ public class GFEResource extends for (IWireframeShape shape : outlineShapes.values()) { shape.dispose(); } + outlineShapes.clear(); } if (shadedShapes != null) { @@ -402,6 +393,7 @@ public class GFEResource extends shadedShape.dispose(); } } + shadedShapes.clear(); } dataManager.getNotificationRouter() @@ -414,13 +406,16 @@ public class GFEResource extends if (this.gridDisplay != null) { this.gridDisplay.dispose(); + this.gridDisplay = null; } if (this.contourDisplay != null) { this.contourDisplay.dispose(); + this.contourDisplay = null; } clearVectorDisplays(); + lastDisplayedTime = null; } private void clearVectorDisplays() { @@ -448,8 +443,17 @@ public class GFEResource extends * @seecom.raytheon.viz.core.rsc.IVizResource#init(com.raytheon.viz.core. * IGraphicsTarget) */ + @SuppressWarnings("unchecked") @Override protected void initInternal(IGraphicsTarget target) throws VizException { + parm.getListeners().addGridChangedListener(this.gridChanged); + parm.getListeners().addParmInventoryChangedListener( + this.parmInventoryChanged); + parm.getListeners().addParmIDChangedListener(this.parmIdChanged); + + dataManager.getNotificationRouter().addObserver(notificationObserver); + + Message.registerInterest(this, ShowISCGridsMsg.class); // Get the font configured for this parm type String fontPrefName = ""; @@ -461,10 +465,6 @@ public class GFEResource extends fontPrefName = "BoundedArea_font"; } - if (gfeFont != null) { - gfeFont.dispose(); - } - gfeFont = GFEFonts.makeGFEIFont(target, fontPrefName, 2); } diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFESystemResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFESystemResource.java index 15e7606b1e..8b3c71e863 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFESystemResource.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/GFESystemResource.java @@ -106,9 +106,6 @@ public class GFESystemResource extends this.dataManager = dataManager; this.editTools = new HashSet(); this.persistentRenderables = new HashSet(); - - // The following renderables are always ready - this.persistentRenderables.add(new SampleRenderable()); } /* @@ -127,6 +124,7 @@ public class GFESystemResource extends ((SampleRenderable) r).dispose(); } } + this.persistentRenderables.clear(); } /* @@ -147,7 +145,8 @@ public class GFESystemResource extends */ @Override protected void initInternal(IGraphicsTarget target) throws VizException { - + // The following renderables are always ready + this.persistentRenderables.add(new SampleRenderable()); } /** diff --git a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java index 3c4b6a9279..959f5caa56 100644 --- a/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java +++ b/cave/com.raytheon.viz.gfe/src/com/raytheon/viz/gfe/rsc/colorbar/GFEColorbarResource.java @@ -355,7 +355,11 @@ public class GFEColorbarResource extends */ @Override protected void initInternal(IGraphicsTarget target) throws VizException { - // this.target = target; + colorbarScaleFont = GFEFonts.makeGFEIFont(target, "ColorBarScale_font", + 1); + colorbarWxLabelFont = GFEFonts.makeGFEIFont(target, + "ColorBarWxLabel_font", 2); + pickupFont = GFEFonts.makeGFEIFont(target, "ColorBarPickUp_font", 3); IDisplayPaneContainer container = getResourceContainer(); if (container != null) { @@ -379,23 +383,6 @@ public class GFEColorbarResource extends return; } - // int curIndex = this.descriptor.getCurrentTimeFrame(); - - if (colorbarScaleFont == null) { - colorbarScaleFont = GFEFonts.makeGFEIFont(target, - "ColorBarScale_font", 1); - } - - if (colorbarWxLabelFont == null) { - colorbarWxLabelFont = GFEFonts.makeGFEIFont(target, - "ColorBarWxLabel_font", 2); - } - - if (pickupFont == null) { - pickupFont = GFEFonts - .makeGFEIFont(target, "ColorBarPickUp_font", 3); - } - IExtent screenExtent = paintProps.getView().getExtent(); // Construct a bar that is 25 pixels high