From bf8ecd8f52a968642552071b3a8936351b744fd1 Mon Sep 17 00:00:00 2001 From: Stephen Gilbert Date: Wed, 10 Dec 2014 14:30:28 -0500 Subject: [PATCH 1/2] VLab Issue #5612 - Fix NSharp crashes when using WINTER/FIRE/HAIL buttons Change-Id: I7f3c69455fab32945f8d19094002074445135dd4 Former-commit-id: afc03f606f9660c1428687f909531ef556fef39a [formerly 21f10e4299dcdeb5aacda8866f715ffa63ab72cc] Former-commit-id: 161c395bbc0b549c2e8f96a0065ae47cdb6a5d7e --- .../rsc/NsharpSpcGraphsPaneResource.java | 183 ++++++------------ .../ncep/ui/nsharp/natives/NsharpNative.java | 12 +- .../ui/nsharp/view/NsharpPaletteWindow.java | 1 + 3 files changed, 64 insertions(+), 132 deletions(-) diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpSpcGraphsPaneResource.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpSpcGraphsPaneResource.java index 597aca18de..d92226edb6 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpSpcGraphsPaneResource.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpSpcGraphsPaneResource.java @@ -15,6 +15,8 @@ package gov.noaa.nws.ncep.ui.nsharp.display.rsc; * 05/23/2014 Chin Chen update SHIP, STP Stats based on bigsharp version 2013Jun12 * 08/18/2014 Chin Chen implemented SARS, FIRE, HAIL, WINTER SPC graphs based on * bigsharp version 2013Jun12 + * 12/03/2014 DR#16884 Chin Chen fixed issue, NSHARP crashes if user loops a product and + * then clicks WINTER/FIRE buttons in Toolbar * * * @@ -109,21 +111,11 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { private float nonSupercell[] = { 8.2f, 12.2f, 14.4f, 15.8f, 17.0f, 20.0f, 23.2f, 27.0f, 30.4f, 32.0f }; - private String hailSize[][] = { - { "", "<1", "1-1.5", "1.75", "2", "2.5", "2.75", "3-4", ">4" }, - { "+1 STD", "1.9", "2.0", "2.3", "2.8", "2.9", "3.0", "3.0", "3.0" }, - { "AVG", "1.5", "1.5", "1.8", "2.3", "2.5", "2.5", "2.6", "2.7" }, - { "-1 STD", "1.1", "1.1", "1.3", "1.7", "2.1", "2.1", "2.2", "2.4" } }; private RGB white = NsharpConstants.color_white; private RGB cyan = NsharpConstants.color_cyan_md; - private RGB hailSizeColor[][] = { - { white, white, white, white, white, white, white, white, white }, - { white, cyan, cyan, cyan, cyan, cyan, cyan, cyan, cyan }, - { white, cyan, cyan, cyan, cyan, cyan, cyan, cyan, cyan }, - { white, cyan, cyan, cyan, cyan, cyan, cyan, cyan, cyan } }; private NsharpNative.NsharpLibrary.HailInfoStr hailInfo = new NsharpNative.NsharpLibrary.HailInfoStr(); @@ -133,6 +125,18 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { private NsharpNative.NsharpLibrary.WinterInfoStr winterInfo = new NsharpNative.NsharpLibrary.WinterInfoStr(); + private String hailSize[][] = { + { "", "<1", "1-1.5", "1.75", "2", "2.5", "2.75", "3-4", ">4" }, + { "+1 STD", "1.9", "2.0", "2.3", "2.8", "2.9", "3.0", "3.0", "3.0" }, + { "AVG", "1.5", "1.5", "1.8", "2.3", "2.5", "2.5", "2.6", "2.7" }, + { "-1 STD", "1.1", "1.1", "1.3", "1.7", "2.1", "2.1", "2.2", "2.4" } }; + + private RGB hailSizeColor[][] = { + { white, white, white, white, white, white, white, white, white }, + { white, cyan, cyan, cyan, cyan, cyan, cyan, cyan, cyan }, + { white, cyan, cyan, cyan, cyan, cyan, cyan, cyan, cyan }, + { white, cyan, cyan, cyan, cyan, cyan, cyan, cyan, cyan } }; + public NsharpSpcGraphsPaneResource(AbstractResourceData resourceData, LoadProperties loadProperties, NsharpAbstractPaneDescriptor desc) { super(resourceData, loadProperties, desc); @@ -140,21 +144,6 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { rightGraph = NsharpPaletteWindow.getRightGraph(); } - private void underDevelopment(int side) throws VizException { - double xpos; - if (side == left) - xpos = spcLeftXOrig + spcFrameWidth / 2; - else - xpos = spcRightXOrig + spcFrameWidth / 2; - DrawableString str = new DrawableString("under development", - NsharpConstants.color_green); - str.font = font12; - str.horizontalAlignment = HorizontalAlignment.LEFT; - str.verticallAlignment = VerticalAlignment.TOP; - ypos = spcYOrig + spcHeight / 2; - str.setCoordinates(xpos, ypos); - target.drawStrings(str); - } private void setXyStartingPosition(int side) { ystart = spcYOrig; @@ -298,35 +287,6 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { // System.out.println("java hail str #"+ (i+1)+ " "+ hailStr); } - /* - * ypos = spcYEnd - 4 * charHeight; for(int i=0; i < 2; i++){ String - * supStr = new String(sarsInfo.getTorStr(), (i*60), 60); - * //System.out.println("tor str #"+ (1+ i)+ " "+ supStr); RGB strColor - * = NsharpConstants.gempakColorToRGB.get(sarsInfo.getTorStrColor()); - * supStr = supStr.substring(0, supStr.indexOf('\0'));// get rid of - * tailing null char(s), as DrawableString will print them out - * DrawableString supercellMatchStr = new DrawableString(supStr, - * strColor); supercellMatchStr.font = font10; - * supercellMatchStr.horizontalAlignment = HorizontalAlignment.LEFT; - * supercellMatchStr.verticallAlignment = VerticalAlignment.TOP; xpos = - * xstart ; ypos = ypos + charHeight; - * supercellMatchStr.setCoordinates(xpos, ypos); - * strList.add(supercellMatchStr); - * - * String sighailStr = new String(sarsInfo.getSighailStr(), (i*60), 60); - * //System.out.println("sighail str #"+ (1+ i)+ " "+ sighailStr); RGB - * strColor1 = - * NsharpConstants.gempakColorToRGB.get(sarsInfo.getSighailStrColor()); - * sighailStr = sighailStr.substring(0, sighailStr.indexOf('\0'));// get - * rid of tailing null char(s), as DrawableString will print them out - * DrawableString sighailMatchStr = new DrawableString(sighailStr, - * strColor1); sighailMatchStr.font = font10; - * sighailMatchStr.horizontalAlignment = HorizontalAlignment.LEFT; - * sighailMatchStr.verticallAlignment = VerticalAlignment.TOP; xpos = - * xstart + 0.51 *spcFrameWidth; sighailMatchStr.setCoordinates(xpos, - * ypos); strList.add(sighailMatchStr); } - */ - target.drawStrings(strList.toArray(new DrawableString[strList.size()])); target.drawLine(lineList.toArray(new DrawableLine[lineList.size()])); } @@ -1621,13 +1581,15 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { // logic statements for Thompson et al. (2012) WAF sample // 39 sigtor, 28 non-sigtor supercells if (cin >= 10) { + // setcolor(7) psigt_stpcin = "0.58"; - stpcColor = NsharpConstants.color_magenta;// setcolor(7); + stpcColor = NsharpConstants.color_magenta;; } // 39 sigtor, 32 non-sigtor supercells else if (cin >= 8) { + // setcolor(7) psigt_stpcin = "0.55"; - stpcColor = NsharpConstants.color_magenta;// setcolor(7); + stpcColor = NsharpConstants.color_magenta; } // 54 sigtor, 104 non-sigtor supercells else if (cin >= 6) { @@ -1745,17 +1707,6 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { valueStp.verticallAlignment = VerticalAlignment.TOP; valueStp.setCoordinates(tboxValueStart, ypos); strList.add(valueStp); - - // reset parcel to previous "oldlplchoice" , TBD - /* - * float pres; if(oldlplchoice == - * NsharpNativeConstants.PARCELTYPE_USER_DEFINED){ - * if(NsharpParcelDialog.getAccess() != null){ pres = - * NsharpParcelDialog.getAccess().getUserDefdParcelMb(); } else pres = - * NsharpNativeConstants.parcelToLayerMap.get(oldlplchoice); } else pres - * = NsharpNativeConstants.parcelToLayerMap.get(oldlplchoice); - * nsharpNative.nsharpLib.define_parcel(oldlplchoice,pres); - */ target.drawStrings(strList.toArray(new DrawableString[strList.size()])); target.drawLine(lineList.toArray(new DrawableLine[lineList.size()])); @@ -1876,7 +1827,7 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { short oldlplchoice; _parcel pcl = new _parcel(); - ; + _lplvalues lpvls = new _lplvalues(); nsharpNative.nsharpLib.get_lpvaluesData(lpvls); // oldlplchoice = lpvls.flag; @@ -1931,12 +1882,6 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { lineList.add(ebsline); } float pres; - /* - * if(oldlplchoice == NsharpNativeConstants.PARCELTYPE_USER_DEFINED){ - * if(NsharpParcelDialog.getAccess() != null){ pres = - * NsharpParcelDialog.getAccess().getUserDefdParcelMb(); } else pres = - * NsharpNativeConstants.parcelToLayerMap.get(oldlplchoice); } else - */ oldlplchoice = rscHandler.getCurrentParcel(); pres = NsharpNativeConstants.parcelToLayerMap.get(oldlplchoice); nsharpNative.nsharpLib.define_parcel(oldlplchoice, pres); @@ -1958,20 +1903,17 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { hRatio = paintProps.getView().getExtent().getWidth() / paintProps.getCanvasBounds().width; DrawableLine line = new DrawableLine(); + line.setCoordinates(spcRightXOrig, spcYOrig); + line.addPoint(spcRightXOrig, spcYOrig + spcHeight); line.lineStyle = LineStyle.SOLID; line.basics.color = NsharpConstants.color_white; line.width = 1; - line.setCoordinates(spcRightXOrig, spcYOrig); - line.addPoint(spcRightXOrig, spcYOrig + spcHeight); target.drawLine(line); PixelExtent spcExt = new PixelExtent(new Rectangle((int) spcLeftXOrig, (int) spcYOrig, (int) spcWidth, (int) spcHeight)); target.drawRect(spcExt, NsharpConstants.color_white, 1f, 1f); // box // border // line - PixelExtent extent = new PixelExtent(new Rectangle((int) spcLeftXOrig, - (int) spcYOrig, (int) spcFrameWidth, (int) spcHeight)); - // target.setupClippingPlane(extent); switch (leftGraph) { case EBS: plotEBS(left); @@ -1995,10 +1937,6 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { plotSars(left); break; } - // target.clearClippingPlane(); - extent = new PixelExtent(new Rectangle((int) spcRightXOrig, - (int) spcYOrig, (int) spcFrameWidth, (int) spcHeight)); - // target.setupClippingPlane(extent); switch (rightGraph) { case EBS: plotEBS(right); @@ -2022,7 +1960,7 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { plotSars(right); break; } - // target.clearClippingPlane(); + } @Override @@ -2030,19 +1968,46 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { super.initInternal(target); } - /* - * private void disposeEbsShape(){ if(ebsBkgLblShape != null) - * ebsBkgLblShape.dispose(); if(ebsBkgLineShape != null) - * ebsBkgLineShape.dispose(); if(ebsSupercellShape != null) - * ebsSupercellShape.dispose(); if(ebsMrglSupShape != null) - * ebsMrglSupShape.dispose(); if(ebsNonSupSgape != null) - * ebsNonSupSgape.dispose(); } - */ @Override protected void disposeInternal() { super.disposeInternal(); } + + public NsharpConstants.SPCGraph getLeftGraph() { + return leftGraph; + } + + public void setGraphs(NsharpConstants.SPCGraph leftGraph, + NsharpConstants.SPCGraph rightGraph) { + this.leftGraph = leftGraph; + this.rightGraph = rightGraph; + getSpcGraphsInfo(); + rscHandler.refreshPane(); + } + + public NsharpConstants.SPCGraph getRightGraph() { + return rightGraph; + } + + public synchronized void getSpcGraphsInfo() { + if (rightGraph == NsharpConstants.SPCGraph.SARS + || leftGraph == NsharpConstants.SPCGraph.SARS) { + nsharpNative.nsharpLib.getSarsInfo(sarsInfo); + } + if (leftGraph == NsharpConstants.SPCGraph.WINTER + || rightGraph == NsharpConstants.SPCGraph.WINTER) { + nsharpNative.nsharpLib.getWinterInfo(winterInfo); + } + if (rightGraph == NsharpConstants.SPCGraph.FIRE + || leftGraph == NsharpConstants.SPCGraph.FIRE) { + nsharpNative.nsharpLib.getFireInfo(fireInfo); + } + if (leftGraph == NsharpConstants.SPCGraph.HAIL + || rightGraph == NsharpConstants.SPCGraph.HAIL) { + nsharpNative.nsharpLib.getHailInfo(hailInfo); + } + } @Override public void handleResize() { @@ -2064,38 +2029,4 @@ public class NsharpSpcGraphsPaneResource extends NsharpAbstractPaneResource { spcYEnd = ext.getMaxY(); } - public NsharpConstants.SPCGraph getLeftGraph() { - return leftGraph; - } - - public void setGraphs(NsharpConstants.SPCGraph leftGraph, - NsharpConstants.SPCGraph rightGraph) { - this.leftGraph = leftGraph; - this.rightGraph = rightGraph; - getSpcGraphsInfo(); - rscHandler.refreshPane(); - } - - public NsharpConstants.SPCGraph getRightGraph() { - return rightGraph; - } - - public void getSpcGraphsInfo() { - if (leftGraph == NsharpConstants.SPCGraph.WINTER - || rightGraph == NsharpConstants.SPCGraph.WINTER) { - nsharpNative.nsharpLib.getWinterInfo(winterInfo); - } - if (leftGraph == NsharpConstants.SPCGraph.FIRE - || rightGraph == NsharpConstants.SPCGraph.FIRE) { - nsharpNative.nsharpLib.getFireInfo(fireInfo); - } - if (leftGraph == NsharpConstants.SPCGraph.HAIL - || rightGraph == NsharpConstants.SPCGraph.HAIL) { - nsharpNative.nsharpLib.getHailInfo(hailInfo); - } - if (leftGraph == NsharpConstants.SPCGraph.SARS - || rightGraph == NsharpConstants.SPCGraph.SARS) { - nsharpNative.nsharpLib.getSarsInfo(sarsInfo); - } - } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/natives/NsharpNative.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/natives/NsharpNative.java index db8229d9b6..e8bbdbda45 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/natives/NsharpNative.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/natives/NsharpNative.java @@ -790,12 +790,12 @@ public class NsharpNative { @Override protected List getFieldOrder() { - return Arrays.asList(new String[] { "oprh", "layerDepth", - "meanLayerRh", "meanLayerMixRat", "meanLayerPw", - "meanLayerOmega", "initPhase", "tempProfile1", - "tempProfile2", "tempProfile3", "wetbulbProfile1", - "wetbulbProfile2", "wetbulbProfile3", "bestGuess1", - "bestGuess2" }); + return Arrays.asList(new String[] { "mopw", "oprh", + "layerDepth", "meanLayerRh", "meanLayerMixRat", + "meanLayerPw", "meanLayerOmega", "initPhase", + "tempProfile1", "tempProfile2", "tempProfile3", + "wetbulbProfile1", "wetbulbProfile2", + "wetbulbProfile3", "bestGuess1", "bestGuess2" }); } } diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaletteWindow.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaletteWindow.java index be2d25a49b..dd31940cce 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaletteWindow.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/view/NsharpPaletteWindow.java @@ -1603,6 +1603,7 @@ public class NsharpPaletteWindow extends ViewPart implements SelectionListener, } else { hailBtn.setEnabled(false); } + hailBtn.setEnabled(false); //Chin ::: temporarily disable HAIL button hailBtn.addListener(SWT.MouseUp, new Listener() { public void handleEvent(Event event) { if (leftGraph != NsharpConstants.SPCGraph.HAIL From 98e6910c268ec11bda017d3a4816deca2006ce99 Mon Sep 17 00:00:00 2001 From: Stephen Gilbert Date: Wed, 10 Dec 2014 16:02:05 -0500 Subject: [PATCH 2/2] VLab Issue #5618 - Fix NSharp compare source feature Change-Id: Ib87bb9701c606f3c622cfe575205289ff7761854 Former-commit-id: b18e85285344dc6a61540b07b6478abf9e91ab02 [formerly 4c33e5bf594bb87a7823f3bf5452f2c322df8eec] Former-commit-id: 2862d63dddfb9c23dbebacb6c8ebb460a72dc3d8 --- .../display/rsc/NsharpResourceHandler.java | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpResourceHandler.java b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpResourceHandler.java index f9f861282f..03d11e0f34 100644 --- a/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpResourceHandler.java +++ b/ncep/gov.noaa.nws.ncep.ui.nsharp/src/gov/noaa/nws/ncep/ui/nsharp/display/rsc/NsharpResourceHandler.java @@ -14,6 +14,7 @@ * 01/13/2014 Chin Chen TTR829- when interpolation, edit graph is allowed * 02/03/2014 1106 Chin Chen Need to be able to use clicking on the Src,Time, or StnId to select display * 08/12/2014 Chin Chen fixed issue that "load archive file with wrong time line displayed" + * 12/04/2014 DR16888 Chin Chen fixed issue that "Comp(Src) button not functioning properly in NSHARP display" * * * @author Chin Chen @@ -575,11 +576,12 @@ public class NsharpResourceHandler { * The following code is to create a list of stns within the range * of user defined radius (minimum distance) to "current" station * and also has data loaded with same time line as "current" time - * line. Note that we have two time line formats, yymmdd/hh(day)Vxxx - * and yymmdd/hh(day). A same time line is compared by yymmdd/hh + * line. Note that we have two time line formats, MM.DDVxxx(day) + * and MM.DD(day). A same time line is compared by MM.DD * only. All qualified stations, including current station, found * will be listed and used for SND comparison. */ + String TIME_COMPARE_STRING = "MM.DD"; compSndSelectedElemList.clear(); // CompSndSelectedElem curStnTimeIndexCouple = new // CompSndSelectedElem(currentStnElementListIndex,currentTimeElementListIndex,currentSndElementListIndex); @@ -593,7 +595,12 @@ public class NsharpResourceHandler { .get(currentSndElementListIndex).getStnInfo(); gc.setStartingGeographicPoint(currentStnInfo.getLongitude(), currentStnInfo.getLatitude()); - int timeLineLengthToComp = "yymmdd/hh".length(); + + // String curTimeString = timeElementList.get(currentTimeElementListIndex).getElementDescription(); + + int timeLineLengthToComp = TIME_COMPARE_STRING.length(); + + String currentTimeLineToComp = timeElementList .get(currentTimeElementListIndex).getElementDescription() .substring(0, timeLineLengthToComp); @@ -1862,15 +1869,15 @@ public class NsharpResourceHandler { NsharpStationInfo stnInfo, boolean fromArchive) { // // testing code // stnInfo.setStnId("KUKI"); - // Set keysettest = new HashSet(soundMap.keySet()); - // for (String key : keysettest) { - // List sndLy = soundMap.remove(key); // String +// Set keysettest = new HashSet(soundMap.keySet()); +// for (String key : keysettest) { +// List sndLy = soundMap.remove(key); // String // // newkey= - // // key.replace("NCUAIR", "gpduair"); // String newkey = - // // key.replace("NAMS", "SSS"); - // String newkey = key.replace("140303/12", "120109/12"); - // soundMap.put(newkey, sndLy); - // } // +// String newkey =key.replace("NCUAIR", "gpduair"); // String newkey = + // String newkey= key.replace("NAMS", "SSS"); + //String newkey = key.replace("130925/00(Wed)V000", "130925/00(Thu)V000"); +// soundMap.put(newkey, sndLy); +// } // // stnInfo.setSndType(stnInfo.getSndType().replace("NCUAIR", // // // "gpduair")); // stnInfo.setSndType(stnInfo.getSndType().replace( // // "NAMS","SSS"));