@@ -0,0 +1,1702 @@
+package infn.bed.util;%0A%0Aimport infn.bed.geometry.GeometricConstants;%0A%0Aimport java.awt.geom.Rectangle2D;%0Aimport java.util.ArrayList;%0A%0A/**%0A * Dynamically populates a world.%0A *%0A * @author Angelo Licastro%0A */%0Apublic class DynamicPopulator %7B%0A%09%0A%09/**%0A%09 * Returns a dynamically populated world.%0A%09 * %0A%09 * @param worldRectangle The world (a Rectangle2D.Double object) to dynamically populate.%0A%09 * @return An ArrayList of Rectangle2D.Double objects that form a dynamically populated world.%0A%09 * The position of each Rectangle2D.Double is relative to the position of worldRectangle.%0A%09 */%0A%09public static ArrayList%3CRectangle2D.Double%3E getDynamicallyPopulatedWorld(Rectangle2D.Double worldRectangle) %7B%0A%09%09if ((GeometricConstants.CHANNELS %25 GeometricConstants.ROWS) == 0) %7B%0A%09%09%09ArrayList%3CRectangle2D.Double%3E dynamicallyPopulatedWorldRectangle = new ArrayList%3C%3E(GeometricConstants.CHANNELS);%0A%09%09%09double horizontalAdjustmentFactor = worldRectangle.getMinX();%0A%09%09%09double verticalAdjustmentFactor = worldRectangle.getMinY();%0A%09%09%09double itemWidth = worldRectangle.getWidth() / GeometricConstants.COLUMNS;%0A%09%09%09double itemHeight = worldRectangle.getHeight() / GeometricConstants.ROWS;%0A%09%09%09double x;%0A%09%09%09double y;%0A%09%09%09for (int i = 0; i %3C GeometricConstants.ROWS; i++) %7B%0A%09%09%09%09y = verticalAdjustmentFactor + (worldRectangle.getHeight() / GeometricConstants.ROWS) * i;%0A%09%09%09%09for (int j = 0; j %3C GeometricConstants.COLUMNS; j++) %7B%0A%09%09%09%09%09x = horizontalAdjustmentFactor + (worldRectangle.getWidth() / GeometricConstants.COLUMNS) * j;%0A%09%09%09%09%09dynamicallyPopulatedWorldRectangle.add(new Rectangle2D.Double(x, y, itemWidth, itemHeight));%0A%09%09%09%09%7D%0A%09%09%09%7D%0A%09%09%09return dynamicallyPopulatedWorldRectangle;%0A%09%09%7D else %7B%0A%09%09%09throw new ArithmeticException();%0A%09%09%7D%0A%09%7D%0A%0A%7D%0A

Add DynamicPopulator