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
On 9/27/2010 5:08 PM, Michael Bedward wrote:
> Hi Sergey,
>
> Have a look at the RenderListener interface (in gt-render module)
> which has a featureRenderer method that is called by the renderer each
> time a feature is rendered. That method gets the feature passed to it
> as an argument.
>
> Michael
>
> On 27 September 2010 19:44, LSA<[email protected]> wrote:
>
>> Hi,
>>
>> I am using geotools 2.6.3.
>>
>> What I need to do is to draw some custom drawing near each feature. For
>> now, I perform this task by using MapPaneListener.onRenderingStopped,
>> but this impose performance penalty.
>> Is it possible to register some sort of callback, which will be called
>> every time feature is rendered?. In this callback, I would like to have
>> links to Graphics2D and Feature (but maybe something different will
>> work, too).
>>
>> Thanks in advance,
>> 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