From 631cc5cabeb201a799a04b69572761b05c16e614 Mon Sep 17 00:00:00 2001 From: Brian Clements Date: Wed, 1 Jul 2015 14:02:46 -0500 Subject: [PATCH] Omaha #4597 better labels for lightning resources Change-Id: I5e7792e881c95cbb1ecea30320e9f0892457013c Former-commit-id: d2b5d5e1d4bd2e67e34c212ff09595e36abbaeab --- .../viz/lightning/LightningResource.java | 22 ++--- .../viz/lightning/LightningResourceData.java | 97 ++++++++++++------- 2 files changed, 69 insertions(+), 50 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 50b1da5fbe..13c64d1acf 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 @@ -59,6 +59,7 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties; import com.raytheon.uf.viz.core.rsc.capabilities.ColorableCapability; import com.raytheon.uf.viz.core.rsc.capabilities.DensityCapability; import com.raytheon.uf.viz.core.rsc.capabilities.MagnificationCapability; +import com.raytheon.viz.lightning.LightningResourceData.DisplayType; import com.raytheon.viz.lightning.cache.LightningFrame; import com.raytheon.viz.lightning.cache.LightningFrameMetadata; import com.raytheon.viz.lightning.cache.LightningFrameRetriever; @@ -97,6 +98,7 @@ import com.raytheon.viz.lightning.cache.LightningFrameRetriever; * Mar 05, 2015 4233 bsteffen include source in cache key. * Apr 09, 2015 4386 bclement added updateLightningFrames() * Jul 01, 2015 4592 bclement cloud flashes are now points instead of circles + * Jul 01, 2015 4597 bclement reworked resource name using DisplayType * * * @@ -210,26 +212,14 @@ public class LightningResource extends } else { rval = convertTimeIntervalToString(absTimeInterval); } - if (resourceData.isExclusiveForType()) { - String modifier; - if (resourceData.isHandlingCloudFlashes()) { - modifier = "Cloud Flash "; - } else if (resourceData.isHandlingNegativeStrikes()) { - modifier = "Negative "; - } else if (resourceData.isHandlingPositiveStrikes()) { - modifier = "Positive "; - } else if (resourceData.isHandlingPulses()) { - modifier = "Pulse "; - } else { - /* space to preserve formatting */ - modifier = " "; - } - rval += modifier; + DisplayType displayType = resourceData.getDisplayType(); + if (!displayType.equals(DisplayType.UNDEFINED)) { + rval += displayType.label + ' '; } String source = resourceData.getSource(); if (source != null) { - rval += source + " "; + rval += source + ' '; } return rval; } diff --git a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java index bcc57dd76e..37dc8b633a 100644 --- a/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java +++ b/cave/com.raytheon.viz.lightning/src/com/raytheon/viz/lightning/LightningResourceData.java @@ -46,9 +46,10 @@ import com.raytheon.uf.viz.core.rsc.LoadProperties; * ------------ ---------- ----------- -------------------------- * Feb 18, 2009 chammack Initial creation * Feb 27, 2013 DCS 152 jgerth Support for WWLLN and multiple sources - * Jun 19, 2014 3214 bclement added pulse and cloud flash support - * Jul 07, 2014 3333 bclement removed plotLightSource field + * Jun 19, 2014 3214 bclement added pulse and cloud flash support + * Jul 07, 2014 3333 bclement removed plotLightSource field * Mar 05, 2015 4233 bsteffen include source in cache key. + * Jul 01, 2015 4597 bclement added DisplayType * * * @author chammack @@ -59,6 +60,20 @@ public class LightningResourceData extends AbstractRequestableResourceData { private static final transient IUFStatusHandler statusHandler = UFStatus .getHandler(LightningResourceData.class); + /* + * certain combination of lightning types get specific display labels + */ + public static enum DisplayType { + UNDEFINED(""), CLOUD_FLASH("Cloud Flash"), NEGATIVE("Negative"), POSITIVE( + "Positive"), PULSE("Pulse"), TOTAL_FLASH("Total"), CLOUD_TO_GROUND( + "Cloud to Ground"); + public final String label; + + private DisplayType(String name) { + this.label = name; + } + } + @XmlAttribute private boolean handlingPositiveStrikes = true; @@ -73,7 +88,7 @@ public class LightningResourceData extends AbstractRequestableResourceData { @XmlAttribute private int countPosition = 0; - + @Override protected AbstractVizResource constructResource( LoadProperties loadProperties, PluginDataObject[] objects) { @@ -97,8 +112,8 @@ public class LightningResourceData extends AbstractRequestableResourceData { @Override public boolean isUpdatingOnMetadataOnly() { - if (this.isUpdatingOnMetadataOnly == false) - return false; + if (this.isUpdatingOnMetadataOnly == false) + return false; return true; } @@ -159,32 +174,6 @@ public class LightningResourceData extends AbstractRequestableResourceData { return handlingPulses; } - /** - * @see #isHandlingCloudFlashes() - * @see #isHandlingNegativeStrikes() - * @see #isHandlingPositiveStrikes() - * @see #isHandlingPulses() - * @return true if resource data handles exactly one type of data - */ - public boolean isExclusiveForType() { - boolean[] bools = { isHandlingCloudFlashes(), - isHandlingNegativeStrikes(), isHandlingPositiveStrikes(), - isHandlingPulses() }; - boolean handlingZero = true; - boolean handlingMoreThanOne = false; - for (boolean handlingSomething : bools) { - if (handlingSomething) { - if (handlingZero) { - handlingZero = false; - } else { - handlingMoreThanOne = true; - break; - } - } - } - return !handlingZero && !handlingMoreThanOne; - } - /** * @param handlingPulses * the handlingPulses to set @@ -194,11 +183,10 @@ public class LightningResourceData extends AbstractRequestableResourceData { } /** - * @return countPosition - * the countPosition to get - JJG + * @return countPosition the countPosition to get - JJG */ public int getCountPosition() { - return countPosition; + return countPosition; } /** @@ -218,6 +206,47 @@ public class LightningResourceData extends AbstractRequestableResourceData { return null; } + public DisplayType getDisplayType() { + DisplayType rval; + byte bitset = 0x00; + if (handlingCloudFlashes) { + bitset |= 0x01; + } + if (handlingNegativeStrikes) { + bitset |= 0x02; + } + if (handlingPositiveStrikes) { + bitset |= 0x04; + } + if (handlingPulses) { + bitset |= 0x08; + } + + switch (bitset) { + case 0x01: + rval = DisplayType.CLOUD_FLASH; + break; + case 0x02: + rval = DisplayType.NEGATIVE; + break; + case 0x04: + rval = DisplayType.POSITIVE; + break; + case 0x06: + rval = DisplayType.CLOUD_TO_GROUND; + break; + case 0x07: + rval = DisplayType.TOTAL_FLASH; + break; + case 0x08: + rval = DisplayType.PULSE; + break; + default: + rval = DisplayType.UNDEFINED; + } + return rval; + } + /* * (non-Javadoc) *