Hi,
So I'm guessing that you want you're temporary polygon layer to
contain the rectangle? If this is the case then don't use the
IDrawCommands. Those are just for very temporary decorations in the
view. I would use the following code to add the rectangle to the
temporary layer. Do this after you create the resource but before
you create the layer so you don't have to worry about committing the
added polygon.
GeometryFactory fac=new GeometryFactory();
LinearRIng ring = fac.createLinearRing( new Coordinate[]{
new Coordinate( -180,-90 ),
new Coordinate( 180,-90 ),
new Coordinate( 180,90 ),
new Coordinate( -180,90 ),
new Coordinate( -180,-90 ),
});
Polygon poly = fac.createPolygon( ring, new LinearRing[0] );
FeatureStore fs=resource.resolve( FeatureStore.class, progressMonitor)
featureBuilder.getFeatureType().createFeature( new Object[] { ....,
poly, ...} ); // insert other parameters
fs.addFeatures( DataUtilities.toCollection( new Feature[]{ feature } );
That's it :-P.
If that's not the purpose of the layer and you want something else to
draw the rectangle then consider creating a new MapGraphic. It is
essentially an interface with a single method to implement. You just
draw to the Graphics2D that you are passed. You will have to
determine where the corners are. The ViewportModel has methods to
help with that. Also you can create a ToolContext object which has
a number of helpful methods on it.
ApplicationGIS.createContext( map ) will do the trick.
Hope this helps,
Jesse
On 22-Feb-07, at 3:11 AM, [EMAIL PROTECTED] wrote:
An: User-friendly Desktop Internet GIS
Von: Jesse Eichar
Datum: 20.02.2007 02:13PM
On 20-Feb-07, at 4:38 AM, [EMAIL PROTECTED] wrote:
Now we have the problem that the map of the wms server is quite
colorful and in different scale ranges different colors are the
ground color. Therefore the icons (squares, circles, ..) which
represent the items of the shapefile are not as good visibile as the
user wants it. My idea: Create an shapefile with an polygon,
covering
the complete world, set its colour to black and give a controller to
the user to adjust the opacity. Now the user can dim the brightness
of the wms map and the shapfile items (which are on the top of the
layer stack) are more visible.
ii) Good idea? Bad idea? Bullshit? Is there an internal (in udig)
mechanism to adjust the brightness of a png delivered by the wms
server?
I'd suggest creating a style for the feature layer that has a lower
opacity to tone down the colors use 50% maybe. Or use a different
color. I think it would be easier. But yes you can modify the
brightness of a GridCoverage. Never having done it you will have to
ask the Geotools users list for advice on how to do it.
I tried to create a temporary layer with one polygon but I
failed :-) All
that stuff (udig, org.geotools) is quite new for me. Perhaps
someone can
help me. Sorry if I'm annoying you.
at first I created the layer:
IGeoResource resource = null;
// (like net.refractions.udig.ui.FeatureTypeEditor#368)
FeatureTypeBuilder featureBuilder =
FeatureTypeBuilder.newInstance("DimLayerFactory");
featureBuilder.addType(AttributeTypeFactory.newAttributeType("name",
String.class, true, Integer.MAX_VALUE));
featureBuilder.addType(AttributeTypeFactory.newAttributeType
("geometry",
Polygon.class,true,Integer.MAX_VALUE,null,
DefaultGeographicCRS.WGS84));
// (like
net.refractions.udig.project.ui.internal.actionsNewLayerAction#41)
resource =
CatalogPlugin.getDefault().getLocalCatalog().createTemporaryResource
(featureBuilder.getFeatureType());
if (resource != null){
LayerFactory layerFactory = map.getLayerFactory();
Layer layer = layerFactory.createLayer(resource);
layer.setName("DimLayer");
return layer;
}
this works. I can use the polygon edit tools of the toolbars since
it is
the layer with the highest z-order and all other layers are either
wms or
based on shape files containing points.
in the second step I want to create a rectangle covering the complete
world. I debugged how the RectangleTool works.. huh.. :) In
IDrawCommand I
read the hint that one can either use an EditCommand to create a new
feature or a DrawCommand which won't create a feature in the layer but
which will be executed on every repaint. To create a DrawCommand
would mean
to work with the coordinates of the viewpart. This doesn't seem to
be the
best way. I would prefer generating a polygon as a feature of the
layer. I
tried to understand the model behind Feature and their Attributes
but ...
as I said it's all quite new for me.
The polygon should be centered on 0,0 the width should be 360° and the
height 180°.
The feature containing this polygon should be added to layer I created
above. The style of this layer I will change via its
styleblackboard and a
sld xml file.
Perhaps someone can help me to solve this problem?
Or I will create a shape file and read it on program start. But an
in-memory solution would be more satisfying.
tony roth
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel
_______________________________________________
User-friendly Desktop Internet GIS (uDig)
http://udig.refractions.net
http://lists.refractions.net/mailman/listinfo/udig-devel