Change color of feature by ID (GeoTools)

المشرف العام

Administrator
طاقم الإدارة
I am trying to change the color of a specific object, by ID (or another feature). Currently I am able to extract data about an shapefile and display that data. However, I want to be able to change the color of a specific feature (all features that match X ID) based on the ID of the feature (assuming it has one).

Code:

private void changeLineColor() { ArrayList tempArray = new ArrayList(); SimpleFeatureTypeBuilder typeBuilder = new SimpleFeatureTypeBuilder(); typeBuilder.setName("Features"); typeBuilder.add("geom-attr-name", MultiLineString.class); typeBuilder.add("id", Integer.class); typeBuilder.add("id", Integer.class); SimpleFeatureType type = typeBuilder.buildFeatureType(); SimpleFeatureBuilder builder = new SimpleFeatureBuilder(type); DefaultFeatureCollection features = new DefaultFeatureCollection(); try (FeatureIterator iterator = collection.features()) { while (iterator.hasNext()) { SimpleFeature feature = iterator.next(); tempArray.add(feature); // all features } } catch (Exception ex) { Logger.getLogger(ShapefileExporter.class.getName()).log(Level.SEVERE, null, ex); }finally { for (int j = 0; j < tempArray.size(); j++) { System.out.println("Attribute: " + tempArray.get(j) ); } } } It would look something like this, but only for one MultiPolygon, or MultilineString



I would most likely want to make a dialog like this, but the color would only be for matching codes





أكثر...
 
أعلى