ayuda con jgraph
Publicado por luciana (73 intervenciones) el 27/12/2008 15:28:14
Hola estoy intentado utilizar la libreria Jgraph, para ello estoy viendo el ejemplo que viene con ella, la clase HelloWord la cual crea dos vertices y los conecta (para generar un grafo)mi problema es que quiero agregar otro vertice y conectarlo con los ya creados pero no se como hacerlo!!!!si alguien me puede ayudar!!!!!! aca pongo el codigo :
// Construct Model and Graph
GraphModel model = new DefaultGraphModel();
JGraph graph = new JGraph(model);
graph.setCloneable(true);
graph.setInvokesStopCellEditing(true);
graph.setJumpToDefaultPort(true);
DefaultGraphCell[] cells = new DefaultGraphCell[3];
// Create Hello Vertex
cells[0] = createVertex("Hello", 20, 20, 40, 20, null, true);
cells[1] = createVertex("World", 140, 140, 40, 20, Color.ORANGE, true);
// Create Edge
DefaultEdge edge = new DefaultEdge();
// Fetch the ports from the new vertices, and connect them with the edge
edge.setSource(cells[0].getChildAt(0));
edge.setTarget(cells[2].getChildAt(0));
cells[2] = edge;
int arrow = GraphConstants.ARROW_CLASSIC;
GraphConstants.setLineEnd(edge.getAttributes(), arrow);
GraphConstants.setEndFill(edge.getAttributes(), true);
graph.getGraphLayoutCache().insert(cells);
// Construct Model and Graph
GraphModel model = new DefaultGraphModel();
JGraph graph = new JGraph(model);
graph.setCloneable(true);
graph.setInvokesStopCellEditing(true);
graph.setJumpToDefaultPort(true);
DefaultGraphCell[] cells = new DefaultGraphCell[3];
// Create Hello Vertex
cells[0] = createVertex("Hello", 20, 20, 40, 20, null, true);
cells[1] = createVertex("World", 140, 140, 40, 20, Color.ORANGE, true);
// Create Edge
DefaultEdge edge = new DefaultEdge();
// Fetch the ports from the new vertices, and connect them with the edge
edge.setSource(cells[0].getChildAt(0));
edge.setTarget(cells[2].getChildAt(0));
cells[2] = edge;
int arrow = GraphConstants.ARROW_CLASSIC;
GraphConstants.setLineEnd(edge.getAttributes(), arrow);
GraphConstants.setEndFill(edge.getAttributes(), true);
graph.getGraphLayoutCache().insert(cells);
Valora esta pregunta


0