コード例 #1
0
ファイル: IrXmlReader.java プロジェクト: hallvard/caltoopia
  private Connection createConnection(Element element, Network network) {
    String kind = element.getAttribute("kind");

    if (kind.equals("point2point")) {
      Point2PointConnection connection = IrFactory.eINSTANCE.createPoint2PointConnection();
      connection.setId(element.getAttribute("id"));
      doAnnotations(connection, element);
      doAttributes(connection, element);
      ActorInstance sourceInstance = (ActorInstance) findIrObject(element.getAttribute("src"));
      String portName = element.getAttribute("src-port");
      connection.setSource(findPortInstance(sourceInstance, portName, true));
      ActorInstance targetInstance = (ActorInstance) findIrObject(element.getAttribute("dst"));
      portName = element.getAttribute("dst-port");
      connection.setTarget(findPortInstance(targetInstance, portName, false));

      connection.getTarget().getConnections().add(connection);
      connection.getSource().getConnections().add(connection);

      return connection;
    } else if (kind.equals("fromSource")) {
      FromSource connection = IrFactory.eINSTANCE.createFromSource();
      connection.setId(element.getAttribute("id"));
      doAnnotations(connection, element);
      doAttributes(connection, element);
      String portName = element.getAttribute("src-port");
      connection.setSource(findPort(network, portName, false));
      ActorInstance targetInstance = (ActorInstance) findIrObject(element.getAttribute("dst"));
      portName = element.getAttribute("dst-port");
      connection.setTarget(findPortInstance(targetInstance, portName, false));

      connection.getTarget().getConnections().add(connection);

      return connection;
    } else if (kind.equals("toSink")) {
      ToSink connection = IrFactory.eINSTANCE.createToSink();
      connection.setId(element.getAttribute("id"));
      doAnnotations(connection, element);
      doAttributes(connection, element);
      ActorInstance sourceInstance = (ActorInstance) findIrObject(element.getAttribute("src"));
      String portName = element.getAttribute("src-port");
      connection.setSource(findPortInstance(sourceInstance, portName, true));
      portName = element.getAttribute("dst-port");
      connection.setSink(findPort(network, portName, true));

      connection.getSource().getConnections().add(connection);

      return connection;
    }

    assert (false);
    return null;
  }
コード例 #2
0
  @Override
  public Stream caseToSink(ToSink c) {
    String source, target;

    source = c.getSource().getActor().getName() + ":" + c.getSource().getName();
    target = c.getSink().getName();

    hue =
        ((((revhue * 0x0802 & 0x22110) | (revhue * 0x8020 & 0x88440)) * 0x10101 >> 16) & 255)
            / 255.0;
    revhue++;
    revhue %= 128;
    s.println(
        source
            + ":e -> "
            + target
            + ":w [color=\""
            + hue
            + " 1.000 "
            + ((revhue & 1) * 0.5 + 0.5)
            + "\"];");

    return s;
  }