MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / drawNow

Method drawNow

src/main/java/fieldbox/boxes/plugins/Viewport.java:347–420  ·  view source on GitHub ↗
(DrawingInterface context)

Source from the content-addressed store, hash-verified

345 if (c != null) {
346 c.advanceState(x -> {
347 Rect f = this.properties.get(Box.frame);
348 x.aspect = f.w / f.h;
349 return x;
350 });
351 }
352
353 try (Util.ExceptionlessAutoClosable s = GraphicsContext.getContext().stateTracker.save()) {
354
355 Rect f = this.properties.get(Box.frame);
356
357 boolean clips = this.properties.isTrue(Viewport.clips, true);
358 Optional<Drawing> od = this.first(Drawing.drawing);
359
360 // TODO, blast radius of change to DrawingInterface? Viewports cannot clip properly on non-window renderers
361 Vec2 tl = od.get().drawingSystemToWindowSystem(new Vec2(f.x, f.y));
362 Vec2 bl = od.get().drawingSystemToWindowSystem(new Vec2(f.x + f.w, f.y + f.h));
363
364 FieldBoxWindow window = this.first(Boxes.window).get();
365 int h = window.getHeight();
366 int w = window.getWidth();
367 float rs = window.getRetinaScaleFactor();
368 int[] v = new int[]{(int) ((int) tl.x * rs) + 5 + 10, (int) ((int) (h - bl.y) * rs) + 3 + 13, (int) ((int) (bl.x - tl.x + 2) * rs) - 9 - 20, (int) ((int) (bl.y - tl.y + 2) * rs - 12 - 18)};
369
370 if (clips) {
371 GraphicsContext.getContext().stateTracker.scissor.set(v);
372 GraphicsContext.getContext().stateTracker.viewport.set(v);
373 }
374
375 Map<String, Supplier<FLine>> q = breadthFirst(downwards()).filter(x -> x.properties.has(lines3))
376 .flatMap(x -> x.properties.get(lines3)
377 .entrySet()
378 .stream())
379 .collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue(), (old, n) -> old));
380 Map<String, Supplier<Collection<Supplier<FLine>>>> q2 = breadthFirst(downwards()).filter(x -> x.properties.has(bulkLines3))
381 .flatMap(x -> x.properties.get(bulkLines3)
382 .entrySet()
383 .stream())
384 .collect(Collectors.toMap(x -> x.getKey(), x -> x.getValue(), (old, n) -> old));
385
386 standard.lines_builder.open();
387 standard.triangles_builder.open();
388 standard.points_builder.open();
389
390 try {
391 q.values()
392 .stream()
393 .map(x -> x.get())
394 .filter(x -> x != null)
395 .forEach(x -> StandardFLineDrawing.dispatchLine(x, standard.triangles_builder, standard.lines_builder, standard.points_builder, Optional.empty(), ""));
396 q2.values()
397 .stream()
398 .map(x -> x.get())
399 .filter(x -> x != null)
400 .flatMap(x -> x.stream())
401 .filter(x -> x != null)
402 .map(x -> x.get())
403 .filter(x -> x != null)
404 .forEach(x -> StandardFLineDrawing.dispatchLine(x, standard.triangles_builder, standard.lines_builder, standard.points_builder, Optional.empty(), ""));

Callers

nothing calls this directly

Calls 15

advanceStateMethod · 0.95
getContextMethod · 0.95
dispatchLineMethod · 0.95
updateAllMethod · 0.95
isTrueMethod · 0.80
firstMethod · 0.80
getRetinaScaleFactorMethod · 0.80
collectMethod · 0.80
breadthFirstMethod · 0.80
downwardsMethod · 0.80
emptyMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected