Package org.activiti.bpmn.model

Examples of org.activiti.bpmn.model.GraphicInfo


   * @param targetElement
   * @param graphicInfoList
   * @return
   */
  protected static List<GraphicInfo> connectionPerfectionizer(DefaultProcessDiagramCanvas processDiagramCanvas, BpmnModel bpmnModel, BaseElement sourceElement, BaseElement targetElement, List<GraphicInfo> graphicInfoList) {
    GraphicInfo sourceGraphicInfo = bpmnModel.getGraphicInfo(sourceElement.getId());
    GraphicInfo targetGraphicInfo = bpmnModel.getGraphicInfo(targetElement.getId());
   
    DefaultProcessDiagramCanvas.SHAPE_TYPE sourceShapeType = getShapeType(sourceElement);
    DefaultProcessDiagramCanvas.SHAPE_TYPE targetShapeType = getShapeType(targetElement);
   
    return processDiagramCanvas.connectionPerfectionizer(sourceShapeType, targetShapeType, sourceGraphicInfo, targetGraphicInfo, graphicInfoList);
View Full Code Here


    }
    return null;
  }
 
  protected static GraphicInfo getLineCenter(List<GraphicInfo> graphicInfoList) {
    GraphicInfo gi = new GraphicInfo();
   
    int xPoints[]= new int[graphicInfoList.size()];
    int yPoints[]= new int[graphicInfoList.size()];
   
    double length = 0;
    double[] lengths = new double[graphicInfoList.size()];
    lengths[0] = 0;
    double m;
    for (int i=1; i<graphicInfoList.size(); i++) {
        GraphicInfo graphicInfo = graphicInfoList.get(i);
        GraphicInfo previousGraphicInfo = graphicInfoList.get(i-1);
       
        if (i == 1) {
          xPoints[0] = (int) previousGraphicInfo.getX();
          yPoints[0] = (int) previousGraphicInfo.getY();
        }
        xPoints[i] = (int) graphicInfo.getX();
        yPoints[i] = (int) graphicInfo.getY();
       
        length += Math.sqrt(
                Math.pow((int) graphicInfo.getX() - (int) previousGraphicInfo.getX(), 2) +
                Math.pow((int) graphicInfo.getY() - (int) previousGraphicInfo.getY(), 2)
              );
        lengths[i] = length;
      }
      m = length / 2;
      int p1 = 0, p2 = 1;
      for (int i = 1; i < lengths.length; i++) {
      double len = lengths[i];
      p1 = i-1;
      p2 = i;
      if (len > m) {
        break;
      }
    }
     
      GraphicInfo graphicInfo1 = graphicInfoList.get(p1);
      GraphicInfo graphicInfo2 = graphicInfoList.get(p2);
     
      double AB = (int)graphicInfo2.getX() - (int)graphicInfo1.getX();
      double OA = (int)graphicInfo2.getY() - (int)graphicInfo1.getY();
      double OB = lengths[p2] - lengths[p1];
      double ob =  m - lengths[p1];
      double ab =  AB * ob / OB;
      double oa =  OA * ob / OB;
     
View Full Code Here

    double maxX = 0;
    double minY = Double.MAX_VALUE;
    double maxY = 0;

    for (Pool pool : bpmnModel.getPools()) {
      GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(pool.getId());
      minX = graphicInfo.getX();
      maxX = graphicInfo.getX() + graphicInfo.getWidth();
      minY = graphicInfo.getY();
      maxY = graphicInfo.getY() + graphicInfo.getHeight();
    }
   
    List<FlowNode> flowNodes = gatherAllFlowNodes(bpmnModel);
    for (FlowNode flowNode : flowNodes) {

      GraphicInfo flowNodeGraphicInfo = bpmnModel.getGraphicInfo(flowNode.getId());
     
      // width
      if (flowNodeGraphicInfo.getX() + flowNodeGraphicInfo.getWidth() > maxX) {
        maxX = flowNodeGraphicInfo.getX() + flowNodeGraphicInfo.getWidth();
      }
      if (flowNodeGraphicInfo.getX() < minX) {
        minX = flowNodeGraphicInfo.getX();
      }
      // height
      if (flowNodeGraphicInfo.getY() + flowNodeGraphicInfo.getHeight() > maxY) {
        maxY = flowNodeGraphicInfo.getY() + flowNodeGraphicInfo.getHeight();
      }
      if (flowNodeGraphicInfo.getY() < minY) {
        minY = flowNodeGraphicInfo.getY();
      }

      for (SequenceFlow sequenceFlow : flowNode.getOutgoingFlows()) {
        List<GraphicInfo> graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(sequenceFlow.getId());
        if (graphicInfoList != null) {
          for (GraphicInfo graphicInfo : graphicInfoList) {
            // width
            if (graphicInfo.getX() > maxX) {
              maxX = graphicInfo.getX();
            }
            if (graphicInfo.getX() < minX) {
              minX = graphicInfo.getX();
            }
            // height
            if (graphicInfo.getY() > maxY) {
              maxY = graphicInfo.getY();
            }
            if (graphicInfo.getY()< minY) {
              minY = graphicInfo.getY();
            }
          }
        }
      }
    }
   
    List<Artifact> artifacts = gatherAllArtifacts(bpmnModel);
    for (Artifact artifact : artifacts) {

      GraphicInfo artifactGraphicInfo = bpmnModel.getGraphicInfo(artifact.getId());
     
      if (artifactGraphicInfo != null) {
        // width
        if (artifactGraphicInfo.getX() + artifactGraphicInfo.getWidth() > maxX) {
          maxX = artifactGraphicInfo.getX() + artifactGraphicInfo.getWidth();
        }
        if (artifactGraphicInfo.getX() < minX) {
          minX = artifactGraphicInfo.getX();
        }
        // height
        if (artifactGraphicInfo.getY() + artifactGraphicInfo.getHeight() > maxY) {
          maxY = artifactGraphicInfo.getY() + artifactGraphicInfo.getHeight();
        }
        if (artifactGraphicInfo.getY() < minY) {
          minY = artifactGraphicInfo.getY();
        }
      }

      List<GraphicInfo> graphicInfoList = bpmnModel.getFlowLocationGraphicInfo(artifact.getId());
      if (graphicInfoList != null) {
        for (GraphicInfo graphicInfo : graphicInfoList) {
            // width
            if (graphicInfo.getX() > maxX) {
              maxX = graphicInfo.getX();
            }
            if (graphicInfo.getX() < minX) {
              minX = graphicInfo.getX();
            }
            // height
            if (graphicInfo.getY() > maxY) {
              maxY = graphicInfo.getY();
            }
            if (graphicInfo.getY()< minY) {
              minY = graphicInfo.getY();
            }
        }
      }
    }
   
    int nrOfLanes = 0;
    for (Process process : bpmnModel.getProcesses()) {
      for (Lane l : process.getLanes()) {
       
        nrOfLanes++;
       
        GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(l.getId());
        // // width
        if (graphicInfo.getX() + graphicInfo.getWidth() > maxX) {
          maxX = graphicInfo.getX() + graphicInfo.getWidth();
        }
        if (graphicInfo.getX() < minX) {
          minX = graphicInfo.getX();
        }
        // height
        if (graphicInfo.getY() + graphicInfo.getHeight() > maxY) {
          maxY = graphicInfo.getY() + graphicInfo.getHeight();
        }
        if (graphicInfo.getY() < minY) {
          minY = graphicInfo.getY();
        }
      }
    }
   
    // Special case, see http://jira.codehaus.org/browse/ACT-1431
View Full Code Here

public class BpmnShapeParser implements BpmnXMLConstants {
 
  public void parse(XMLStreamReader xtr, BpmnModel model) throws Exception {
   
    String id = xtr.getAttributeValue(null, ATTRIBUTE_DI_BPMNELEMENT);
    GraphicInfo graphicInfo = new GraphicInfo();
   
    String strIsExpanded = xtr.getAttributeValue(null, ATTRIBUTE_DI_IS_EXPANDED);
    if ("true".equalsIgnoreCase(strIsExpanded)) {
      graphicInfo.setExpanded(true);
    }
   
    BpmnXMLUtil.addXMLLocation(graphicInfo, xtr);
    while (xtr.hasNext()) {
      xtr.next();
      if (xtr.isStartElement() && ELEMENT_DI_BOUNDS.equalsIgnoreCase(xtr.getLocalName())) {
        graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_X)));
        graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_Y)));
        graphicInfo.setWidth(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_WIDTH)));
        graphicInfo.setHeight(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_HEIGHT)));
       
        model.addGraphicInfo(id, graphicInfo);
        break;
      } else if (xtr.isEndElement() && ELEMENT_DI_SHAPE.equalsIgnoreCase(xtr.getLocalName())) {
        break;
View Full Code Here

      xtr.next();
      if (xtr.isStartElement() && ELEMENT_DI_LABEL.equalsIgnoreCase(xtr.getLocalName())) {
        while (xtr.hasNext()) {
          xtr.next();
          if (xtr.isStartElement() && ELEMENT_DI_BOUNDS.equalsIgnoreCase(xtr.getLocalName())) {
            GraphicInfo graphicInfo = new GraphicInfo();
            BpmnXMLUtil.addXMLLocation(graphicInfo, xtr);
            graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_X)).intValue());
            graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_Y)).intValue());
            graphicInfo.setWidth(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_WIDTH)).intValue());
            graphicInfo.setHeight(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_HEIGHT)).intValue());
            model.addLabelGraphicInfo(id, graphicInfo);
            break;
          } else if(xtr.isEndElement() && ELEMENT_DI_LABEL.equalsIgnoreCase(xtr.getLocalName())) {
            break;
          }
        }
       
      } else if (xtr.isStartElement() && ELEMENT_DI_WAYPOINT.equalsIgnoreCase(xtr.getLocalName())) {
        GraphicInfo graphicInfo = new GraphicInfo();
        BpmnXMLUtil.addXMLLocation(graphicInfo, xtr);
        graphicInfo.setX(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_X)).intValue());
        graphicInfo.setY(Double.valueOf(xtr.getAttributeValue(null, ATTRIBUTE_DI_Y)).intValue());
        wayPointList.add(graphicInfo);
       
      } else if(xtr.isEndElement() && ELEMENT_DI_EDGE.equalsIgnoreCase(xtr.getLocalName())) {
        break;
      }
View Full Code Here

       
        xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_SHAPE, BPMNDI_NAMESPACE);
        xtw.writeAttribute(ATTRIBUTE_DI_BPMNELEMENT, elementId);
        xtw.writeAttribute(ATTRIBUTE_ID, "BPMNShape_" + elementId);
       
        GraphicInfo graphicInfo = model.getGraphicInfo(elementId);
        FlowElement flowElement = model.getFlowElement(elementId);
        if (flowElement instanceof SubProcess && graphicInfo.getExpanded() != null) {
          xtw.writeAttribute(ATTRIBUTE_DI_IS_EXPANDED, String.valueOf(graphicInfo.getExpanded()));
        }
       
        xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE);
        xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, "" + graphicInfo.getHeight());
        xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, "" + graphicInfo.getWidth());
        xtw.writeAttribute(ATTRIBUTE_DI_X, "" + graphicInfo.getX());
        xtw.writeAttribute(ATTRIBUTE_DI_Y, "" + graphicInfo.getY());
        xtw.writeEndElement();
       
        xtw.writeEndElement();
      }
    }
   
    for (String elementId : model.getFlowLocationMap().keySet()) {
     
      if (model.getFlowElement(elementId) != null || model.getArtifact(elementId) != null ||
          model.getMessageFlow(elementId) != null) {
     
        xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_EDGE, BPMNDI_NAMESPACE);
        xtw.writeAttribute(ATTRIBUTE_DI_BPMNELEMENT, elementId);
        xtw.writeAttribute(ATTRIBUTE_ID, "BPMNEdge_" + elementId);
       
        List<GraphicInfo> graphicInfoList = model.getFlowLocationGraphicInfo(elementId);
        for (GraphicInfo graphicInfo : graphicInfoList) {
          xtw.writeStartElement(OMGDI_PREFIX, ELEMENT_DI_WAYPOINT, OMGDI_NAMESPACE);
          xtw.writeAttribute(ATTRIBUTE_DI_X, "" + graphicInfo.getX());
          xtw.writeAttribute(ATTRIBUTE_DI_Y, "" + graphicInfo.getY());
          xtw.writeEndElement();
        }
       
        GraphicInfo labelGraphicInfo = model.getLabelGraphicInfo(elementId);
        FlowElement flowElement = model.getFlowElement(elementId);
        MessageFlow messageFlow = null;
        if (flowElement == null) {
          messageFlow = model.getMessageFlow(elementId);
        }
       
        boolean hasName = false;
        if (flowElement != null && StringUtils.isNotEmpty(flowElement.getName())) {
          hasName = true;
       
        } else if (messageFlow != null && StringUtils.isNotEmpty(messageFlow.getName())) {
          hasName = true;
        }
       
        if (labelGraphicInfo != null && hasName) {
          xtw.writeStartElement(BPMNDI_PREFIX, ELEMENT_DI_LABEL, BPMNDI_NAMESPACE);
          xtw.writeStartElement(OMGDC_PREFIX, ELEMENT_DI_BOUNDS, OMGDC_NAMESPACE);
          xtw.writeAttribute(ATTRIBUTE_DI_HEIGHT, "" + labelGraphicInfo.getHeight());
          xtw.writeAttribute(ATTRIBUTE_DI_WIDTH, "" + labelGraphicInfo.getWidth());
          xtw.writeAttribute(ATTRIBUTE_DI_X, "" + labelGraphicInfo.getX());
          xtw.writeAttribute(ATTRIBUTE_DI_Y, "" + labelGraphicInfo.getY());
          xtw.writeEndElement();
          xtw.writeEndElement();
        }
       
        xtw.writeEndElement();
View Full Code Here

      int width = (int) graphicInfo.getWidth();
      int height = (int) graphicInfo.getHeight();
     
      double scale = .6;
     
      GraphicInfo eventInfo = new GraphicInfo();
      eventInfo.setX(x + width*(1-scale)/2);
      eventInfo.setY(y + height*(1-scale)/2);
      eventInfo.setWidth(width*scale);
      eventInfo.setHeight(height*scale);
      drawCatchingEvent(eventInfo, true, null, "eventGateway", scaleFactor);
     
      double r = width / 6.;
     
      // create pentagon (coords with respect to center)
View Full Code Here

  public List<GraphicInfo> connectionPerfectionizer(SHAPE_TYPE sourceShapeType, SHAPE_TYPE targetShapeType, GraphicInfo sourceGraphicInfo, GraphicInfo targetGraphicInfo, List<GraphicInfo> graphicInfoList) {
    Shape shapeFirst = createShape(sourceShapeType, sourceGraphicInfo);
    Shape shapeLast = createShape(targetShapeType, targetGraphicInfo);

    if (graphicInfoList != null && graphicInfoList.size() > 0) {
      GraphicInfo graphicInfoFirst = graphicInfoList.get(0);
      GraphicInfo graphicInfoLast = graphicInfoList.get(graphicInfoList.size()-1);
      if (shapeFirst != null) {
        graphicInfoFirst.setX(shapeFirst.getBounds2D().getCenterX());
        graphicInfoFirst.setY(shapeFirst.getBounds2D().getCenterY());
      }
      if (shapeLast != null) {
        graphicInfoLast.setX(shapeLast.getBounds2D().getCenterX());
        graphicInfoLast.setY(shapeLast.getBounds2D().getCenterY());
      }
 
      Point p = null;
     
      if (shapeFirst != null) {
        Line2D.Double lineFirst = new Line2D.Double(graphicInfoFirst.getX(), graphicInfoFirst.getY(), graphicInfoList.get(1).getX(), graphicInfoList.get(1).getY());
        p = getIntersection(shapeFirst, lineFirst);
        if (p != null) {
          graphicInfoFirst.setX(p.getX());
          graphicInfoFirst.setY(p.getY());
        }
      }
 
      if (shapeLast != null) {
        Line2D.Double lineLast = new Line2D.Double(graphicInfoLast.getX(), graphicInfoLast.getY(), graphicInfoList.get(graphicInfoList.size()-2).getX(), graphicInfoList.get(graphicInfoList.size()-2).getY());
        p = getIntersection(shapeLast, lineLast);
        if (p != null) {
          graphicInfoLast.setX(p.getX());
          graphicInfoLast.setY(p.getY());
        }
      }
    }

    return graphicInfoList;
View Full Code Here

      }
      sequenceFlow.setWaypoints(waypoints);
    } else if (bpmnModel.getArtifact(key) != null) {
      // it's an association, so nothing to do
    } else {
      GraphicInfo graphicInfo = null;
      if (graphicList != null && !graphicList.isEmpty()) {
        graphicInfo = graphicList.get(0);
      } else {
        graphicInfo = new GraphicInfo();
      }
      LOGGER.warn("Invalid reference in 'bpmnElement' attribute, sequenceFlow " + key + " not found");
    }
  }
View Full Code Here

          if (!bpmnModel.getFlowLocationMap().isEmpty()) {
           
            int maxX = 0;
            int maxY = 0;
            for (String key : bpmnModel.getLocationMap().keySet()) {
              GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key);
              double elementX = graphicInfo.getX() + graphicInfo.getWidth();
              if (maxX < elementX) {
                maxX = (int) elementX;
              }
              double elementY = graphicInfo.getY() + graphicInfo.getHeight();
              if (maxY < elementY) {
                maxY = (int) elementY;
              }
            }
           
View Full Code Here

TOP

Related Classes of org.activiti.bpmn.model.GraphicInfo

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.