From db95e6621bb98ff4a526ce213123a904870f8fd8 Mon Sep 17 00:00:00 2001 From: Ben Steffensmeier Date: Fri, 3 Aug 2012 14:10:04 -0500 Subject: [PATCH] Issue #1001 synchronize paint with add. Former-commit-id: 2c9737ca5ccc85a3c5e8df5841e8a9637cccf80b [formerly 2c9737ca5ccc85a3c5e8df5841e8a9637cccf80b [formerly 825c08e6ce89b0c4b042c9e85f7abbc7b9a675ef]] Former-commit-id: 798d26e95470c6dc4f5e376cdc2dc1dbefd3a014 Former-commit-id: e9cde98072115be9cad280de7cda0c25492b39d6 --- .../viz/lightning/LightningResource.java | 88 ++++++++++--------- 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java index 23ee4b4a41..b3215c3dac 100644 --- a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java +++ b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResource.java @@ -359,57 +359,59 @@ public class LightningResource extends .get(this.lastPaintedTime); if (cacheObject != null) { - LightningFrame bundle = cacheObject.getObjectAsync(); - if (bundle == null) { - needsUpdate = true; - issueRefresh(); - } else { - if (needsUpdate) { - needsUpdate = false; - currNegList = new ArrayList( - bundle.posLatLonList.size()); - currPosList = new ArrayList( - bundle.negLatLonList.size()); + synchronized (cacheObject.getMetadata()) { + LightningFrame bundle = cacheObject.getObjectAsync(); + if (bundle == null) { + needsUpdate = true; + issueRefresh(); + } else { + if (needsUpdate) { + needsUpdate = false; + currNegList = new ArrayList( + bundle.posLatLonList.size()); + currPosList = new ArrayList( + bundle.negLatLonList.size()); + + if (resourceData.isHandlingPositiveStrikes()) { + for (double[] pos : bundle.posLatLonList) { + currPosList.add(descriptor.worldToPixel(pos)); + } + } + if (resourceData.isHandlingNegativeStrikes()) { + for (double[] neg : bundle.negLatLonList) { + currNegList.add(descriptor.worldToPixel(neg)); + } + } + } if (resourceData.isHandlingPositiveStrikes()) { - for (double[] pos : bundle.posLatLonList) { - currPosList.add(descriptor.worldToPixel(pos)); + List positive = new ArrayList( + currPosList.size()); + for (double[] pos : currPosList) { + if (extent.contains(pos)) { + positive.add(pos); + } } + posCount = positive.size(); + + target.drawPoints(positive, color, PointStyle.CROSS, + magnification); } + if (resourceData.isHandlingNegativeStrikes()) { - for (double[] neg : bundle.negLatLonList) { - currNegList.add(descriptor.worldToPixel(neg)); + List negative = new ArrayList( + currPosList.size()); + for (double[] neg : currNegList) { + if (extent.contains(neg)) { + negative.add(neg); + } } + negCount = negative.size(); + + target.drawPoints(negative, color, PointStyle.DASH, + magnification); } } - - if (resourceData.isHandlingPositiveStrikes()) { - List positive = new ArrayList( - currPosList.size()); - for (double[] pos : currPosList) { - if (extent.contains(pos)) { - positive.add(pos); - } - } - posCount = positive.size(); - - target.drawPoints(positive, color, PointStyle.CROSS, - magnification); - } - - if (resourceData.isHandlingNegativeStrikes()) { - List negative = new ArrayList( - currPosList.size()); - for (double[] neg : currNegList) { - if (extent.contains(neg)) { - negative.add(neg); - } - } - negCount = negative.size(); - - target.drawPoints(negative, color, PointStyle.DASH, - magnification); - } } }