Package edu.uci.ics.jung.visualization.control

Examples of edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse


        vv = new VisualizationViewer<String,Number>(persistentLayout);
       
        // add my listener for ToolTips
        vv.setVertexToolTipTransformer(new ToStringLabeller());
        DefaultModalGraphMouse gm = new DefaultModalGraphMouse();
        vv.setGraphMouse(gm);
       
        // create a frome to hold the graph
        final JFrame frame = new JFrame();
        frame.getContentPane().add(new GraphZoomScrollPane(vv));
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        // create a control panel and buttons for demo
        // functions
        JPanel p = new JPanel();
       
        JButton persist = new JButton("Save Layout");
        // saves the graph vertex positions to a file
        persist.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                try {
                    persistentLayout.persist(fileName);
                } catch (IOException e1) {
                    System.err.println("got "+e1);
              }
            }
        });
        p.add(persist);

        JButton restore = new JButton("Restore Layout");
        // restores the graph vertex positions from a file
        // if new vertices were added since the last 'persist',
        // they will be placed at random locations
        restore.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
//                PersistentLayout<String,Number> pl = (PersistentLayout<String,Number>) vv.getGraphLayout();
                try {
                    persistentLayout.restore(fileName);
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        });
        p.add(restore);
        p.add(gm.getModeComboBox());

        frame.getContentPane().add(p, BorderLayout.SOUTH);
        frame.pack();//setSize(600, 600);
        frame.setVisible(true);
    }
View Full Code Here


        vv.getRenderContext().setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(vv.getPickedEdgeState(), Color.black, Color.cyan));
        vv.getRenderContext().setVertexFillPaintTransformer(new PickableVertexPaintTransformer<String>(vv.getPickedVertexState(), Color.red, Color.yellow));

        // add my listener for ToolTips
        vv.setVertexToolTipTransformer(new ToStringLabeller());
        final ModalGraphMouse graphMouse = new DefaultModalGraphMouse();
        vv.setGraphMouse(graphMouse);

        satellite =
            new SatelliteVisualizationViewer<String,Number>(vv, new Dimension(200,200));
        satellite.getRenderContext().setEdgeDrawPaintTransformer(new PickableEdgePaintTransformer<Number>(satellite.getPickedEdgeState(), Color.black, Color.cyan));
View Full Code Here

    * @param viewer
    * @return
    */
   public static JComponent createGraphMouseControl(VisualizationViewer viewer)
   {
      DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();
      viewer.setGraphMouse(graphMouse);
      viewer.addKeyListener(graphMouse.getModeKeyListener());

      JComboBox modeBox = graphMouse.getModeComboBox();
      // modeBox.addItem("Details");
      modeBox.addItemListener(graphMouse.getModeListener());
      // modeBox.addItemListener( new LoggingListener("modebox"));
      // viewer.addGraphMouseListener(new LoggingListener("graphmouse"));
      graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);

      return modeBox;
   }
View Full Code Here

    vv.setBackground(Color.black);
   
    // add a listener for ToolTips
    vv.setVertexToolTipTransformer(new ToStringLabeller());
   
    final DefaultModalGraphMouse graphMouse = new DefaultModalGraphMouse();

    vv.setGraphMouse(graphMouse);
    vv.addKeyListener(graphMouse.getModeKeyListener());
   
   
    JFrame frame = new JFrame();
   
    Container content = frame.getContentPane();
   
   
    GraphZoomScrollPane gzsp = new GraphZoomScrollPane(vv);
    content.add(gzsp);
   
  
   
    JComboBox modeBox = graphMouse.getModeComboBox();
    modeBox.addItemListener(graphMouse.getModeListener());
    graphMouse.setMode(ModalGraphMouse.Mode.TRANSFORMING);
   
    final ScalingControl scaler = new CrossoverScalingControl();

    JButton plus = new JButton("+");
    plus.addActionListener(new ActionListener() {
View Full Code Here

TOP

Related Classes of edu.uci.ics.jung.visualization.control.DefaultModalGraphMouse

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.