Package urban.model

Examples of urban.model.Site


          Entry<Link, RuleGraph> entry1 = children.next();
          Entry<Link, RuleGraph> entry2 = children.next();
         
          Node a = entry1.getValue().getRoot();
          Node b = entry2.getValue().getRoot();
          get(rhs,a).add(new Site(a.getName(), entry1.getKey().getDst(), null, ""+i));
          get(rhs,b).add(new Site(b.getName(), entry2.getKey().getDst(), null, ""+i));
          i++;
          q.add(entry1.getValue());
          q.add(entry2.getValue());
        } else {
          ordering.add(root);
          String agent = root.getName();
          List<Site> sitesL = get(lhs, root);
          List<Site> sitesR = get(rhs, root);
          addAll(sitesL, root.getSitesL());
          addAll(sitesR, root.getSitesR());
          for(Entry<Link, RuleGraph> e : sorted(graph.getChildren())){
            if (e.getValue() == null){
              String siteName = e.getKey().getSrc();
              sitesL.add(new Site(agent, siteName, null, "_"));
              sitesR.add(new Site(agent, siteName, null, "_"));         
            } else {
              if (!lhs.containsKey(e.getValue().getRoot())){
                q.add(e.getValue());
              }
              String src = e.getKey().getSrc();
              sitesL.add(new Site(agent, src, null, ""+i));
              sitesR.add(new Site(agent, src, null, ""+i));
              Node root2 = e.getValue().getRoot();
              String dst = e.getKey().getDst();
              get(lhs, root2).add(new Site(root2.getName(), dst, null, ""+i));
              get(rhs, root2).add(new Site(root2.getName(), dst, null, ""+i));       
              i++;
            }
          }
        }
      }
View Full Code Here


    }
  }

  private RuleGraph createRoot(Shape.ShapePlusSite arg0, Data d) {
    RuleGraph rg;
    Site s = arg0.site;
    if (s.getState() == null){
      rg = new RuleGraph(new BondNode());
      RuleGraph r1 = new RuleGraph(new Node(arg0.agent));
      final Link key = new Link("1",s.getName());
      if (template == null){
        rg.addChild(key, r1);
        d.q.add(pairOf(arg0.agent, r1));
      } else {
        rg.addChild(key, template.getChildrenMap().get(key));
        rg.addChild(new Link("2",s.getName()), r1);
        d.q.add(pairOf(arg0.agent, r1));
      }
 
      Pair<Agent, RuleGraph> r2 = createRuleGraph(d, rg, arg0.agent, s);
      if (r2 != null && r2.fst != null)
        d.q.add(r2);
    } else {
      rg = new RuleGraph(new SiteNode(arg0.agent, s.getName(),s.getState()));
      d.q.add(pairOf(arg0.agent, rg));
    }
    return rg;
  }
View Full Code Here

      while(lhsIt.hasNext()) {
        Agent a = lhsIt.next();

        Iterator<Site> asIt = a.getSites().iterator();
        while(asIt.hasNext()){
          Site s = asIt.next();
         
          String m = s.getBindingMark();
          if (m != null && !"?".equals(m) && !"_".equals(m)){
            if (first.containsKey(m))
              second.put(m, pairOf(a,s));
            else
              first.put(m, pairOf(a,s));
View Full Code Here

    return this;
  }
  @Override
  public Site transform(Site arg0) {
    if (test.evaluate(arg0)){
      return new Site(arg0.getAgent(),
          newName == null ? arg0.getName() : newName,
          newState == null ? arg0.getState() : newState,
          !isBindingSet ? arg0.getBindingMark() : newBindingMark);
    }
    return arg0;
View Full Code Here

      l.add(site(e));
    return l;
  }

  private Site site(Entry<String, String> e) {
    return new Site(name, e.getKey(), e.getValue(), null);
  }
View Full Code Here

      final Entry<Link, RuleGraph> left = iterator.next();
      final Entry<Link, RuleGraph> right = iterator.next();

      return new Predicate<ShapePlusSite>() {
        public boolean evaluate(ShapePlusSite p) {
          Site s = p.site;
          if (!onLeft && s.getBindingMark() == null)
            return false;
          if (onLeft && s.getBindingMark() != null)
            return false;
          return test(s, left) || test(s, right);
        }

        private boolean test(Site s, Entry<Link, RuleGraph> e) {
          return (e.getKey().getDst().equals(s.getName())
          && e.getValue().getRoot().getName().equals(s.getAgent()));
        }
      };
    } else {
      final String state = ((SiteNode)root).getLeft().getState();
     
      return new Predicate<ShapePlusSite>() {
        public boolean evaluate(ShapePlusSite p) {
          Site s = p.site;
         
          return root.getName().equals(s.getAgent())
          && root.getGenerator().equals(s.getName())
          && (
            (onLeft && state.equals(s.getState()))
          ||
            (!onLeft && !state.equals(s.getState()))
          );         
        }
      };   
    }
  }
View Full Code Here

   * @param qualifiedName
   * @return A list of possible states for the given site
   */
  public Collection<String> getStatesForSite(String qualifiedName) {
    getSites();
    final Site site = sites.get(qualifiedName);
    if (site == null)
      return null;
    final String state = site.getState();
    if (state == null)
      return null;
    return Arrays.asList(state.split(", "));
  }
View Full Code Here

    final Entry<Link, RuleGraph> left = iterator.next();
    final Entry<Link, RuleGraph> right = iterator.next();

    return new Predicate<ShapePlusSite>() {
      public boolean evaluate(ShapePlusSite p) {
        Site s = p.site;
        if (s.getBindingMark() != null)
          return false;
        return (firstAgent && test(s, left)) || (!firstAgent && test(s, right));
      }

      private boolean test(Site s, Entry<Link, RuleGraph> e) {
        return (e.getKey().getDst().equals(s.getName())
        && e.getValue().getRoot().getName().equals(s.getAgent()));
      }
    };
  }
View Full Code Here

    SortedBag<Site> result = getSorted(Collections.<Site>emptyList());

    Iterator<Site> i1= s1.iterator();
    Iterator<Site> i2 = s2.iterator();
   
    Site x=null,y = null;
    while(x != null || i1.hasNext() || y != null || i2.hasNext()){
     
      if (i1.hasNext())
        x = i1.next();
      if (i2.hasNext())
        y = i2.next();

      if (x == null){
        result.add(y);
        y = null;
        continue;
      }
     
      if (y == null){
        result.add(x);
        x = null;
        continue;
      }
     
      int comparison = x.getName().compareTo(y.getName());
     
      if (comparison == 0){ // have the same name
        result.add(mergeSite(x,y));
        x = null;
        y = null;
View Full Code Here

    } else if (x.getState() != null) {
      states = x.getState();
    } else if (y.getState() != null) {
        states = y.getState();
    }
    return new Site(x.getAgent(), x.getName(), states, null);
  }
View Full Code Here

TOP

Related Classes of urban.model.Site

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.