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

47
LINES

< > BotCompany Repo | #1012305 // WebNode v2 with L<Lisp>

JavaX fragment (include)

1  
sclass WebNode implements _SetField {
2  
  Web web;
3  
  new L<Lisp> labels;
4  
  O visInfo; // visualisation info
5  
  
6  
  public void _setField(S f, O x) {
7  
    if (f.equals('web)) web = (Web) x;
8  
    else if (f.equals('labels)) labels = (L) x;
9  
    else if (f.equals('visInfo)) visInfo = x;
10  
  }
11  
  
12  
  *() {}
13  
  *(Web *web) { web.fireNewNode(this); }
14  
  
15  
  void addLabel(S label) { addLabel(web.parseLabel(label)); }
16  
  
17  
  void addLabel(Lisp label) {
18  
    if (setAdd(labels, label) && web != null)
19  
      web.index(label, this);
20  
  }
21  
  
22  
  void addLabels(Collection<Lisp> l) { for (Lisp lbl : l) addLabel(lbl); }
23  
  void addStrings(Collection<S> l) { for (S lbl : l) addLabel(lbl); }
24  
  
25  
  bool hasLabel(Lisp label) { ret labels.contains(label); }
26  
  bool hasLabel(S label) { ret labels.contains(web.parseLabel(label)); }
27  
  
28  
  toString { ret l(labels) == 1 ? str(first(labels)) : str(labels); }
29  
  
30  
  int count() { ret 1 + l(labels); }
31  
  S text() { ret web.unparseLabel(first(labels)); }
32  
  L<S> texts() { ret web.unparseLabels(labels); }
33  
  
34  
  void relation(S arrow, S b) {
35  
    web.getRelation(this, web.node(b)).addLabel(arrow);
36  
  }
37  
  
38  
  Lisp parseLabel(S l) { ret web.parseLabel(l); }
39  
  S unparseLabel(Lisp l) { ret web.unparseLabel(l); }
40  
  
41  
  L<Lisp> labels() { ret labels; }
42  
  bool hasLabels() { ret nempty(labels); }
43  
  void setLabel(int i, Lisp l) { labels.set(i, l); }
44  
  
45  
  O visInfo() { ret visInfo; }
46  
  void visInfo(O o) { visInfo = o; }
47  
}

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: #1012305
Snippet name: WebNode v2 with L<Lisp>
Eternal ID of this version: #1012305/4
Text MD5: 45e5e31689631ab2dc5e6fb49b7e33fb
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-27 17:46:00
Source code size: 1470 bytes / 47 lines
Pitched / IR pitched: No / No
Views / Downloads: 364 / 984
Version history: 3 change(s)
Referenced in: [show references]