Search in sources :

Example 1 with Node

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

the class CanvasCommon method getToolTipText.

public String getToolTipText(MouseEvent arg0, Graph main_graph) {
    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 = objectAt(main_graph, x, y, getGraphics());
    if (obj != null && obj instanceof Node) {
        Node node = (Node) obj;
        String tip = node.getDescription();
        if (tip != null) {
            if (tip.indexOf('\n') >= 0) {
                StringBuffer sb = new StringBuffer();
                int i, n = tip.length();
                char ch;
                sb.append("<html>");
                for (i = 0; i < n; i++) {
                    ch = tip.charAt(i);
                    if (ch == '\n')
                        sb.append("<br>");
                    else
                        sb.append(ch);
                }
                sb.append("</html>");
                return sb.toString();
            } else
                return tip;
        } else
            return null;
    } else
        return null;
}
Also used : Node(com.centurylink.mdw.designer.display.Node)

Example 2 with Node

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

the class CanvasCommon method objectAt.

public Object objectAt(Graph process, int x, int y, Graphics g) {
    Node node;
    Link link;
    if (selected_obj != null) {
        if (selected_obj instanceof Node) {
            node = (Node) selected_obj;
            if (onSelectableAnchor(x, y, node.x, node.y, node.w, node.h))
                return node;
            else if (node.labelOnPoint(g, x, y)) {
                at_anchor = -2;
                delta_x = x - node.x;
                delta_y = y - node.y;
                return node;
            }
        } else if (selected_obj instanceof Link) {
            link = (Link) selected_obj;
            int cx, cy, n = link.getNumberOfControlPoints();
            for (int i = 0; i < n; i++) {
                cx = link.getControlPointX(i);
                cy = link.getControlPointY(i);
                if (Math.abs(cx - x) <= 3 && Math.abs(cy - y) <= 3) {
                    at_anchor = i;
                    delta_x = x - cx;
                    delta_y = y - cy;
                    return link;
                }
            }
            if (link.labelOnPoint(g, x, y)) {
                at_anchor = -2;
                delta_x = x - link.lx;
                delta_y = y - link.ly;
                return link;
            }
        } else if (selected_obj instanceof SubGraph) {
            SubGraph subgraph = (SubGraph) selected_obj;
            if (subgraph.isSwimLane()) {
                if (onSelectableAnchor(x, y, subgraph.x, subgraph.y, SubGraph.SWIMLANE_LABEL_BAR_WIDTH, subgraph.h))
                    return subgraph;
            } else {
                if (onSelectableAnchor(x, y, subgraph.x, subgraph.y, subgraph.w, subgraph.h))
                    return subgraph;
            }
        } else if (selected_obj instanceof Graph) {
            if (onSelectableAnchor(x, y, process.lx, process.ly, process.lw, process.lh))
                return process;
        } else if (selected_obj instanceof TextNote) {
            TextNote note = (TextNote) selected_obj;
            if (onSelectableAnchor(x, y, note.x, note.y, note.w, note.h))
                return note;
        }
    }
    at_anchor = -1;
    Object obj = process.objectAt(x, y, g);
    if (obj != null) {
        if (obj instanceof Node) {
            delta_x = x - ((Node) obj).x;
            delta_y = y - ((Node) obj).y;
        } else if (obj instanceof SubGraph) {
            delta_x = x - ((SubGraph) obj).x;
            delta_y = y - ((SubGraph) obj).y;
        } else if (obj instanceof Graph) {
            delta_x = x - ((Graph) obj).lx;
            delta_y = y - ((Graph) obj).ly;
        } else if (obj instanceof TextNote) {
            delta_x = x - ((TextNote) obj).x;
            delta_y = y - ((TextNote) obj).y;
        }
        return obj;
    }
    return null;
}
Also used : Graph(com.centurylink.mdw.designer.display.Graph) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Node(com.centurylink.mdw.designer.display.Node) TextNote(com.centurylink.mdw.designer.display.TextNote) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link)

Example 3 with Node

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

the class CanvasCommon method mousePressed.

protected void mousePressed(MouseEvent arg0, Graph main_graph) {
    closeLabelEditor();
    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 = objectAt(main_graph, x, y, getGraphics());
    if (selected_obj != null && selected_obj instanceof GraphFragment && obj != null && ((GraphFragment) selected_obj).contains(obj)) {
        // dragging to move
        drag_x = x;
        drag_y = y;
    } else if (selected_obj != null && obj != null && obj instanceof Node && arg0.isControlDown()) {
        GraphFragment frag;
        if (selected_obj instanceof Node) {
            frag = new GraphFragment(main_graph.getId());
            frag.nodes.add((Node) selected_obj);
            selected_obj = frag;
        } else if (selected_obj instanceof SubGraph) {
            frag = new GraphFragment(main_graph.getId());
            frag.subgraphs.add((SubGraph) selected_obj);
            selected_obj = frag;
        } else if (selected_obj instanceof Link) {
            frag = new GraphFragment(main_graph.getId());
            frag.links.add((Link) selected_obj);
            selected_obj = frag;
        } else if (selected_obj instanceof GraphFragment) {
            frag = (GraphFragment) selected_obj;
        } else
            frag = null;
        if (frag != null)
            frag.nodes.add((Node) obj);
        repaint();
    } else if (obj != null) {
        selected_obj = obj;
        if (obj instanceof Node) {
            if (arg0.isShiftDown() && !main_graph.isReadonly()) {
                drag_to_create_link = true;
            }
        }
        // closeLabelEditor(true);
        repaint();
    } else if (selected_obj != null) {
        selected_obj = null;
        // closeLabelEditor(true);
        repaint();
        marquee = new Rectangle(arg0.getX(), arg0.getY(), 0, 0);
    } else {
        marquee = new Rectangle(arg0.getX(), arg0.getY(), 0, 0);
    }
    this.requestFocus();
}
Also used : Node(com.centurylink.mdw.designer.display.Node) GraphFragment(com.centurylink.mdw.designer.display.GraphFragment) Rectangle(java.awt.Rectangle) SubGraph(com.centurylink.mdw.designer.display.SubGraph) Link(com.centurylink.mdw.designer.display.Link)

Example 4 with Node

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

the class CanvasCommon method draw_subgraph.

private void draw_subgraph(Graphics g, Graph process, SubGraph subgraph, boolean drawStatus) {
    if (drawStatus && subgraph.getStatus() != null)
        drawNodeOrSubgraphStatus(subgraph.getStatus(), g, subgraph.x, subgraph.y, subgraph.w, subgraph.h, process.nodestyle.equals(Node.NODE_STYLE_ICON));
    if (subgraph.isNew())
        g.setColor(NEW_COLOR);
    else if (subgraph.isDeleted())
        g.setColor(Color.LIGHT_GRAY);
    else
        g.setColor(LIGHT_BLUE);
    g.drawRoundRect(subgraph.x, subgraph.y, subgraph.w, subgraph.h, 12, 12);
    // String subtype = subgraph.getAttribute(WorkAttributeConstant.EMBEDDED_PROCESS_TYPE);
    // if (subtype==null || subtype.equals(ProcessVisibilityConstant.EMBEDDED_ERROR_PROCESS))
    // g.setColor(Color..red);
    // else
    g.setColor(Color.BLACK);
    subgraph.lx = subgraph.x + 10;
    subgraph.ly = subgraph.y + 4;
    g.drawString(subgraph.getName(), subgraph.lx, subgraph.ly);
    if (Node.ID_DATABASE.equals(process.getNodeIdType())) {
        g.setColor(Color.GRAY);
        g.drawString("[" + subgraph.getProcessVO().getProcessId().toString() + "]", subgraph.x + 10, subgraph.y + subgraph.h + 4);
    } else if (Node.ID_LOGICAL.equals(process.getNodeIdType())) {
        g.setColor(Color.GRAY);
        g.drawString("[" + subgraph.getLogicalId() + "]", subgraph.x + 10, subgraph.y + subgraph.h + 4);
    } else if (Node.ID_REFERENCE.equals(process.getNodeIdType())) {
        g.setColor(Color.GRAY);
        g.drawString("[" + subgraph.getReferenceId() + "]", subgraph.x + 10, subgraph.y + subgraph.h + 4);
    } else if (Node.ID_SEQUENCE.equals(process.getNodeIdType())) {
        g.setColor(Color.GRAY);
        g.drawString("[" + String.valueOf(subgraph.getSequenceId()) + "]", subgraph.x + 10, subgraph.y + subgraph.h + 4);
    }
    for (Node node : subgraph.nodes) {
        drawNode(node, g, drawStatus, process.nodestyle);
    }
    if (drawStatus) {
        for (Link conn : subgraph.links) {
            if (!conn.isHidden() && conn.getColor() == Color.LIGHT_GRAY)
                drawConnector(g, process, conn);
        }
        for (Link conn : subgraph.links) {
            if (!conn.isHidden() && conn.getColor() != Color.LIGHT_GRAY)
                drawConnector(g, process, conn);
        }
    } else {
        for (Link link : subgraph.links) {
            if (!link.isHidden())
                this.drawConnector(g, process, link);
        }
    }
}
Also used : Node(com.centurylink.mdw.designer.display.Node) Link(com.centurylink.mdw.designer.display.Link)

Example 5 with Node

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

the class CanvasCommon method draw_graph.

protected void draw_graph(Graphics g, Graph process, boolean drawStatus) {
    if (g instanceof Graphics2D && normal_stroke == null) {
        normal_stroke = ((Graphics2D) g).getStroke();
        line_stroke = new BasicStroke(3.0f);
        float[] dash = { 10.0f, 10.0f };
        dash_stroke = new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 10.0f, dash, 0.0f);
        grid_stroke = new BasicStroke(0.2f);
    }
    if (editable) {
        Dimension canvas_size = this.getSize();
        g.setColor(Color.GRAY);
        ((Graphics2D) g).setStroke(grid_stroke);
        for (int x = grid_size; x < canvas_size.width; x += grid_size) {
            g.drawLine(x, 0, x, canvas_size.height);
        }
        for (int y = grid_size; y < canvas_size.height; y += grid_size) {
            g.drawLine(0, y, canvas_size.width, y);
        }
    }
    g.setFont(normal_font);
    if (drawStatus) {
        for (Link conn : process.links) {
            if (!conn.isHidden() && conn.getColor() == Color.LIGHT_GRAY)
                drawConnector(g, process, conn);
        }
        for (Link conn : process.links) {
            if (!conn.isHidden() && conn.getColor() != Color.LIGHT_GRAY)
                drawConnector(g, process, conn);
        }
    } else {
        for (Link conn : process.links) {
            if (!conn.isHidden())
                drawConnector(g, process, conn);
        }
    }
    drawMainProcess(g, process);
    for (Node node : process.nodes) {
        drawNode(node, g, drawStatus, process.nodestyle);
    }
    for (SubGraph subgraph : process.subgraphs) {
        draw_subgraph(g, process, subgraph, drawStatus);
    }
    if (process.notes != null) {
        for (TextNote note : process.notes) {
            draw_textnote(g, note);
        }
    }
}
Also used : BasicStroke(java.awt.BasicStroke) Node(com.centurylink.mdw.designer.display.Node) TextNote(com.centurylink.mdw.designer.display.TextNote) Dimension(java.awt.Dimension) 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