使用JUNG Framework修改可编辑图表选项

时间:2012-01-18 15:53:42

标签: java jung

基于JUNG框架示例,我可以创建一个可编辑的图形(节点和弧形),如:

        graph = new SparseMultigraph<Number,Number>();

        this.layout = new StaticLayout<Number,Number>(graph, 
            new Dimension(600,600));

        vv =  new VisualizationViewer<Number,Number>(layout);
        vv.setBackground(Color.white);

        final GraphZoomScrollPane panel = new GraphZoomScrollPane(vv);
        JFrame frame = new JFrame();
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.add(panel);
        Factory<Number> vertexFactory = new VertexFactory();
        Factory<Number> edgeFactory = new EdgeFactory();

        final EditingModalGraphMouse<Number,Number> graphMouse = 
            new EditingModalGraphMouse<Number,Number>(vv.getRenderContext(), vertexFactory, edgeFactory);

        vv.setGraphMouse(graphMouse);
        vv.addKeyListener(graphMouse.getModeKeyListener());

        graphMouse.setMode(ModalGraphMouse.Mode.PICKING);

        frame.pack();
        frame.setVisible(true);

然而,每当我右键单击时,我都会看到创建新顶点和添加有向/无向边的选项。我有可能用我自己的选项覆盖这个菜单吗?

0 个答案:

没有答案