Esempio n. 1
0
 // Update Undo/Redo Button State based on Undo Manager
 protected void updateHistoryButtons() {
   // The View Argument Defines the Context
   editor.mainToolBar.setActionEnabled(
       MainActions.ACTION_UNDO, undoManager.canUndo(graph.getGraphLayoutCache()));
   editor.mainToolBar.setActionEnabled(
       MainActions.ACTION_REDO, undoManager.canRedo(graph.getGraphLayoutCache()));
 }
Esempio n. 2
0
 /** 重做上一步 */
 public void redo() {
   if (undoManager == null) return;
   try {
     undoManager.redo(graph.getGraphLayoutCache());
   } catch (Exception ex) {
     System.err.println(ex);
   } finally {
     updateHistoryButtons();
   }
 }
Esempio n. 3
0
 /** 组合选中的元素 */
 public void groupSelectedCells() {
   Object[] cells = graph.getSelectionCells();
   // Order Cells by Model Layering
   cells = graph.order(cells);
   // If Any Cells in View
   if (cells != null && cells.length > 0) {
     DefaultGraphCell group = new DefaultGraphCell();
     // Insert into model
     graph.getGraphLayoutCache().insertGroup(group, cells);
   }
 }
Esempio n. 4
0
  /**
   * 连接两个Port
   *
   * @param source
   * @param target
   */
  public void connect(Port source, Port target) {
    for (Iterator it = source.edges(); it.hasNext(); ) {
      Edge e = (Edge) it.next();
      if (e.getTarget() == target) {
        this.repaint();
        return;
      }
    }
    // Construct Edge with no label
    DefaultEdge edge = new DefaultEdge();
    if (graph.getModel().acceptsSource(edge, source)
        && graph.getModel().acceptsTarget(edge, target)) {

      edge.setUserObject(new FlowEdgeObject(edge));
      // Create a Map thath holds the attributes for the edge
      edge.getAttributes().applyMap(createEdgeAttributes());
      // Insert the Edge and its Attributes
      graph.getGraphLayoutCache().insertEdge(edge, source, target);

      // 添加到树结构
      // editor.strutcView.addFlowRoute(graph, edge);
    }
  }
Esempio n. 5
0
 /** 将选中的元素往下一层 */
 public void toBack() {
   graph.getGraphLayoutCache().toBack(graph.getSelectionCells());
 }
Esempio n. 6
0
 /** 将选中的元素往上一层 */
 public void toFront() {
   graph.getGraphLayoutCache().toFront(graph.getSelectionCells());
 }
Esempio n. 7
0
 /** 取消元素的组合 */
 public void ungroupSelectedCells() {
   graph.getGraphLayoutCache().ungroup(graph.getSelectionCells());
 }