@Before
public void setUp() throws Exception {
handler=new TestHandler(3);
FeatureStore<SimpleFeatureType, SimpleFeature> source = ((ILayer) handler.getContext().getMapLayers().get(0)).getResource(FeatureStore.class, null);
FilterFactory filterFac=CommonFactoryFinder.getFilterFactory(GeoTools.getDefaultHints());
GeometryFactory geomFac=new GeometryFactory();
int i=0;
for( FeatureIterator<SimpleFeature> iter = source.getFeatures().features(); iter.hasNext(); ){
SimpleFeature feature = iter.next();
source.modifyFeatures(feature.getFeatureType().getDescriptor("name"), "feature"+i, filterFac.id(FeatureUtils.stringToId(filterFac, feature.getID()))); //$NON-NLS-1$//$NON-NLS-2$
Geometry geom;
if( i==0 ){
geom=geomFac.createPoint(new Coordinate(0,10));
}else if( i==1 ){
geom=geomFac.createLineString(new Coordinate[]{
new Coordinate( 10,10), new Coordinate(10,20)
});
}else{
geom=geomFac.createLinearRing(
new Coordinate[]{
new Coordinate( 20,10), new Coordinate(40,10),
new Coordinate( 40,40), new Coordinate(20,40),
new Coordinate( 20,10)
}
);
geom=geomFac.createPolygon((LinearRing) geom, new LinearRing[0]);
}
source.modifyFeatures(feature.getFeatureType().getGeometryDescriptor(), geom, filterFac.id(FeatureUtils.stringToId(filterFac, feature.getID())));
i++;
}
((EditManager) handler.getContext().getEditManager()).commitTransaction();
((RenderManager)handler.getContext().getRenderManager()).setMapDisplay(new TestViewportPane(new Dimension(500,500)));