Wiki source code of HTTP-based Service
Version 14.6 by uru on 2023/07/11 10:33
Show last authors
author | version | line-number | content |
---|---|---|---|
1 | A simple HTTP POST request is used to send the input graph and retrieve its the layouted version. You can just perform your own request to the correct URL and pass all required information. However, as we might change internal APIs we recommend you to use the (very small) wrapper implementations we provide for a specific language. We do not provide a wrapper for each language, feel free to write your own and contact us so we can add it to the list below. | ||
2 | |||
3 | {{info}} | ||
4 | You might want to have a look at the //Live// section of our exemplary server at [[http:~~/~~/layout.rtsys.informatik.uni-kiel.de:9444>>url:http://layout.rtsys.informatik.uni-kiel.de:9444||shape="rect"]] to play around. | ||
5 | {{/info}} | ||
6 | |||
7 | = Language Bindings = | ||
8 | |||
9 | Each zip archive contains the wrapper class you can use to call our service as well as a small example illustrating the usage pattern for the specific language. | ||
10 | |||
11 | * [[JavaScript>>attach:JavaScript-0.1.0.zip]] | ||
12 | * [[Java>>attach:Java-0.1.0.zip]] | ||
13 | * [[C#>>attach:C#-0.1.0.zip]] | ||
14 | * [[Python>>attach:Python-0.1.0.zip]] | ||
15 | |||
16 | = Examples = | ||
17 | |||
18 | The graph is passed in serialized form of either graph format. In this example we use the JSON format (for JavaScript also native JSON can be passed). | ||
19 | |||
20 | {{code title="graph"}} | ||
21 | "{id:\"root\",children:[{id:\"n1\",labels:[{text:\"n1\"}],width:100,height:100}," | ||
22 | + "{id:\"n2\",labels:[{text:\"n2\"}],width:100,height:50,children:[{id:\"n3\"," | ||
23 | + "labels:[{text:\"n3\"}],width:20,height:20},{id:\"n4\",labels:[{text:\"n4\"}],width:20," | ||
24 | + "height:20}],edges:[{id:\"e4\",source:\"n3\",target:\"n4\"}]}]," | ||
25 | + "edges:[{id:\"e1\",source:\"n1\",target:\"n2\"}]}"; | ||
26 | {{/code}} | ||
27 | |||
28 | {{code title="options"}} | ||
29 | spacing: 100 | ||
30 | algorithm: "de.cau.cs.kieler.klay.layered" | ||
31 | edgeRouting: ORTHOGONAL | ||
32 | {{/code}} | ||
33 | |||
34 | === JavaScript === | ||
35 | |||
36 | {{code language="js"}} | ||
37 | var graph = "[graph]"; | ||
38 | var options = { opt1: val1 }; | ||
39 | $.kielerLayout({graph: graph, options: options, | ||
40 | iFormat: 'org.json', oFormat: 'org.json', | ||
41 | success : function (data) { | ||
42 | console.log(data); | ||
43 | } | ||
44 | }); | ||
45 | {{/code}} | ||
46 | |||
47 | === Java === | ||
48 | |||
49 | {{code language="java"}} | ||
50 | String graph = "[graph]"; | ||
51 | Map<String, Object> opts = new HashMap<String, Object>(); | ||
52 | String layouted = KIELERLayout.layout(server, "org.json", "org.json", options, graph); | ||
53 | {{/code}} | ||
54 | |||
55 | === C# === | ||
56 | |||
57 | {{code language="c#"}} | ||
58 | String graph = "[graph]"; | ||
59 | Dictionary<String, Object> options = new Dictionary<String, Object>(); | ||
60 | String layouted = KIELER.KIELERLayout.layout(server, "org.json", "org.json", options, graph); | ||
61 | {{/code}} | ||
62 | |||
63 | = Available Layout Algorithms and Options = | ||
64 | |||
65 | The available layout algorithms along with the available options and some further information can be requested under the following URL. A JSON object is returned, the structure and contained data equals the //ServiceData// class in the diagram shown below. Furthermore, several algorithms offer a //preview image// illustration a possible result. You can retrieve this image as a png using the second URL. Optionally the image can be retrieved base64 encoded. | ||
66 | |||
67 | {{noformat}} | ||
68 | http://layout.rtsys.informatik.uni-kiel.de:9444/layout/serviceData | ||
69 | |||
70 | http://layout.rtsys.informatik.uni-kiel.de:9444/layout/previewImage/[imgPath][?base64=true] | ||
71 | {{/noformat}} | ||
72 | |||
73 | [[image:attach:ServiceData.png]] | ||
74 | |||
75 | \\ |