Exemple #1
0
 /** 删除选中的元素 */
 public void deleteSelectedCells() {
   if (!graph.isSelectionEmpty()) {
     Object[] cells = graph.getSelectionCells();
     cells = graph.getDescendants(cells);
     graph.getModel().remove(cells);
   }
 }
Exemple #2
0
  // From GraphSelectionListener Interface
  public void valueChanged(GraphSelectionEvent e) {

    // 设置工具条相关按钮的可用性
    editor.mainToolBar.setActionEnabled(MainActions.ACTION_GROUP, graph.getSelectionCount() > 1);
    // Update Button States based on Current Selection
    boolean enabled = !graph.isSelectionEmpty();
    editor.mainToolBar.setActionEnabled(MainActions.ACTION_DELETE, enabled);
    editor.mainToolBar.setActionEnabled(MainActions.ACTION_UNGROUP, enabled);
    editor.mainToolBar.setActionEnabled(MainActions.ACTION_TOFRONT, enabled);
    editor.mainToolBar.setActionEnabled(MainActions.ACTION_TOBACK, enabled);
    editor.mainToolBar.setActionEnabled(MainActions.ACTION_COPY, enabled);
    editor.mainToolBar.setActionEnabled(MainActions.ACTION_CUT, enabled);
    if (graph.getSelectionCount() > 0) {

      Object c = graph.getSelectionCell();
      if (c instanceof DefaultGraphCell) {
        DefaultGraphCell cell = (DefaultGraphCell) c;
        Object uo = cell.getUserObject();
        Rectangle2D rect = GraphConstants.getBounds(cell.getAttributes());
        if (rect != null) {
          editor.messageView.warn(
              "rect=" + rect.getX() + ":" + rect.getY() + rect.getWidth() + ":" + rect.getHeight());
        }

        if (uo instanceof FlowElementObject) {
          editor.propertiesView.resetProperties(((FlowElementObject) uo).getProperties());
        } else {
          // System.out.println("uo="+uo);
          undo();
          editor.messageView.warn("不能这样操作,请在操作左加的属性值");
          // System.out.println("不能这样操作");
          // editor.propertiesView.resetProperties(null);
        }
      } else {
        undo();
        // editor.propertiesView.resetProperties(null);
        editor.messageView.warn("不能这样操作,操作对像,不能识别" + c.getClass().getName());
      }

    } else {
      editor.propertiesView.resetProperties(graph.getGraphInfo().getProperties());
    }
    // System.out.println("Change");
  }