GraphStream Users

Archives de la liste Aide


Re: Changing node css on runtime


Chronologique Discussions 
  • From: Stefan Balev <stefan.balev AT gmail.com>
  • To: graphstream-users AT litislab.fr, klahaag AT googlemail.com
  • Subject: Re: Changing node css on runtime
  • Date: Sat, 30 Jun 2012 23:24:20 +0200

Thanks Klaus. It seems the same problem as in issue #66. I've reopened it.

--
Stefan

2012/6/30
<klahaag AT googlemail.com>:
> The problem comes again from the SwingViewer.
> Minimal code example:
> https://gist.github.com/6e2a899f92b3c04771b6
>
> The node should be red, but it is blue and not redrawn. Tested on Windows 7
> and Ubuntu 11.10 – JRE 1.7.
> If I change Viewer.ThreadingModel.GRAPH_IN_SWING_THREAD to
> Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD
> then the css change works. Node that it doesn’t matter, if the graph itself
> is created by the main or by the swing thread.
> In both cases only Viewer.ThreadingModel.GRAPH_IN_ANOTHER_THREAD works.
> Has anyone else this problem? Should I add an issue report to the tracker?
> Regards
> Klaus
>
> From: Stefan Balev
> Sent: Saturday, June 30, 2012 2:28 PM
> To:
> graphstream-users AT litislab.fr
> ;
> klahaag AT googlemail.com
> Subject: Re: Changing node css on runtime
>
> Hi Klaus,
>
> The viewer updates automatically (just as it does when you add and delete
> nodes and edges). It is a sink of the graph and receives and processes all
> the events coming from it. For example the following code:
>
> g.display()
> Node n = g.getNode(0);
> while (true) {
>   Thread.sleep(1000);
>   n.addAttribute("ui.style", "fill-color: blue;");
>   Thread.sleep(1000);
>   n.addAttribute("ui.style", "fill-color: red;");
> }
>
> should produce a node changing its color approximately each second.
>
> As an alternative of "ui.style" you can use "ui.class", for example :
>
> g.addAttribute("ui.stylesheet", "node{ size: 20px; fill-color: blue; }"
> + " node.highlighted{ fill-color: red;}");
> ...
> while (true) {
>   Thread.sleep(1000);
>   n.addAttribute("ui.class", "highlighted;");
>   Thread.sleep(1000);
>   n.removeAttribute("ui.class");
> }
>
> Cheers,
>
> --
> Stefan
>
>
> 2012/6/30 
> <klahaag AT googlemail.com>:
>> Hi everyone,
>> I got a quick question: I want to change the css on runtime and update the
>> viewer. But i am not sure on how to update it.
>> Codewise:
>>
>> Node n = graph.addNode("0");
>> n.addAttribute("ui.style", nodeCss);
>> // do something
>> n = graph.getNode("0");
>> n.setAttribute("ui.style", highlightedNodeCss);
>> // How to update the view now to make the css change visible?
>>
>> Thanks for reading
>> Klaus
>



Archives gérées par MHonArc 2.6.16.

Top of page