/** * Generate a random {@link PolyLine} within bounds. * * @param numberPoints * The number of points in the {@link PolyLine} * @param bounds * The bounds for the points to be in * @return The random {@link PolyLine} */ public static PolyLine random(final int numberPoints, final Rectangle bounds) { final List<Location> locations = new ArrayList<>(); IntStream.range(0, numberPoints).forEach(index -> locations.add(Location.random(bounds))); return new PolyLine(locations); }
/** * Generate a random polygon within bounds. * * @param numberPoints * The number of points in the polygon * @param bounds * The bounds for the points to be in * @return The random {@link Polygon} */ public static Polygon random(final int numberPoints, final Rectangle bounds) { final List<Location> locations = new ArrayList<>(); IntStream.range(0, numberPoints).forEach(index -> locations.add(Location.random(bounds))); return new Polygon(locations); }
private static ChangeItem generateChangeItem(final ItemType type, final ChangeAction action) { final List<Location> locations = new ArrayList<>(); switch (type) { case AREA: case LINE: case EDGE: final int size = 2 + RANDOM_GENERATOR.nextInt(50); for (int i = 0; i < size; i++) { locations.add(Location.random(Rectangle.MAXIMUM)); } break; case POINT: case NODE: default: locations.add(Location.random(Rectangle.MAXIMUM)); } return new SimpleChangeItem(-1 * NEW_ITEM_IDENTIFIER++, randomString(), type, action, locations, RandomTagsSupplier.randomTags(5)); }
while (nodes.size() < 10) nodes.add(Location.random(bounds));
for (long i = 0; i < estimates.getNodeNumber(); i++) final Location geometry = Location.random(bounds); builder.addNode(startIdentifiers.getNodeStartIdentifier() + i, geometry, RandomTagsSupplier.randomTags(5)); final PolyLine geometry = new PolyLine(tips[0], Location.random(bounds), Location.random(bounds), Location.random(bounds), tips[1]); builder.addEdge(startIdentifiers.getEdgeStartIdentifier() + i, geometry, RandomTagsSupplier.randomTags(5)); final Location geometry = Location.random(bounds); builder.addPoint(startIdentifiers.getPointStartIdentifier() + i, geometry, RandomTagsSupplier.randomTags(5));
builder.addPoint(getNextIdentifier(), Location.random(Rectangle.MAXIMUM), randomTags);