Search in sources :

Example 21 with SubGraph

use of com.centurylink.mdw.designer.display.SubGraph in project mdw-designer by CenturyLinkCloud.

the class CanvasCommon method moveNode.

protected void moveNode(int ex, int ey) {
    Node selected_node = (Node) selected_obj;
    GraphCommon graph = selected_node.graph;
    int x = selected_node.x;
    int y = selected_node.y;
    int w = selected_node.w;
    int h = selected_node.h;
    x = ex - delta_x;
    y = ey - delta_y;
    if (x < graph.x)
        x = graph.x;
    else if (x + w > graph.x + graph.w)
        x = graph.x + graph.w - w;
    if (y < graph.y)
        y = graph.y;
    else if (y + h > graph.y + graph.h)
        y = graph.y + graph.h - h;
    selected_node.x = x;
    selected_node.y = y;
    Graph process = (graph instanceof SubGraph) ? ((SubGraph) graph).getGraph() : (Graph) graph;
    graph.recalcLinkPosition(selected_node, process.arrowstyle);
    // selected_node.save();
    if (!process.isReadonly())
        process.setDirtyLevel(Graph.GEOCHANGE);
    if (graph instanceof SubGraph && process.isSwimLanes()) {
        if (graph.w < x + w + 40)
            graph.w = x + w + 40;
    }
    resizeCanvasToFit(x + w, y + h, process.zoom);
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) GraphCommon(com.centurylink.mdw.designer.display.GraphCommon) Node(com.centurylink.mdw.designer.display.Node) SubGraph(com.centurylink.mdw.designer.display.SubGraph)

Example 22 with SubGraph

use of com.centurylink.mdw.designer.display.SubGraph in project mdw-designer by CenturyLinkCloud.

the class CanvasCommon method keyPressed.

protected void keyPressed(KeyEvent arg0, Graph main_graph, DesignerPage page, boolean recordchange) {
    if (useLabelEditor && arg0.getSource() == labelEditor) {
        return;
    }
    if (main_graph.isReadonly())
        return;
    int keycode = arg0.getKeyCode();
    char ch = arg0.getKeyChar();
    if (selected_obj != null) {
        if ((useLabelEditor && editing_obj != null) || (!useLabelEditor && textEditor != null)) {
        // do not need to do any thing - handled by editor
        } else if (selected_obj instanceof Node) {
            if (keycode == KeyEvent.VK_DELETE) {
                if (page.getConfirmation("Are you sure you want to delete the node?")) {
                    main_graph.removeNode((Node) selected_obj, recordchange);
                    selected_obj = null;
                    repaint();
                }
            } else if (ch != KeyEvent.CHAR_UNDEFINED && !arg0.isControlDown()) {
                String label = ((Node) selected_obj).getName();
                if (label == null)
                    label = "";
                if (keycode != KeyEvent.VK_BACK_SPACE) {
                    label = label + ch;
                    updateLabel(selected_obj, label, main_graph);
                }
                openLabelEditor((Node) selected_obj, main_graph.zoom);
                repaint();
            } else {
                if (keycode == KeyEvent.VK_DOWN || keycode == KeyEvent.VK_UP || keycode == KeyEvent.VK_LEFT || keycode == KeyEvent.VK_RIGHT) {
                    handleArrowKey(keycode, arg0, (Node) selected_obj, main_graph);
                }
            }
        } else if (selected_obj instanceof Link) {
            if (keycode == KeyEvent.VK_DELETE) {
                if (page.getConfirmation("Are you sure you want to delete the link?")) {
                    main_graph.removeLink((Link) selected_obj, recordchange);
                    selected_obj = null;
                    repaint();
                }
            } else if (ch != KeyEvent.CHAR_UNDEFINED) {
                String label = ((Link) selected_obj).getLabelAndEventType();
                if (label == null)
                    label = "";
                if (label.length() == 0)
                    ((Link) selected_obj).calcLinkLabelPosition();
                if (keycode != KeyEvent.VK_BACK_SPACE) {
                    label = label + ch;
                    updateLabel(selected_obj, label, main_graph);
                }
                openLabelEditor((Link) selected_obj, main_graph.zoom);
                repaint();
            } else {
                if (keycode == KeyEvent.VK_DOWN || keycode == KeyEvent.VK_UP || keycode == KeyEvent.VK_LEFT || keycode == KeyEvent.VK_RIGHT) {
                    if (at_anchor >= 0) {
                        Link link = (Link) selected_obj;
                        int x = link.getControlPointX(at_anchor);
                        int y = link.getControlPointY(at_anchor);
                        switch(keycode) {
                            case KeyEvent.VK_UP:
                                y--;
                                break;
                            case KeyEvent.VK_DOWN:
                                y++;
                                break;
                            case KeyEvent.VK_LEFT:
                                x--;
                                break;
                            case KeyEvent.VK_RIGHT:
                                x++;
                                break;
                        }
                        link.moveControlPoint(at_anchor, x, y, main_graph.arrowstyle);
                        arg0.consume();
                        repaint();
                    }
                }
            }
        } else if (selected_obj instanceof SubGraph) {
            if (keycode == KeyEvent.VK_DELETE) {
                if (page.getConfirmation("Are you sure you want to delete the embedded process?")) {
                    main_graph.removeSubGraph((SubGraph) selected_obj);
                    selected_obj = null;
                    repaint();
                }
            }
        } else if (selected_obj instanceof GraphFragment) {
            if (keycode == KeyEvent.VK_DELETE) {
                if (page.getConfirmation("Are you sure you want to delete the selected objects?")) {
                    GraphFragment frag = (GraphFragment) selected_obj;
                    for (Link l : frag.links) {
                        main_graph.removeLink(l, recordchange);
                    }
                    for (Node n : frag.nodes) {
                        main_graph.removeNode(n, recordchange);
                    }
                    for (SubGraph sg : frag.subgraphs) {
                        main_graph.removeSubGraph(sg);
                    }
                    selected_obj = null;
                    repaint();
                }
            }
        } else if (selected_obj instanceof TextNote) {
            if (keycode == KeyEvent.VK_DELETE) {
                if (page.getConfirmation("Are you sure you want to delete the selected note?")) {
                    main_graph.removeTextNote((TextNote) selected_obj);
                    selected_obj = null;
                    repaint();
                }
            }
        }
    }
}
Also used : Node(com.centurylink.mdw.designer.display.Node) GraphFragment(com.centurylink.mdw.designer.display.GraphFragment) TextNote(com.centurylink.mdw.designer.display.TextNote) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link)

Example 23 with SubGraph

use of com.centurylink.mdw.designer.display.SubGraph in project mdw-designer by CenturyLinkCloud.

the class CanvasCommon method paintDraggingAndSelection.

protected void paintDraggingAndSelection(Graphics g) {
    if (dragging && drag_to_create_link) {
        if (selected_obj instanceof Node) {
            g.setColor(Color.GREEN);
            g.drawLine(((Node) selected_obj).x + delta_x, ((Node) selected_obj).y + delta_y, drag_x, drag_y);
        }
    } else if (selected_obj != null) {
        if (selected_obj instanceof Node) {
            drawSelectionBox(g, (Node) selected_obj);
        } else if (selected_obj instanceof Link) {
            drawSelectionBox(g, (Link) selected_obj);
        } else if (selected_obj instanceof SubGraph) {
            drawSelectionBox(g, (SubGraph) selected_obj);
        } else if (selected_obj instanceof Graph) {
            drawSelectionBox(g, (Graph) selected_obj);
        } else if (selected_obj instanceof GraphFragment) {
            drawSelectionBox(g, (GraphFragment) selected_obj);
        } else if (selected_obj instanceof TextNote) {
            drawSelectionBox(g, (TextNote) selected_obj);
        }
    }
    if (useLabelEditor && selected_obj != null) /*&& at_anchor==-2 */
    {
        if (labelEditor.isVisible()) {
            Rectangle rect = labelEditor.getBounds();
            g.drawRect(rect.x - 1, rect.y - 1, rect.width + 2, rect.height + 2);
        } else {
            Label label;
            int lx, ly;
            if (selected_obj instanceof Node) {
            // label = ((Node)selected_obj).label;
            // lx = ((Node)selected_obj).lx;
            // ly = ((Node)selected_obj).ly;
            // g.drawRect(lx-1, ly-1, label.width+2, label.height+2);
            } else if (selected_obj instanceof Link) {
                label = ((Link) selected_obj).label;
                if (label != null) {
                    lx = ((Link) selected_obj).lx;
                    ly = ((Link) selected_obj).ly;
                    g.drawRect(lx - 1, ly - 1, label.width + 2, label.height + 2);
                }
            } else if (selected_obj instanceof TextNote) {
                JTextArea textarea = ((TextNote) selected_obj).textarea;
                lx = ((TextNote) selected_obj).x;
                ly = ((TextNote) selected_obj).y;
                g.drawRect(lx - 1, ly - 1, textarea.getWidth() + 2, textarea.getHeight() + 2);
            }
        // else GraphSegment
        }
    }
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) JTextArea(javax.swing.JTextArea) Node(com.centurylink.mdw.designer.display.Node) GraphFragment(com.centurylink.mdw.designer.display.GraphFragment) Rectangle(java.awt.Rectangle) Label(com.centurylink.mdw.designer.display.Label) TextNote(com.centurylink.mdw.designer.display.TextNote) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link)

Example 24 with SubGraph

use of com.centurylink.mdw.designer.display.SubGraph in project mdw-designer by CenturyLinkCloud.

the class CanvasCommon method performPaste.

private void performPaste(GraphFragment sourcefrag, Graph process, boolean recordchange) {
    if (sourcefrag.isEmpty())
        return;
    Rectangle visibleRect = this.getVisibleRect();
    Rectangle boundingRect = sourcefrag.getBoundary();
    process.save_temp_vars();
    GraphFragment targetfrag = new GraphFragment(process.getId());
    Map<Long, Long> nodeIdMap = new HashMap<Long, Long>();
    int xoff = 0, yoff = 0;
    if (visibleRect.intersects(boundingRect)) {
        if (sourcefrag.getSourceProcessId().equals(process.getId())) {
            xoff = 40;
            yoff = 40;
        } else {
            for (SubGraph subgraph : process.subgraphs) {
                if (sourcefrag.getSourceProcessId().equals(subgraph.getId())) {
                    xoff = 40;
                    yoff = 40;
                    break;
                }
            }
        }
    } else {
        xoff = visibleRect.x - boundingRect.x + 100;
        yoff = visibleRect.y - boundingRect.y + 100;
    }
    for (Node sourcenode : sourcefrag.nodes) {
        Node node = process.addNode(process, sourcenode.nodet, xoff, yoff, recordchange, true);
        targetfrag.nodes.add(node);
        nodeIdMap.put(sourcenode.getActivityId(), node.getActivityId());
        if (recordchange)
            node.getChanges().setChangeType(Changes.NEW);
    }
    for (Link sourcelink : sourcefrag.links) {
        Link link = process.addLink(process, sourcelink.conn, nodeIdMap.get(sourcelink.conn.getFromWorkId()), nodeIdMap.get(sourcelink.conn.getToWorkId()), xoff, yoff, recordchange, true);
        targetfrag.links.add(link);
        if (recordchange)
            link.getChanges().setChangeType(Changes.NEW);
    }
    for (SubGraph sourceSubgraph : sourcefrag.subgraphs) {
        // if (xoff>0) yoff = sourceSubgraph.h + 15;
        SubGraph subgraph = process.addSubGraph(sourceSubgraph.getProcessVO(), xoff, yoff, recordchange);
        if (subgraph != null) {
            targetfrag.subgraphs.add(subgraph);
            // TODO below only mark the entire subgraph as new
            if (recordchange)
                subgraph.getChanges().setChangeType(Changes.NEW);
        }
    }
    if (targetfrag.isNode())
        selected_obj = targetfrag.getOnlyNode();
    else if (targetfrag.isSubGraph())
        selected_obj = targetfrag.getOnlySubGraph();
    else
        selected_obj = targetfrag;
    repaint();
}
Also used : HashMap(java.util.HashMap) Node(com.centurylink.mdw.designer.display.Node) Rectangle(java.awt.Rectangle) GraphFragment(com.centurylink.mdw.designer.display.GraphFragment) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link)

Example 25 with SubGraph

use of com.centurylink.mdw.designer.display.SubGraph in project mdw-designer by CenturyLinkCloud.

the class GraphClipboard method put.

public void put(Object obj) {
    ProcessTransferVO transfer;
    GraphFragment fragment;
    if (obj instanceof Node) {
        fragment = new GraphFragment(((Node) obj).graph.getProcessVO().getProcessId());
        fragment.nodes.add((Node) obj);
    } else if (obj instanceof SubGraph) {
        fragment = new GraphFragment(((SubGraph) obj).getGraph().getId());
        fragment.subgraphs.add((SubGraph) obj);
    } else if (obj instanceof GraphFragment) {
        fragment = (GraphFragment) obj;
    } else
        return;
    transfer = new ProcessTransferVO(fragment);
    clipboard.setContents(transfer, this);
}
Also used : Node(com.centurylink.mdw.designer.display.Node) GraphFragment(com.centurylink.mdw.designer.display.GraphFragment) SubGraph(com.centurylink.mdw.designer.display.SubGraph)

Aggregations

SubGraph (com.centurylink.mdw.designer.display.SubGraph)25 Node (com.centurylink.mdw.designer.display.Node)17 Graph (com.centurylink.mdw.designer.display.Graph)14 Link (com.centurylink.mdw.designer.display.Link)13 GraphFragment (com.centurylink.mdw.designer.display.GraphFragment)8 TextNote (com.centurylink.mdw.designer.display.TextNote)8 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)4 Rectangle (java.awt.Rectangle)4 HashMap (java.util.HashMap)3 VariableVO (com.centurylink.mdw.model.value.variable.VariableVO)2 Paragraph (com.lowagie.text.Paragraph)2 Graphics2D (java.awt.Graphics2D)2 AuthenticationException (com.centurylink.mdw.auth.AuthenticationException)1 DataAccessException (com.centurylink.mdw.common.exception.DataAccessException)1 TranslationException (com.centurylink.mdw.common.exception.TranslationException)1 DataAccessOfflineException (com.centurylink.mdw.dataaccess.DataAccessOfflineException)1 DesignerDataAccess (com.centurylink.mdw.designer.DesignerDataAccess)1 GraphCommon (com.centurylink.mdw.designer.display.GraphCommon)1 Label (com.centurylink.mdw.designer.display.Label)1 ProcessInstanceLoader (com.centurylink.mdw.designer.runtime.ProcessInstanceLoader)1