Setting a ofset in icon in GIS3D

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Setting a ofset in icon in GIS3D

Juan José Pérez Consuegra
I'm using icons, png files, for mi visualization in GIS3D, everything seems to ok, but a cant set the offset of the icon, so the coordenates are the ones of the botton left cornes of the icon.

I use this code to make the BufferedImage
        BufferedImage bi = null;
        try {
            File f = new File("src/dronesPC/drone.png");
            bi = ImageIO.read(f);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return new BufferedImageTexture(bi);

this way the image seem to be painted from 0,0 relative position, and I can't find the way to change id to get the center of the image target the coordenates point. Is there any way??

And, althought is anothere question, anyone knows how to add an aditional wms layer in code??

Thanks

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Reply | Threaded
Open this post in threaded view
|

Re: Setting a ofset in icon in GIS3D

Tatara, Eric R.
The MarkStyle interface specifies: public Offset getIconOffset(T obj);

that you can override in your style class and provide the offset for the icon.  To center the icon, use an offset as follows:

/**
     * The gov.nasa.worldwind.render.Offset is used to position the icon from
     *   the mark point location.  If no offset is provided, the lower left corner
     *   of the icon is located at the point (lat lon) position.  Using values of
     *   (0.5,0.5) will position the icon center over the lat lon location.
     *   The first two arguments in the Offset constructor are the x and y
     *   offset values.  The third and fourth arguments are the x and y units
     *   for the offset. AVKey.FRACTION represents units of the image texture
     *   size, with 1.0 being one image width/height.  AVKey.PIXELS can be used
     *   to specify the offset in pixels.
     */
    Offset iconOffset = new Offset(0.5d, 0.5d, AVKey.FRACTION, AVKey.FRACTION);

and

    @Override
    public Offset getIconOffset(RadioTower agent){
        return iconOffset;
    }

Please see the TowerAgentStyle in the Geography demo for an example of icon offset.

Eric Tatara, PhD, PE
Software Engineer
Global Security Sciences Division
Argonne National Laboratory

From: Juan José Pérez Consuegra [[hidden email]]
Sent: Wednesday, January 25, 2017 7:54 AM
To: [hidden email]
Subject: [Repast-interest] Setting a ofset in icon in GIS3D

I'm using icons, png files, for mi visualization in GIS3D, everything seems to ok, but a cant set the offset of the icon, so the coordenates are the ones of the botton left cornes of the icon.

I use this code to make the BufferedImage
        BufferedImage bi = null;
        try {
            File f = new File("src/dronesPC/drone.png");
            bi = ImageIO.read(f);
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        return new BufferedImageTexture(bi);

this way the image seem to be painted from 0,0 relative position, and I can't find the way to change id to get the center of the image target the coordenates point. Is there any way??

And, althought is anothere question, anyone knows how to add an aditional wms layer in code??

Thanks

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest