}
// projector
else {}
final RandomGenerator rng = new MersenneTwister(123);
final Simulator simulator = new Simulator(rng, Measure.valueOf(1000L,
SI.MILLI(SI.SECOND)));
final ImmutableList.Builder<ImmutableList<Point>> pointBuilder = ImmutableList
.builder();
for (final String word : WORDS) {
pointBuilder.add(SwarmDemo.measureString(word, FONT_SIZE, SPACING, 2));
}
final ImmutableList<ImmutableList<Point>> points = pointBuilder.build();
int max = 0;
double xMax = 0;
double yMax = 0;
for (final List<Point> ps : points) {
max = Math.max(max, ps.size());
for (final Point p : ps) {
xMax = Math.max(p.x, xMax);
yMax = Math.max(p.y, yMax);
}
}
int width = DoubleMath.roundToInt(xMax / SPACING, RoundingMode.CEILING);
width += VERTICAL_LINE_SPACING - width % VERTICAL_LINE_SPACING;
width += ((width / VERTICAL_LINE_SPACING) % 2) == 0 ? VERTICAL_LINE_SPACING
: 0;
int height = DoubleMath.roundToInt(yMax / SPACING, RoundingMode.CEILING) + 2;
height += height % 2;
final Graph<?> g = createGrid(width, height, 1, VERTICAL_LINE_SPACING,
SPACING);
final RoadModel roadModel = new BlockingGraphRoadModel(g, SI.METER,
NonSI.KILOMETERS_PER_HOUR);
final PDPModel pdpModel = new DefaultPDPModel();
simulator.register(roadModel);
simulator.register(pdpModel);
final List<Point> borderNodes = newArrayList(getBorderNodes(g));
Collections.shuffle(borderNodes, new Random(123));
simulator.register(new AgvModel(rng, ImmutableList
.<ImmutableList<Point>> builder().addAll(points)
.add(ImmutableList.copyOf(borderNodes))
.build(), getBorderNodes(g)));
simulator.configure();
for (int i = 0; i < NUM_VECHICLES; i++) {
simulator.register(new AGV(rng));
}
simulator.addTickListener(new TickListener() {
@Override
public void tick(TimeLapse time) {
if (time.getStartTime() > endTime) {
simulator.stop();
}
}
@Override
public void afterTick(TimeLapse timeLapse) {}