@Override
  public Map.Entry<String, List<String>> extractLinkURIs(
      final String entitySetName, final String entityId, final String linkName) throws Exception {

    final LinkInfo links = readLinks(entitySetName, entityId, linkName, Accept.XML);
    return extractLinkURIs(links.getLinks());
  }
  @Override
  public void handleEvent(PersonDepartureEvent event) {
    // count only car travelers
    if (!event.getLegMode().equals(TransportMode.car)) return;

    LinkInfo linkInfo = linkInfos.get(event.getLinkId());
    linkInfo.addEvent(event);
  }
Example #3
0
    @Override
    public void startElement(String uri, String localName, String qName, Attributes attributes)
        throws SAXException {
      super.startElement(uri, localName, qName, attributes);
      if (qName != null && qName.length() > 0) localName = qName;
      level++;
      L.d(tab() + "<" + localName + ">");
      currentAttributes = attributes;
      elements.push(localName);
      // String currentElement = elements.peek();
      if (!insideFeed && "feed".equals(localName)) {
        insideFeed = true;
      } else if ("entry".equals(localName)) {
        if (!insideFeed) {
          insideFeed = true;
          singleEntry = true;
        }
        insideEntry = true;
        entryInfo = new EntryInfo();
      } else if ("category".equals(localName)) {
        if (insideEntry) {
          String category = attributes.getValue("label");
          if (category != null) entryInfo.categories.add(category);
        }
      } else if ("id".equals(localName)) {

      } else if ("updated".equals(localName)) {

      } else if ("title".equals(localName)) {

      } else if ("link".equals(localName)) {
        LinkInfo link = new LinkInfo(url, attributes);
        if (link.isValid() && insideFeed) {
          L.d(tab() + link.toString());
          if (insideEntry) {
            if (link.type != null) {
              entryInfo.links.add(link);
              int priority = link.getPriority();
              if (link.type.startsWith("application/atom+xml")) {
                entryInfo.link = link;
              } else if (priority > 0
                  && (entryInfo.link == null || entryInfo.link.getPriority() < priority)) {
                entryInfo.link = link;
              }
            }
          } else {
            if ("self".equals(link.rel)) docInfo.selfLink = link;
            else if ("alternate".equals(link.rel)) docInfo.alternateLink = link;
          }
        }
      } else if ("author".equals(localName)) {
        authorInfo = new AuthorInfo();
      }
    }
Example #4
0
 @Override
 public void handleEvent(PersonArrivalEvent event) {
   LinkInfo info = this.map.get(event.getLinkId());
   if (info == null) {
     return;
   }
   synchronized (info) {
     info.onLink--;
     info.text = Integer.toString(info.onLink);
     updateColor(info);
   }
 }
Example #5
0
  public void run() {
    ServerSocket server = null;
    try {
      server = new ServerSocket(link.getSerPort());
      System.out.println("System Online!");
    } catch (Exception e) {
      e.printStackTrace();
      return;
    }
    try {
      Socket remoteSocket = server.accept();
      System.out.println("remoteSocket accpet!");
      Socket localSocket = server.accept();
      System.out.println("localSocket  accpet!");
      remoteSocket.setSoTimeout(0);
      localSocket.setSoTimeout(0);

      remoteSocket.setTcpNoDelay(true);
      localSocket.setTcpNoDelay(true);

      new TransferDown(remoteSocket, localSocket, "ToCZ");
      new TransferUp(remoteSocket, localSocket, "ToYonYou");

    } catch (Exception e) {
      e.printStackTrace();
    }
  }
Example #6
0
  @Override
  public void handleEvent(LinkLeaveEvent event) {
    LinkInfo info = this.map.get(event.getLinkId());
    if (info == null) {
      return;
    }
    //		if (event.getLinkId().toString().contains("el")){
    //			throw new RuntimeException("ERROR");
    //		}

    synchronized (info) {
      info.onLink--;
      info.text = Integer.toString(info.onLink);
      updateColor(info);
    }
  }
  public boolean onSingleTapUp(MotionEvent e) {
    LinkInfo link = null;

    if (mMode == Mode.Viewing && !tapDisabled) {
      MuPDFView pageView = (MuPDFView) getDisplayedView();
      Hit item = pageView.passClickEvent(e.getX(), e.getY());
      onHit(item);
      if (item == Hit.Nothing) {
        if (
        /*mLinksEnabled && */ pageView != null
            && (link = pageView.hitLink(e.getX(), e.getY())) != null) {
          link.acceptVisitor(
              new LinkInfoVisitor() {
                @Override
                public void visitInternal(LinkInfoInternal li) {
                  // Clicked on an internal (GoTo) link
                  // TODO: goto page in landscape mode
                  setDisplayedViewIndex(li.pageNumber);
                }

                @Override
                public void visitExternal(LinkInfoExternal li) {
                  Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(li.url));
                  mContext.startActivity(intent);
                }

                @Override
                public void visitRemote(LinkInfoRemote li) {
                  // Clicked on a remote (GoToR) link
                }
              });
        } else if (e.getX() < tapPageMargin) {
          super.smartMoveBackwards();
        } else if (e.getX() > super.getWidth() - tapPageMargin) {
          super.smartMoveForwards();
          // } else if (e.getY() < tapPageMargin) {
          //	super.smartMoveBackwards();
          // } else if (e.getY() > super.getHeight() - tapPageMargin) {
          //	super.smartMoveForwards();
        } else {
          onTapMainDocArea();
        }
      }
    }
    return super.onSingleTapUp(e);
  }
Example #8
0
 public LinkInfo getBestAcquisitionLink() {
   LinkInfo best = null;
   int bestPriority = 0;
   for (LinkInfo link : links) {
     // boolean isAcquisition = link.rel!=null && link.rel.indexOf("acquisition")>=0;
     int priority = link.getPriority();
     if (priority > 0 && priority > bestPriority) {
       if (link.getPriority() > 0 && (best == null || best.getPriority() < link.getPriority())) {
         best = link;
         bestPriority = priority;
       }
     }
   }
   return best;
 }
 @Override
 public void handleEvent(LinkLeaveEvent event) {
   LinkInfo linkInfo = linkInfos.get(event.getLinkId());
   linkInfo.addEvent(event);
 }
Example #10
0
  public QSimDensityDrawer(Scenario sc) {
    for (Link l : sc.getNetwork().getLinks().values()) {
      if (l.getId().toString().contains("jps")
          || l.getId().toString().contains("el")
          || l.getAllowedModes().contains("walk2d")
          || l.getCapacity() >= 100000
          || l.getFreespeed() > 100
          || l.getId().toString().contains("el")) {
        continue;
      }

      float width = (float) (l.getCapacity() / sc.getNetwork().getCapacityPeriod() / 1.3);

      boolean isCar = false;
      if (l.getFreespeed() > 1.35) {
        width = (float) (l.getNumberOfLanes() * 3.5);
        isCar = true;
      } else {
        width = (float) (width);
      }

      double dx = l.getToNode().getCoord().getX() - l.getFromNode().getCoord().getX();
      double dy = l.getToNode().getCoord().getY() - l.getFromNode().getCoord().getY();
      double length = Math.sqrt(dx * dx + dy * dy);
      dx /= length;
      dy /= length;
      LinkInfo info = new LinkInfo();

      info.id = l.getId();
      info.cap =
          (l.getLength() / ((NetworkImpl) sc.getNetwork()).getEffectiveCellSize())
              * l.getNumberOfLanes();

      double x0 = l.getFromNode().getCoord().getX();
      double y0 = l.getFromNode().getCoord().getY();

      double x1 = l.getToNode().getCoord().getX();
      double y1 = l.getToNode().getCoord().getY();

      x0 += dy * width / 2;
      x1 += dy * width / 2;
      y0 -= dx * width / 2;
      y1 -= dx * width / 2;

      info.width = width;
      info.x0 = x0;
      info.x1 = x1;
      info.y0 = y0;
      info.y1 = y1;

      double tan = dx / dy;
      double atan = Math.atan(tan);
      if (atan > 0) {
        atan -= Math.PI / 2;
      } else {
        atan += Math.PI / 2;
      }

      double offsetX = dy * .075;
      double offsetY = -dx * .075;
      if (dx > 0) {
        offsetX *= -1;
        offsetY *= -1;
      }

      info.tx = (x0 + x1) / 2 + offsetX;
      info.ty = (y0 + y1) / 2 + offsetY;
      info.text = "0";
      info.atan = atan;
      info.isCar = isCar;
      if (isCar) {
        info.cap = l.getLength() / 7.5 * l.getNumberOfLanes();
      }

      this.links.add(info);
      this.map.put(l.getId(), info);
    }
  }
Example #11
0
 @Override
 public void reset(int iteration) {
   for (LinkInfo li : this.links) {
     li.onLink = 0;
   }
 }
Example #12
0
 private void updateColor(LinkInfo l) {
   //		if (l.onLink > l.cap) {
   //			l.cap = l.onLink;
   //		}
   if (l.onLink > l.cap) {
     //			log.warn("Assumed storage capacity is smaler than actual storage capacity.");
     l.cap = l.onLink;
   }
   double density = 5.4 * l.onLink / l.cap;
   if (density == 0) {
     l.r = 0;
     l.g = 0;
     l.b = 0;
     l.a = 128;
   } else if (density < 1) {
     //			l.a = (int) (128 + 128 * (density/0.25));
     //			l.r = 0;
     //			l.g = 255;
     //			l.b = 0;
     //			l.a = (int) (128 + 128 * (density/0.25));
     l.r = 0;
     l.g = 192;
     l.b = 0;
     l.a = 255;
   } else if (density < 2) {
     //			l.a = 255;
     //			l.g = 255;
     //			l.b = 0;
     //			l.r = (int) (255 * ((density-.25)/0.75));
     l.r = 192;
     l.g = 192;
     l.b = 0;
     l.a = 255;
     //			l.r = (int) (255 * ((density-.25)/0.75));
   } else if (density < 2) {
     //			l.a = 255;
     //			l.g = 255 - (int) (255 * ((density-1)));;
     //			l.b = 0;
     //			l.r = 255;
     l.r = 192;
     l.g = 192;
     l.b = 0;
     l.a = 255;
   } else {
     //			l.a = 255;
     //			l.g = 0;
     //			l.b = (int) (128 * (density-2)/3.4);
     //			l.r = 255 - l.b;
     l.r = 192;
     l.g = 0;
     l.b = 0;
     l.a = 255;
   }
 }
 /**
  * Create an operation that will list all the content keys at the given link.
  *
  * @param link Link to request content keys from.
  * @return The list operation.
  */
 public static DefaultListOperation<ContentKeyInfo> list(LinkInfo<ContentKeyInfo> link) {
   return new DefaultListOperation<ContentKeyInfo>(
       link.getHref(), new GenericType<ListResult<ContentKeyInfo>>() {});
 }
Example #14
0
  private void loadScenario(Scenario scRsp) {
    Map<String, Node> nodes = new HashMap<>();
    for (Node n : scRsp.getNet().getNodesList()) {
      nodes.put(n.getId(), n);
    }
    Set<String> handled = new HashSet<>();
    for (Link l : scRsp.getNet().getLinksList()) {

      Node from = nodes.get(l.getFromNodeId());
      Node to = nodes.get(l.getToNodeId());
      StringBuffer b1 = new StringBuffer();
      StringBuffer b2 = new StringBuffer();
      b1.append(from.getId());
      b1.append('_');
      b1.append(to.getId());
      String id = b1.toString();
      b2.append(to.getId());
      b2.append('_');
      b2.append(from.getId());
      String refId = b2.toString();

      LinkInfo i = new LinkInfo();
      i.x0 = from.getX();
      i.y0 = from.getY();
      i.x1 = to.getX();
      i.y1 = to.getY();
      i.width = l.getCapacity() * 3;
      // LinkInfoPoly p = new LinkInfoPoly();
      // double dx = (to.getX() - from.getX());
      // double dy = (to.getY() - from.getY());
      // double length = Math.sqrt(dx * dx + dy * dy);
      // dx /= length;
      // dy /= length;
      // double x0 = from.getX() - dy * l.getCapacity() / 2;
      // double y0 = from.getY() + dx * l.getCapacity() / 2;
      // double x1 = from.getX() + dy * l.getCapacity() / 2;
      // double y1 = from.getY() - dx * l.getCapacity() / 2;
      // double x2 = to.getX() + dy * l.getCapacity() / 2;
      // double y2 = to.getY() - dx * l.getCapacity() / 2;
      // double x3 = to.getX() - dy * l.getCapacity() / 2;
      // double y3 = to.getY() + dx * l.getCapacity() / 2;
      // p.x = new double[] { x0, x1, x2, x3, x0 };
      // p.y = new double[] { y0, y1, y2, y3, y0 };
      //
      double area = l.getLength() * l.getCapacity();
      i.area = area;
      //
      // this.linkPolys.put(l.getId(), p);
      this.linkInfos.put(l.getId(), i);
      if (handled.contains(refId)) {
        continue;
      }
      handled.add(id);

      this.drawer.addLineStatic(
          from.getX(),
          from.getY(),
          to.getX(),
          to.getY(),
          192,
          192,
          192,
          255,
          0,
          3 * l.getCapacity());
    }
  }