Quantcast

update background of network projection during runtime

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

update background of network projection during runtime

Hannes Thomsen
Dear List,

I want to update the background of a network projection based on a
dynamic variable to indicate the system state visually (without grid or
continouos space). At least I found a place where I can set the
background, however, the background does not change during runtime.

Here is my code:

Projection net = context.getProjection("network");
Iterator it = net.getProjectionListeners().iterator();
Object obj;

while (it.hasNext()){
     obj = it.next();
     if (obj instanceof DisplayOGL2D ) {
         DisplayOGL2D dis = (DisplayOGL2D) obj;
         dis.setBackgroundColor(NEWCOLOR);
         dis.getBackgroundColor().toString();
         System.out.print(dis.getBackgroundColor().toString()); // works!!!

Thanks a lot!

Hannes


------------------------------------------------------------------------------
_______________________________________________
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: update background of network projection during runtime

srcnick
Its not ideal, but currently the best way to do this is to create an agent with a method that can be called to reflect the system state. This is your “background agent”.  If you style the agent as a very large rectangle, whose color is dependent on the results of its system state method then it will show up as a dynamic background. The agent should be of a different type, so it appears separately in the display wizard and  you can set its layer lower than the other agents.

Nick

> On Sep 11, 2016, at 4:23 PM, Hannes Thomsen <[hidden email]> wrote:
>
> Dear List,
>
> I want to update the background of a network projection based on a
> dynamic variable to indicate the system state visually (without grid or
> continouos space). At least I found a place where I can set the
> background, however, the background does not change during runtime.
>
> Here is my code:
>
> Projection net = context.getProjection("network");
> Iterator it = net.getProjectionListeners().iterator();
> Object obj;
>
> while (it.hasNext()){
>     obj = it.next();
>     if (obj instanceof DisplayOGL2D ) {
>         DisplayOGL2D dis = (DisplayOGL2D) obj;
>         dis.setBackgroundColor(NEWCOLOR);
>         dis.getBackgroundColor().toString();
>         System.out.print(dis.getBackgroundColor().toString()); // works!!!
>
> Thanks a lot!
>
> Hannes
>
>
> ------------------------------------------------------------------------------
> _______________________________________________
> Repast-interest mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/repast-interest


------------------------------------------------------------------------------
_______________________________________________
Repast-interest mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/repast-interest
Loading...