@Override
  public void populate(SquareWithCircles square, Location referenceLocation) {
    // set up fuse
    int idx = square.depth() <= 6 ? square.depth() : 6;
    Location topLeft = square.square.getTopLeft();

    // {{ compute min and max coords
    int minx = (int) topLeft.x();
    int miny = (int) topLeft.y() - square.square.getWidth() + CIRCE_RADIUS_BY_DEPTH[idx];
    int maxx = (int) topLeft.x() + square.square.getWidth() - CIRCE_RADIUS_BY_DEPTH[idx];
    int maxy = (int) topLeft.y();
    // }}

    // {{ compute location bounds
    Location minLocation = new Location(minx, miny, 0, DistanceUnit.LIGHT_YEAR);
    Location maxLocation = new Location(maxx, maxy, 0, DistanceUnit.LIGHT_YEAR);
    // }}

    // populate 1 new circle per square
    // square.circles.add(new Circle(minLocation, CIRCE_RADIUS_BY_DEPTH[idx]));
    // square.circles.add(new Circle(maxLocation, CIRCE_RADIUS_BY_DEPTH[idx]));
    Location randomLocation = new RandomLocation(minLocation, maxLocation, square.random);
    square.circles.add(new Circle(randomLocation, CIRCE_RADIUS_BY_DEPTH[idx]));
    /*for (int count = 1; count <= 1; count++) {
    	Location randomLocation = new RandomLocation(minLocation,
    			maxLocation, square.random);
    	square.circles.add(new Circle(randomLocation,
    			CIRCE_RADIUS_BY_DEPTH[idx]));
    }*/
  }
Ejemplo n.º 2
0
  /*
   * (non-Javadoc)
   *
   * @see com.cohesiva.drifter.split.containers.Container#
   * computeContainerIndexAfterSplit(com.cohesiva.drifter.common.IStellar)
   */
  @Override
  protected int computeContainerIndexAfterSplit(IStellar element) {
    int index = 0;

    Location planeCenter = this.bounds().center();
    Location planarLocation = element.locate();

    if (planarLocation.x() > planeCenter.x()) index |= 1;
    if (planarLocation.y() > planeCenter.y()) index |= 2;

    return index;
  }