Forums

Full Version: SG - List for MultiEdgeRenderer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I need to present a piece of code for the following sourceforge thread:
https://sourceforge.net/forum/message.ph...id=5154213

Code:
    /*
     * This belongs to the class GraphViewPath
     */
    
    // Knowing the graph would be nice, assign it where you set
    // g = new GraphMLReader().readGraph(datafile);
    protected Graph m_graph;
    
    // Initialized in constructor
    protected EdgeList list;
    
    // Recalculates the *whole* set, you may wish to do that partially too
    @SuppressWarnings("unchecked")
    protected void updateList() {
        list.clear();
        
        Iterator<Edge> edges = m_graph.getEdges().tuples();
        
        while (edges.hasNext()) {
            Edge edge = edges.next();
            // Ok, maybe you got to be careful with what´s target and source
            
            // Maybe think of using edge.getSourceNode().getString("name")
            String source = edge.getSourceNode().get("name").toString();
            String target = edge.getTargetNode().get("name").toString();
            
            int count = list.nrDuplicated(source, target);
            if (count > 0) {
                int radius = 40 * count;
                // TODO: now here you got to add the radius to a field of the edge and in your
                // layout you just get that value and you can access the radius
            }
            
            list.add(new EdgeContainer(source, target));
            
        }
    }
Reference URL's