コード例 #1
0
ファイル: PolicyNet.java プロジェクト: tuura/workcraft
  public Locality createLocality(ArrayList<Node> nodes, Container parent) {
    Locality locality = new Locality();
    parent.add(locality);
    parent.reparent(nodes, locality);

    ArrayList<Node> connectionsToLocality = new ArrayList<>();
    for (Connection connection : Hierarchy.getChildrenOfType(parent, Connection.class)) {
      if (Hierarchy.isDescendant(connection.getFirst(), locality)
          && Hierarchy.isDescendant(connection.getSecond(), locality)) {
        connectionsToLocality.add(connection);
      }
    }
    parent.reparent(connectionsToLocality, locality);

    splitBundlesByLocalities(nodes);

    return locality;
  }
コード例 #2
0
 public void coloriseTokens(Transition t) {
   VisualStg visualStg = (VisualStg) getUnderlyingModel();
   VisualTransition vt = visualStg.getVisualTransition(t);
   if (vt == null) return;
   Color tokenColor = Color.black;
   ColorGenerator tokenColorGenerator = vt.getTokenColorGenerator();
   if (tokenColorGenerator != null) {
     // generate token colour
     tokenColor = tokenColorGenerator.updateColor();
   } else {
     // combine preset token colours
     for (Connection c : visualStg.getConnections(vt)) {
       if ((c.getSecond() == vt) && (c instanceof VisualConnection)) {
         VisualConnection vc = (VisualConnection) c;
         if (vc.isTokenColorPropagator()) {
           if (vc.getFirst() instanceof VisualPlace) {
             VisualPlace vp = (VisualPlace) c.getFirst();
             tokenColor = Coloriser.colorise(tokenColor, vp.getTokenColor());
           } else if (vc instanceof VisualImplicitPlaceArc) {
             VisualImplicitPlaceArc vipa = (VisualImplicitPlaceArc) vc;
             tokenColor = Coloriser.colorise(tokenColor, vipa.getTokenColor());
           }
         }
       }
     }
   }
   // propagate the colour to postset tokens
   for (Connection c : visualStg.getConnections(vt)) {
     if ((c.getFirst() == vt) && (c instanceof VisualConnection)) {
       VisualConnection vc = (VisualConnection) c;
       if (vc.isTokenColorPropagator()) {
         if (vc.getSecond() instanceof VisualPlace) {
           VisualPlace vp = (VisualPlace) c.getSecond();
           vp.setTokenColor(tokenColor);
         } else if (vc instanceof VisualImplicitPlaceArc) {
           VisualImplicitPlaceArc vipa = (VisualImplicitPlaceArc) vc;
           vipa.setTokenColor(tokenColor);
         }
       }
     }
   }
 }