當前位置: 首頁>>代碼示例>>Java>>正文


Java VisualizationViewer.setGraphMouse方法代碼示例

本文整理匯總了Java中edu.uci.ics.jung.visualization.VisualizationViewer.setGraphMouse方法的典型用法代碼示例。如果您正苦於以下問題:Java VisualizationViewer.setGraphMouse方法的具體用法?Java VisualizationViewer.setGraphMouse怎麽用?Java VisualizationViewer.setGraphMouse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在edu.uci.ics.jung.visualization.VisualizationViewer的用法示例。


在下文中一共展示了VisualizationViewer.setGraphMouse方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setUpView

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
private void setUpView(Graph graph)
    {                 
//        layout = new SpringLayout2(graph);
        layout = new KKLayout(graph);
        //layout.setSize(new Dimension(700,700));
        vv = new VisualizationViewer(layout);
        vv.setPreferredSize(new Dimension(900,900));
        vv.setBackground( Color.white );
        // Tell the renderer to use our own customized label rendering
        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
        vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
        vv.getRenderer().getVertexLabelRenderer().setPosition(Position.CNTR);
        getContentPane().add(new GraphZoomScrollPane(vv), BorderLayout.CENTER);

        /*Mouse controller plugins*/
        PluggableGraphMouse gm = new PluggableGraphMouse();
        gm.add(new TranslatingGraphMousePlugin(MouseEvent.BUTTON3_MASK));
        gm.add(new ScalingGraphMousePlugin(new CrossoverScalingControl(), 0, 1.1f, 0.9f));
        gm.add(new PickingGraphMousePlugin());
        vv.setGraphMouse(gm);
    }
 
開發者ID:sinantie,項目名稱:Generator,代碼行數:22,代碼來源:VisualiseHypergraph.java

示例2: applyStyles

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
public static <V, E> void applyStyles(final VisualizationViewer<V, E> visualizationViewer) {
    final RenderContext<V, E> renderContext = visualizationViewer.getRenderContext();

    renderContext.setEdgeLabelRenderer(new DefaultEdgeLabelRenderer(WidgetUtils.BG_COLOR_BLUE_MEDIUM, false));
    renderContext.setEdgeStrokeTransformer(input -> stroke);
    renderContext.setEdgeDrawPaintTransformer(input -> WidgetUtils.BG_COLOR_LESS_BRIGHT);
    renderContext.setVertexLabelRenderer(new DefaultVertexLabelRenderer(WidgetUtils.BG_COLOR_BLUE_MEDIUM));
    renderContext.setEdgeFontTransformer(GraphUtils.createFontTransformer());
    renderContext.setVertexFontTransformer(GraphUtils.createFontTransformer());

    final DefaultModalGraphMouse<Object, Integer> graphMouse = new DefaultModalGraphMouse<Object, Integer>() {
        @Override
        public void mouseWheelMoved(final MouseWheelEvent e) {
            // avoid zooming
            return;
        }
    };
    graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
    graphMouse.setZoomAtMouse(false);

    visualizationViewer.setGraphMouse(graphMouse);
}
 
開發者ID:datacleaner,項目名稱:DataCleaner,代碼行數:23,代碼來源:GraphUtils.java

示例3: GraphRenderer

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
 * Full constructor
 * 
 * @param graph
 *            The graph to render
 * @param layout
 *            The layout to use
 */
public GraphRenderer(Graph<V, E> graph, Layout<V, E> layout) {
	this.graph = graph;
	this.setBackground(Color.WHITE);
	layout.setSize(new Dimension(1680, 1050));

	final VisualizationViewer<V, E> viewer = new VisualizationViewer<V, E>(
			layout);
	viewer.setBackground(Color.WHITE);
	viewer.getRenderContext().setVertexDrawPaintTransformer(
			new BlackVertexDrawPaintFunction<V>());
	viewer.getRenderContext().setVertexFillPaintTransformer(
			new HighlightingVertexFillPaintFunction<V>());
	viewer.getRenderContext().setEdgeDrawPaintTransformer(
			new HighlightingEdgePaintFunction());
	viewer.getRenderContext().setEdgeStrokeTransformer(
			new HighlightingEdgeStrokeFunction());
	viewer.getRenderContext().setVertexLabelTransformer(
			new ToStringLabeller<V>());
	viewer.setGraphMouse(new DefaultModalGraphMouse<V, E>());

	this.setLayout(new BorderLayout());
	this.add(viewer, BorderLayout.CENTER);
}
 
開發者ID:markuskorbel,項目名稱:adt.reference,代碼行數:32,代碼來源:GraphRenderer.java

示例4: main

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
public static void main(String[] args) {
  DirectedSparseGraph<String, String> g = new DirectedSparseGraph<String, String>();
  g.addVertex("Square");
  g.addVertex("Rectangle");
  g.addVertex("Circle");
  g.addEdge("Edge1", "Square", "Rectangle");
  g.addEdge("Edge2", "Square", "Circle");
  g.addEdge("Edge3", "Circle", "Square");
  
  VisualizationViewer<String, String> vv =
    new VisualizationViewer<String, String>(
      new FRLayout<String, String>(g), new Dimension(400,400));
  Transformer<String, String> transformer = new Transformer<String, String>() {
    @Override public String transform(String arg0) { return arg0; }
  };
  vv.getRenderContext().setVertexLabelTransformer(transformer);
  transformer = new Transformer<String, String>() {
    @Override public String transform(String arg0) { return arg0; }
  };
  vv.getRenderContext().setEdgeLabelTransformer(transformer);
  vv.getRenderer().setVertexRenderer(new MyRenderer());
 
  // The following code adds capability for mouse picking of vertices/edges. Vertices can even be moved!
  final DefaultModalGraphMouse<String,Number> graphMouse = new DefaultModalGraphMouse<String,Number>();
  vv.setGraphMouse(graphMouse);
  graphMouse.setMode(ModalGraphMouse.Mode.PICKING);
 
  JFrame frame = new JFrame();
  frame.getContentPane().add(vv);
  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  frame.pack();
  frame.setVisible(true);
}
 
開發者ID:marcvanzee,項目名稱:mdp-plan-revision,代碼行數:34,代碼來源:VertexShapes.java

示例5: initGraph

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
private void initGraph() {
	try {
		labelMap = new HashMap();
		iconMap = new HashMap();
		graph = new DelegateForest();
		treeLayout = new TreeLayout(graph);
		balloonLayout = new BalloonLayout(graph);
		vv = new VisualizationViewer(balloonLayout);
		vv.setSize(new Dimension(800, 800));
		refreshGraph();
		vv.setBackground(Color.white);
		vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());
		vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
		vv.setVertexToolTipTransformer(new EntityTransformer());
		graphPanel = new GraphZoomScrollPane(vv);
		DefaultModalGraphMouse mouse = new DefaultModalGraphMouse();
		vv.setGraphMouse(mouse);
		mouse.add(new MemoriaGraphMouse(this));
		// T O D O  MemoriaPanel compile error suppress 2 lines
		//VertexStringerImpl localVertexStringerImpl = new VertexStringerImpl(/*this.labelMap*/);
		//this.vv.getRenderContext().setVertexLabelTransformer(new VertexStringerImpl(/*localVertexStringerImpl*/));
		VertexIconShapeTransformer transformer = new VertexIconShapeTransformer(new EllipseVertexShapeTransformer());
		DefaultVertexIconTransformer iconTransformer = new DefaultVertexIconTransformer();
		transformer.setIconMap(iconMap);
		iconTransformer.setIconMap(iconMap);
		vv.getRenderContext().setVertexShapeTransformer(transformer);
		vv.getRenderContext().setVertexIconTransformer(iconTransformer);
	} catch (Exception exc) {
		SbApp.error("MemoriaPanel.initGraph()",exc);
	}
}
 
開發者ID:markkohdev,項目名稱:oStorybook,代碼行數:33,代碼來源:MemoriaPanel.java

示例6: startFunction

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
public JPanel startFunction() {
    Graph g = getGraph();
    
    pr = new PluggableRenderer();
    Layout layout = new FRLayout(g);
    vv = new VisualizationViewer(layout, pr);
    // add Shape based pick support
    vv.setPickSupport(new ShapePickSupport());
    PickedState picked_state = vv.getPickedState();
    
    affineTransformer = vv.getLayoutTransformer();
    
    // create decorators
    vcf = new SeedColor(picked_state);
    ewcs = 
        new EdgeWeightStrokeFunction(edge_weight);
    vsh = new VertexStrokeHighlight(picked_state);
    ff = new FontHandler();
    vs_none = new ConstantVertexStringer(null);
    es_none = new ConstantEdgeStringer(null);
    vssa = new VertexShapeSizeAspect(voltages);
    show_edge = new DirectionDisplayPredicate(true, true);
    show_arrow = new DirectionDisplayPredicate(true, false);
    show_vertex = new VertexDisplayPredicate(false);

    // uses a gradient edge if unpicked, otherwise uses picked selection
    edgePaint = new GradientPickedEdgePaintFunction( new PickableEdgePaintFunction(picked_state,Color.black,Color.cyan), 
            vv, vv, picked_state);
    
    pr.setVertexPaintFunction(vcf);
    pr.setVertexStrokeFunction(vsh);
    pr.setVertexStringer(vs_none);
    pr.setVertexFontFunction(ff);
    pr.setVertexShapeFunction(vssa);
    pr.setVertexIncludePredicate(show_vertex);
    
    pr.setEdgePaintFunction( edgePaint );
    pr.setEdgeStringer(es_none);
    pr.setEdgeFontFunction(ff);
    pr.setEdgeStrokeFunction(ewcs);
    pr.setEdgeIncludePredicate(show_edge);
    pr.setEdgeShapeFunction(new EdgeShape.Line());
    pr.setEdgeArrowPredicate(show_arrow);
    JPanel jp = new JPanel();
    jp.setLayout(new BorderLayout());
    
    vv.setBackground(Color.white);
    GraphZoomScrollPane scrollPane = new GraphZoomScrollPane(vv);
    jp.add(scrollPane);
    gm = new DefaultModalGraphMouse();
    vv.setGraphMouse(gm);
    gm.add(new PopupGraphMousePlugin());

    addBottomControls( jp );
    vssa.setScaling(true);

    vv.setToolTipFunction(new VoltageTips());
    vv.setToolTipText("<html><center>Use the mouse wheel to zoom<p>Click and Drag the mouse to pan<p>Shift-click and Drag to Rotate</center></html>");
    

    
    return jp;
}
 
開發者ID:dev-cuttlefish,項目名稱:cuttlefish,代碼行數:64,代碼來源:PluggableRendererDemo.java

示例7: ShortestPathDemo

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
public ShortestPathDemo() {

	this.mGraph = getGraph();
	setBackground(Color.WHITE);
	// show graph
       final Layout<String,Number> layout = new FRLayout<String,Number>(mGraph);
       final VisualizationViewer<String,Number> vv = new VisualizationViewer<String,Number>(layout);
       vv.setBackground(Color.WHITE);

       vv.getRenderContext().setVertexDrawPaintTransformer(new MyVertexDrawPaintFunction<String>());
       vv.getRenderContext().setVertexFillPaintTransformer(new MyVertexFillPaintFunction<String>());
       vv.getRenderContext().setEdgeDrawPaintTransformer(new MyEdgePaintFunction());
       vv.getRenderContext().setEdgeStrokeTransformer(new MyEdgeStrokeFunction());
       vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>());
       vv.setGraphMouse(new DefaultModalGraphMouse<String, Number>());
       vv.addPostRenderPaintable(new VisualizationViewer.Paintable(){
           
           public boolean useTransform() {
               return true;
           }
           public void paint(Graphics g) {
               if(mPred == null) return;
               
               // for all edges, paint edges that are in shortest path
               for (Number e : layout.getGraph().getEdges()) {
                   
                   if(isBlessed(e)) {
                       String v1 = mGraph.getEndpoints(e).getFirst();
                       String v2 = mGraph.getEndpoints(e).getSecond();
                       Point2D p1 = layout.transform(v1);
                       Point2D p2 = layout.transform(v2);
                       p1 = vv.getRenderContext().getMultiLayerTransformer().transform(Layer.LAYOUT, p1);
                       p2 = vv.getRenderContext().getMultiLayerTransformer().transform(Layer.LAYOUT, p2);
                       Renderer<String,Number> renderer = vv.getRenderer();
                       renderer.renderEdge(
                               vv.getRenderContext(),
                               layout,
                               e);
                   }
               }
           }
       });
       
       setLayout(new BorderLayout());
       add(vv, BorderLayout.CENTER);
       // set up controls
       add(setUpControls(), BorderLayout.SOUTH);
}
 
開發者ID:marcvanzee,項目名稱:mdp-plan-revision,代碼行數:49,代碼來源:ShortestPathDemo.java

示例8: render

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
@SuppressWarnings({ "rawtypes", "unchecked" })
public static void render(Node tree) {
	// Grafo
	Factory<DirectedGraph<Node, Integer>> factory = DirectedOrderedSparseMultigraph
			.<Node, Integer> getFactory();
	graph = new DelegateTree<Node, Integer>(factory);

	// Adiciona os v�rtices ao grafo
	graph.addVertex(tree);
	build(tree);

	// Layout
	TreeLayout<Node, Integer> layout = new TreeLayout<Node, Integer>(graph,
			75, 50);

	// Visualiza��o
	VisualizationViewer<Node, Integer> vv = new VisualizationViewer<Node, Integer>(
			layout);
	VertexLabelAsShapeRenderer<Node, Integer> vlasr = new VertexLabelAsShapeRenderer<Node, Integer>(
			vv.getRenderContext());

	/* V�rtices */
	// Cor da borda
	vv.getRenderContext().setVertexDrawPaintTransformer(
			new ConstantTransformer(Color.black));
	// Cor de fundo
	vv.getRenderContext().setVertexFillPaintTransformer(
			new ConstantTransformer(Color.lightGray));
	// R�tulo como string
	vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
	// Formato retangular
	vv.getRenderContext().setVertexShapeTransformer(vlasr);
	// Posiciona texto dentro
	vv.getRenderer().setVertexLabelRenderer(vlasr);

	/* Arestas */
	// Remove a seta da aresta
	vv.getRenderContext().setEdgeArrowPredicate(
			new Predicate<Context<Graph<Node, Integer>, Integer>>() {
				@Override
				public boolean evaluate(
						Context<Graph<Node, Integer>, Integer> arg0) {
					return false;
				}
			});
	// Formato da linha
	vv.getRenderContext().setEdgeShapeTransformer(new EdgeShape.Line());

	// Habilita suporte ao mouse
	final DefaultModalGraphMouse<Node, Integer> graphMouse = new DefaultModalGraphMouse<Node, Integer>();
	vv.setGraphMouse(graphMouse);

	// Cria a janela do JFrame
	JFrame jf = new JFrame();
	jf.getContentPane().add(vv);
	jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	jf.setTitle("Abstract Syntax Tree");
	jf.pack();
	jf.setExtendedState(JFrame.MAXIMIZED_BOTH);
	jf.setVisible(true);
}
 
開發者ID:navossoc,項目名稱:minipascal,代碼行數:62,代碼來源:AST.java

示例9: showFull

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
     * Show the full StateMachine with a special formater.
     * <p/>
     * @param <T>          type of state machine
     * @param stateMachine the statemachine to show
     * @param formater     an optional formater
     */
    public static <T> void showFull(final StateMachine<T> stateMachine, final StateFormater<T> formater) {
        DirectedGraph<State<T>, String> g = new DirectedSparseMultigraph<>();
        int i = 0;
        for (Link<T> link : stateMachine.getLinks()) {
            // TODO: A Graph needs for each transition a unique id. A StateMachine not. So we build it here.
            g.addEdge("[" + (i++) + "] " + link.getTransition().toString(), link.getSource(), link.getDestination());
        }

        FRLayout<State<T>, String> layout = new FRLayout<>(g);
//        layout.setRepulsionMultiplier(2);
//        layout.setMaxIterations(20);
        layout.setSize(new Dimension(1100, 950)); // sets the initial size of the space
        VisualizationViewer<State<T>, String> vv = new VisualizationViewer<>(layout);
        vv.setPreferredSize(new Dimension(1280, 1024)); //Sets the viewing area size

        vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());

        vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.AUTO);

//                final VisualizationModel<String,Number> visualizationModel =
//            new DefaultVisualizationModel<String,Number>(layout, preferredSize);
        // this class will provide both label drawing and vertex shapes
        VertexLabelAsShapeRenderer<State<T>, String> vlasr = new VertexLabelAsShapeRenderer<>(vv.getRenderContext());
//
//        // customize the render context
        if ( formater != null ) {
            vv.getRenderContext().setVertexLabelTransformer((state) -> {
                return formater.toHtml(state);
            });
            vv.setVertexToolTipTransformer((state) -> {
                return formater.toToolTipHtml(state);
            });
        }

        vv.getRenderContext().setVertexShapeTransformer(vlasr);
        vv.getRenderContext().setVertexLabelRenderer(new DefaultVertexLabelRenderer(Color.RED));
        vv.getRenderContext().setEdgeDrawPaintTransformer((input) -> {
            return Color.DARK_GRAY;
        });
        vv.getRenderContext().setEdgeStrokeTransformer((input) -> {
            return new BasicStroke(2.5f);
        });

        // customize the renderer
        vv.getRenderer().setVertexRenderer(new GradientVertexRenderer<State<T>, String>(Color.LIGHT_GRAY, Color.WHITE, true));
        vv.getRenderer().setVertexLabelRenderer(vlasr);
        DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
        gm.setMode(ModalGraphMouse.Mode.TRANSFORMING);
        vv.setGraphMouse(gm);
        vv.addKeyListener(gm.getModeKeyListener());

        JFrame frame = new JFrame("Simple Graph View");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().setLayout(new BorderLayout());
        frame.getContentPane().add(vv, BorderLayout.CENTER);
        frame.getContentPane().add(gm.getModeComboBox(), BorderLayout.SOUTH);
        frame.pack();
        frame.setVisible(true);
    }
 
開發者ID:gg-net,項目名稱:dwoss,代碼行數:68,代碼來源:Grapher.java

示例10: setupGraph

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
public static void setupGraph(DirectedSparseGraph g){
	
	bg = g;
	
	Layout<BooleanNode, TravelEdge> layout = new DAGLayout(bg);
       layout.setSize(new Dimension(300,300)); // sets the initial size of the layout space

       VisualizationViewer<BooleanNode,TravelEdge> vv = new VisualizationViewer<BooleanNode,TravelEdge>(layout);
       vv.setPreferredSize(new Dimension(500,500)); //Sets the viewing area size

       Transformer<BooleanNode,Paint> vertexPaint = new Transformer<BooleanNode,Paint>() {
       	public Paint transform(BooleanNode i) {
       		if (i.isCurrentNode()){
       			return Color.RED;
       		} else if (i.getObserved()){
       			return Color.BLUE;
       		} else if (i.isStartNode()) {
       			return Color.GREEN;
       		} else if (i.isEndNode()){
       			return Color.BLACK;
       		} else {
       			return Color.WHITE;
       		}
       	}
       	}; 
       	
       vv.getRenderContext().setVertexFillPaintTransformer(vertexPaint);
       vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
	
       PluggableGraphMouse gm = new PluggableGraphMouse();
       gm.add(new NetworkGameMousePlugin());
       
       vv.setGraphMouse(gm); 
       
       frame = new JFrame("Simple Graph View");
       frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
       frame.getContentPane().add(vv); 
       
       JMenuBar menuBar = new JMenuBar();
       
       JMenu restartMenu = new JMenu();
       restartMenu.setText("Restart");
       menuBar.add(restartMenu);
       JMenuItem restartItem = new JMenuItem("Restart level");
       
       restartItem.addActionListener(new ActionListener() {
           public void actionPerformed(ActionEvent evt) {
               restartLevel();
           }
       });
       
       restartMenu.add(restartItem);
       
       
       
       frame.setJMenuBar(menuBar);
       
       
       frame.pack();
       frame.setVisible(true);  

       
       
}
 
開發者ID:ksotala,項目名稱:BayesGame,代碼行數:65,代碼來源:SeparationGame.java

示例11: main

import edu.uci.ics.jung.visualization.VisualizationViewer; //導入方法依賴的package包/類
/**
     * @param args the command line arguments
     */
    public static void main(String[] args) {        
        JFrame frame = new JFrame("Editing and Mouse Menu Demo");
        SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge> g = 
                new SparseMultigraph<GraphElements.MyVertex, GraphElements.MyEdge>();
        // Layout<V, E>, VisualizationViewer<V,E>
//        Map<GraphElements.MyVertex,Point2D> vertexLocations = new HashMap<GraphElements.MyVertex, Point2D>();
        Layout<GraphElements.MyVertex, GraphElements.MyEdge> layout = new StaticLayout(g);
        layout.setSize(new Dimension(300,300));
        VisualizationViewer<GraphElements.MyVertex,GraphElements.MyEdge> vv = 
                new VisualizationViewer<GraphElements.MyVertex,GraphElements.MyEdge>(layout);
        vv.setPreferredSize(new Dimension(350,350));
        // Show vertex and edge labels
        vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller());
        vv.getRenderContext().setEdgeLabelTransformer(new ToStringLabeller());
        // Create a graph mouse and add it to the visualization viewer
        EditingModalGraphMouse gm = new EditingModalGraphMouse(vv.getRenderContext(), 
                 GraphElements.MyVertexFactory.getInstance(),
                GraphElements.MyEdgeFactory.getInstance()); 
        // Set some defaults for the Edges...
        GraphElements.MyEdgeFactory.setDefaultCapacity(192.0);
        GraphElements.MyEdgeFactory.setDefaultWeight(5.0);
        // Trying out our new popup menu mouse plugin...
        PopupVertexEdgeMenuMousePlugin myPlugin = new PopupVertexEdgeMenuMousePlugin();
        // Add some popup menus for the edges and vertices to our mouse plugin.
        JPopupMenu edgeMenu = new MyMouseMenus.EdgeMenu(frame);
        JPopupMenu vertexMenu = new MyMouseMenus.VertexMenu();
        myPlugin.setEdgePopup(edgeMenu);
        myPlugin.setVertexPopup(vertexMenu);
        gm.remove(gm.getPopupEditingPlugin());  // Removes the existing popup editing plugin
        
        gm.add(myPlugin);   // Add our new plugin to the mouse
        
        vv.setGraphMouse(gm);

        
        //JFrame frame = new JFrame("Editing and Mouse Menu Demo");
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.getContentPane().add(vv);
        
        // Let's add a menu for changing mouse modes
        JMenuBar menuBar = new JMenuBar();
        JMenu modeMenu = gm.getModeMenu();
        modeMenu.setText("Mouse Mode");
        modeMenu.setIcon(null); // I'm using this in a main menu
        modeMenu.setPreferredSize(new Dimension(80,20)); // Change the size so I can see the text
        
        menuBar.add(modeMenu);
        frame.setJMenuBar(menuBar);
        gm.setMode(ModalGraphMouse.Mode.EDITING); // Start off in editing mode
        frame.pack();
        frame.setVisible(true);    
    }
 
開發者ID:ksotala,項目名稱:BayesGame,代碼行數:56,代碼來源:EditorMouseMenu.java


注:本文中的edu.uci.ics.jung.visualization.VisualizationViewer.setGraphMouse方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。