asclass ImageSurfaceMouseHandler > MouseAdapter is AutoCloseable { ImageSurface is; void register(ImageSurface is) { this.is = is; is.tools.add(this); is.addMouseListener(this); is.addMouseMotionListener(this); } close { if (is == null) ret; is.tools.remove(this); is.removeMouseListener(this); is.removeMouseMotionListener(this); is = null; } Pt getPt(MouseEvent e) { ret toPt(getPoint(e)); } Point getPoint(MouseEvent e) { ret new Point((int) (e.getX()/is.getZoomX()), (int) (e.getY()/is.getZoomY())); } ImageSurface getImageSurface() { ret is; } }