Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Selected & fixed Node

Help
graderz42
2009-08-25
2013-05-29
  • graderz42
    graderz42
    2009-08-25

    Hello
    I've read GraphView in prefuse & other examples, but i still don't understand how to change color of selected node and make the node fixed

    I think the code to make that is like this, but when I copy this, it doesn't work
    I don't understand how tuplesetlistener act
    =====
    // fix selected focus nodes
            TupleSet focusGroup = m_vis.getGroup(Visualization.FOCUS_ITEMS);
            focusGroup.addTupleSetListener(new TupleSetListener() {
                public void tupleSetChanged(TupleSet ts, Tuple[] add, Tuple[] rem)
                {
                    for ( int i=0; i<rem.length; ++i )
                        ((VisualItem)rem[i]).setFixed(false);
                    for ( int i=0; i<add.length; ++i ) {
                        ((VisualItem)add[i]).setFixed(false);
                        ((VisualItem)add[i]).setFixed(true);
                    }
                    if ( ts.getTupleCount() == 0 ) {
                        ts.addTuple(rem[0]);
                        ((VisualItem)rem[0]).setFixed(false);
                    }
                    m_vis.run("draw");
                }
            });
    ======

    please give me enlightenment :D
    thanks a lot

     
    • graderz42
      graderz42
      2009-08-28

      somebody plz help me

       
  • Adam M. Smith
    Adam M. Smith
    2011-06-07

    This post is old, but I figured I would reply just so that people who see it in a search can get an answer. 

    The code you posted is only for managing the Visualization.FOCUS_ITEMS group whenever that TupleSet is changed.  This listener sets 'fixed' property to true or false.  To change the color of the fixed nodes, you must also implement an action to draw the fixed nodes as a different color.  The graphview demo uses

    {
    // normal
    ColorAction fill = new ColorAction(nodes, VisualItem.FILLCOLOR, ColorLib.rgb(200,200,255));
    // the fixed group
    fill.add(VisualItem.FIXED, ColorLib.rgb(255,100,100));}
    

    Then (I'm pretty sure), you have to add a FocusControl to the Display so that the clicked nodes are added to the VisualItem.FOCUS_ITEMS group when they are clicked.

    {display.addControlListener(new FocusControl(1));}
    
     
  • Amendra
    Amendra
    2012-09-11

    Dear all,

    I have made a visualization application to visualize the discussion forum network.
    I have managed to select nodes and changes it color. Now, what I am trying to do is to change the color of rest of the unfocused nodes in the graph. Your help will be really appreciated.  Thank You.

    regards,
    student

     
  • Björn Kruse
    Björn Kruse
    2012-09-15

    Hi,

    just change the base color of your ColorAction? Then all other nodes will have that new color, but the focus nodes get the color defined in the rule.

    On a high level said, you need to identify a group of nodes (put them into a secondary/focus group or set a special datafield value). Then create a ColorAction rule for that group or datafield value.

    hope that helps,
    Björn