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

void org::_3pq::jgrapht::ext::JGraphModelAdapter::handleJGraphInsertedVertex ( GraphCell  jVertex  )  [inline, package]

Adds to the underlying JGraphT graph a vertex corresponding to the specified JGraph vertex. In JGraph, two vertices with the same user object are in principle allowed; in JGraphT, this would lead to duplicate vertices, which is not allowed. So if such vertex already exists, the specified vertex is REMOVED from the JGraph graph and a a warning is printed.

This method is to be called only for vertices that have already been added to the JGraph graph.

Parameters:
jVertex the JGraph vertex that has been added.

Definition at line 554 of file JGraphModelAdapter.java.

References org::_3pq::jgrapht::ext::JGraphModelAdapter::ShieldedGraph::addVertex(), internalRemoveCell(), m_cellToVertex, and m_vertexToCell.

                                                         {
        Object jtVertex;

        if( jVertex instanceof DefaultGraphCell ) {
            jtVertex = ( (DefaultGraphCell) jVertex ).getUserObject(  );
        }
        else {
            // FIXME: Why toString? Explain if for a good reason otherwise fix.
            jtVertex = jVertex.toString(  );
        }

        if( m_vertexToCell.containsKey( jtVertex ) ) {
            // We have to remove the new vertex, because it would lead to
            // duplicate vertices. We can't use ShieldedGraph.removeVertex for
            // that, because it would remove the wrong (existing) vertex.
            System.err.println( "Warning: detected two JGraph vertices with "
                + "the same JGraphT vertex as user object. It is an "
                + "indication for a faulty situation that should NOT happen."
                + "Removing vertex: " + jVertex );
            internalRemoveCell( jVertex );
        }
        else {
            m_jtGraph.addVertex( jtVertex );

            m_cellToVertex.put( jVertex, jtVertex );
            m_vertexToCell.put( jtVertex, jVertex );
        }
    }


Generated by  Doxygen 1.6.0   Back to index