Skip to content

Commit 134e4d4

Browse files
author
Seren
committed
length is replaced by viewRegion. setGeneInfoUrl method added
1 parent 934d554 commit 134e4d4

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

src/at/gmi/nordborglab/widgets/geneviewer/client/GeneViewer.java

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
import com.google.gwt.uibinder.client.UiField;
4242
import com.google.gwt.user.client.DOM;
4343
import com.google.gwt.user.client.Element;
44+
import com.google.gwt.user.client.Window;
4445
import com.google.gwt.user.client.ui.Composite;
4546
import com.google.gwt.user.client.ui.FlowPanel;
4647
import com.google.gwt.user.client.ui.HTMLPanel;
@@ -53,7 +54,7 @@
5354

5455
public class GeneViewer extends Composite implements HasMouseMoveHandlers, HasZoomResizeHandlers,HasHandlers,
5556
HasFetchGenesHandlers,FetchGeneHandler, HasHighlightGeneHandlers,
56-
HasUnhighlightGeneHandlers,HasClickGeneHandlers,HighlightGeneHandler,UnhighlightGeneHandler{
57+
HasUnhighlightGeneHandlers,HasClickGeneHandlers,HighlightGeneHandler,UnhighlightGeneHandler,ClickGeneHandler{
5758

5859
interface Resources extends ClientBundle
5960
{
@@ -69,12 +70,13 @@ interface GeneViewerUiBinder extends UiBinder<Widget, GeneViewer> {
6970
}
7071

7172
protected boolean fetchGenes = true;
72-
protected int length = 30000;
73+
protected int viewStart = 0;
74+
protected int viewEnd = 0;
7375
protected String chromosome;
7476
protected DataSource datasource;
7577
protected boolean isShowDescription = true;
76-
7778
protected HashMap<String, String> descriptions = new HashMap<String, String>();
79+
protected String geneInfoUrl = null;
7880

7981
@UiField Processing<GeneViewerInstance> processing;
8082
@UiField FlowPanel container;
@@ -103,13 +105,22 @@ public void setDataSource(DataSource datasource) {
103105
}
104106

105107
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;
107115
}
108116

109117
public void setIsShowDescription(boolean isShowDescription) {
110118
this.isShowDescription = isShowDescription;
111119
}
112120

121+
public void setGeneInfoUrl(String geneInfoUrl) {
122+
this.geneInfoUrl = geneInfoUrl;
123+
}
113124

114125

115126
public void setChromosome(String chromosome) {
@@ -144,13 +155,17 @@ public void load(final Runnable onLoad) throws ResourceException {
144155
public void run() {
145156
if (!processing.isLoaded())
146157
return;
147-
processing.getInstance().setLength(length);
158+
processing.getInstance().setViewRegion(viewStart,viewEnd);
148159
processing.getInstance().setChromosome(chromosome);
149160
addFetchGeneHandler(GeneViewer.this);
150161
if (isShowDescription) {
151162
addHighlightGeneHandler(GeneViewer.this);
152163
addUnhighlightGeneHandlers(GeneViewer.this);
153164
}
165+
if (geneInfoUrl != null)
166+
{
167+
addClickGeneHandler(GeneViewer.this);
168+
}
154169
if (onLoad != null)
155170
onLoad.run();
156171
}
@@ -296,4 +311,15 @@ public HandlerRegistration addHighlightGeneHandler(
296311
public void onUnhighlightGene(UnhighlightGeneEvent event) {
297312
description_popup.hide();
298313
}
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+
}
299325
}

0 commit comments

Comments
 (0)