Peppe,

NACK.. this is going to get very slow for huge datasets containing empty geoms 
only, as it is run on every redraw of the layer tree. please cache the state 
and use a layer change listener or else users will complain about a frozen OJ 
some time in the future and we will have a hard time to pinpoint the reason, 
again ;)

..ede

On 13.11.2016 18:41, jump-pilot-...@lists.sourceforge.net wrote:
> Revision: 5185
>           http://sourceforge.net/p/jump-pilot/code/5185
> Author:   ma15569
> Date:     2016-11-13 17:41:37 +0000 (Sun, 13 Nov 2016)
> Log Message:
> -----------
> The layer tree shows a table icon for layers that have features with empty 
> geometries 
> 
> Modified Paths:
> --------------
>     core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java
> 
> Modified: 
> core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java
> ===================================================================
> --- 
> core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java    
>     2016-11-13 17:21:20 UTC (rev 5184)
> +++ 
> core/trunk/src/com/vividsolutions/jump/workbench/ui/LayerNameRenderer.java    
>     2016-11-13 17:41:37 UTC (rev 5185)
> @@ -36,6 +36,7 @@
>  import java.awt.Rectangle;
>  import java.io.File;
>  import java.util.Iterator;
> +import java.util.List;
>  
>  import javax.swing.DefaultListCellRenderer;
>  import javax.swing.Icon;
> @@ -54,9 +55,11 @@
>  import org.openjump.core.rasterimage.RasterImageLayer;
>  
>  import com.vividsolutions.jts.geom.Envelope;
> +import com.vividsolutions.jts.geom.Geometry;
>  import com.vividsolutions.jump.I18N;
>  import com.vividsolutions.jump.feature.Feature;
>  import com.vividsolutions.jump.feature.FeatureCollection;
> +import com.vividsolutions.jump.feature.FeatureCollectionWrapper;
>  import com.vividsolutions.jump.io.datasource.DataSourceQuery;
>  import com.vividsolutions.jump.util.StringUtil;
>  import com.vividsolutions.jump.workbench.JUMPWorkbench;
> @@ -118,6 +121,7 @@
>      private ImageIcon rasterIcon = IconLoader.icon("map_13.png");
>      private ImageIcon sextante_rasterIcon = IconLoader.icon("mapSv2_13.png");
>      private ImageIcon sextante_rasterIcon2 = 
> IconLoader.icon("mapSv2_13bw.png");
> +    private ImageIcon table_Icon = IconLoader.icon("Table.gif");
>      private final static String LAYER_NAME = I18N
>              
> .get("org.openjump.core.ui.plugin.layer.LayerPropertiesPlugIn.Layer-Name");
>      private final static String FILE_NAME = I18N.get("ui.MenuNames.FILE");
> @@ -379,6 +383,12 @@
>                      .getFeatureCollectionWrapper().size() > 1 ? 
> multiRasterIcon
>                      : rasterIcon);
>              imageLabel.setVisible(true);
> +        } else if (showColorPanel && layerable instanceof Layer
> +            && isTable((Layer) layerable)) {
> +          //Show a table icon if the Layer has features with empty geometries
> +        imageLabel.setIcon(table_Icon);
> +        imageLabel.setVisible(true);
> +
>          } else if (showColorPanel && layerable instanceof Layer) {
>              colorPanel.init((Layer) layerable, isSelected,
>                      list.getBackground(), list.getSelectionBackground());
> @@ -1022,4 +1032,27 @@
>                  && bgc.equals(p.getBackground()) && p.isOpaque();
>          return !colorMatchOrOpaque && super.isOpaque();
>      }
> +    
> +    /* 
> +     * [Giuseppe Aruta 11.2016] . True if all the layer geometries are empty
> +     * (Geometrycollection empty). Workaround to decode table files (like 
> .csv or .dbf)
> +     *  so that they are loaded in Sextante as table
> +      */
> +    public static boolean isTable(Layer layer) {
> +        FeatureCollectionWrapper featureCollection = layer
> +                .getFeatureCollectionWrapper();
> +        List featureList = featureCollection.getFeatures();
> +        Geometry nextGeo = null;
> +        for (@SuppressWarnings("unchecked")
> +        Iterator<FeatureCollectionWrapper> i = featureList.iterator(); i
> +                .hasNext();) {
> +            Feature feature = (Feature) i.next();
> +            nextGeo = feature.getGeometry();
> +        }
> +        if (!featureCollection.isEmpty() && nextGeo.isEmpty()) {
> +            return true;
> +        } else {
> +            return false;
> +        }
> +    }
>  }
> \ No newline at end of file
> 
> 
> ------------------------------------------------------------------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today. http://sdm.link/xeonphi
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
> 

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to