43
43
import com .google .gwt .user .client .Element ;
44
44
import com .google .gwt .user .client .Window ;
45
45
import com .google .gwt .user .client .ui .Composite ;
46
+ import com .google .gwt .user .client .ui .DockLayoutPanel ;
46
47
import com .google .gwt .user .client .ui .FlowPanel ;
47
48
import com .google .gwt .user .client .ui .HTMLPanel ;
48
49
import com .google .gwt .user .client .ui .Label ;
50
+ import com .google .gwt .user .client .ui .LayoutPanel ;
49
51
import com .google .gwt .user .client .ui .PopupPanel ;
52
+ import com .google .gwt .user .client .ui .ProvidesResize ;
53
+ import com .google .gwt .user .client .ui .RequiresResize ;
50
54
import com .google .gwt .user .client .ui .PopupPanel .PositionCallback ;
55
+ import com .google .gwt .user .client .ui .ResizeComposite ;
51
56
import com .google .gwt .user .client .ui .Widget ;
52
57
import com .processingjs .client .Processing ;
53
58
54
59
55
60
public class GeneViewer extends Composite implements HasMouseMoveHandlers , HasZoomResizeHandlers ,HasHandlers ,
56
61
HasFetchGenesHandlers ,FetchGeneHandler , HasHighlightGeneHandlers ,
57
- HasUnhighlightGeneHandlers ,HasClickGeneHandlers ,HighlightGeneHandler ,UnhighlightGeneHandler ,ClickGeneHandler {
62
+ HasUnhighlightGeneHandlers ,HasClickGeneHandlers ,HighlightGeneHandler ,UnhighlightGeneHandler ,ClickGeneHandler , RequiresResize {
58
63
59
64
interface Resources extends ClientBundle
60
65
{
@@ -69,22 +74,26 @@ interface Resources extends ClientBundle
69
74
interface GeneViewerUiBinder extends UiBinder <Widget , GeneViewer > {
70
75
}
71
76
77
+ public enum SHOW_RANGE_SELECTOR {None ,Bottom ,Top };
78
+
72
79
protected boolean fetchGenes = true ;
80
+ protected boolean dynamicWidth = false ;
73
81
protected int viewStart = 0 ;
74
82
protected int viewEnd = 0 ;
75
83
protected int width = 1000 ;
76
- protected int height = 200 ;
84
+ protected int height = 250 ;
77
85
protected String chromosome ;
78
86
protected DataSource datasource ;
79
87
protected boolean isShowDescription = true ;
80
88
protected HashMap <String , String > descriptions = new HashMap <String , String >();
81
89
protected String geneInfoUrl = null ;
90
+ protected SHOW_RANGE_SELECTOR show_range_selector = SHOW_RANGE_SELECTOR .Bottom ;
82
91
83
92
@ UiField Processing <GeneViewerInstance > processing ;
84
- @ UiField FlowPanel container ;
85
93
@ UiField PopupPanel description_popup ;
86
94
@ UiField Label description_label ;
87
95
@ UiField Label position_label ;
96
+ @ UiField FlowPanel container ;
88
97
//@UiField Label chromosome_label;
89
98
@ UiField SpanElement name_label ;
90
99
@@ -97,7 +106,9 @@ public GeneViewer() {
97
106
98
107
public void setSize (Integer width ,Integer height )
99
108
{
100
- this .width = width ;
109
+ if (!dynamicWidth ) {
110
+ this .width = width ;
111
+ }
101
112
this .height = height ;
102
113
}
103
114
@@ -111,6 +122,8 @@ public void setLength(int length) {
111
122
}
112
123
113
124
public void setViewRegion (int start , int end ) {
125
+ if (this .viewStart == start && this .viewEnd == end )
126
+ return ;
114
127
this .viewStart = start ;
115
128
this .viewEnd = end ;
116
129
if (processing .isLoaded ()) {
@@ -126,12 +139,20 @@ public void setGeneInfoUrl(String geneInfoUrl) {
126
139
this .geneInfoUrl = geneInfoUrl ;
127
140
}
128
141
142
+ public void setRangeSelectorPosition (SHOW_RANGE_SELECTOR show_range_selector ) {
143
+ this .show_range_selector = show_range_selector ;
144
+ if (processing .isLoaded ())
145
+ processing .getInstance ().showRangeSelector (this .show_range_selector .ordinal ());
146
+ }
147
+
129
148
130
149
public void setChromosome (String chromosome ) {
131
150
this .chromosome = chromosome ;
132
151
}
133
152
134
153
public void updateZoom (Integer start ,Integer end ) {
154
+ if (processing .getInstance ().getZoomStart () == start && processing .getInstance ().getZoomEnd () == end )
155
+ return ;
135
156
if (processing .isLoaded ())
136
157
processing .getInstance ().updateZoom (start ,end );
137
158
}
@@ -152,14 +173,16 @@ public void setGeneData(JavaScriptObject geneData)
152
173
processing .getInstance ().setGeneData (geneData );
153
174
}
154
175
176
+
177
+
155
178
public void load (final Runnable onLoad ) throws ResourceException {
156
179
Runnable onLoadCode = new Runnable ()
157
180
{
158
181
@ Override
159
182
public void run () {
160
183
if (!processing .isLoaded ())
161
184
return ;
162
- processing .getInstance ().setSize (width ,height );
185
+ processing .getInstance ().setLayoutSize (width ,height );
163
186
processing .getInstance ().setViewRegion (viewStart ,viewEnd );
164
187
processing .getInstance ().setChromosome (chromosome );
165
188
addFetchGeneHandler (GeneViewer .this );
@@ -327,4 +350,19 @@ public void onClickGene(ClickGeneEvent event) {
327
350
if (geneInfoUrl != null && !geneInfoUrl .isEmpty ())
328
351
Window .open (geneInfoUrl .replace ("{0}" , event .getGene ().getName ()),"" ,"" );
329
352
}
353
+
354
+ @ Override
355
+ public void onResize () {
356
+ if (!dynamicWidth )
357
+ return ;
358
+ width = container .getOffsetWidth ();
359
+ if (processing .isLoaded ()) {
360
+ processing .getInstance ().setLayoutSize (width ,height );
361
+ processing .getInstance ().redraw (false );
362
+ }
363
+ }
364
+
365
+ public void setDynamicWidth (boolean flag ) {
366
+ this .dynamicWidth = flag ;
367
+ }
330
368
}
0 commit comments