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

32
LINES

< > BotCompany Repo | #1011120 // webFromTriple

JavaX fragment (include)

static Web webFromTriple(CharSequence a, CharSequence b, CharSequence c) {
  ret webFromTriple(triple(symbol(a), symbol(b), symbol(c)));
}

static Web webFromTriple(Triple<Symbol> t) {
  if (t == null) null;
  ret webFromTriple(t, 0.2, 0.2, 0.8, 0.7);
}

static Web webFromTriple(Triple<Symbol> t, double x1, double y1, double x2, double y2) {
  if (t == null) null;
  Web web = webWithoutIndexAndLock(); // save space
  S a = unnull(str(t.a)), b = unnull(str(t.b)), c = unnull(str(t.c));
  
  // ensure we are making 3 nodes, even if texts are identical
  // ("singular is singular")
  WebNode nodeA = web.newNode(a), nodeC = web.newNode(c);
  web_addRelation(nodeA, nodeC, b);
  
  web_setPosition(first(web.nodes), x1, y1);
  web_setPosition(second(web.nodes), x2, y2);
  
  if (t instanceof TripleWeb) {
    TripleWeb w = cast t;
    web.globalID = w.globalID();
    web.created = w.created();
    web.source = w.source();
    web.unverified = w.unverified();
  }
  
  ret web;
}

Author comment

Began life as a copy of #1010397

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1011120
Snippet name: webFromTriple
Eternal ID of this version: #1011120/21
Text MD5: da3293795b9cb0dcf45071ff64c44c0d
Author: stefan
Category: javax / a.i.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-12-26 05:44:45
Source code size: 1014 bytes / 32 lines
Pitched / IR pitched: No / No
Views / Downloads: 480 / 500
Version history: 20 change(s)
Referenced in: [show references]