Hi Jérémy

The DirectLayer class can be used for this sort of thing:

http://docs.geotools.org/latest/javadocs/index.html?org/geotools/map/DirectLayer.html

You sub-class it and provide an implementation of the draw method.
Here is a quick and dirty example...

// WARNING - NOT TESTED
public class MyIconLayer extends DirectLayer {
    private final ImageIcon icon;

    public MyIconLayer( ImageIcon icon ) { this.icon = icon; }

    // displays icon at map centre
    public draw(Graphics2D graphics, MapContent content, MapViewport viewport) {
        Rectangle rect = viewport.getScreenArea();
        int centreX = (int) rect.getCentreX();
        int centreY = (int) rect.getCentreY();

        int imageX = centreX - icon.getImageWidth() / 2;
        int imageY = centreY - icon.getImageHeight() / 2;

        graphics.drawImage(icon.getImage(), imageX, imageY, null);
    }
}


Michael


On 3 June 2012 08:40, jérémy lacombe <[email protected]> wrote:
> Hi everybody,
>
> I just wanna ask a simple question, can someone know if i can do something
> like :
>
>
>         final ImageIcon imageIcon = new ImageIcon("22bis.png", "bonjour");
>         MapContent map = new MapContent(){
>             private static final long serialVersionUID = 1L;
>             Image image = imageIcon.getImage();
>             {setOpacity(1.0f);}
>             public void paint (Graphics g)
>             {
>                 g.drawImage(image, 0, 0, this);
>                 super.paintComponent(g);
>             }
>         };
>
> on the MapContent ???
>
> I want to put an image behind my shapefile just to have something more
> butiful than the shapefile alone ^^
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> GeoTools-GT2-Users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
>

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
GeoTools-GT2-Users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users

Reply via email to