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)

sclass WebNode implements _SetField {
  Web web;
  new L<Lisp> labels;
  O visInfo; // visualisation info
  
  public void _setField(S f, O x) {
    if (f.equals('web)) web = (Web) x;
    else if (f.equals('labels)) labels = (L) x;
    else if (f.equals('visInfo)) visInfo = x;
  }
  
  *() {}
  *(Web *web) { web.fireNewNode(this); }
  
  void addLabel(S label) { addLabel(web.parseLabel(label)); }
  
  void addLabel(Lisp label) {
    if (setAdd(labels, label) && web != null)
      web.index(label, this);
  }
  
  void addLabels(Collection<Lisp> l) { for (Lisp lbl : l) addLabel(lbl); }
  void addStrings(Collection<S> l) { for (S lbl : l) addLabel(lbl); }
  
  bool hasLabel(Lisp label) { ret labels.contains(label); }
  bool hasLabel(S label) { ret labels.contains(web.parseLabel(label)); }
  
  toString { ret l(labels) == 1 ? str(first(labels)) : str(labels); }
  
  int count() { ret 1 + l(labels); }
  S text() { ret web.unparseLabel(first(labels)); }
  L<S> texts() { ret web.unparseLabels(labels); }
  
  void relation(S arrow, S b) {
    web.getRelation(this, web.node(b)).addLabel(arrow);
  }
  
  Lisp parseLabel(S l) { ret web.parseLabel(l); }
  S unparseLabel(Lisp l) { ret web.unparseLabel(l); }
  
  L<Lisp> labels() { ret labels; }
  bool hasLabels() { ret nempty(labels); }
  void setLabel(int i, Lisp l) { labels.set(i, l); }
  
  O visInfo() { ret visInfo; }
  void visInfo(O o) { visInfo = o; }
}

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: 451 / 1070
Version history: 3 change(s)
Referenced in: [show references]