Skip to content

Commit a4c26dc

Browse files
author
Seren
committed
processingjs version 1.2.1 requires to set the size explicitly
1 parent d481d29 commit a4c26dc

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

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

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,8 @@ interface GeneViewerUiBinder extends UiBinder<Widget, GeneViewer> {
7272
protected boolean fetchGenes = true;
7373
protected int viewStart = 0;
7474
protected int viewEnd = 0;
75+
protected int width = 1000;
76+
protected int height = 200;
7577
protected String chromosome;
7678
protected DataSource datasource;
7779
protected boolean isShowDescription = true;
@@ -95,9 +97,8 @@ public GeneViewer() {
9597

9698
public void setSize(Integer width,Integer height)
9799
{
98-
Element elem = processing.getElement();
99-
DOM.setElementAttribute(elem, "width", width.toString());
100-
DOM.setElementAttribute(elem, "height", height.toString());
100+
this.width= width;
101+
this.height = height;
101102
}
102103

103104
public void setDataSource(DataSource datasource) {
@@ -112,6 +113,9 @@ public void setLength(int length) {
112113
public void setViewRegion(int start, int end) {
113114
this.viewStart = start;
114115
this.viewEnd = end;
116+
if (processing.isLoaded()) {
117+
processing.getInstance().setViewRegion(start, end);
118+
}
115119
}
116120

117121
public void setIsShowDescription(boolean isShowDescription) {
@@ -155,6 +159,7 @@ public void load(final Runnable onLoad) throws ResourceException {
155159
public void run() {
156160
if (!processing.isLoaded())
157161
return;
162+
processing.getInstance().setSize(width,height);
158163
processing.getInstance().setViewRegion(viewStart,viewEnd);
159164
processing.getInstance().setChromosome(chromosome);
160165
addFetchGeneHandler(GeneViewer.this);

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
/* @pjs transparent="true"; */
22
int fps = 1;
33
String data_raw = null;
44
GenomeBrowser browser = null;
@@ -9,9 +9,7 @@ var eventHandler = {};
99

1010
void setup()
1111
{
12-
//size(1000,200);
1312
frameRate(fps);
14-
background(255)
1513
smooth();
1614
layout = new Layout(width,height);
1715
browser = new GenomeBrowser("");
@@ -22,12 +20,18 @@ void setup()
2220
void draw()
2321
{
2422
background(255)
23+
background(0,0,0,0);
2524
browser.render();
2625
}
2726

2827

2928
// API for access via javascript
3029

30+
void api_setSize(int width,int height) {
31+
size(width,height);
32+
layout.setSize(width,height);
33+
}
34+
3135
void api_addEventHandler(String handler,callback)
3236
{
3337
eventHandler[handler] = callback;
@@ -258,10 +262,14 @@ class Layout
258262

259263

260264

261-
Layout(int width,int height)
265+
Layout(width,height)
262266
{
263267
zoomEnd = viewEnd;
264-
this.width = width;
268+
setSize(width,height);
269+
}
270+
271+
void setSize(int width,int height) {
272+
this.width = width;
265273
this.height = height;
266274
initArea();
267275
initPxPerBb();
@@ -911,7 +919,12 @@ class CDS extends GeneFeature
911919
}
912920
}
913921

914-
922+
void mouseOut() {
923+
if (eventHandler['unhighlightGeneEvent'] != null)
924+
{
925+
eventHandler['unhighlightGeneEvent']();
926+
}
927+
}
915928

916929
void mouseMoved() {
917930
layout.mousePositionX = mouseX;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,8 @@ public final native int getViewEnd() /*-{
128128
public final native void redraw(boolean isFetchGenes) /*-{
129129
this.api_redraw(isFetchGenes);
130130
}-*/;
131+
132+
public final native void setSize(int width, int height) /*-{
133+
this.api_setSize(width,height);
134+
}-*/;
131135
}

0 commit comments

Comments
 (0)