Example #1
0
 private void convertFlowLayout(
     final YExternalNetElement incomingElement,
     final YExternalNetElement outgoingElement,
     final YNet net) {
   YNetLayout netLayout = getContext().getLayout().getNetLayout(net.getID());
   YFlowLayout flowLayout =
       new YFlowLayout(incomingElement, outgoingElement, getContext().getNumberFormat());
   flowLayout.setBounds(convertShapeBounds(getShape()));
   flowLayout.setLineStyle(convertLineStyle(getShape()));
   flowLayout.setSourcePort(convertPort(incomingElement, edgeShape.getDockerAt(0)));
   flowLayout.setPoints(convertDockers(edgeShape.getDockersReadOnly()));
   flowLayout.setTargetPort(
       convertPort(outgoingElement, edgeShape.getDockerAt(edgeShape.getNumDockers() - 1)));
   netLayout.addFlowLayout(flowLayout);
 }
Example #2
0
  /*
   * (non-Javadoc)
   *
   * @see de.hbrs.oryx.yawl.converter.handler.oryx.OryxHandler#convert()
   */
  @Override
  public void convert() {
    YNet net = getContext().getNet(netShape);

    BasicShape incomingShape = getShape().getIncomingsReadOnly().get(0);
    BasicShape outgoingShape = getShape().getOutgoingsReadOnly().get(0);

    YExternalNetElement incomingElement = net.getNetElement(convertYawlId(net, incomingShape));
    YExternalNetElement outgoingElement = net.getNetElement(convertYawlId(net, outgoingShape));

    if (incomingElement == null
        || outgoingElement == null
        || incomingElement.getID() == null
        || outgoingElement.getID() == null) {
      getContext()
          .addConversionWarnings(
              new ConversionException(
                  "Missing source or target for Edge with ID "
                      + getShape().getResourceId()
                      + " in Net "
                      + net.getID()));
      return;
    }

    YFlow flow = new YFlow(incomingElement, outgoingElement);
    flow.setDocumentation(edgeShape.getProperty("documentation"));

    try {
      convertFlowsInto(flow, incomingShape, outgoingShape, net);
    } catch (JSONException e) {
      getContext().addConversionWarnings("Can not convert flow predicates and ordering", e);
    } catch (ConversionException e) {
      getContext().addConversionWarnings(e);
    }

    convertFlowLayout(incomingElement, outgoingElement, net);

    outgoingElement.addPreset(flow);
  }
  @Test
  public void testGetShapesAtPosition() {
    BasicDiagram d = new BasicDiagram("aDiagram");

    BasicNode n1 = new BasicNode("n1");
    BasicNode n2 = new BasicNode("n2");
    BasicNode n3 = new BasicNode("n3");
    BasicNode n4 = new BasicNode("n4");
    BasicNode n5 = new BasicNode("n5");

    BasicEdge e1 = new BasicEdge("e1");
    BasicEdge e2 = new BasicEdge("e2");
    BasicEdge e3 = new BasicEdge("e3");
    BasicEdge e4 = new BasicEdge("e4");
    BasicEdge e5 = new BasicEdge("e5");

    List<String> idsList =
        Arrays.asList(new String[] {"n1", "n2", "n3", "n4", "n5", "e1", "e2", "e3", "e4", "e5"});

    d.addChildShape(n1);
    d.addChildShape(n2);
    d.addChildShape(n3);
    d.addChildShape(n4);
    d.addChildShape(n5);
    d.addChildShape(e1);
    d.addChildShape(e2);
    d.addChildShape(e3);
    d.addChildShape(e4);
    d.addChildShape(e5);

    // n2, n4, e3, e5 shall be at point (10, 100)

    n2.setBounds(
        new Bounds(
            new Point(randomHelper(-400, -40), randomHelper(10, 100)),
            new Point(randomHelper(10, 100), randomHelper(100, 500))));

    n4.setBounds(
        new Bounds(
            new Point(randomHelper(9, 9), randomHelper(10, 10)),
            new Point(randomHelper(100, 200), randomHelper(300, 400))));

    e3.addDocker(new Point(randomHelper(5, 7), randomHelper(10, 90)));
    e3.addDocker(new Point(randomHelper(10, 20), randomHelper(100, 1000)));

    e5.addDocker(new Point(randomHelper(-100, -40), randomHelper(0, 100)));
    e5.addDocker(new Point(randomHelper(40, 400), randomHelper(100, 300)));

    // the others not
    n1.setBounds(
        new Bounds(
            new Point(randomHelper(-40, -400), randomHelper(10, 100)),
            new Point(randomHelper(-10, -100), randomHelper(50, 500))));

    n3.setBounds(
        new Bounds(
            new Point(randomHelper(40, 400), randomHelper(-10, -100)),
            new Point(randomHelper(40, 100), randomHelper(-50, -500))));

    n5.setBounds(
        new Bounds(
            new Point(randomHelper(-400, -40), randomHelper(10, 100)),
            new Point(randomHelper(-100, -10), randomHelper(50, 500))));

    e1.addDocker(new Point(randomHelper(5, 7), randomHelper(-90, -10)));
    e1.addDocker(new Point(randomHelper(10, 20), randomHelper(-1000, -100)));

    e2.addDocker(new Point(randomHelper(-7, -5), randomHelper(10, 90)));
    e2.addDocker(new Point(randomHelper(-20, -10), randomHelper(100, 1000)));

    e4.addDocker(new Point(randomHelper(5, 7), randomHelper(-90, -10)));
    e4.addDocker(new Point(randomHelper(-20, -10), randomHelper(100, 1000)));

    Collections.shuffle(idsList);
    d.reorderListOfAllShapes(idsList);

    List<BasicShape> x = d.getShapesAtPosition(new Point(10, 100));

    assertEquals(4, x.size());
    assertTrue(x.contains(n2));
    assertTrue(x.contains(n4));
    assertTrue(x.contains(e3));
    assertTrue(x.contains(e5));
  }