Hi Ede
I checked. It looks complicate for me to load a featurecollection into a
JTable.
I found a quick way from Sextante gui, that I modified.
It generates a loop to fill all JTable records with feature values.
I post the code below.

 public static TableModel setTableModelFromFeatureCollection(
            FeatureCollection featureCollection) {
        final DefaultTableModel model = new DefaultTableModel();
        String[] fields;
        int iCount;
        iCount = featureCollection.getFeatures().size();
        FeatureSchema schema = featureCollection.getFeatureSchema();
        ArrayList<String> ar = new ArrayList<String>();
        String name;
        for (int j = 0; j < schema.getAttributeNames().size(); j++) {
            name = schema.getAttributeName(j).toString();
            ar.add(name);
        }
        fields = ar.toArray(new String[0]);
        final String[][] data = new String[iCount][fields.length];
        Feature[] featArray = featureCollection.getFeatures().toArray(
                new Feature[0]);
        for (int i = 0; i < featArray.length; i++) {
            Feature feat = featArray[i];
            for (int j = 0; j < schema.getAttributeCount(); j++) {
                data[i][j] = feat.getAttribute(j).toString();
            }
        }
        model.setDataVector(data, fields);
        return model;
    }

Peppe

2017-12-12 18:23 GMT+01:00 <edgar.sol...@web.de>:

> Peppe,
>
> did you check the AttributeTable plugin? if there is, it will probably be
> in use there?
>
> ..ede
>
> On 12.12.2017 17:50, Giuseppe Aruta wrote:
> > Hi all
> > does OJ alreay have a way to load a featurecollection into a JTable?
> > I know Geotools has a such way (http://docs.geotools.org/
> stable/userguide/tutorial/filter/query.html):
> >
> > JTable table
> > SimpleFeatureCollection features ....
> > FeatureCollectionTableModel model = new FeatureCollectionTableModel(
> features);
> > table.setModel(model); (*)
> >
> > I don't want to use geotools neither to "reinvent the wheel". Do we have
> something similar (and simple)?
> > thanks in advance.
> >
> > Peppe
> >
> > (*) Geometry attributes are saved as string
> >
> >
> > ------------------------------------------------------------
> ------------------
> > Check out the vibrant tech community on one of the world's most
> > engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> >
> >
> >
> > _______________________________________________
> > Jump-pilot-devel mailing list
> > Jump-pilot-devel@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
> >
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Jump-pilot-devel mailing list
> Jump-pilot-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to