Package org.aperteworkflow.bpm.graph

Examples of org.aperteworkflow.bpm.graph.TransitionArc


            Collection<GraphElement> pge = processGraphElements.values() ;
           
           
            for (GraphElement ge : pge) { 
                if( ge instanceof TransitionArc){
                  TransitionArc ta = (TransitionArc)ge;
                    transitionaArcsList.add(ta);
                 
              }
            }
           
       
           
            ArrayList<GraphElement> res = new ArrayList<GraphElement>();
            for (HistoryActivityInstance hpi : list) {
                loger.fine("Handling: " + hpi.getActivityName());
                if (hpi instanceof HistoryActivityInstanceImpl) {
                    HistoryActivityInstanceImpl activity = (HistoryActivityInstanceImpl) hpi;
                    String activityName = activity.getActivityName();
                    if (res.isEmpty()) { //initialize start node and its transition
                        GraphElement startNode = processGraphElements.get("__AWF__start_node");
                        if (startNode != null) {
                            res.add(startNode);
                        }
                        GraphElement firstTransition = processGraphElements.get("__AWF__start_transition_to_" + activityName);
                        if (firstTransition != null) {
                            res.add(firstTransition);
                        }
                    }
                  
                    StateNode sn = (StateNode) processGraphElements.get(activityName);
                   
                  
                   
                    ArrayList<StateNode> arrayList = new ArrayList<StateNode>();
                    Collection<GraphElement> values = processGraphElements.values();
                    for (GraphElement graphElement : values) {
            if(graphElement instanceof StateNode){
              arrayList.add((StateNode) graphElement);
            }
                     
                     
          }
                    if (sn == null) continue;
                    sn = sn.cloneNode();
                    sn.setUnfinished(activity.getEndTime() == null);
                    sn.setLabel(activityName + ": " + hpi.getDuration() + "ms");
                    res.add(sn);
                    //look for transition
                    TransitionArc ta = (TransitionArc) processGraphElements.get(activityName + "_" + activity.getTransitionName());
                    if (ta == null) { //look for default!
                        ta = (TransitionArc) processGraphElements.get("__AWF__default_transition_" + activityName);
                    }
                    if (ta == null) {
                        continue;
                    }
                   
           
                   
                 
                   
                    res.add(ta.cloneNode());
                } else {
                    loger.severe("Unsupported entry: " + hpi);
                }
            }
           
View Full Code Here


                                    int startY = startNode.getY() + startNode.getHeight()/2;
                                    //and the same for end node
                                    int endX   = endNode.getX() + endNode.getWidth()/2;
                                    int endY   = endNode.getY() + endNode.getHeight()/2;

                                    TransitionArc arc = new TransitionArc();
                                    arc.setName(name);
                                    arc.addPoint(startX, startY);
                                    for (String docker : dockers) {
                                        String[] split = docker.split(",",2);
                                        arc.addPoint(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
                                    }
                                    arc.addPoint(endX, endY);

                                    double a;//remember about vertical line
                                    double b;

                                    endX = arc.getPath().get(1).getX();
                                    endY = arc.getPath().get(1).getY();
                                    if (startX - endX == 0) { //whoa - vertical line - simple case, but requires special approach
                                        if (endY > startNode.getY()+startNode.getHeight()) { //below
                                            startY = startNode.getY()+startNode.getHeight();
                                        } else {
                                            startY = startNode.getY();
                                        }
                                    } else {
                                        a = ((double)(startY-endY))/((double)(startX - endX));
                                        b = (double)startY - (double)startX*a;
                                        for (int x = startX; x <= endX; x++) {
                                            int y = (int) Math.round(a*x+b);
                                            boolean inside = false;
                                            if (x >= startNode.getX() && x <= startNode.getX() + startNode.getWidth()) {
                                                if (y >= startNode.getY() && y <= startNode.getY() + startNode.getHeight()) {
                                                    inside = true;
                                                }
                                            }
                                            if (!inside) {
                                                startX = x;
                                                startY = y;
                                                break;
                                            }
                                        }
                                        for (int x = startX; x > endX; x--) {
                                            int y = (int) Math.round(a*x+b);
                                            boolean inside = false;
                                            if (x >= startNode.getX() && x <= startNode.getX() + startNode.getWidth()) {
                                                if (y >= startNode.getY() && y <= startNode.getY() + startNode.getHeight()) {
                                                    inside = true;
                                                }
                                            }
                                            if (!inside) {
                                                startX = x;
                                                startY = y;
                                                break;
                                            }
                                        }
                                    }
                                    arc.getPath().get(0).setX(startX);
                                    arc.getPath().get(0).setY(startY);

                                    endX = arc.getPath().get(arc.getPath().size()-1).getX();
                                    endY = arc.getPath().get(arc.getPath().size()-1).getY();
                                    startX = arc.getPath().get(arc.getPath().size()-2).getX();
                                    startY = arc.getPath().get(arc.getPath().size()-2).getY();
                                    if (startX - endX == 0) { //whoa - vertical line - simple case, but requires special approach
                                       if (startY > endNode.getY()+endNode.getHeight()) { //below
                                           endY = endNode.getY()+endNode.getHeight();
                                       } else {
                                           endY = endNode.getY();
                                       }
                                    } else {
                                        a = ((double)(startY-endY))/((double)(startX - endX));//remember about vertical line
                                        //startY = startX*a+b
                                        b = (double)startY - (double)startX*a;
                                        for (int x = endX; x <= startX; x++) {
                                            int y = (int) Math.round(a*x+b);
                                            boolean inside = false;
                                            if (x >= endNode.getX() && x <= endNode.getX() + endNode.getWidth()) {
                                                if (y >= endNode.getY() && y <= endNode.getY() + endNode.getHeight()) {
                                                    inside = true;
                                                }
                                            }
                                            if (!inside) {
                                                endX = x;
                                                endY = y;
                                                break;
                                            }
                                        }
                                        for (int x = endX; x > startX; x--) {
                                            int y = (int) Math.round(a*x+b);
                                            boolean inside = false;
                                            if (x >= endNode.getX() && x <= endNode.getX() + endNode.getWidth()) {
                                                if (y >= endNode.getY() && y <= endNode.getY() + endNode.getHeight()) {
                                                    inside = true;
                                                }
                                            }
                                            if (!inside) {
                                                endX = x;
                                                endY = y;
                                                break;
                                            }
                                        }
                                    }
                                    arc.getPath().get(arc.getPath().size()-1).setX(endX);
                                    arc.getPath().get(arc.getPath().size()-1).setY(endY);
                                    arc.setDestination(to);
                                    arc.setSource(startNodeName);

                                    res.put(startNodeName + "_" + name,arc);
                                    if ("start".equals(nodeType)) {
                                        res.put("__AWF__start_transition_to_" + to, arc);
                                    }
View Full Code Here

                                                                    sn.getX(),
                                                                    sn.getY(),
                                                                    sn.getHeight(),
                                                                    sn.getWidth()));
                                            } else if (el instanceof TransitionArc) {
                                                TransitionArc ta = (TransitionArc) el;
                                                TransitionArcPoint prevPoint = null;
                                                for (TransitionArcPoint p : ta.getPath()) {
                                                    if (prevPoint != null) {
                                                        svg.append(String.format("<line x1=\"%d\" y1=\"%d\" x2=\"%d\" y2=\"%d\"\n" +
                                                                "  style=\"" + strokeStyle + "\"/>\n",
                                                                prevPoint.getX(),
                                                                prevPoint.getY(),
View Full Code Here

        HistoricActivityInstance prev = null;
        for (HistoricActivityInstance activity : list) {
            LOGGER.fine("Handling: " + activity.getActivityName());
            String activityName = activity.getActivityName();
            if (prev != null) {
                TransitionArc ta = (TransitionArc) processGraphElements.get("__AWF__" + prev.getActivityName() + "_" + activityName);
                if (ta == null) { //look for default!
                    ta = (TransitionArc) processGraphElements.get("__AWF__default_transition_" + prev.getActivityName());
                }
                if (ta != null) {
                    res.add(ta.cloneNode());

                }
            }
            prev = activity;

            //activiti notes first event quite well
//            if (res.isEmpty()) { //initialize start node and its transition
//                GraphElement startNode = processGraphElements.get("__AWF__start_node");
//                if (startNode != null) {
//                    res.add(startNode);
//                }
//                GraphElement firstTransition = processGraphElements.get("__AWF__start_transition_to_" + activityName);
//                if (firstTransition != null) {
//                    res.add(firstTransition);
//                }
//            }
            StateNode sn = (StateNode) processGraphElements.get(activityName);
            if (sn == null) continue;
            sn = sn.cloneNode();
            sn.setUnfinished(activity.getEndTime() == null);
//            sn.setLabel(activityName + ": " + activity.getDurationInMillis() + "ms");
            res.add(sn);
            //look for transition
        }

        HistoricProcessInstanceQuery historyProcessInstanceQuery = getProcessEngine().getHistoryService()
                .createHistoricProcessInstanceQuery().processInstanceId(pi.getInternalId());
        HistoricProcessInstance historyProcessInstance = historyProcessInstanceQuery.singleResult();
        if (historyProcessInstance != null && historyProcessInstance.getEndActivityId() != null) {
            StateNode sn = (StateNode) processGraphElements.get(historyProcessInstance.getEndActivityId());
            if (sn != null) {
                if (prev != null) {
                    TransitionArc ta = (TransitionArc) processGraphElements.get("__AWF__" + prev.getActivityName() + "_" + sn.getLabel());
                    if (ta == null) { //look for default!
                        ta = (TransitionArc) processGraphElements.get("__AWF__default_transition_" + prev.getActivityName());
                    }
                    if (ta != null) {
                        res.add(ta.cloneNode());

                    }
                }
                StateNode e = sn.cloneNode();
                e.setUnfinished(true);
View Full Code Here

      private void fillListWithAllPosibleTransitionArc(
          GraphElement originalGraphElement,
          List<TransitionArc> transitionArcList) {

        if (originalGraphElement instanceof TransitionArc) {
          TransitionArc transitionArc = (TransitionArc) originalGraphElement;
          transitionArcList.add(transitionArc);
        }

      }
View Full Code Here

            for (String nodeType : nodeTypes) {
                NodeList nodes = processElement.getElementsByTagName(nodeType);
                for (int i = 0; i < nodes.getLength(); i++) {
                    Element node = (Element) nodes.item(i);
                    try {
                        TransitionArc arc = arcById.get(node.getAttribute("id"));
                        if (arc == null) {
                            continue;
                        }
                        String name = node.getAttribute("name");
                        arc.setName(name);
                        res.put(name, arc);
                        StateNode startNode = nodeById.get(node.getAttribute("sourceRef"));
                        StateNode endNode = nodeById.get(node.getAttribute("targetRef"));
                        if (startNode == null || endNode == null) {
                            continue;
                        }
                                                        //calculate line start node which is a center of the start node
                        int startX = startNode.getX() + startNode.getWidth()/2;
                        int startY = startNode.getY() + startNode.getHeight()/2;
                        //and the same for end node
                        int endX   = endNode.getX() + endNode.getWidth()/2;
                        int endY   = endNode.getY() + endNode.getHeight()/2;

                        arc.getPath().add(0, new TransitionArcPoint(startX, startY));
                        arc.addPoint(endX, endY);

                        double a;//remember about vertical line
                        double b;

                        endX = arc.getPath().get(1).getX();
                        endY = arc.getPath().get(1).getY();
                        if (startX - endX == 0) { //whoa - vertical line - simple case, but requires special approach
                            if (endY > startNode.getY()+startNode.getHeight()) { //below
                                startY = startNode.getY()+startNode.getHeight();
                            } else {
                                startY = startNode.getY();
                            }
                        } else {
                            a = ((double)(startY-endY))/((double)(startX - endX));
                            b = (double)startY - (double)startX*a;
                            for (int x = startX; x <= endX; x++) {
                                int y = (int) Math.round(a*x+b);
                                boolean inside = false;
                                if (x >= startNode.getX() && x <= startNode.getX() + startNode.getWidth()) {
                                    if (y >= startNode.getY() && y <= startNode.getY() + startNode.getHeight()) {
                                        inside = true;
                                    }
                                }
                                if (!inside) {
                                    startX = x;
                                    startY = y;
                                    break;
                                }
                            }
                            for (int x = startX; x > endX; x--) {
                                int y = (int) Math.round(a*x+b);
                                boolean inside = false;
                                if (x >= startNode.getX() && x <= startNode.getX() + startNode.getWidth()) {
                                    if (y >= startNode.getY() && y <= startNode.getY() + startNode.getHeight()) {
                                        inside = true;
                                    }
                                }
                                if (!inside) {
                                    startX = x;
                                    startY = y;
                                    break;
                                }
                            }
                        }
                        arc.getPath().get(0).setX(startX);
                        arc.getPath().get(0).setY(startY);

                        endX = arc.getPath().get(arc.getPath().size()-1).getX();
                        endY = arc.getPath().get(arc.getPath().size()-1).getY();
                        startX = arc.getPath().get(arc.getPath().size()-2).getX();
                        startY = arc.getPath().get(arc.getPath().size()-2).getY();
                        if (startX - endX == 0) { //whoa - vertical line - simple case, but requires special approach
                           if (startY > endNode.getY()+endNode.getHeight()) { //below
                               endY = endNode.getY()+endNode.getHeight();
                           } else {
                               endY = endNode.getY();
                           }
                        } else {
                            a = ((double)(startY-endY))/((double)(startX - endX));//remember about vertical line
                            //startY = startX*a+b
                            b = (double)startY - (double)startX*a;
                            for (int x = endX; x <= startX; x++) {
                                int y = (int) Math.round(a*x+b);
                                boolean inside = false;
                                if (x >= endNode.getX() && x <= endNode.getX() + endNode.getWidth()) {
                                    if (y >= endNode.getY() && y <= endNode.getY() + endNode.getHeight()) {
                                        inside = true;
                                    }
                                }
                                if (!inside) {
                                    endX = x;
                                    endY = y;
                                    break;
                                }
                            }
                            for (int x = endX; x > startX; x--) {
                                int y = (int) Math.round(a*x+b);
                                boolean inside = false;
                                if (x >= endNode.getX() && x <= endNode.getX() + endNode.getWidth()) {
                                    if (y >= endNode.getY() && y <= endNode.getY() + endNode.getHeight()) {
                                        inside = true;
                                    }
                                }
                                if (!inside) {
                                    endX = x;
                                    endY = y;
                                    break;
                                }
                            }
                        }
                        arc.getPath().get(arc.getPath().size()-1).setX(endX);
                        arc.getPath().get(arc.getPath().size()-1).setY(endY);

                        res.put("__AWF__" + startNode.getLabel() + "_" + endNode.getLabel(),
                                arc);
                        res.put("__AWF__default_transition_" + startNode.getLabel(),
                                arc);
View Full Code Here

                    <omgdi:waypoint x="552.0" y="198.0"/>
                    <omgdi:waypoint x="552.3181702913334" y="60.0"/>
                    <omgdi:waypoint x="274.0" y="60.0"/>
                 </bpmndi:BPMNEdge>
                 */
                TransitionArc ta = new TransitionArc();
                ta.setId(node.getAttribute("bpmnElement"));
                NodeList waypointList = node.getElementsByTagNameNS("http://www.omg.org/spec/DD/20100524/DI", "waypoint");
                if (waypointList.getLength() == 0) {
                    continue;
                }
                for (int j = 1; j < waypointList.getLength()-1; j++) {//skip first and last docker - we have to calculate them manually
                    Element waypointEl = (Element) waypointList.item(j);
                    ta.addPoint(new Double(waypointEl.getAttribute("x")).intValue(),
                            new Double(waypointEl.getAttribute("y")).intValue());
                }
                arcById.put(ta.getId(), ta);
                LOGGER.fine("Found arc" + ta);
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
            }
        }
View Full Code Here

TOP

Related Classes of org.aperteworkflow.bpm.graph.TransitionArc

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.