Examples of PickSupport


Examples of edu.uci.ics.jung.visualization.PickSupport

               
                isInVV = true;
            }
            Point2D ip = vv.inverseViewTransform(p);

            PickSupport picksupport = vv.getPickSupport();
            final PickedState pickedstate = vv.getPickedState();
            Vertex v = picksupport.getVertex(ip.getX(), ip.getY());
            if (v != null && info.hasSomethingToDisplay(v)) {
                info.refreshInfo(v);
                info.moveTo(v);
                info.setVisible(true);
            } else {
View Full Code Here

Examples of edu.uci.ics.jung.visualization.PickSupport

    }
   
    public void mousePressed(MouseEvent e) {
        down = e.getPoint();
        VisualizationViewer vv = (VisualizationViewer)e.getSource();
        PickSupport pickSupport = vv.getPickSupport();
        PickedState pickedState = vv.getPickedState();

        if(pickSupport != null && pickedState != null) {
            Layout layout = vv.getGraphLayout();
            if(e.getModifiers() == getModifiers()) {
                vv.addPostRenderPaintable(lensPaintable);
                rect.setFrameFromDiagonal(down,down);
                // p is the screen point for the mouse event
                Point2D p = e.getPoint();
                // take away the view transform
                Point2D ip = vv.inverseViewTransform(p);
               
                vertex = pickSupport.getVertex(ip.getX(), ip.getY());
                if(vertex != null) {
                    if(pickedState.isPicked(vertex) == false) {
                        pickedState.clearPickedVertices();
                        pickedState.pick(vertex, true);
                        vv.fireStateChanged();
                    }
                    // layout.getLocation applies the layout transformer so
                    // q is transformed by the layout transformer only
                    Point2D q = layout.getLocation(vertex);
                    // transform the mouse point to graph coordinate system
                    Point2D gp = vv.inverseLayoutTransform(ip);

                    offsetx = (float) (gp.getX()-q.getX());
                    offsety = (float) (gp.getY()-q.getY());
                } else if(isPickingEdges() &&
                        (edge = pickSupport.getEdge(ip.getX(), ip.getY())) != null) {
                    pickedState.clearPickedEdges();
                    pickedState.pick(edge, true);
                } else {
                    pickedState.clearPickedEdges();
                    pickedState.clearPickedVertices();
                    vv.fireStateChanged();
                }
               
            } else if(e.getModifiers() == (addToSelectionModifiers)) {
                vv.addPostRenderPaintable(lensPaintable);
                rect.setFrameFromDiagonal(down,down);
                Point2D p = e.getPoint();
                // remove view transform
                Point2D ip = vv.inverseViewTransform(p);
                vertex = pickSupport.getVertex(ip.getX(), ip.getY());
                if(vertex != null) {
                    boolean wasThere = pickedState.pick(vertex, !pickedState.isPicked(vertex));
                    if(wasThere) {
                        vertex = null;
                    } else {
                        // layout.getLocation applies the layout transformer so
                        // q is transformed by the layout transformer only
                        Point2D q = layout.getLocation(vertex);
                        // translate mouse point to graph coord system
                        Point2D gp = vv.inverseLayoutTransform(ip);

                        offsetx = (float) (gp.getX()-q.getX());
                        offsety = (float) (gp.getY()-q.getY());
                    }
                } else if(isPickingEdges() &&
                        (edge = pickSupport.getEdge(ip.getX(), ip.getY())) != null) {
                    pickedState.pick(edge, !pickedState.isPicked(edge));
                }
            }
        }
       if(vertex != null) e.consume();
View Full Code Here

Examples of edu.uci.ics.jung.visualization.PickSupport

        if (checkModifiers(e) || e.getModifiers() == mskbutton) {
            final VisualizationViewer vv = (VisualizationViewer)e.getSource();
            final Graph graph = vv.getGraphLayout().getGraph();
            Point2D ip = vv.inverseViewTransform(p);

            PickSupport picksupport = vv.getPickSupport();
            final PickedState pickedstate = vv.getPickedState();
            Vertex v = picksupport.getVertex(ip.getX(), ip.getY());
            if (v != null && hasSomethingToDisplay(v, vv)) {
                String hostname = getGraphManager().getLabel(v);
               
                // open the new window
                GraphEvent ge = new GraphEvent(this);
View Full Code Here

Examples of edu.uci.ics.jung.visualization.PickSupport

   * (non-Javadoc)
   *
   * @see java.awt.event.MouseListener#mouseClicked(java.awt.event.MouseEvent)
   */
  public void mouseClicked(MouseEvent e) {
    PickSupport ps = vv.getPickSupport();
    /*
     * if user clicks right button (BUTTON3) shows popups with related
     * options else runs events to manage edge/vertex selection
     *
     */
    if (ps != null) {
      if (e.getButton() == (int) e.BUTTON3) {
        // shows popup
        final Vertex v = ps.getVertex(e.getX(), e.getY());
        if (v != null) {
          JPopupMenu popup = new JPopupMenu();
          popup.add(new AbstractAction("Action 1") {
            public void actionPerformed(ActionEvent e) {
              System.out.println("performed action 1");
            }
          });
          popup.add(new AbstractAction("Show data") {
            public void actionPerformed(ActionEvent e) {
              System.out.println(v.toString()+" has been selected with right click");
              // convert vertex into XGrapher node
              Node n = mapper.toXGrapher(v);
              // fire event
              app.commBus().fireEvent(XGrapherEventType.NODE_SELECTION,
                  null, n);
            }
          });
          popup.show(vv, e.getX(), e.getY());
        } else {
          final edu.uci.ics.jung.graph.Edge edge = ps.getEdge(e
              .getX(), e.getY());
          if (edge != null) {
            JPopupMenu popup = new JPopupMenu();
            popup.add(new AbstractAction(edge.getUserDatum(GraphAttributeType.NAME).toString()) {
              public void actionPerformed(ActionEvent e) {
                System.out.println("Shown popup of"
                    + edge.toString());
              }
            });
            popup.show(vv, e.getX(), e.getY());

          }
        }

      } else {
        // runs events to manage edge/vertex selection

        Vertex v = ps.getVertex(e.getX(), e.getY());
        if (v != null) {
          // a vertex has been selected
          System.out.println(v.toString());
          // convert vertex into XGrapher node
          Node n = mapper.toXGrapher(v);
          // fire event
          app.commBus().fireEvent(XGrapherEventType.NODE_SELECTION,
              null, n);
        } else {
          edu.uci.ics.jung.graph.Edge jedge = ps.getEdge(e.getX(), e
              .getY());
          if (jedge != null) {
            // an edge has been selected
            System.out.println(jedge.toString());
            // convert jung edge into XGrapher edge
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.