Package rinde.sim.core.graph

Examples of rinde.sim.core.graph.Point


  @Override
  public void renderDynamic(GC gc, ViewPort vp, long time) {
    final Set<Taxi> taxis = rm.get().getObjectsOfType(Taxi.class);
    synchronized (taxis) {
      for (final Taxi t : taxis) {
        final Point p = rm.get().getPosition(t);
        final int x = vp.toCoordX(p.x) - 5;
        final int y = vp.toCoordY(p.y) - 30;

        final VehicleState vs = pm.get().getVehicleState(t);
View Full Code Here


    final String string = "AgentWise";
    final List<Point> points = measureString(string, 30, 30, 0);
    final RandomGenerator rng = new MersenneTwister(123);
    final Simulator sim = new Simulator(rng, Measure.valueOf(1000L,
        SI.MILLI(SI.SECOND)));
    sim.register(new PlaneRoadModel(new Point(0, 0), new Point(4500, 1200),
        SI.METER, Measure.valueOf(1000d, NonSI.KILOMETERS_PER_HOUR)));
    sim.configure();
    for (final Point p : points) {
      sim.register(new Vehicle(p, rng));
    }
View Full Code Here

    final int white = (int) Math.pow(2, 24) / 2 - 1;
    for (int i = 0; i < image.getBounds().width; i++) {
      for (int j = vCorrection; j < image.getBounds().height; j++) {
        final int color = image.getImageData().getPixel(i, j);
        if (color < white) {
          coordinateBuilder.add(new Point(i * spacing, (j - vCorrection)
              * spacing));
        }
      }
    }
    final ImmutableList<Point> points = coordinateBuilder.build();
View Full Code Here

      rm = Optional.absent();
    }

    @Override
    public void initRoadUser(RoadModel model) {
      final Point startPos = model.getRandomPosition(rng);
      model.addObjectAt(this, startPos);

      rm = Optional.of(model);
      setDestination(destPos);
    }
View Full Code Here

     */
    public void setInactive() {
      if (active) {
        active = false;
        final List<Point> bounds = rm.get().getBounds();
        final Point p = rm.get().getRandomPosition(rng);
        if (rng.nextBoolean()) {
          doSetDestination(new Point(bounds.get(rng.nextInt(2)).x, p.y));
        } else {
          doSetDestination(new Point(p.x, bounds.get(rng.nextInt(2)).y));
        }
      }
    }
View Full Code Here

      final int radius = 2;
      gc.setBackground(new Color(gc.getDevice(), 255, 0, 0));
      final Map<RoadUser, Point> objects = rm.get().getObjectsAndPositions();
      synchronized (objects) {
        for (final Entry<RoadUser, Point> entry : objects.entrySet()) {
          final Point p = entry.getValue();
          gc.fillOval((int) (vp.origin.x + (p.x - vp.rect.min.x) * vp.scale)
              - radius, (int) (vp.origin.y + (p.y - vp.rect.min.y) * vp.scale)
              - radius, 2 * radius, 2 * radius);
        }
      }
View Full Code Here

  private final int[] y = { 1, 1, 1, 0, -1, -1, -1, 0 };

  @Nullable
  public Point getTargetFor(Truck element) {
    float maxField = Float.NEGATIVE_INFINITY;
    Point maxFieldPoint = null;

    for (int i = 0; i < x.length; i++) {
      final Point p = new Point(element.getPosition().x + x[i],
          element.getPosition().y + y[i]);

      if (p.x < minX || p.x > maxX || p.y < minY || p.y > maxY) {
        continue;
      }
View Full Code Here

  public Map<Point, Float> getFields(Truck truck) {
    final Map<Point, Float> fields = new HashMap<Point, Float>();

    for (int i = 0; i < x.length; i++) {
      final Point p = new Point(truck.getPosition().x + x[i],
          truck.getPosition().y + y[i]);

      if (p.x < minX || p.x > maxX || p.y < minY || p.y > maxY) {
        continue;
      }

      fields.put(new Point(x[i], y[i]), getField(p, truck));
    }

    float avg = 0;
    for (final Point p : fields.keySet()) {
      avg += fields.get(p);
View Full Code Here

        SI.MILLI(SI.SECOND)));

    // register a PlaneRoadModel, a model which facilitates the moving of
    // RoadUsers on a plane. The plane is bounded by two corner points:
    // (0,0) and (10,10)
    sim.register(new PlaneRoadModel(new Point(0, 0), new Point(10, 10),
        SI.KILOMETER, Measure.valueOf(VEHICLE_SPEED, NonSI.KILOMETERS_PER_HOUR)));
    // configure the simulator, once configured we can no longer change the
    // configuration (i.e. add new models) but we can start adding objects
    sim.configure();
View Full Code Here

      }
      if (communications > MAX_MSGs) {
        simulator.unregister(this);
        return;
      }
      final Point destination = rs.getRandomPosition(rnd);
      currentPackage = new ExamplePackage("dummy package", destination);
      simulator.register(currentPackage);
      path = new LinkedList<Point>(rs.getShortestPathTo(this, destination));
    } else {
      rs.followPath(this, path, timeLapse);
View Full Code Here

TOP

Related Classes of rinde.sim.core.graph.Point

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.