コード例 #1
0
ファイル: ColorWorld.java プロジェクト: zlongshen/mason
  @Override
  public void start() {
    super.start();

    agents.clear(); // remove any agents from previous runs

    // add agents to the simulation
    addAgents();

    // ensure both GeomFields Color same area
    agents.setMBR(county.getMBR());
  }
コード例 #2
0
  private void createHouseholds() {
    // create households
    households.clear();
    householdsField.clear();
    householdsField.setMBR(highSchoolZones.getMBR());

    Envelope bounds = highSchoolZones.getMBR();

    // this is needed because
    Geometry exemplar = ((MasonGeometry) highSchoolZones.getGeometries().get(0)).getGeometry();

    for (int i = 0; i < numHouseholds; i++) {
      Household h = new Household(this);
      households.add(h);
      Coordinate coord;
      do {
        coord = getRandomCoordinate(bounds);
      } while (!highSchoolZones.isCovered(coord));

      Point pt = GeometryFactory.createPointFromInternalCoord(coord, exemplar);
      h.location = pt;
      householdsField.addGeometry(new MasonGeometry(pt));
    }
  }