Logo Search packages:      
Sourcecode: libjgrapht-java version File versions  Download package

void org::_3pq::jgrapht::ext::JGraphModelAdapter::handleJGraphChangedEdge ( org.jgraph.graph.Edge  jEdge  )  [inline, package]

Adds/removes an edge to/from the underlying JGraphT graph according to the change in the specified JGraph edge. If both vertices are connected, we ensure to have a corresponding JGraphT edge. Otherwise, we ensure NOT to have a corresponding JGraphT edge.

This method is to be called only for edges that have already been changed in the JGraph graph.

Parameters:
jEdge the JGraph edge that has changed.

Definition at line 440 of file JGraphModelAdapter.java.

References handleJGraphInsertedEdge(), handleJGraphRemovedEdge(), isDangling(), m_cellToEdge, and m_cellToVertex.

                                                                {
        if( isDangling( jEdge ) ) {
            if( m_cellToEdge.containsKey( jEdge ) ) {
                // a non-dangling edge became dangling -- remove the JGraphT
                // edge by faking as if the edge is removed from the JGraph.
                // TODO: Consider keeping the JGraphT edges outside the graph
                // to avoid loosing user data, such as weights.
                handleJGraphRemovedEdge( jEdge );
            }
            else {
                // a dangling edge is still dangling -- just ignore.
            }
        }
        else {
            // edge is not dangling
            if( m_cellToEdge.containsKey( jEdge ) ) {
                // edge already has a corresponding JGraphT edge.
                // check if any change to its endpoints.
                org._3pq.jgrapht.Edge jtEdge =
                    (org._3pq.jgrapht.Edge) m_cellToEdge.get( jEdge );

                Object                jSource = getSourceVertex( this, jEdge );
                Object                jTarget = getTargetVertex( this, jEdge );

                Object                jtSource = m_cellToVertex.get( jSource );
                Object                jtTarget = m_cellToVertex.get( jTarget );

                if( jtEdge.getSource(  ) == jtSource
                        && jtEdge.getTarget(  ) == jtTarget ) {
                    // no change in edge's endpoints -- nothing to do.
                }
                else {
                    // edge's end-points have changed -- need to refresh the
                    // JGraphT edge. Refresh by faking as if the edge has been
                    // removed from JGraph and then added again.
                    // ALSO HERE: consider an alternative that maintains user data
                    handleJGraphRemovedEdge( jEdge );
                    handleJGraphInsertedEdge( jEdge );
                }
            }
            else {
                // a new edge
                handleJGraphInsertedEdge( jEdge );
            }
        }
    }


Generated by  Doxygen 1.6.0   Back to index