Revision: 6452
          http://sourceforge.net/p/jump-pilot/code/6452
Author:   ma15569
Date:     2020-09-12 21:09:51 +0000 (Sat, 12 Sep 2020)
Log Message:
-----------
removed a bug that was giving a null exception if no Sextante raster was 
selected during pixel inspection

Modified Paths:
--------------
    core/trunk/src/org/openjump/core/ui/plugin/raster/RasterQueryCursorTool.java

Modified: 
core/trunk/src/org/openjump/core/ui/plugin/raster/RasterQueryCursorTool.java
===================================================================
--- 
core/trunk/src/org/openjump/core/ui/plugin/raster/RasterQueryCursorTool.java    
    2020-09-12 13:51:30 UTC (rev 6451)
+++ 
core/trunk/src/org/openjump/core/ui/plugin/raster/RasterQueryCursorTool.java    
    2020-09-12 21:09:51 UTC (rev 6452)
@@ -131,10 +131,10 @@
         RasterImageLayer rLayer = null;
 
         final WorkbenchContext wbcontext = this.getWorkbench().getContext();
-        RasterImageLayer aLayer = null;
-
-        Layerable[] ls = (Layerable[]) wbcontext.getLayerNamePanel()
+        @SuppressWarnings("unchecked")
+               RasterImageLayer[] ls = (RasterImageLayer[]) 
wbcontext.getLayerableNamePanel()
                 .selectedNodes(RasterImageLayer.class)
+                .toArray(new RasterImageLayer[] {});
                 .toArray(new Layerable[] {});
         if (ls != null && ls.length > 0) {
             rLayer = (RasterImageLayer) ls[0];
@@ -305,21 +305,21 @@
     public void mouseMoved(MouseEvent me) {
 
         final WorkbenchContext wbcontext = this.getWorkbench().getContext();
-        RasterImageLayer aLayer = null;
-        for (java.util.Iterator i = wbcontext.getLayerNamePanel()
-                .selectedNodes(RasterImageLayer.class).iterator(); 
i.hasNext();) {
-            aLayer = (RasterImageLayer) i.next();
-        }
+          
+        for (Object layerable : 
wbcontext.getLayerableNamePanel().selectedNodes(Layerable.class)) {
+            Layerable layer = (Layerable)layerable;
+        
+                if (layer instanceof RasterImageLayer) {
         String cellValues = null;
         try {
             cellValues = "";
             Coordinate tentativeCoordinate = getPanel().getViewport()
                     .toModelCoordinate(me.getPoint());
-            for (int b = 0; b < aLayer.getNumBands(); b++) {
-                Double cellValue = aLayer.getCellValue(tentativeCoordinate.x,
+            for (int b = 0; b < ((RasterImageLayer) layer).getNumBands(); b++) 
{
+                Double cellValue = ((RasterImageLayer) 
layer).getCellValue(tentativeCoordinate.x,
                         tentativeCoordinate.y, b);
                 if (cellValue != null) {
-                    if (aLayer.isNoData(cellValue)) {
+                    if (((RasterImageLayer) layer).isNoData(cellValue)) {
                         cellValues = cellValues.concat(Double
                                 .toString(cellValue))
                                 + "("
@@ -336,23 +336,15 @@
         } catch (RasterDataNotFoundException ex) {
             cellValues = "???";
         } catch (IOException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+                cellValues = " - ";
         } catch (NoninvertibleTransformException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+                cellValues = " - ";
         }
-        name = aLayer.getName();
-
-        // gContext.getWorkbenchContext()
-        // .getLayerViewPanel()
-        // .setToolTipText(
-        // "(" + name + ") " + VALUE + ": "
-        // + cellValues.toString());
-
+        name = ((RasterImageLayer) layer).getName();
         getPanel().getContext().setStatusMessage(
                 "[" + LAYER + ": " + name + "] " + VALUE + ": "
-                        + cellValues.toString());
+                        + cellValues.toString());}
+        }
     }
     
     @Override



_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to