Quantcast

Re: Setting a ofset in icon in GIS3D

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

Re: Setting a ofset in icon in GIS3D

Juan José Pérez Consuegra
Hello again,

I know it isn't important, just for visualisation, but it would be very usefull for me to get iconOffset working. I have check my style class, and it is the same as tower class style, or  at least, I can't see any difference.

Here is my style class:

    private Offset IconOffset;
    private Offset LabelOffset;    
    private Font fuente;

    
    public jisrAgenteStyle(){

        IconOffset = new Offset(0.5d, 0.5d, AVKey.FRACTION, AVKey.FRACTION);
        LabelOffset = new Offset(1d, 1d, AVKey.FRACTION, AVKey.FRACTION);
        fuente = new Font("Agency FB", Font.PLAIN, 15);
       
    }   
   
   
   
    @Override
    public WWTexture getTexture(jisrAgente agent, WWTexture texture) {
           
        // If the texture is already defined, then just return the same texture since
        //  we don't want to update the tower agent appearance.  The only time the
        //  below code will actually be used is on the initialization of the display
        //  when the icons are created.
        if (texture != null)
            return texture;
       
        // BasicWWTexture is useful when the texture is a non-changing image.
        URL localUrl = WorldWind.getDataFileStore().requestFile("icons/agente.png");
        if (localUrl != null)    {
            return new BasicWWTexture(localUrl, false);
        }
       
        return null;
    }
   
   
    @Override
    public Offset getIconOffset(jisrAgente agent){
        return IconOffset;
    }
   

    @Override
    public String getLabel(jisrAgente agent){
        return agent.getNombre();
    }
   
    @Override
    public Color getLabelColor(jisrAgente agent) {
        return Color.BLUE;
    }

    @Override
    public Font getLabelFont(jisrAgente agent) {
        return fuente;
    }

    @Override
    public Offset getLabelOffset(jisrAgente agent) {
        return LabelOffset;
    }



Label offset works fine, but with icons doesn't,  here is a picture of my simulation, it can clearly seen as the square icon (file) has the center in the left botton corner related with circle, and it doens't matter if I change values in my code.

capturaSimulacion.JPG


thanks in advance,

Juanjo

------------------------------------------------------------------------------
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
|  
Report Content as Inappropriate

Re: Setting a ofset in icon in GIS3D

Tatara, Eric R.

There’s a bug in the display code so that getIconOffset() isn’t called even though it is supposed to be.  There are two workarounds:

 

If the icon offset is constant, you can apply it when the Mark is created by overriding MarkStyle.getPlaceMark() as follows using the TowerAgentStyle example:

 

// Optional

PlaceMark mark;

     

@Override

public PlaceMark getPlaceMark(RadioTower agent, PlaceMark mark) {

           

      if (mark == null)

            mark = new PlaceMark();

           

      mark.setAltitudeMode(WorldWind.CLAMP_TO_GROUND);

      mark.setLineEnabled(false);

           

      mark.getAttributes().setImageOffset(getIconOffset(agent));

           

      // Optional

      this.mark = mark;

           

      return mark;

}

 

This will set the offset using the mark attribute one time.  You can optionally also store the PlaceMark object in the style class and dynamically change the attributes in other methods, such as getScale() which is called every time the display is updated

 

@Override  

public double getScale(RadioTower agent) {

           

      mark.getAttributes().setImageOffset(getIconOffset(agent));

      return 1;

}

 

 

From: Juan José Pérez Consuegra [mailto:[hidden email]]
Sent: Monday, February 20, 2017 4:11 AM
To: [hidden email]
Subject: Re: [Repast-interest] Setting a ofset in icon in GIS3D

 

Hello again,

I know it isn't important, just for visualisation, but it would be very usefull for me to get iconOffset working. I have check my style class, and it is the same as tower class style, or  at least, I can't see any difference.

Here is my style class:

    private Offset IconOffset;
    private Offset LabelOffset;    
    private Font fuente;

    
    public jisrAgenteStyle(){

        IconOffset = new Offset(0.5d, 0.5d, AVKey.FRACTION, AVKey.FRACTION);
        LabelOffset = new Offset(1d, 1d, AVKey.FRACTION, AVKey.FRACTION);
        fuente = new Font("Agency FB", Font.PLAIN, 15);
       
    }   
   
   
   
    @Override
    public WWTexture getTexture(jisrAgente agent, WWTexture texture) {
           
        // If the texture is already defined, then just return the same texture since
        //  we don't want to update the tower agent appearance.  The only time the
        //  below code will actually be used is on the initialization of the display
        //  when the icons are created.
        if (texture != null)
            return texture;
       
        // BasicWWTexture is useful when the texture is a non-changing image.
        URL localUrl = WorldWind.getDataFileStore().requestFile("icons/agente.png");
        if (localUrl != null)    {
            return new BasicWWTexture(localUrl, false);
        }
       
        return null;
    }
   
   
    @Override
    public Offset getIconOffset(jisrAgente agent){
        return IconOffset;
    }
   

    @Override
    public String getLabel(jisrAgente agent){
        return agent.getNombre();
    }
   
    @Override
    public Color getLabelColor(jisrAgente agent) {
        return Color.BLUE;
    }

    @Override
    public Font getLabelFont(jisrAgente agent) {
        return fuente;
    }

    @Override
    public Offset getLabelOffset(jisrAgente agent) {
        return LabelOffset;
    }


Label offset works fine, but with icons doesn't,  here is a picture of my simulation, it can clearly seen as the square icon (file) has the center in the left botton corner related with circle, and it doens't matter if I change values in my code.

capturaSimulacion.JPG

thanks in advance,

Juanjo


------------------------------------------------------------------------------
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
Loading...