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 package org.utgenome.config;
26
27 import java.util.ArrayList;
28 import java.util.HashSet;
29 import java.util.List;
30 import java.util.Set;
31
32 import org.utgenome.gwt.utgb.client.view.TrackView;
33
34
35
36
37
38
39
40 public class OldViewXML {
41
42 public static class Prop {
43 public String key;
44 public String value;
45 }
46
47 public static class TrackGroup {
48
49 public String className;
50
51 public GroupProperties groupProperties = new GroupProperties();
52 public List<Prop> property = new ArrayList<Prop>();
53 public List<Track> track = new ArrayList<Track>();
54
55 public String getProperty(String key) {
56 for (Prop p : groupProperties.property) {
57 if (p.key != null && p.key.equals(key)) {
58 return p.value;
59 }
60 }
61 return null;
62 }
63
64 public Set<String> propKeySet() {
65 HashSet<String> keySet = new HashSet<String>();
66 for (Prop p : groupProperties.property) {
67 if (p.key != null) {
68 keySet.add(p.key);
69 }
70 }
71 return keySet;
72 }
73
74 }
75
76 public static class GroupProperties {
77 public List<Prop> property = new ArrayList<Prop>();
78 public TrackWindow trackWindow = new TrackWindow();
79 }
80
81 public static class TrackWindow {
82 public int start;
83 public int end;
84 public int width;
85 }
86
87 public static class Track {
88
89 public String name;
90 public String className;
91 public int height;
92 public boolean pack;
93
94 public List<Prop> property = new ArrayList<Prop>();
95 }
96
97 public TrackGroup trackGroup;
98
99 public TrackView toTrackView() {
100 TrackView v = new TrackView();
101 v.trackGroup.class_ = trackGroup.className;
102 v.trackGroup.id = 1;
103
104
105 TrackView.Coordinate c = new TrackView.Coordinate();
106 c.start = trackGroup.groupProperties.trackWindow.start;
107 c.end = trackGroup.groupProperties.trackWindow.end;
108 c.species = trackGroup.getProperty("species");
109 c.ref = trackGroup.getProperty("revision");
110 c.chr = trackGroup.getProperty("target");
111
112 c.pixelWidth = trackGroup.groupProperties.trackWindow.width;
113
114 v.trackGroup.coordinate = c;
115 for (Prop p : trackGroup.property) {
116 v.trackGroup.property.put(p.key, p.value);
117 }
118 for (String key : trackGroup.propKeySet()) {
119 if (key == null)
120 continue;
121
122 if (key.equals("species") || key.equals("revision") || key.equals("target"))
123 continue;
124
125 String val = trackGroup.getProperty(key);
126 v.trackGroup.property.put(key, val);
127 }
128
129 for (Track each : trackGroup.track) {
130 TrackView.Track t = new TrackView.Track();
131 t.name = each.name;
132 t.height = each.height;
133 t.pack = each.pack;
134 t.class_ = each.className;
135 if (t.class_.startsWith("org.utgenome.gwt.utgb.client.track.lib."))
136 t.class_ = t.class_.replace("org.utgenome.gwt.utgb.client.track.lib.", "");
137
138 for (Prop p : each.property) {
139 t.property.put(p.key, p.value);
140 }
141
142 v.track.add(t);
143 }
144
145 return v;
146 }
147 }