41
41
import com .google .gwt .uibinder .client .UiField ;
42
42
import com .google .gwt .user .client .DOM ;
43
43
import com .google .gwt .user .client .Element ;
44
+ import com .google .gwt .user .client .Window ;
44
45
import com .google .gwt .user .client .ui .Composite ;
45
46
import com .google .gwt .user .client .ui .FlowPanel ;
46
47
import com .google .gwt .user .client .ui .HTMLPanel ;
53
54
54
55
public class GeneViewer extends Composite implements HasMouseMoveHandlers , HasZoomResizeHandlers ,HasHandlers ,
55
56
HasFetchGenesHandlers ,FetchGeneHandler , HasHighlightGeneHandlers ,
56
- HasUnhighlightGeneHandlers ,HasClickGeneHandlers ,HighlightGeneHandler ,UnhighlightGeneHandler {
57
+ HasUnhighlightGeneHandlers ,HasClickGeneHandlers ,HighlightGeneHandler ,UnhighlightGeneHandler , ClickGeneHandler {
57
58
58
59
interface Resources extends ClientBundle
59
60
{
@@ -69,12 +70,13 @@ interface GeneViewerUiBinder extends UiBinder<Widget, GeneViewer> {
69
70
}
70
71
71
72
protected boolean fetchGenes = true ;
72
- protected int length = 30000 ;
73
+ protected int viewStart = 0 ;
74
+ protected int viewEnd = 0 ;
73
75
protected String chromosome ;
74
76
protected DataSource datasource ;
75
77
protected boolean isShowDescription = true ;
76
-
77
78
protected HashMap <String , String > descriptions = new HashMap <String , String >();
79
+ protected String geneInfoUrl = null ;
78
80
79
81
@ UiField Processing <GeneViewerInstance > processing ;
80
82
@ UiField FlowPanel container ;
@@ -103,13 +105,22 @@ public void setDataSource(DataSource datasource) {
103
105
}
104
106
105
107
public void setLength (int length ) {
106
- this .length = length ;
108
+ this .viewStart = 0 ;
109
+ this .viewEnd = length ;
110
+ }
111
+
112
+ public void setViewRegion (int start , int end ) {
113
+ this .viewStart = start ;
114
+ this .viewEnd = end ;
107
115
}
108
116
109
117
public void setIsShowDescription (boolean isShowDescription ) {
110
118
this .isShowDescription = isShowDescription ;
111
119
}
112
120
121
+ public void setGeneInfoUrl (String geneInfoUrl ) {
122
+ this .geneInfoUrl = geneInfoUrl ;
123
+ }
113
124
114
125
115
126
public void setChromosome (String chromosome ) {
@@ -144,13 +155,17 @@ public void load(final Runnable onLoad) throws ResourceException {
144
155
public void run () {
145
156
if (!processing .isLoaded ())
146
157
return ;
147
- processing .getInstance ().setLength ( length );
158
+ processing .getInstance ().setViewRegion ( viewStart , viewEnd );
148
159
processing .getInstance ().setChromosome (chromosome );
149
160
addFetchGeneHandler (GeneViewer .this );
150
161
if (isShowDescription ) {
151
162
addHighlightGeneHandler (GeneViewer .this );
152
163
addUnhighlightGeneHandlers (GeneViewer .this );
153
164
}
165
+ if (geneInfoUrl != null )
166
+ {
167
+ addClickGeneHandler (GeneViewer .this );
168
+ }
154
169
if (onLoad != null )
155
170
onLoad .run ();
156
171
}
@@ -296,4 +311,15 @@ public HandlerRegistration addHighlightGeneHandler(
296
311
public void onUnhighlightGene (UnhighlightGeneEvent event ) {
297
312
description_popup .hide ();
298
313
}
314
+
315
+ public void redraw (boolean isFetchGenes ) {
316
+ processing .getInstance ().redraw (isFetchGenes );
317
+ }
318
+
319
+
320
+ @ Override
321
+ public void onClickGene (ClickGeneEvent event ) {
322
+ if (geneInfoUrl != null && !geneInfoUrl .isEmpty ())
323
+ Window .open (geneInfoUrl .replace ("{0}" , event .getGene ().getName ()),"" ,"" );
324
+ }
299
325
}
0 commit comments