Skip to content

Commit 19d18d3

Browse files
committed
Changed GenomeStat from normal Java object to Javascript Overlay Type
1 parent 83a669e commit 19d18d3

File tree

2 files changed

+40
-42
lines changed

2 files changed

+40
-42
lines changed

src/main/java/at/gmi/nordborglab/widgets/geneviewer/client/datasource/GenomeStat.java

Lines changed: 36 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,43 +2,50 @@
22

33
import java.util.List;
44

5-
public class GenomeStat {
6-
7-
private final String name;
8-
private final String label;
9-
private final String color;
10-
private final boolean isStepPlot;
11-
private final boolean isStackable;
12-
13-
public GenomeStat(String name,String color,boolean isStackable,boolean isStepPlot,String label) {
14-
this.name = name;
15-
this.color = color;
16-
this.isStackable = isStackable;
17-
this.isStepPlot = isStepPlot;
18-
this.label = label;
19-
}
5+
import com.google.gwt.core.client.JavaScriptObject;
6+
7+
public class GenomeStat extends JavaScriptObject{
208

21-
public String getName() {
22-
return name;
23-
}
249

25-
public String getLabel() {
10+
protected GenomeStat() {}
11+
12+
public final native String getName() /*-{
13+
return this.name;
14+
}-*/;
15+
16+
public final String getDisplayName() {
17+
String label = getLabel();
2618
if (label == null || label.isEmpty())
27-
return name;
19+
return getName();
2820
return label;
2921
}
3022

31-
public String getColor() {
32-
return color;
33-
}
23+
public final native String getLabel() /*-{
24+
if (typeof this.label != 'undefined') {
25+
return this.label;
26+
}
27+
return null;
28+
}-*/;
3429

35-
public boolean isStackable() {
36-
return isStackable;
37-
}
3830

39-
public boolean isStepPlot() {
40-
return isStepPlot;
41-
}
31+
32+
public final native String getColor() /*-{
33+
return this.color;
34+
}-*/;
35+
36+
public final native boolean isStackable() /*-{
37+
if (typeof this.isStackable != 'undefined') {
38+
return this.isStackable;
39+
}
40+
return true;
41+
}-*/;
42+
43+
public final native boolean isStepPlot() /*-{
44+
if (typeof this.isStepPlot != 'undefined') {
45+
return this.isStepPlot;
46+
}
47+
return false;
48+
}-*/;
4249

4350
public static GenomeStat getFromName(List<GenomeStat> stats,String name) {
4451
for (GenomeStat stat: stats) {

src/main/java/at/gmi/nordborglab/widgets/geneviewer/client/datasource/impl/JBrowseDataSourceImpl.java

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import at.gmi.nordborglab.widgets.geneviewer.client.datasource.SearchGeneCallback;
1616

1717
import com.google.gwt.core.client.JsArray;
18+
import com.google.gwt.core.client.JsonUtils;
1819
import com.google.gwt.http.client.Request;
1920
import com.google.gwt.http.client.RequestBuilder;
2021
import com.google.gwt.http.client.RequestCallback;
@@ -229,19 +230,9 @@ public void onResponseReceived(Request request, Response response) {
229230
JSONObject retval = value.isObject();
230231
if (retval.get("status").isString().stringValue().equals("OK"))
231232
{
232-
JSONArray stats_array = retval.get("stats").isArray();
233-
for (int i = 0;i<stats_array.size();i++) {
234-
JSONObject stats_item = stats_array.get(i).isObject();
235-
boolean isStackable = true;
236-
boolean isStepPlot = false;
237-
String label = null;
238-
if (stats_item.containsKey("isStepPlot"))
239-
isStepPlot = stats_item.get("isStepPlot").isBoolean().booleanValue();
240-
if (stats_item.containsKey("isStackable"))
241-
isStackable = stats_item.get("isStackable").isBoolean().booleanValue();
242-
if (stats_item.containsKey("label"))
243-
label = stats_item.get("label").isString().stringValue();
244-
genomeStats.add(new GenomeStat(stats_item.get("name").isString().stringValue(), "blue",isStackable,isStepPlot,label));
233+
JsArray<GenomeStat> array = JsonUtils.safeEval(retval.get("stats").toString());
234+
for (int i =0;i<array.length();i++) {
235+
genomeStats.add(array.get(i));
245236
}
246237
callback.onFetchGenomeStatsList(genomeStats);
247238
}

0 commit comments

Comments
 (0)