protected void changeShapeSize(
      GraphicsType annType,
      NodeType node,
      BigDecimal newHeight,
      BigDecimal newWidth,
      Map<String, AnnotationData> annotations) {
    super.changeShapeSize(annType, node, newHeight, newWidth, annotations);

    BigDecimal oldH = annType.getSize().getHeight();
    BigDecimal oldW = annType.getSize().getWidth();
    BigDecimal oldX = annType.getPosition().get(0).getX();
    BigDecimal oldY = annType.getPosition().get(0).getY();

    BigDecimal newX = oldW.subtract(newWidth).divide(divisor).add(oldX);
    BigDecimal newY = oldH.subtract(newHeight).divide(divisor).add(oldY);

    SizeType size = new SizeType();
    size.setHeight(newHeight);
    size.setWidth(newWidth);
    PositionType position = new PositionType();
    position.setX(newX);
    position.setY(newY);

    annType.setSize(size);
    annType.getPosition().remove(0);
    annType.getPosition().add(position);

    annotations.put(
        node.getId(), new AnnotationData(oldX, oldY, newX, newY, oldH, oldW, newHeight, newWidth));
  }
 private PositionType calculateFlowPosition(
     final LayoutVertexFactsType vertex, final BigInteger port) throws ParseException {
   PositionType position = ANF_FACTORY.createPositionType();
   LayoutRectangleType rect = getRectangleFromVertex(vertex);
   // TODO decide based on port
   position.setX(convertToBigDecimal(rect.getX()));
   position.setY(convertToBigDecimal(rect.getY()));
   return position;
 }
 private void convertLayoutRectangleAttribute(
     final LayoutRectangleType rect, final GraphicsType graphics) throws ParseException {
   final PositionType position = ANF_FACTORY.createPositionType();
   position.setX(convertToBigDecimal(rect.getX()));
   position.setY(convertToBigDecimal(rect.getY()));
   graphics.getPosition().add(position);
   final SizeType size = ANF_FACTORY.createSizeType();
   size.setHeight(convertToBigDecimal(rect.getH()));
   size.setWidth(convertToBigDecimal(rect.getW()));
   graphics.setSize(size);
 }
Exemplo n.º 4
0
  /* Changes the size of the Gateway Node. */
  private void manipulateSplit(
      CanonicalProcessType cpf,
      AnnotationsType anf,
      GraphicsType splitGraphicsType,
      NodeType splitNode) {
    int index;
    BigDecimal newX, newY;
    PositionType position;
    GraphicsType targetAnn, targetEdgeAnn;
    SplitType split = (SplitType) splitNode;

    BigDecimal oldH = splitGraphicsType.getSize().getHeight();
    BigDecimal oldW = splitGraphicsType.getSize().getWidth();
    BigDecimal oldX = splitGraphicsType.getPosition().get(0).getX();
    BigDecimal oldY = splitGraphicsType.getPosition().get(0).getY();

    Map<EdgeType, NodeType> targets = findSplitNodeTargets(cpf, split.getId());
    for (Map.Entry<EdgeType, NodeType> target : targets.entrySet()) {
      targetAnn = findGraphicsType(anf, target.getValue().getId());
      targetEdgeAnn = findGraphicsType(anf, target.getKey().getId());

      if (targetAnn != null) {
        newX =
            targetAnn
                .getSize()
                .getWidth()
                .divide(divisor)
                .add(targetAnn.getPosition().get(0).getX());
        newY = targetAnn.getPosition().get(0).getY();

        index = 0;
        for (PositionType targetEdgePos : targetEdgeAnn.getPosition()) {
          if (!((targetEdgePos.getX().compareTo(oldX) > 0)
              && (targetEdgePos.getX().compareTo(oldX.add(oldW)) < 0)
              && (targetEdgePos.getY().compareTo(oldY) > 0)
              && (targetEdgePos.getY().compareTo(oldY.add(oldH)) < 0))) {
            position = new PositionType();
            position.setX(newX);
            position.setY(newY);

            targetEdgeAnn.getPosition().set(index, position);
          }
          index++;
        }
      }
    }
  }
 private Collection<PositionType> convertFlowPositions(final LayoutFlowFactsType flowLayout)
     throws ParseException {
   final ArrayList<PositionType> positions = new ArrayList<PositionType>();
   for (final JAXBElement<?> obj :
       flowLayout.getAttributes().getAutosizeOrBackgroundColorOrBendable()) {
     if (obj.getValue() instanceof LayoutPointsType) {
       final LayoutPointsType points = (LayoutPointsType) obj.getValue();
       for (final LayoutPointType point : points.getValue()) {
         final PositionType position = ANF_FACTORY.createPositionType();
         position.setX(convertToBigDecimal(point.getX()));
         position.setY(convertToBigDecimal(point.getY()));
         positions.add(position);
       }
     }
   }
   return positions;
 }
  /* Changes the position of the edges X and Y. */
  private Map<PositionType, PositionType> changeLocation(
      GraphicsType graphicsType, AnnotationData annData) {
    int index = 0;
    PositionType newPos = new PositionType();
    Map<PositionType, PositionType> replace = new HashMap<>();

    for (PositionType pos : graphicsType.getPosition()) {
      if ((pos.getX().compareTo(annData.getOldX()) >= 0)
          && (pos.getX().compareTo(annData.getOldX().add(annData.getOldW())) <= 0)
          && (pos.getY().compareTo(annData.getOldY()) >= 0)
          && (pos.getY().compareTo(annData.getOldY().add(annData.getOldH())) <= 0)) {
        newPos.setX(annData.getNewX().add(annData.getNewW().divide(divisor)));
        newPos.setY(annData.getNewY().add(annData.getNewH().divide(divisor)));
        graphicsType.getPosition().set(index, newPos);
      }
      index++;
    }

    return replace;
  }
 private PositionType getPositionType(int x, int y) {
   PositionType position = new PositionType();
   position.setX(new BigDecimal(x));
   position.setY(new BigDecimal(y));
   return position;
 }