Search in sources :

Example 6 with Node

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

the class CanvasCommon method mouseDragged.

protected void mouseDragged(MouseEvent arg0, Graph main_graph) {
    int x = arg0.getX();
    int y = arg0.getY();
    if (selected_obj != null) {
        if (main_graph.zoom != 100) {
            x = x * 100 / main_graph.zoom;
            y = y * 100 / main_graph.zoom;
        }
        dragging = true;
        if (at_anchor >= 0) {
            if (selected_obj instanceof Node) {
                resizeNode(x, y, main_graph);
            } else if (selected_obj instanceof Link) {
                ((Link) selected_obj).moveControlPoint(at_anchor, x - delta_x, y - delta_y, main_graph.arrowstyle);
                if (!main_graph.isReadonly())
                    main_graph.setDirtyLevel(Graph.GEOCHANGE);
            } else if (selected_obj instanceof SubGraph) {
                resizeSubGraph(x, y);
            } else if (selected_obj instanceof TextNote) {
                resizeTextNote(x, y, main_graph);
            }
        } else {
            if (drag_to_create_link) {
                drag_x = x;
                drag_y = y;
            } else if (selected_obj instanceof Node) {
                moveNode(x, y);
            } else if (selected_obj instanceof Link && at_anchor == -2) {
                // move link label
                Link link = (Link) selected_obj;
                link.lx = x - delta_x;
                link.ly = y - delta_y;
            } else if (selected_obj instanceof SubGraph) {
                if (((SubGraph) selected_obj).isSwimLane())
                    moveSubgraph(0, y);
                else
                    moveSubgraph(x, y);
            } else if (selected_obj instanceof Graph) {
                moveGraphLabel(x, y);
            } else if (selected_obj instanceof GraphFragment) {
                ((GraphFragment) selected_obj).shift(main_graph, x - drag_x, y - drag_y, main_graph.arrowstyle);
                drag_x = x;
                drag_y = y;
                if (!main_graph.isReadonly())
                    main_graph.setDirtyLevel(Graph.GEOCHANGE);
            } else if (selected_obj instanceof TextNote) {
                moveTextNote(x, y);
            }
        }
        repaint();
    } else if (marquee != null) {
        if (x < 0)
            x = 0;
        else if (x > this.getWidth())
            x = this.getWidth();
        if (y < 0)
            y = 0;
        else if (y > this.getHeight())
            y = this.getHeight();
        drawRubberBand(marquee, x - marquee.x, y - marquee.y);
    }
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) 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 7 with Node

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

the class CanvasCommon method mouseReleased.

protected void mouseReleased(MouseEvent arg0, Graph main_graph, String curr_link_type, DesignerPage page, boolean recordchange) {
    // if (main_graph.isReadonly()) return;
    int x = arg0.getX();
    int y = arg0.getY();
    if (main_graph.zoom != 100) {
        x = x * 100 / main_graph.zoom;
        y = y * 100 / main_graph.zoom;
    }
    Object obj = main_graph.objectAt(x, y, getGraphics());
    if (arg0.getButton() != 1) {
        if (arg0.isPopupTrigger() && obj != null) {
            JPopupMenu popup;
            if (obj instanceof Node) {
                popup = this.popup_activity;
                selected_obj = obj;
            } else if (obj instanceof Link) {
                popup = this.popup_transition;
                selected_obj = obj;
            } else
                popup = null;
            if (popup != null) {
                popup.show(this, arg0.getX(), arg0.getY());
            }
        }
        return;
    }
    if (dragging) {
        if (drag_to_create_link) {
            Node startnode = (Node) selected_obj;
            Node endnode = (obj != null && (obj instanceof Node)) ? (Node) obj : null;
            if (endnode != null && endnode.graph.equals(startnode.graph)) {
                int ctrl_pts = 2;
                String linktype = curr_link_type;
                if (endnode == startnode) {
                    linktype = Link.CURVE;
                } else if (linktype.equals(Link.CURVE)) {
                    ctrl_pts = 4;
                }
                Link conn = main_graph.addLink(startnode, endnode, EventType.FINISH, linktype, ctrl_pts, recordchange);
                selected_obj = conn;
            } else
                selected_obj = null;
        } else if (selected_obj instanceof Link && at_anchor >= 0) {
            Link link = (Link) selected_obj;
            Node node = (obj != null && (obj instanceof Node)) ? (Node) obj : null;
            if (link.to == link.from) {
                // a link to the node itself
                if (at_anchor == 0 && (node == null || node != link.from)) {
                    // move back to the node
                    moveBackFrom(link, main_graph.arrowstyle);
                }
            } else if (at_anchor == 0) {
                if (node == null || node == link.to) {
                    // move back to the node
                    moveBackFrom(link, main_graph.arrowstyle);
                } else if (node != link.from && node.graph.equals(link.from.graph)) {
                    // change 'from'
                    link.setFrom(node);
                }
            // else do nothing
            } else if (at_anchor == link.getNumberOfControlPoints() - 1) {
                if (node == null || node == link.from) {
                    // move back to the node
                    moveBackTo(link, main_graph.arrowstyle);
                } else if (node != link.to && node.graph.equals(link.to.graph)) {
                    // change 'to'
                    link.setTo(node);
                }
            // else do nothing
            } else {
                // a middle link
                if (link.isElbowType()) {
                    if (at_anchor == 1) {
                        moveBackFrom(link, main_graph.arrowstyle);
                    }
                    if (at_anchor == link.getNumberOfControlPoints() - 2) {
                        moveBackTo(link, main_graph.arrowstyle);
                    }
                }
            }
        } else if (selected_obj instanceof SubGraph) {
            mouseReleased_subgraph();
        } else if (selected_obj instanceof Node && at_anchor < 0) {
            // move node
            checkIfMoveIntoSubprocess((Node) selected_obj, x, y, page, recordchange);
        }
        repaint();
        dragging = false;
    // } else if (useLabelEditor && editing_obj!=null) {
    // labelEditor.setZoom(main_graph.zoom);
    // labelEditor.setVisible(true);
    // repaint();  // TODO do we need this?
    } else if (useLabelEditor && obj != null && at_anchor == -2) {
        if (obj instanceof Node) {
            if (!main_graph.isReadonly()) {
                openLabelEditor((Node) obj, main_graph.zoom);
            }
        } else if (obj instanceof Link) {
            if (!main_graph.isReadonly()) {
                openLabelEditor((Link) obj, main_graph.zoom);
            }
        }
    // else not possible (TextNote never has at_anchor==-2)
    } else if (useLabelEditor && obj instanceof TextNote || !useLabelEditor && textEditor != null) {
        if (!main_graph.isReadonly()) {
            openLabelEditor((TextNote) obj, main_graph.zoom);
        }
    } else if (marquee != null) {
        GraphFragment frag = new GraphFragment(main_graph, marquee);
        if (!frag.isEmpty()) {
            if (frag.isNode())
                selected_obj = frag.getOnlyNode();
            else if (frag.isSubGraph())
                selected_obj = frag.getOnlySubGraph();
            else
                selected_obj = frag;
        }
        marquee = null;
        repaint();
    }
    drag_to_create_link = false;
}
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) JPopupMenu(javax.swing.JPopupMenu) Link(com.centurylink.mdw.designer.display.Link)

Example 8 with Node

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

the class ExportHelper method printOneProcessPdf.

private Chapter printOneProcessPdf(DocWriter writer, DesignerCanvas canvas, String type, int chapterNumber, Graph process, String filename, Rectangle page_size) throws Exception {
    Paragraph cTitle = new Paragraph("Workflow Process: \"" + process.getName() + "\"", chapterFont);
    Chapter chapter = new Chapter(cTitle, chapterNumber);
    // print image
    printGraphPdf(writer, canvas, process, page_size, type, filename, chapter, chapterNumber);
    // print documentation text
    printGraphPdf(process, chapter);
    for (Node node : process.getNodes(nodeIdType)) {
        printNodePdf(node, chapter);
    }
    for (SubGraph subgraph : process.getSubgraphs(nodeIdType)) {
        printGraphPdf(subgraph, chapter);
        for (Node node : subgraph.getNodes(nodeIdType)) {
            printNodePdf(node, chapter);
        }
    }
    if (options.contains(VARIABLES)) {
        printVariablesPdf(chapter, process.getProcessVO().getVariables(), options.contains(SECTION_NUMBER) ? 1 : 0);
    }
    return chapter;
}
Also used : Node(com.centurylink.mdw.designer.display.Node) Chapter(com.lowagie.text.Chapter) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Paragraph(com.lowagie.text.Paragraph)

Example 9 with Node

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

the class FlowchartPage method actionPerformed.

public void actionPerformed(ActionEvent event) {
    String cmd = event.getActionCommand();
    if (cmd.equals(Constants.ACTION_DELETE)) {
        if (process.isReadonly()) {
            return;
        }
        if (canvas.getSelectedObject() != null) {
            if (canvas.getSelectedObject() instanceof Node) {
                if (getConfirmation("Are you sure you want to delete the node?")) {
                    process.removeNode((Node) canvas.getSelectedObject(), this.recordchange);
                }
            } else if (canvas.getSelectedObject() instanceof Link) {
                if (getConfirmation("Are you sure you want to delete the link?")) {
                    process.removeLink((Link) canvas.getSelectedObject(), this.recordchange);
                }
            } else if (canvas.getSelectedObject() instanceof SubGraph) {
                if (getConfirmation("Are you sure you want to delete the handler?")) {
                    process.removeSubGraph((SubGraph) canvas.getSelectedObject());
                }
            } else if (canvas.getSelectedObject() instanceof GraphFragment) {
                if (getConfirmation("Are you sure you want to delete the selected objects?")) {
                    GraphFragment frag = (GraphFragment) canvas.getSelectedObject();
                    for (Link l : frag.links) {
                        process.removeLink(l, recordchange);
                    }
                    for (Node n : frag.nodes) {
                        process.removeNode(n, recordchange);
                    }
                    for (SubGraph sg : frag.subgraphs) {
                        // TODO record changes
                        process.removeSubGraph(sg);
                    }
                }
            } else if (canvas.getSelectedObject() instanceof TextNote) {
                if (getConfirmation("Are you sure you want to delete the note?")) {
                    process.removeTextNote((TextNote) canvas.getSelectedObject());
                }
            }
            canvas.setSelectedObject(null);
            canvas.repaint();
        }
    } else if (cmd.equals(Constants.ACTION_TIPMODE)) {
        JCheckBox tipMode = (JCheckBox) event.getSource();
        showtip = tipMode.isSelected();
    } else if (cmd.equals(ACTION_RECORD_CHANGES)) {
        JCheckBox checkbox = (JCheckBox) event.getSource();
        recordchange = checkbox.isSelected();
    } else if (cmd.equals(ACTION_SHOW_ID)) {
        if (process != null) {
            JComboBox showId = (JComboBox) event.getSource();
            process.setNodeIdType((String) showId.getSelectedItem());
            canvas.repaint();
        }
    // else during init
    } else if (cmd.equals(Constants.ACTION_START)) {
        showStartProcessDialog(null);
    } else if (cmd.equals(ACTION_RUN_ACTIVITY)) {
        if (model.canExecuteProcess(process.getProcessVO())) {
            Node node = (Node) canvas.getSelectedObject();
            showStartProcessDialog(node);
        } else
            this.showError("You are not authorized to run processes");
    } else if (cmd.equals(ACTION_ARROWTYPE)) {
        JComboBox arrowType = (JComboBox) event.getSource();
        ImageIcon arrowTypeIcon = (ImageIcon) arrowType.getSelectedItem();
        setArrowStyle(arrowTypeIcon.getDescription());
    } else if (cmd.equals(ACTION_NODETYPE)) {
        JComboBox nodeType = (JComboBox) event.getSource();
        ImageIcon nodeTypeIcon = (ImageIcon) nodeType.getSelectedItem();
        setNodeStyle(nodeTypeIcon.getDescription());
    } else if (cmd.equals(ACTION_ZOOM)) {
        int zoomLevel = Graph.zoomLevels[zoomWidget.getSelectedIndex()];
        canvas.zoom(process, zoomLevel);
    } else if (cmd.equals(ACTION_ALL_LINK_STYLE_CHANGE)) {
        process.changeAllLinkStyle(this.linktype);
        canvas.repaint();
    } else if (cmd.equals(ACTION_COMMIT_CHANGES)) {
        if (process.isReadonly()) {
            return;
        }
        if (getConfirmation("This will commit recorded changes. Proceed?")) {
            process.commitChanges();
            canvas.repaint();
        }
    } else if (cmd.equals(ACTION_MARK_AS_NEW)) {
        markChangeType(Changes.NEW);
    } else if (cmd.equals(ACTION_MARK_AS_DELETED)) {
        markChangeType(Changes.DELETE);
    } else if (cmd.equals(ACTION_MARK_AS_NOCHANGE)) {
        markChangeType(Changes.NONE);
    } else if (cmd.equals(ACTION_LINEUP_HORIZONTAL)) {
        lineUpActivities(false);
    } else if (cmd.equals(ACTION_LINEUP_VERTICAL)) {
        lineUpActivities(true);
    } else if (cmd.equals(ACTION_ADD_NOTE)) {
        if (process.isReadonly()) {
            return;
        }
        addNote();
    } else {
        super.actionPerformed(event);
    }
}
Also used : JCheckBox(javax.swing.JCheckBox) ImageIcon(javax.swing.ImageIcon) JComboBox(javax.swing.JComboBox) 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) Point(java.awt.Point)

Example 10 with Node

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

the class RunTimeDesignerCanvas method paintComponent.

/*
     * (non-Javadoc)
     *
     * @see javax.swing.JComponent#paintComponent(java.awt.Graphics)
     */
public void paintComponent(Graphics g) {
    super.paintComponent(g);
    Graph process = page.getProcess();
    if (process != null) {
        if (g instanceof Graphics2D) {
            Graphics2D g2d = (Graphics2D) g;
            g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
            g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
            if (process.zoom != 100) {
                double scale = process.zoom / 100.0;
                g2d.scale(scale, scale);
            }
        }
        draw_graph(g, process, true);
        if (page.frame != null && !page.frame.isVisible() && 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);
            }
        }
    }
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Node(com.centurylink.mdw.designer.display.Node) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link) Graphics2D(java.awt.Graphics2D)

Aggregations

Node (com.centurylink.mdw.designer.display.Node)27 SubGraph (com.centurylink.mdw.designer.display.SubGraph)18 Link (com.centurylink.mdw.designer.display.Link)14 GraphFragment (com.centurylink.mdw.designer.display.GraphFragment)10 Graph (com.centurylink.mdw.designer.display.Graph)9 TextNote (com.centurylink.mdw.designer.display.TextNote)8 Rectangle (java.awt.Rectangle)5 ProcessInstanceVO (com.centurylink.mdw.model.value.process.ProcessInstanceVO)3 ActivityInstanceVO (com.centurylink.mdw.model.value.work.ActivityInstanceVO)3 Activity (com.centurylink.mdw.plugin.designer.model.Activity)2 ActivityImpl (com.centurylink.mdw.plugin.designer.model.ActivityImpl)2 Graphics2D (java.awt.Graphics2D)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)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