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

Method draw

src/main/java/fieldbox/boxes/FLineDrawing.java:240–341  ·  view source on GitHub ↗
(DrawingInterface context)

Source from the content-addressed store, hash-verified

238
239 // we need to be able to assign blame and propagate exceptions into callbacks
240 @Override
241 public void draw(DrawingInterface context) {
242
243 Util.Errors error = new Util.Errors();
244 Optional<TextDrawing> text = context.getTextDrawing(this);
245
246 this.breadthFirst(this.both())
247 .forEach(Util.wrap(x -> {
248 float ON = x == root ? 1 : (float) Planes.on(root, x);
249 if (ON <= 0) {
250 return;
251 }
252
253
254 Log.log("drawing.trace", () -> "lines for " + x);
255
256 if (x.properties.isTrue(Box.hidden, false)) return;
257
258 String defaultLayer = x.properties.getOr(layer, () -> "__main__");
259
260 Map<String, Function<Box, FLine>> drawing = x.properties.computeIfAbsent(frameDrawing, this::defaultdrawsLines);
261
262 List<FLine> all = new ArrayList<>();
263 Iterator<Function<Box, FLine>> it = drawing.values()
264 .iterator();
265 while (it.hasNext()) {
266 Function<Box, FLine> f = it.next();
267 FLine fl = f.apply(x);
268 if (fl == null) it.remove();
269 else if (fl.nodes.size() > 0) all.add(fl);
270 }
271
272 Log.log("drawing.trace", () -> " --> " + drawing);
273
274 drawing.values()
275 .stream()
276 .map(c -> c.apply(x))
277 .filter(fline -> fline != null)
278 .collect(Collectors.toList())
279 .forEach(fline -> {
280 dispatchLine(fline, context, text, defaultLayer, ON);
281 });
282 Map<String, Supplier<FLine>> ll = x.properties.getOrConstruct(lines);
283
284 all = new ArrayList<>();
285 Iterator<Supplier<FLine>> it2 = ll.values()
286 .iterator();
287 while (it2.hasNext()) {
288 Supplier<FLine> f = it2.next();
289 FLine fl = f.get();
290 if (fl == null) it2.remove();
291 else if (fl.nodes.size() > 0) all.add(fl);
292 }
293
294 Log.log("drawing.trace", () -> " --> " + ll);
295
296 ll.values()
297 .stream()

Callers

nothing calls this directly

Calls 15

wrapMethod · 0.95
onMethod · 0.95
logMethod · 0.95
dispatchLineMethod · 0.95
hasErrorsMethod · 0.95
getErrorsMethod · 0.95
getTextDrawingMethod · 0.80
breadthFirstMethod · 0.80
isTrueMethod · 0.80
getOrMethod · 0.80
computeIfAbsentMethod · 0.80
collectMethod · 0.80

Tested by

no test coverage detected