sclass CirclesRelater extends MouseAdapter { Canvas canvas; CirclesAndLines cal; Circle circle; Pt p; bool popupTrigger; componentPopupMenu_Adapter popup; int minDist = 20; *(Canvas *canvas, CirclesAndLines *cal) { if (containsInstance(canvas.tools, CirclesRelater)) ret; canvas.tools.add(this); canvas.addMouseListener(this); canvas.addMouseMotionListener(this); popup = findMouseListener(canvas, componentPopupMenu_Adapter); canvas.removeMouseListener(popup); } public void mousePressed(MouseEvent e) { popupTrigger = e.isPopupTrigger(); if (e.getButton() != MouseEvent.BUTTON1) circle = findCircle(p = canvas.pointFromEvent(e)); else circle = null; } public void mouseDragged(MouseEvent e) { } public void mouseReleased(MouseEvent e) { Pt pt = canvas.pointFromEvent(e); int d = (int) pointDistance(p, pt); print("Dist: " + d); if (circle == null || d < minDist) { if (popupTrigger && popup != null) popup.displayMenu2(e); ret; } if (circle != null) { final Circle circle2 = findCircle(pt); final Circle circle1 = circle; if (circle1 != circle2 && circle2 != null) { final JTextField tf = jTextField(); showFormTitled("Link nodes", "Node 1", circle1.text, "Connection Name", tf, "Node 2", circle2.text, r { cal.arrow(circle1, toUpper(getTextTrim(tf)), circle2); canvas.update(); }); } } circle = null; } Circle findCircle(Pt p) { ret cal.findCircle(canvas, p); } }
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1007778 |
Snippet name: | CirclesRelater |
Eternal ID of this version: | #1007778/20 |
Text MD5: | 31e761655b114016901a01f2f4a95d27 |
Author: | stefan |
Category: | javax / a.i. / gui |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2017-08-27 19:39:21 |
Source code size: | 1655 bytes / 56 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 553 / 1157 |
Version history: | 19 change(s) |
Referenced in: | #1034167 - Standard Classes + Interfaces (LIVE, continuation of #1003674) |