forked from sbgn/libsbgn
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathWriteExampleAnnotation.java
More file actions
77 lines (58 loc) · 1.78 KB
/
WriteExampleAnnotation.java
File metadata and controls
77 lines (58 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package org.sbgn;
import org.sbgn.bindings.*;
import org.sbgn.bindings.Glyph.Callout;
import javax.xml.bind.JAXBException;
import java.io.File;
public class WriteExampleAnnotation
{
public static void main(String[] args) throws JAXBException
{
File f = new File ("test-output.sbgn");
Sbgn sbgn = new Sbgn();
Map map = new Map();
map.setLanguage("process description");
sbgn.getMap().add(map);
// create a glyph with an id and class "macromolecule"
Glyph g1 = new Glyph();
g1.setId("g1");
g1.setClazz("macromolecule");
// create a glyph with an id and class "annotation"
Glyph g2 = new Glyph();
g2.setId("g2");
g2.setClazz("annotation");
Callout callout = new Callout();
callout.setTarget(g1);
Point point = new Point();
point.setX(160);
point.setY(200);
callout.setPoint(point);
g2.setCallout(callout);
// add the glyph to the map
map.getGlyph().add(g1);
map.getGlyph().add(g2);
// define the bounding box of the glyph
Bbox bbox1 = new Bbox();
bbox1.setX(90);
bbox1.setY(160);
bbox1.setW(380);
bbox1.setH(210);
g1.setBbox(bbox1);
// define the bounding box of the annotation
Bbox bbox2 = new Bbox();
bbox2.setX(5);
bbox2.setY(5);
bbox2.setW(220);
bbox2.setH(125);
g2.setBbox(bbox2);
// define a label for this glyph
org.sbgn.bindings.Label label1 = new org.sbgn.bindings.Label();
label1.setText("LABEL");
g1.setLabel(label1);
// define a label for this annotation
org.sbgn.bindings.Label label2 = new org.sbgn.bindings.Label();
label2.setText("INFO");
g2.setLabel(label2);
// now write everything to disk
SbgnUtil.writeToFile(sbgn, f);
}
}