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

56
LINES

< > BotCompany Repo | #1007778 // CirclesRelater

JavaX fragment (include)

1  
sclass CirclesRelater extends MouseAdapter {
2  
  Canvas canvas;
3  
  CirclesAndLines cal;
4  
  Circle circle;
5  
  Pt p;
6  
  bool popupTrigger;
7  
  componentPopupMenu_Adapter popup;
8  
  int minDist = 20;
9  
10  
  *(Canvas *canvas, CirclesAndLines *cal) {
11  
    if (containsInstance(canvas.tools, CirclesRelater)) ret;
12  
    canvas.tools.add(this);
13  
    canvas.addMouseListener(this);
14  
    canvas.addMouseMotionListener(this);
15  
    
16  
    popup = findMouseListener(canvas, componentPopupMenu_Adapter);
17  
    canvas.removeMouseListener(popup);
18  
  }
19  
20  
  public void mousePressed(MouseEvent e) {
21  
    popupTrigger = e.isPopupTrigger();
22  
    if (e.getButton() != MouseEvent.BUTTON1)
23  
      circle = findCircle(p = canvas.pointFromEvent(e));
24  
    else circle = null;
25  
  }
26  
27  
  public void mouseDragged(MouseEvent e) {
28  
  }
29  
30  
  public void mouseReleased(MouseEvent e) {
31  
    Pt pt = canvas.pointFromEvent(e);
32  
    int d = (int) pointDistance(p, pt);
33  
    print("Dist: " + d);
34  
    if (circle == null || d < minDist) {
35  
      if (popupTrigger && popup != null) popup.displayMenu2(e);
36  
      ret;
37  
    }
38  
    if (circle != null) {
39  
      final Circle circle2 = findCircle(pt);
40  
      final Circle circle1 = circle;
41  
      if (circle1 != circle2 && circle2 != null) {
42  
        final JTextField tf = jTextField();
43  
        showFormTitled("Link nodes",
44  
          "Node 1", circle1.text,
45  
          "Connection Name", tf,
46  
          "Node 2", circle2.text, r {
47  
            cal.arrow(circle1, toUpper(getTextTrim(tf)), circle2);
48  
            canvas.update();
49  
          });
50  
      }
51  
    }
52  
    circle = null;
53  
  }
54  
  
55  
  Circle findCircle(Pt p) { ret cal.findCircle(canvas, p); }
56  
}

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: 552 / 1156
Version history: 19 change(s)
Referenced in: [show references]