Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

28
LINES

< > BotCompany Repo | #1033786 // ImageSurfaceMouseHandler

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (26706L/168K).

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; }
}

Author comment

Began life as a copy of #1033785

download  show line numbers  debug dex  old transpilations   

Travelled to 4 computer(s): bhatertpkbcr, ekrmjmnbrukm, mowyntqkapby, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033786
Snippet name: ImageSurfaceMouseHandler
Eternal ID of this version: #1033786/6
Text MD5: 2f9942fce5721adbb32642d1a55d8fd2
Transpilation MD5: f42ea2d530f6780d807996e7d889c4e3
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-02-15 22:18:10
Source code size: 654 bytes / 28 lines
Pitched / IR pitched: No / No
Views / Downloads: 115 / 205
Version history: 5 change(s)
Referenced in: [show references]