srecord noeq G22JavaObjectVisualizer(G22Utils g22utils) is Swingable { settable bool withTypeAndTime = true; settable bool singleLineLayout; // TODO transient settable O object; transient settable long nanos = -1; *(G22Utils *g22utils, O *object) {} cachedVisualize { JComponent c; S type = null; try { c = visualize2(object); if (withTypeAndTime) type = shortClassName(object); } catch e { c = jErrorView(e); type = "Error"; } if (withTypeAndTime) { S timeDesc = nanos < 0 ? "" : formatElapsedTimeWithAppropriateUnit(nanosToSeconds(nanos)); c = northAndCenterWithMargins( westAndEastWithMargin( withLabel("Result type:", jlabel(type)), empty(timeDesc) ? jpanel() : withLabel("Execution time:", jlabel(timeDesc))), ), c); } ret c; } JComponent visualize2(O object) { if (object cast Throwable) ret jErrorView(object); if (object == null || eq(object, "")) ret jpanel(); if (object cast Int) object = toLong(object); if (object cast Long) ret fontSizePlus(10, jcenteredLabel(n2(object))); if (object cast Number) ret fontSizePlus(10, jcenteredLabel(str(object))); if (object cast MakesBufferedImage) object = toBufferedImage(object); if (object cast BufferedImage) ret jscroll_centered_borderless(g22utils.stdImageSurface(object)); ret jcenteredlabel(shorten(str(object))); } }