sclass ImageSurfaceWithXMarkers extends ImageSurface { new L markers; Runnable onMarkersChanged; *(BufferedImage img, Collection _markers) { super(img); addAll(this.markers, allToFloat(_markers)); overlay = voidfunc(Graphics2D g) { g.setColor(Color.red); for (float x : markers) { Pt p = pointToComponentCoordinates(x, 0); g.drawLine(p.x, 0, p.x, getHeight()-1); } }; disableImageSurfaceSelector(this); imageSurfaceOnMouseDrag(this, new VF1 { Float marker; public void get(Pt p) { if (p == null) ret with marker = null; Pt pComponent = pointToComponentCoordinates(p.x, p.y); if (pointFarOutsideOfComponent(ImageSurfaceWithXMarkers.this, pComponent) || pointOutsideOfImage(image, p)) { if (marker != null) { markers.remove(marker); fireMarkersChanged(); _print("Markers: " + l(markers)); } ret with marker = null; } if (marker == null) marker = floatCloseTo(markers, p.x, 2/zoomX); Float m = marker; marker = (float) p.x; if (m == null) { markers.add(marker); _print("Markers: " + l(markers)); } else replaceElementOnce(markers, m, marker); fireMarkersChanged(); } }); } void fireMarkersChanged { repaint(); pcallF(onMarkersChanged); } }