GraphStream Users

Archives de la liste Aide


Re: Changing style attribute


Chronologique Discussions 
  • From: Antoine Dutot <antoine.dutot AT gmail.com>
  • To: Florent Chuffart <florent.chuffart AT gmail.com>, graphstream-users AT litislab.fr
  • Subject: Re: Changing style attribute
  • Date: Fri, 1 Jul 2011 19:40:58 +0200

Another solution is to use the alternative viewer available in gs-ui.jar, where the bug is not present.

Regards,

Antoine

2011/7/1 Antoine Dutot <antoine.dutot AT gmail.com>
Ok, I spotted the error: if no "ui.size" attribute has been set yet, but the size-mode is dyn-size, the renderer tries to fetch the "ui.size" attribute but finds none and produces the exception you reported.

I corrected the error on GitHub. I can produce a gs-core.jar with the correction if you want. In the mean time, you can get rid of the error by putting the "ui.size" attribute as soon as the node is created and preferably before the graph is displayed.

Sorry for this, but thank you to have spotted the bug ;-)

Regards,

Antoine

2011/7/1 Florent Chuffart <florent.chuffart AT gmail.com>
Re,

Here is a piece of code

import org.graphstream.graph.implementations.MultiGraph;
public class GsBug {

   public static void main(String[] args) {
       MultiGraph graph = new MultiGraph("VIEW", false, true);
       graph.addAttribute("ui.stylesheet", styleSheet);
       graph.display();
       graph.addNode("FOO").changeAttribute("ui.label", "FOO");
       graph.addNode("BAR").changeAttribute("ui.label", "BAR");
       graph.getNode("FOO").setAttribute("ui.class", "red");
       graph.getNode("BAR").setAttribute("ui.color", 1.);
   }
   static protected String styleSheet = ""
           + "node {"
           + "       fill-mode: dyn-plain;"
           + "       size-mode: dyn-size;"
           + "       fill-color: blue, green;"
           + "}"
           + "node.red {"
           + "       fill-color: red;"
           + "}"
           + "";

}

and the error...

Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: cannot convert null value
       at org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.convertValue(StyleConstants.java:476)
       at org.graphstream.ui.swingViewer.basicRenderer.NodeRenderer.pushDynStyle(NodeRenderer.java:74)
       at org.graphstream.ui.swingViewer.basicRenderer.ElementRenderer.render(ElementRenderer.java:95)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGroup(SwingBasicGraphRenderer.java:316)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGraphElements(SwingBasicGraphRenderer.java:293)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGraph(SwingBasicGraphRenderer.java:213)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.render(SwingBasicGraphRenderer.java:158)
       at org.graphstream.ui.swingViewer.DefaultView.render(DefaultView.java:259)
       at org.graphstream.ui.swingViewer.DefaultView.paint(DefaultView.java:191)
       at javax.swing.JComponent._paintImmediately(JComponent.java:5098)
       at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
       at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:811)
       at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
       at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
       at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)
       at java.awt.EventQueue.access$000(EventQueue.java:85)
       at java.awt.EventQueue$1.run(EventQueue.java:638)
       at java.awt.EventQueue$1.run(EventQueue.java:636)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:647)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
       at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: cannot convert null value
       at org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.convertValue(StyleConstants.java:476)
       at org.graphstream.ui.swingViewer.basicRenderer.NodeRenderer.pushDynStyle(NodeRenderer.java:74)
       at org.graphstream.ui.swingViewer.basicRenderer.ElementRenderer.render(ElementRenderer.java:95)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGroup(SwingBasicGraphRenderer.java:316)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGraphElements(SwingBasicGraphRenderer.java:293)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGraph(SwingBasicGraphRenderer.java:213)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.render(SwingBasicGraphRenderer.java:158)
       at org.graphstream.ui.swingViewer.DefaultView.render(DefaultView.java:259)
       at org.graphstream.ui.swingViewer.DefaultView.paint(DefaultView.java:191)
       at javax.swing.JComponent._paintImmediately(JComponent.java:5098)
       at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
       at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:811)
       at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
       at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
       at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
       at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
       at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)
       at java.awt.EventQueue.access$000(EventQueue.java:85)
       at java.awt.EventQueue$1.run(EventQueue.java:638)
       at java.awt.EventQueue$1.run(EventQueue.java:636)
       at java.security.AccessController.doPrivileged(Native Method)
       at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
       at java.awt.EventQueue.dispatchEvent(EventQueue.java:647)
       at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
       at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
       at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
       at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
       at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: cannot convert null value
       at org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.convertValue(StyleConstants.java:476)
       at org.graphstream.ui.swingViewer.basicRenderer.NodeRenderer.pushDynStyle(NodeRenderer.java:74)
       at org.graphstream.ui.swingViewer.basicRenderer.ElementRenderer.render(ElementRenderer.java:95)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGroup(SwingBasicGraphRenderer.java:316)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGraphElements(SwingBasicGraphRenderer.java:293)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGraph(SwingBasicGraphRenderer.java:213)
       at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.render(SwingBasicGraphRenderer.java:158)
       at org.graphstream.ui.swingViewer.DefaultView.render(DefaultView.java:259)
       at org.graphstream.ui.swingViewer.DefaultView.paint(DefaultView.java:191)
       at javax.swing.JComponent._paintImmediately(JComponent.java:5098)
       ...

--
Florent Chuffart
florent.chuffart AT gmail.com




Le 1 juil. 2011 à 16:13, Antoine Dutot a écrit :

> It's strange because the error trace points at a place where the viewer tries to convert a "ui.size" value (an object) into a number, saying that the attribute value is null. I am searching a possible bug in GraphStream (among the ocean of bugs it contains ;-)). Do you have a code excerpt so that I can test it ?
>
> Antoine
>
> 2011/7/1 Florent Chuffart <florent.chuffart AT gmail.com>
> Hi,
>
> It works for size,
>
> using
>        n.setAttribute("ui.color", "1");
> or
>        n.setAttribute("ui.color", 1);
>
>
> I obtain...
>
> Exception in thread "AWT-EventQueue-0" java.lang.RuntimeException: cannot convert null value
>        at org.graphstream.ui.graphicGraph.stylesheet.StyleConstants.convertValue(StyleConstants.java:476)
>        at org.graphstream.ui.swingViewer.basicRenderer.NodeRenderer.pushDynStyle(NodeRenderer.java:74)
>        at org.graphstream.ui.swingViewer.basicRenderer.ElementRenderer.render(ElementRenderer.java:95)
>        at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGroup(SwingBasicGraphRenderer.java:316)
>        at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGraphElements(SwingBasicGraphRenderer.java:293)
>        at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.renderGraph(SwingBasicGraphRenderer.java:213)
>        at org.graphstream.ui.swingViewer.basicRenderer.SwingBasicGraphRenderer.render(SwingBasicGraphRenderer.java:158)
>        at org.graphstream.ui.swingViewer.DefaultView.render(DefaultView.java:259)
>        at org.graphstream.ui.swingViewer.DefaultView.paint(DefaultView.java:191)
>        at javax.swing.JComponent._paintImmediately(JComponent.java:5098)
>        at javax.swing.JComponent.paintImmediately(JComponent.java:4882)
>        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:811)
>        at javax.swing.RepaintManager.paintDirtyRegions(RepaintManager.java:713)
>        at javax.swing.RepaintManager.seqPaintDirtyRegions(RepaintManager.java:693)
>        at javax.swing.SystemEventQueueUtilities$ComponentWorkRequest.run(SystemEventQueueUtilities.java:125)
>        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
>        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:677)
>        at java.awt.EventQueue.access$000(EventQueue.java:85)
>        at java.awt.EventQueue$1.run(EventQueue.java:638)
>        at java.awt.EventQueue$1.run(EventQueue.java:636)
>        at java.security.AccessController.doPrivileged(Native Method)
>        at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87)
>        at java.awt.EventQueue.dispatchEvent(EventQueue.java:647)
>        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296)
>        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211)
>        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201)
>        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196)
>        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188)
>        at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
>
>
> --
> Florent Chuffart
> florent.chuffart AT gmail.com
>
>
>
>
> Le 1 juil. 2011 à 13:47, Antoine Dutot a écrit :
>
> > 2011/7/1 Florent Chuffart <florent.chuffart AT gmail.com>
> > is there a documentation about attributes ("ui.class" "ui.style"...) name ?
> >
> > "ui.class" is described in http://graphstream-project.org/doc/Tutorials/Graph-Visualisation_1.0/#adding-style-classes
> >
> > The "ui.style" is not yet documented, it is a way to add style to a stylesheet, but this is not very efficient.
> >
> > > Is there a problem with the style sheet ?
> > >
> >
> > Yeah,
> >
> > I have 2 graph explorations that run in parallel. One change the color, the other change the size.
> > So by using the style sheet I have to
> >  - define 4 classes : greensmall greenbig redsmall redbig
> >  - check which class is set for my current node (for example redsmall)
> >  - and adapt (for example the color): set the new class as greensmall
> >
> > A better way consists in only change the attribute color independently of the size.
> >
> > You have several ways to do this. First you can have several classes for one node (one that describe the size, one that desrcibes the color for example).
> >
> > But another more efficient and better way would be to use the dynamic mode for color and size. Put such a style on nodes:
> >
> > node {
> >     fill-mode: dyn-plain; // dynamic color.
> >     size-mode: dyn-size; // dynamic size.
> >     fill-color: red, green; // two colors.
> > }
> >
> > Then, you can use the "ui.size" attribute to set the size in pixels directly (you can set the "size" in the CSS to give a default size). You can set the color using the "ui.color" attribute using it as follows : 0 means the first color ("red" here) and 1 means the last color ("green" here). In fact the value of "ui.color" is always between 0 and 1 and is an interpolation of the list of colors given by "fill-color". In our case, if you pass the value 0.5 for "ui.color" you will get a mix of red and green. But you can have any number of colors for "fill-color".
> >
> > This way you can change the color and the size independently. Would it be what you expect ? Let me know (if you think this can deserve a dedicated tutorial, please let me know also, this may not be quite clear in the actual documentation).
> >
> > You have an example of this here : http://graphstream-project.org/doc/Tutorials/Graph-Visualisation_1.0/#dynamically-changing-colors-and-size
> >
> > Regards,
> >
> > Antoine
>
>






Archives gérées par MHonArc 2.6.16.

Top of page