static ImageSurface showImageWithSelections(RGBImage img, final L rects) { ret showImageWithSelections(img.getBufferedImage(), rects); } static ImageSurface showImageWithSelections(BufferedImage img, final L rects) { ret showImageWithSelections(img, null, rects); } // for callers to use static Var showImageWithSelections_highlighted; static ImageSurface showImageWithSelections(BufferedImage img, ImageSurface _is, final L _rects) { final ImageSurface is = showImage(img, _is); final L rects = cloneList(_rects); final new Var highlighted; showImageWithSelections_highlighted = highlighted; final new Var lastHighlighted; is.overlay = voidfunc(Graphics2D g) { for (Rect r : rects) is.drawSelectionRect(g, r.getRectangle(), Color.blue, Color.white); if (highlighted.has()) { g.setColor(Color.black); Rect r = scaleRect(highlighted.get(), is.getZoomX(), is.getZoomY()); g.fillRect(r.x, r.y, r.w, r.h); } }; imageSurfaceOnMouseMove(is, voidfunc(Pt p) { Rect h = null; if (p != null) for (Rect r : rects) if (r.contains(p)) { h = r; break; } if (neq(h, highlighted.get())) { highlighted.set(h); if (h != null) lastHighlighted.set(h); is.repaint(); } }); /*componentPopupMenu(is, voidfunc(JPopupMenu menu) { if (highlighted.has()) addMenuItem(menu, "Send selection to " + snippetWithTitle("#1005726"), r { sendImageToProgram(clipBufferedImage(is.getImage(), lastHighlighted.get().getRectangle()), "#1005726"); }); });*/ is.repaint(); ret is; }