One interesting suggestion would be to use a geometry function to create the 
desired shape; and then a polygon symbolizer to draw it.

Jody

On 27/09/2010, at 8:51 PM, Michael Bedward wrote:

> Hi Sergey,
> 
> The problem is that the RenderingExecutor helper class used by
> JMapPane is drawing into a BufferedImage (the backing image of the map
> pane) and then this gets blitted to the screen, overwriting your
> custom drawing.
> 
> One solution would be for your listener to create a separate image
> with a transparent background and draw into that. The override
> onRenderingCompleted to blit that onto the screen after the pane's
> normal backing image has been displayed.
> 
> I know that sounds like a bit clumsy - perhaps someone else here might
> have a better suggestion ?
> 
> Michael
> 
> 
> 
> On 27 September 2010 20:26, LSA <[email protected]> wrote:
>> Hi, Michael,
>> 
>> I tried the following code to draw rectangle around each feature:
>> 
>> mapPane.getRenderer().addRenderListener(new RenderListener() {
>> 
>>             @Override
>>             public void featureRenderer(SimpleFeature feature) {
>>               AffineTransform transform =
>> RendererUtilities.worldToScreenTransform(
>>                   mapPane.getMapContext().getAreaOfInterest(),
>>                   mapPane.getVisibleRect());
>> 
>>               Graphics2D g = ((Graphics2D) mapPane.getGraphics());
>> 
>>               if
>> (!org.apache.commons.lang.ArrayUtils.isEmpty(((Geometry)feature.getDefaultGeometry()).getBoundary().getCoordinates())){
>>                 Coordinate c  =
>> ((Geometry)feature.getDefaultGeometry()).getBoundary().getCoordinates()[0];
>>                 Point2D point = new Point2D.Double(c.x, c.y);
>>                 Point2D result = new Point2D.Double();
>>                 transform.transform(point, result);
>> 
>>                 g.setColor(Color.BLUE);
>>                 g.drawRect((int)result.getX(), (int)result.getY(), 20, 20);
>>               }
>> 
>> 
>> //UiGisUtils.highlightFeatureOnMap(ShapeFileRendererComposite.this,
>> feature, Color.YELLOW, 11);
>>             }
>> 
>>             @Override
>>             public void errorOccurred(Exception arg0) {
>>             }
>>           });
>> 
>> Rectangles appear around some features for a moment only to dissapear
>> after it...
>> 
>> What am I doing wrong?
>> 
>> Sergey
>> 
> 
> ------------------------------------------------------------------------------
> Start uncovering the many advantages of virtual appliances
> and start using them to simplify application deployment and
> accelerate your shift to cloud computing.
> http://p.sf.net/sfu/novell-sfdev2dev
> _______________________________________________
> Geotools-gt2-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users


------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Geotools-gt2-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to