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

32
LINES

< > BotCompany Repo | #1011120 // webFromTriple

JavaX fragment (include)

1  
static Web webFromTriple(CharSequence a, CharSequence b, CharSequence c) {
2  
  ret webFromTriple(triple(symbol(a), symbol(b), symbol(c)));
3  
}
4  
5  
static Web webFromTriple(Triple<Symbol> t) {
6  
  if (t == null) null;
7  
  ret webFromTriple(t, 0.2, 0.2, 0.8, 0.7);
8  
}
9  
10  
static Web webFromTriple(Triple<Symbol> t, double x1, double y1, double x2, double y2) {
11  
  if (t == null) null;
12  
  Web web = webWithoutIndexAndLock(); // save space
13  
  S a = unnull(str(t.a)), b = unnull(str(t.b)), c = unnull(str(t.c));
14  
  
15  
  // ensure we are making 3 nodes, even if texts are identical
16  
  // ("singular is singular")
17  
  WebNode nodeA = web.newNode(a), nodeC = web.newNode(c);
18  
  web_addRelation(nodeA, nodeC, b);
19  
  
20  
  web_setPosition(first(web.nodes), x1, y1);
21  
  web_setPosition(second(web.nodes), x2, y2);
22  
  
23  
  if (t instanceof TripleWeb) {
24  
    TripleWeb w = cast t;
25  
    web.globalID = w.globalID();
26  
    web.created = w.created();
27  
    web.source = w.source();
28  
    web.unverified = w.unverified();
29  
  }
30  
  
31  
  ret web;
32  
}

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: 559 / 579
Version history: 20 change(s)
Referenced in: [show references]