sclass ImageSurfaceWithXMarkers extends ImageSurface { new L<Float> markers; Runnable onMarkersChanged; *(BufferedImage img, Collection<? extends Number> _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<Pt> { 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); } }
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1018714 |
Snippet name: | ImageSurfaceWithXMarkers |
Eternal ID of this version: | #1018714/25 |
Text MD5: | 9b3c4b4661847304091f7ef5ced00dfa |
Author: | stefan |
Category: | javax / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2018-10-14 12:35:26 |
Source code size: | 1511 bytes / 48 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 354 / 934 |
Version history: | 24 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |