Example #1
0
  /**
   * DOCUMENT ME!
   *
   * @param nv DOCUMENT ME!
   * @param o DOCUMENT ME!
   */
  public void applyToNodeView(NodeView nv, Object o, VisualPropertyDependency dep) {
    if ((o == null) || (nv == null)) return;

    if (dep != null && dep.check(VisualPropertyDependency.Definition.NODE_SIZE_LOCKED)) return;

    double width = ((Number) o).doubleValue();
    double difference = width - nv.getWidth();

    if (Math.abs(difference) > 0.1) nv.setWidth(width);
  }
Example #2
0
  /**
   * DOCUMENT ME!
   *
   * @param nv DOCUMENT ME!
   * @param o DOCUMENT ME!
   */
  public void applyToNodeView(NodeView nv, Object o, VisualPropertyDependency dep) {
    if ((o == null) || (nv == null)) return;

    Label nodelabel = nv.getLabel();

    if (!((String) o).equals(nodelabel.getText())) nodelabel.setText((String) o);
  }
  /**
   * @param nodeView The clicked NodeView
   * @param menu popup menu to add the Bypass menu
   */
  public void addNodeContextMenuItems(NodeView nodeView, JPopupMenu menu) {
    NodeBypass nb = new NodeBypass();

    if (menu == null) menu = new JPopupMenu();

    /*
     * Add Node ID as label.
     */
    final String nodeID = nodeView.getNode().getIdentifier();
    final JLabel nodeLabel = new JLabel(nodeID);

    nodeLabel.setForeground(new Color(10, 50, 250, 150));
    nodeLabel.setFont(new Font("SansSerif", Font.BOLD, 18));
    nodeLabel.setBorder(new EmptyBorder(5, 10, 5, 5));
    menu.add(nodeLabel);

    menu.add(nb.addMenu(nodeView.getNode()));
  }
Example #4
0
  /**
   * Constructs the popup menu that will be injected into the popup menu of the node
   *
   * @param nodeView the node view that was clicked on in the graph view
   */
  protected JMenu getPopupMenu(NodeView nodeView) {
    /* Get a handle to the control panel. If the control panel is not shown yet,
     * we don't put anything in the context menu */
    ControlPanel panel = ControlPanel.getShownInstance();
    if (panel == null) return null;

    JMenu menu = new JMenu(ClusterONE.applicationName);
    menu.add(new GrowClusterAction(nodeView.getNode()));
    menu.add(GrowClusterAction.getGlobalInstance());

    return menu;
  }
  public void actionPerformed(ActionEvent e) {

    // sum of coordinates
    double sx = 0;
    double sy = 0;

    // coordinates of center of graph
    double cx = 0;
    double cy = 0;

    // coordinates with graph centered at (0,0)
    double nx;
    double ny;

    CyNetworkView parent = Cytoscape.getCurrentNetworkView();
    // loop through each node to add up all x and all y coordinates
    for (Iterator i = parent.getNodeViewsIterator(); i.hasNext(); ) {
      NodeView nodeView = (NodeView) i.next();
      // get coordinates of node
      double ax = nodeView.getXPosition();
      double ay = nodeView.getYPosition();
      // sum up coordinates of all the nodes
      sx += ax;
      sy += ay;
    }

    // set new coordinates of each node at center (0,0), shrink, then return to
    // original center at (cx, cy)
    for (Iterator i = parent.getNodeViewsIterator(); i.hasNext(); ) {
      NodeView nodeView = (NodeView) i.next();
      nodeView.setXPosition(m * ((nodeView.getXPosition()) - cx) + cx);
      nodeView.setYPosition(m * ((nodeView.getYPosition()) - cy) + cy);
    }

    // remove bends
    for (Iterator i = parent.getEdgeViewsIterator(); i.hasNext(); ) {
      EdgeView edgeView = (EdgeView) i.next();
      edgeView.getBend().removeAllHandles();
    }
  } // Action Performed