|
From: SourceForge.net <no...@so...> - 2007-03-01 23:04:16
|
Read and respond to this message at: https://sourceforge.net/forum/message.php?msg_id=4186710 By: bardack66 Yeah, I ve a look to theses examples. In GraphEditorDemo, nothing about that. All is automatised ... In AddNodeDemo there is : <i> layout.update(); if (!vv.isVisRunnerRunning()) vv.init(); vv.repaint(); </i> In the example, layout is a FRLayout(); But me (I ve doing my application from the GraphEditorDemo), I ve a SparseGraph() The problem is: SparseGraph has no method : update () And when I pass my layout into FRLayout, the onClick on the JPanel , the vertex appears not at the point of click, but more far ... Don t understand Here s my code of the using of JUNGE (method maj must update the graph) <i> public class Tableau extends JApplet implements DragGestureListener, DragSourceListener, DropTargetListener { private static Tableau tableau = null; Graph graph; AbstractLayout layout; /** * the visual component and renderer for the graph */ VisualizationViewer vv; DefaultSettableVertexLocationFunction vertexLocations; /** * create an instance of a simple graph with popup controls to * create a graph. * */ private Tableau() { // allows the precise setting of initial vertex locations vertexLocations = new DefaultSettableVertexLocationFunction(); // create a simple graph for the demo graph = new SparseGraph(); PluggableRenderer pr = new PluggableRenderer(); this.layout = new StaticLayout(graph); layout.initialize(new Dimension(600,600), vertexLocations); vv = new VisualizationViewer(layout, pr); vv.setBackground(Color.white); vv.setPickSupport(new ShapePickSupport()); pr.setEdgeShapeFunction(new EdgeShape.QuadCurve()); pr.setVertexStringer(new VertexStringer() { public String getLabel(ArchetypeVertex v) { return v.toString(); }}); vv.setToolTipFunction(new DefaultToolTipFunction()); Container content = getContentPane(); final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv); content.add(panel); final EditingModalGraphMouse graphMouse = new EditingModalGraphMouse(); // the EditingGraphMouse will pass mouse event coordinates to the // vertexLocations function to set the locations of the vertices as // they are created graphMouse.setVertexLocations(vertexLocations); vv.setGraphMouse(graphMouse); graphMouse.add(new EditingPopupGraphMousePlugin(vertexLocations)); graphMouse.setMode(ModalGraphMouse.Mode.EDITING); final ScalingControl scaler = new CrossoverScalingControl(); JButton plus = new JButton("+"); plus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1.1f, vv.getCenter()); } }); JButton minus = new JButton("-"); minus.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { scaler.scale(vv, 1/1.1f, vv.getCenter()); } }); JPanel controls = new JPanel(); controls.add(plus); controls.add(minus); JComboBox modeBox = graphMouse.getModeComboBox(); controls.add(modeBox); content.add(controls, BorderLayout.SOUTH); } public void maj() { // ... ? } public void dragGestureRecognized(DragGestureEvent e) { } public void dragDropEnd(DragSourceDropEvent e) { } public void dragExit(DragSourceEvent e) { } public void dropActionChanged(DragSourceDragEvent e) { } public void dragOver(DragSourceDragEvent e) { } public void dragEnter(DragSourceDragEvent e) { } public void drop(DropTargetDropEvent e) { if (e.isDataFlavorSupported(Materiel.materielDataFlavor)) { e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); } else { e.rejectDrop(); return; } } public void dragExit(DropTargetEvent e) { } public void dropActionChanged(DropTargetDragEvent e) { } public void dragOver(DropTargetDragEvent e) { } public void dragEnter(DropTargetDragEvent e) { } public static Tableau getInstance() { if (tableau == null) tableau = new Tableau(); return tableau; } } </i> ______________________________________________________________________ You are receiving this email because you elected to monitor this forum. To stop monitoring this forum, login to SourceForge.net and visit: https://sourceforge.net/forum/unmonitor.php?forum_id=252062 |