Documento De Prueba

Páginas: 3 (528 palabras) Publicado: 12 de mayo de 2012
JGraphT visualization using JGraph

http://www.jgrapht.org/visualizations.html

The following applet shows how a JGraphT graph can be visualized using JGraph. Try to play and drag around thevertices and edges to get the feel of it.
Note: Java 1.3 or above must be installed for this applet to work correctly.

a JGraphT graph visualized using JGraph.

It's very simple: the JGraphT librarycomes with an adapter that makes JGraphT graphs compatible with JGraph. To visualize a JGraphT graph you just need to initialize JGraph via that adapter. Example code:
// create a JGraphT graphListenableGraph g = new ListenableDirectedGraph( DefaultEdge.class );

1 of 4

2/12/2012 8:07 PM

JGraphT visualization using JGraph

http://www.jgrapht.org/visualizations.html

// create avisualization using JGraph, via the adapter JGraph jgraph = new JGraph( new JGraphModelAdapter( g ) );

Is that all?! Yes, that's all. Any modification now made to the graph g will automatically bereflected by the JGraph component.

The full source code of this demo is listed below and is also included in the JGraphT distribution (download now).

package org.jgrapht.demo; importjava.awt.Color; import java.awt.Dimension; import java.awt.Rectangle; import java.util.HashMap; import java.util.Map; import javax.swing.JApplet; import javax.swing.JFrame; import org.jgraph.JGraph; importorg.jgraph.graph.DefaultGraphCell; import org.jgraph.graph.GraphConstants; import import import import org.jgrapht.ListenableGraph; org.jgrapht.ext.JGraphModelAdapter;org.jgrapht.graph.ListenableDirectedGraph; org.jgrapht.graph.DefaultEdge;

/** * A demo applet that shows how to use JGraph to visualize JGraphT graphs. * * @author Barak Naveh * * @since Aug 3, 2003 */ public class JGraphAdapterDemoextends JApplet { private static final Color DEFAULT_BG_COLOR = Color.decode( "#FAFBFF" ); private static final Dimension DEFAULT_SIZE = new Dimension( 530, 320 ); // private JGraphModelAdapter...
Leer documento completo

Regístrate para leer el documento completo.

Estos documentos también te pueden resultar útiles

  • Prueba de documento
  • documento de prueba
  • DOCUMENTO PRUEBA
  • Documento De Prueba
  • Documento de prueba
  • Documento prueba
  • Documento De Prueba
  • Documento prueba

Conviértase en miembro formal de Buenas Tareas

INSCRÍBETE - ES GRATIS