Improve code / xml formatting, #54
This commit is contained in:
@@ -37,10 +37,10 @@ public class GdxGL extends GwtGL20 implements GL {
|
||||
this.gl = gl;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void glGetShaderSource(int shader, int bufsize, Buffer length, String source) {
|
||||
// @Override
|
||||
// public void glGetShaderSource(int shader, int bufsize, Buffer length, String source) {
|
||||
//
|
||||
// }
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void glTexImage2D(int target, int level, int internalformat, int width, int height,
|
||||
|
||||
@@ -24,26 +24,26 @@ public class MapConfig extends JavaScriptObject {
|
||||
|
||||
public static native MapConfig get()/*-{
|
||||
return $wnd.mapconfig;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native double getLatitude() /*-{
|
||||
return this.latitude || 0;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native double getLongitude() /*-{
|
||||
return this.longitude || 0;
|
||||
}-*/;
|
||||
return this.longitude || 0;
|
||||
}-*/;
|
||||
|
||||
public final native int getZoom() /*-{
|
||||
return this.zoom || 2;
|
||||
}-*/;
|
||||
return this.zoom || 2;
|
||||
}-*/;
|
||||
|
||||
public final native String getTileSource() /*-{
|
||||
return this.tilesource;
|
||||
}-*/;
|
||||
return this.tilesource;
|
||||
}-*/;
|
||||
|
||||
public final native int getTileSize() /*-{
|
||||
return this.tileSize || 256;
|
||||
}-*/;
|
||||
return this.tileSize || 256;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
||||
@@ -59,10 +59,10 @@ public class MapUrl extends Timer {
|
||||
rotation = Float.parseFloat(p.substring(4));
|
||||
else if (p.startsWith("tilt="))
|
||||
tilt = Float.parseFloat(p.substring(5));
|
||||
// else if (p.startsWith("theme="))
|
||||
// themeName = p.substring(6);
|
||||
// else if (p.startsWith("map="))
|
||||
// mapName = p.substring(4);
|
||||
// else if (p.startsWith("theme="))
|
||||
// themeName = p.substring(6);
|
||||
// else if (p.startsWith("map="))
|
||||
// mapName = p.substring(4);
|
||||
else {
|
||||
String[] opt = p.split("=");
|
||||
if (opt.length > 1)
|
||||
|
||||
@@ -332,19 +332,19 @@ public abstract class GwtApplication implements EntryPoint, Application {
|
||||
**/
|
||||
private static native AgentInfo computeAgentInfo() /*-{
|
||||
var userAgent = navigator.userAgent.toLowerCase();
|
||||
return {
|
||||
// browser type flags
|
||||
isFirefox : userAgent.indexOf("firefox") != -1,
|
||||
isChrome : userAgent.indexOf("chrome") != -1,
|
||||
isSafari : userAgent.indexOf("safari") != -1,
|
||||
isOpera : userAgent.indexOf("opera") != -1,
|
||||
isIE : userAgent.indexOf("msie") != -1,
|
||||
// OS type flags
|
||||
isMacOS : userAgent.indexOf("mac") != -1,
|
||||
isLinux : userAgent.indexOf("linux") != -1,
|
||||
isWindows : userAgent.indexOf("win") != -1
|
||||
};
|
||||
}-*/;
|
||||
return {
|
||||
// browser type flags
|
||||
isFirefox : userAgent.indexOf("firefox") != -1,
|
||||
isChrome : userAgent.indexOf("chrome") != -1,
|
||||
isSafari : userAgent.indexOf("safari") != -1,
|
||||
isOpera : userAgent.indexOf("opera") != -1,
|
||||
isIE : userAgent.indexOf("msie") != -1,
|
||||
// OS type flags
|
||||
isMacOS : userAgent.indexOf("mac") != -1,
|
||||
isLinux : userAgent.indexOf("linux") != -1,
|
||||
isWindows : userAgent.indexOf("win") != -1
|
||||
};
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Returned by {@link #agentInfo}. Kindly borrowed from PlayN.
|
||||
@@ -352,35 +352,35 @@ public abstract class GwtApplication implements EntryPoint, Application {
|
||||
public static class AgentInfo extends JavaScriptObject {
|
||||
public final native boolean isFirefox() /*-{
|
||||
return this.isFirefox;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isChrome() /*-{
|
||||
return this.isChrome;
|
||||
}-*/;
|
||||
return this.isChrome;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isSafari() /*-{
|
||||
return this.isSafari;
|
||||
}-*/;
|
||||
return this.isSafari;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isOpera() /*-{
|
||||
return this.isOpera;
|
||||
}-*/;
|
||||
return this.isOpera;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isIE() /*-{
|
||||
return this.isIE;
|
||||
}-*/;
|
||||
return this.isIE;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isMacOS() /*-{
|
||||
return this.isMacOS;
|
||||
}-*/;
|
||||
return this.isMacOS;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isLinux() /*-{
|
||||
return this.isLinux;
|
||||
}-*/;
|
||||
return this.isLinux;
|
||||
}-*/;
|
||||
|
||||
public final native boolean isWindows() /*-{
|
||||
return this.isWindows;
|
||||
}-*/;
|
||||
return this.isWindows;
|
||||
}-*/;
|
||||
|
||||
protected AgentInfo() {
|
||||
}
|
||||
|
||||
@@ -96,15 +96,15 @@ public class GwtGraphics implements Graphics {
|
||||
|
||||
public static native double getDevicePixelRatioJSNI() /*-{
|
||||
return $wnd.devicePixelRatio || 1.0;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public static native int getWindowWidthJSNI() /*-{
|
||||
return $wnd.innerWidth;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public static native int getWindowHeightJSNI() /*-{
|
||||
return $wnd.innerHeight;
|
||||
}-*/;
|
||||
return $wnd.innerHeight;
|
||||
}-*/;
|
||||
|
||||
public WebGLRenderingContext getContext() {
|
||||
return context;
|
||||
@@ -173,22 +173,22 @@ public class GwtGraphics implements Graphics {
|
||||
}
|
||||
|
||||
private native int getScreenWidthJSNI() /*-{
|
||||
return $wnd.screen.width;
|
||||
}-*/;
|
||||
return $wnd.screen.width;
|
||||
}-*/;
|
||||
|
||||
private native int getScreenHeightJSNI() /*-{
|
||||
return $wnd.screen.height;
|
||||
}-*/;
|
||||
return $wnd.screen.height;
|
||||
}-*/;
|
||||
|
||||
private native boolean isFullscreenJSNI() /*-{
|
||||
if ("webkitIsFullScreen" in $doc) {
|
||||
return $doc.webkitIsFullScreen;
|
||||
}
|
||||
if ("mozFullScreen" in $doc) {
|
||||
return $doc.mozFullScreen;
|
||||
}
|
||||
return false
|
||||
}-*/;
|
||||
if ("webkitIsFullScreen" in $doc) {
|
||||
return $doc.webkitIsFullScreen;
|
||||
}
|
||||
if ("mozFullScreen" in $doc) {
|
||||
return $doc.mozFullScreen;
|
||||
}
|
||||
return false
|
||||
}-*/;
|
||||
|
||||
private void fullscreenChanged() {
|
||||
if (!isFullscreen()) {
|
||||
@@ -198,39 +198,39 @@ public class GwtGraphics implements Graphics {
|
||||
}
|
||||
|
||||
private native boolean setFullscreenJSNI(GwtGraphics graphics, CanvasElement element) /*-{
|
||||
if (element.webkitRequestFullScreen) {
|
||||
element.width = $wnd.screen.width;
|
||||
element.height = $wnd.screen.height;
|
||||
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||
$doc
|
||||
.addEventListener(
|
||||
"webkitfullscreenchange",
|
||||
function() {
|
||||
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
|
||||
}, false);
|
||||
return true;
|
||||
}
|
||||
if (element.mozRequestFullScreen) {
|
||||
element.width = $wnd.screen.width;
|
||||
element.height = $wnd.screen.height;
|
||||
element.mozRequestFullScreen();
|
||||
$doc
|
||||
.addEventListener(
|
||||
"mozfullscreenchange",
|
||||
function() {
|
||||
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
|
||||
}, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}-*/;
|
||||
if (element.webkitRequestFullScreen) {
|
||||
element.width = $wnd.screen.width;
|
||||
element.height = $wnd.screen.height;
|
||||
element.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||
$doc
|
||||
.addEventListener(
|
||||
"webkitfullscreenchange",
|
||||
function() {
|
||||
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
|
||||
}, false);
|
||||
return true;
|
||||
}
|
||||
if (element.mozRequestFullScreen) {
|
||||
element.width = $wnd.screen.width;
|
||||
element.height = $wnd.screen.height;
|
||||
element.mozRequestFullScreen();
|
||||
$doc
|
||||
.addEventListener(
|
||||
"mozfullscreenchange",
|
||||
function() {
|
||||
graphics.@com.badlogic.gdx.backends.gwt.GwtGraphics::fullscreenChanged()();
|
||||
}, false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}-*/;
|
||||
|
||||
private native void exitFullscreen() /*-{
|
||||
if ($doc.webkitExitFullscreen)
|
||||
$doc.webkitExitFullscreen();
|
||||
if ($doc.mozExitFullscreen)
|
||||
$doc.mozExitFullscreen();
|
||||
}-*/;
|
||||
if ($doc.webkitExitFullscreen)
|
||||
$doc.webkitExitFullscreen();
|
||||
if ($doc.mozExitFullscreen)
|
||||
$doc.mozExitFullscreen();
|
||||
}-*/;
|
||||
|
||||
@Override
|
||||
public DisplayMode getDesktopDisplayMode() {
|
||||
|
||||
@@ -271,22 +271,22 @@ public class GwtInput implements Input {
|
||||
*/
|
||||
private native boolean isCursorCatchedJSNI() /*-{
|
||||
if (!navigator.pointer) {
|
||||
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
|
||||
}
|
||||
if (navigator.pointer) {
|
||||
if (typeof (navigator.pointer.isLocked) === "boolean") {
|
||||
// Chrome initially launched with this interface
|
||||
return navigator.pointer.isLocked;
|
||||
} else if (typeof (navigator.pointer.isLocked) === "function") {
|
||||
// Some older builds might provide isLocked as a function
|
||||
return navigator.pointer.isLocked();
|
||||
} else if (typeof (navigator.pointer.islocked) === "function") {
|
||||
// For compatibility with early Firefox build
|
||||
return navigator.pointer.islocked();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}-*/;
|
||||
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
|
||||
}
|
||||
if (navigator.pointer) {
|
||||
if (typeof (navigator.pointer.isLocked) === "boolean") {
|
||||
// Chrome initially launched with this interface
|
||||
return navigator.pointer.isLocked;
|
||||
} else if (typeof (navigator.pointer.isLocked) === "function") {
|
||||
// Some older builds might provide isLocked as a function
|
||||
return navigator.pointer.isLocked();
|
||||
} else if (typeof (navigator.pointer.islocked) === "function") {
|
||||
// For compatibility with early Firefox build
|
||||
return navigator.pointer.islocked();
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* from https://github.com/toji/game-shim/blob/master/game-shim.js
|
||||
@@ -295,40 +295,40 @@ public class GwtInput implements Input {
|
||||
*/
|
||||
private native void setCursorCatchedJSNI(CanvasElement element) /*-{
|
||||
// Navigator pointer is not the right interface according to spec.
|
||||
// Here for backwards compatibility only
|
||||
if (!navigator.pointer) {
|
||||
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
|
||||
}
|
||||
// element.requestPointerLock
|
||||
if (!element.requestPointerLock) {
|
||||
element.requestPointerLock = (function() {
|
||||
return element.webkitRequestPointerLock
|
||||
|| element.mozRequestPointerLock || function() {
|
||||
if (navigator.pointer) {
|
||||
navigator.pointer.lock(element);
|
||||
}
|
||||
};
|
||||
})();
|
||||
}
|
||||
element.requestPointerLock();
|
||||
}-*/;
|
||||
// Here for backwards compatibility only
|
||||
if (!navigator.pointer) {
|
||||
navigator.pointer = navigator.webkitPointer || navigator.mozPointer;
|
||||
}
|
||||
// element.requestPointerLock
|
||||
if (!element.requestPointerLock) {
|
||||
element.requestPointerLock = (function() {
|
||||
return element.webkitRequestPointerLock
|
||||
|| element.mozRequestPointerLock || function() {
|
||||
if (navigator.pointer) {
|
||||
navigator.pointer.lock(element);
|
||||
}
|
||||
};
|
||||
})();
|
||||
}
|
||||
element.requestPointerLock();
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* from https://github.com/toji/game-shim/blob/master/game-shim.js
|
||||
*/
|
||||
private native void exitCursorCatchedJSNI() /*-{
|
||||
if (!$doc.exitPointerLock) {
|
||||
$doc.exitPointerLock = (function() {
|
||||
return $doc.webkitExitPointerLock || $doc.mozExitPointerLock
|
||||
|| function() {
|
||||
if (navigator.pointer) {
|
||||
var elem = this;
|
||||
navigator.pointer.unlock();
|
||||
}
|
||||
};
|
||||
})();
|
||||
}
|
||||
}-*/;
|
||||
if (!$doc.exitPointerLock) {
|
||||
$doc.exitPointerLock = (function() {
|
||||
return $doc.webkitExitPointerLock || $doc.mozExitPointerLock
|
||||
|| function() {
|
||||
if (navigator.pointer) {
|
||||
var elem = this;
|
||||
navigator.pointer.unlock();
|
||||
}
|
||||
};
|
||||
})();
|
||||
}
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* from https://github.com/toji/game-shim/blob/master/game-shim.js
|
||||
@@ -337,8 +337,8 @@ public class GwtInput implements Input {
|
||||
* @return movement in x direction
|
||||
*/
|
||||
private native float getMovementXJSNI(NativeEvent event) /*-{
|
||||
return event.movementX || event.webkitMovementX || 0;
|
||||
}-*/;
|
||||
return event.movementX || event.webkitMovementX || 0;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* from https://github.com/toji/game-shim/blob/master/game-shim.js
|
||||
@@ -347,12 +347,12 @@ public class GwtInput implements Input {
|
||||
* @return movement in y direction
|
||||
*/
|
||||
private native float getMovementYJSNI(NativeEvent event) /*-{
|
||||
return event.movementY || event.webkitMovementY || 0;
|
||||
}-*/;
|
||||
return event.movementY || event.webkitMovementY || 0;
|
||||
}-*/;
|
||||
|
||||
private static native boolean isTouchScreen() /*-{
|
||||
return (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0));
|
||||
}-*/;
|
||||
return (('ontouchstart' in window) || (navigator.msMaxTouchPoints > 0));
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* works only for Chrome > Version 18 with enabled Mouse Lock enable in
|
||||
@@ -384,55 +384,55 @@ public class GwtInput implements Input {
|
||||
// kindly borrowed from our dear playn friends...
|
||||
static native void addEventListener(JavaScriptObject target, String name, GwtInput handler,
|
||||
boolean capture) /*-{
|
||||
target
|
||||
.addEventListener(
|
||||
name,
|
||||
function(e) {
|
||||
handler.@com.badlogic.gdx.backends.gwt.GwtInput::handleEvent(Lcom/google/gwt/dom/client/NativeEvent;)(e);
|
||||
}, capture);
|
||||
}-*/;
|
||||
target
|
||||
.addEventListener(
|
||||
name,
|
||||
function(e) {
|
||||
handler.@com.badlogic.gdx.backends.gwt.GwtInput::handleEvent(Lcom/google/gwt/dom/client/NativeEvent;)(e);
|
||||
}, capture);
|
||||
}-*/;
|
||||
|
||||
private static native float getMouseWheelVelocity(NativeEvent evt) /*-{
|
||||
var delta = 0.0;
|
||||
var agentInfo = @com.badlogic.gdx.backends.gwt.GwtApplication::agentInfo()();
|
||||
var delta = 0.0;
|
||||
var agentInfo = @com.badlogic.gdx.backends.gwt.GwtApplication::agentInfo()();
|
||||
|
||||
if (agentInfo.isFirefox) {
|
||||
if (agentInfo.isMacOS) {
|
||||
delta = 1.0 * evt.detail;
|
||||
} else {
|
||||
delta = 1.0 * evt.detail / 3;
|
||||
}
|
||||
} else if (agentInfo.isOpera) {
|
||||
if (agentInfo.isLinux) {
|
||||
delta = -1.0 * evt.wheelDelta / 80;
|
||||
} else {
|
||||
// on mac
|
||||
delta = -1.0 * evt.wheelDelta / 40;
|
||||
}
|
||||
} else if (agentInfo.isChrome || agentInfo.isSafari) {
|
||||
delta = -1.0 * evt.wheelDelta / 120;
|
||||
// handle touchpad for chrome
|
||||
if (Math.abs(delta) < 1) {
|
||||
if (agentInfo.isWindows) {
|
||||
delta = -1.0 * evt.wheelDelta;
|
||||
} else if (agentInfo.isMacOS) {
|
||||
delta = -1.0 * evt.wheelDelta / 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return delta;
|
||||
}-*/;
|
||||
if (agentInfo.isFirefox) {
|
||||
if (agentInfo.isMacOS) {
|
||||
delta = 1.0 * evt.detail;
|
||||
} else {
|
||||
delta = 1.0 * evt.detail / 3;
|
||||
}
|
||||
} else if (agentInfo.isOpera) {
|
||||
if (agentInfo.isLinux) {
|
||||
delta = -1.0 * evt.wheelDelta / 80;
|
||||
} else {
|
||||
// on mac
|
||||
delta = -1.0 * evt.wheelDelta / 40;
|
||||
}
|
||||
} else if (agentInfo.isChrome || agentInfo.isSafari) {
|
||||
delta = -1.0 * evt.wheelDelta / 120;
|
||||
// handle touchpad for chrome
|
||||
if (Math.abs(delta) < 1) {
|
||||
if (agentInfo.isWindows) {
|
||||
delta = -1.0 * evt.wheelDelta;
|
||||
} else if (agentInfo.isMacOS) {
|
||||
delta = -1.0 * evt.wheelDelta / 3;
|
||||
}
|
||||
}
|
||||
}
|
||||
return delta;
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Kindly borrowed from PlayN.
|
||||
**/
|
||||
protected static native String getMouseWheelEvent() /*-{
|
||||
if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) {
|
||||
return "DOMMouseScroll";
|
||||
} else {
|
||||
return "mousewheel";
|
||||
}
|
||||
}-*/;
|
||||
if (navigator.userAgent.toLowerCase().indexOf('firefox') != -1) {
|
||||
return "DOMMouseScroll";
|
||||
} else {
|
||||
return "mousewheel";
|
||||
}
|
||||
}-*/;
|
||||
|
||||
/**
|
||||
* Kindly borrowed from PlayN.
|
||||
@@ -452,15 +452,15 @@ public class GwtInput implements Input {
|
||||
|
||||
private void hookEvents() {
|
||||
addEventListener(canvas, "mousedown", this, true);
|
||||
// addEventListener(Document.get(), "mousedown", this, true);
|
||||
// addEventListener(Document.get(), "mousedown", this, true);
|
||||
addEventListener(canvas, "mouseup", this, true);
|
||||
// addEventListener(Document.get(), "mouseup", this, true);
|
||||
// addEventListener(Document.get(), "mouseup", this, true);
|
||||
addEventListener(canvas, "mousemove", this, true);
|
||||
// addEventListener(Document.get(), "mousemove", this, true);
|
||||
// addEventListener(Document.get(), "mousemove", this, true);
|
||||
addEventListener(canvas, getMouseWheelEvent(), this, true);
|
||||
// addEventListener(Document.get(), "keydown", this, false);
|
||||
// addEventListener(Document.get(), "keyup", this, false);
|
||||
// addEventListener(Document.get(), "keypress", this, false);
|
||||
// addEventListener(Document.get(), "keydown", this, false);
|
||||
// addEventListener(Document.get(), "keyup", this, false);
|
||||
// addEventListener(Document.get(), "keypress", this, false);
|
||||
addEventListener(canvas, "keydown", this, false);
|
||||
addEventListener(canvas, "keyup", this, false);
|
||||
addEventListener(canvas, "keypress", this, false);
|
||||
|
||||
@@ -379,25 +379,25 @@ public class GLMatrix {
|
||||
System.arraycopy(tmp, 0, mata, 0, 16);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public void finalize() {
|
||||
// if (pointer != 0)
|
||||
// delete(pointer);
|
||||
// }
|
||||
// @Override
|
||||
// public void finalize() {
|
||||
// if (pointer != 0)
|
||||
// delete(pointer);
|
||||
// }
|
||||
|
||||
/* Copyright (C) 2007 The Android Open Source Project
|
||||
/* Copyright (C) 2007 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License. */
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License. */
|
||||
|
||||
/**
|
||||
* Define a projection matrix in terms of six clip planes
|
||||
|
||||
@@ -118,8 +118,8 @@ public class LwHttp implements HttpEngine {
|
||||
|
||||
@Override
|
||||
public boolean requestCompleted(boolean success) {
|
||||
// mHttpRequest.clearOnReadyStateChange();
|
||||
// mHttpRequest = null;
|
||||
// mHttpRequest.clearOnReadyStateChange();
|
||||
// mHttpRequest = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,11 +87,11 @@ public class BitmapTileSource extends UrlTileSource {
|
||||
final Image img = new Image();
|
||||
img.setVisible(false);
|
||||
|
||||
/* As if researching CORS issues doesnt result in
|
||||
/* As if researching CORS issues doesnt result in
|
||||
* enough headache...
|
||||
*
|
||||
* Here are some more special Chrome/Webkit quirks:
|
||||
* MUST SET CORS BEFORE URL! */
|
||||
*
|
||||
* Here are some more special Chrome/Webkit quirks:
|
||||
* MUST SET CORS BEFORE URL! */
|
||||
img.getElement().setAttribute("crossorigin", "anonymous");
|
||||
img.setUrl(uri);
|
||||
|
||||
|
||||
@@ -124,17 +124,17 @@ public class Tessellator {
|
||||
return 0;
|
||||
}
|
||||
|
||||
// if (vo.length() != plen) {
|
||||
// // TODO handle different output points
|
||||
// log.debug(" + io.length());
|
||||
// if (vo.length() != plen) {
|
||||
// // TODO handle different output points
|
||||
// log.debug(" + io.length());
|
||||
//
|
||||
// //for (int i = 0; i < vo.length(); i += 2)
|
||||
// // log.debug(vo.get(i) + " " + vo.get(i + 1));
|
||||
// //for (int i = ppos; i < ppos + plen; i += 2)
|
||||
// // log.debug( points[i]+ " " + points[i + 1]);
|
||||
// //for (int i = 0; i < vo.length(); i += 2)
|
||||
// // log.debug(vo.get(i) + " " + vo.get(i + 1));
|
||||
// //for (int i = ppos; i < ppos + plen; i += 2)
|
||||
// // log.debug( points[i]+ " " + points[i + 1]);
|
||||
//
|
||||
// return 0;
|
||||
// }
|
||||
// return 0;
|
||||
// }
|
||||
|
||||
int numIndices = io.length();
|
||||
|
||||
@@ -164,17 +164,17 @@ public class Tessellator {
|
||||
static native Int32Array tessellate(JsArrayNumber points, int pOffset, int pLength,
|
||||
JsArrayInteger bounds, int bOffset, int bLength)/*-{
|
||||
|
||||
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
bOffset, bOffset + bLength, false);
|
||||
}-*/;
|
||||
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
bOffset, bOffset + bLength, false);
|
||||
}-*/;
|
||||
|
||||
static native TessResult tessellate2(JsArrayNumber points, int pOffset, int pLength,
|
||||
JsArrayInteger bounds, int bOffset, int bLength)
|
||||
/*-{
|
||||
|
||||
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
bOffset, bOffset + bLength, true);
|
||||
}-*/;
|
||||
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
|
||||
bOffset, bOffset + bLength, true);
|
||||
}-*/;
|
||||
|
||||
static final class TessResult extends JavaScriptObject {
|
||||
protected TessResult() {
|
||||
@@ -182,10 +182,10 @@ public class Tessellator {
|
||||
|
||||
native Float32Array getPoints(JavaScriptObject result)/*-{
|
||||
return result.vertices;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
native Int32Array getIndices(JavaScriptObject result)/*-{
|
||||
return result.triangles;
|
||||
}-*/;
|
||||
return result.triangles;
|
||||
}-*/;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,107 +1,107 @@
|
||||
tessellate = (function() {
|
||||
|
||||
Module.TOTAL_MEMORY = 1024 * 1024;
|
||||
Module.TOTAL_MEMORY = 1024 * 1024;
|
||||
|
||||
var c_tessellate = Module.cwrap('tessellate', 'void', [ 'number', 'number',
|
||||
'number', 'number', 'number', 'number' ]);
|
||||
var c_tessellate = Module.cwrap('tessellate', 'void', [ 'number', 'number',
|
||||
'number', 'number', 'number', 'number' ]);
|
||||
|
||||
// special tessellator for extrusion layer - only returns triangle indices
|
||||
var tessellate = function(vertices, v_start, v_end, boundaries, b_start,
|
||||
b_end, mode) {
|
||||
var i;
|
||||
// special tessellator for extrusion layer - only returns triangle indices
|
||||
var tessellate = function(vertices, v_start, v_end, boundaries, b_start,
|
||||
b_end, mode) {
|
||||
var i;
|
||||
|
||||
var v_len = (v_end - v_start);
|
||||
var b_len = (b_end - b_start);
|
||||
var v_len = (v_end - v_start);
|
||||
var b_len = (b_end - b_start);
|
||||
|
||||
var p = Module._malloc(v_len * 8);
|
||||
var p = Module._malloc(v_len * 8);
|
||||
|
||||
for (i = 0; i < v_len; ++i)
|
||||
Module.setValue(p + i * 8, vertices[v_start + i], 'double');
|
||||
for (i = 0; i < v_len; ++i)
|
||||
Module.setValue(p + i * 8, vertices[v_start + i], 'double');
|
||||
|
||||
var contours = Module._malloc((b_len + 1) * 4);
|
||||
var contours = Module._malloc((b_len + 1) * 4);
|
||||
|
||||
// pointer to first contour
|
||||
Module.setValue(contours + 0, p + 0, 'i32');
|
||||
var offset = p;
|
||||
// pointer to first contour
|
||||
Module.setValue(contours + 0, p + 0, 'i32');
|
||||
var offset = p;
|
||||
|
||||
// pointer to further contours + end
|
||||
for (i = 0; i < b_len; ++i) {
|
||||
offset += 8 * boundaries[b_start + i];
|
||||
Module.setValue(contours + 4 * (i + 1), offset, 'i32');
|
||||
}
|
||||
// pointer to further contours + end
|
||||
for (i = 0; i < b_len; ++i) {
|
||||
offset += 8 * boundaries[b_start + i];
|
||||
Module.setValue(contours + 4 * (i + 1), offset, 'i32');
|
||||
}
|
||||
|
||||
var ppcoordinates_out = Module._malloc(4);
|
||||
var pptris_out = Module._malloc(4);
|
||||
var pnverts = Module._malloc(4);
|
||||
var pntris = Module._malloc(4);
|
||||
var ppcoordinates_out = Module._malloc(4);
|
||||
var pptris_out = Module._malloc(4);
|
||||
var pnverts = Module._malloc(4);
|
||||
var pntris = Module._malloc(4);
|
||||
|
||||
c_tessellate(ppcoordinates_out, pnverts, pptris_out, pntris, contours,
|
||||
contours + 4 * (b_len + 1));
|
||||
c_tessellate(ppcoordinates_out, pnverts, pptris_out, pntris, contours,
|
||||
contours + 4 * (b_len + 1));
|
||||
|
||||
var pcoordinates_out = Module.getValue(ppcoordinates_out, 'i32');
|
||||
var ptris_out = Module.getValue(pptris_out, 'i32');
|
||||
var pcoordinates_out = Module.getValue(ppcoordinates_out, 'i32');
|
||||
var ptris_out = Module.getValue(pptris_out, 'i32');
|
||||
|
||||
var nverts = Module.getValue(pnverts, 'i32');
|
||||
var ntris = Module.getValue(pntris, 'i32');
|
||||
var nverts = Module.getValue(pnverts, 'i32');
|
||||
var ntris = Module.getValue(pntris, 'i32');
|
||||
|
||||
var result_triangles = null;
|
||||
var result_vertices = null;
|
||||
var result_triangles = null;
|
||||
var result_vertices = null;
|
||||
|
||||
if (mode){
|
||||
result_triangles = new Int32Array(ntris * 3);
|
||||
for (i = 0; i < 3 * ntris; ++i)
|
||||
result_triangles[i] = Module.getValue(ptris_out + i * 4, 'i32');
|
||||
|
||||
result_vertices = new Float32Array(nverts * 2);
|
||||
for (i = 0; i < 2 * nverts; ++i)
|
||||
result_vertices[i] = Module.getValue(pcoordinates_out + i * 8, 'double');
|
||||
|
||||
} else {
|
||||
if (nverts * 2 == v_len) {
|
||||
result_triangles = new Int32Array(ntris * 3);
|
||||
|
||||
for (i = 0; i < 3 * ntris; ++i) {
|
||||
result_triangles[i] = Module.getValue(ptris_out + i * 4, 'i32') * 2;
|
||||
}
|
||||
// when a ring has an odd number of points one (or rather two)
|
||||
// additional vertices will be added. so the following rings
|
||||
// needs extra offset...
|
||||
var start = 0;
|
||||
for ( var j = 0, m = b_len - 1; j < m; j++) {
|
||||
start += boundaries[b_start + j];
|
||||
if (mode){
|
||||
result_triangles = new Int32Array(ntris * 3);
|
||||
for (i = 0; i < 3 * ntris; ++i)
|
||||
result_triangles[i] = Module.getValue(ptris_out + i * 4, 'i32');
|
||||
|
||||
result_vertices = new Float32Array(nverts * 2);
|
||||
for (i = 0; i < 2 * nverts; ++i)
|
||||
result_vertices[i] = Module.getValue(pcoordinates_out + i * 8, 'double');
|
||||
|
||||
} else {
|
||||
if (nverts * 2 == v_len) {
|
||||
result_triangles = new Int32Array(ntris * 3);
|
||||
|
||||
for (i = 0; i < 3 * ntris; ++i) {
|
||||
result_triangles[i] = Module.getValue(ptris_out + i * 4, 'i32') * 2;
|
||||
}
|
||||
// when a ring has an odd number of points one (or rather two)
|
||||
// additional vertices will be added. so the following rings
|
||||
// needs extra offset...
|
||||
var start = 0;
|
||||
for ( var j = 0, m = b_len - 1; j < m; j++) {
|
||||
start += boundaries[b_start + j];
|
||||
|
||||
// even number of points?
|
||||
if (!((boundaries[b_start + j] >> 1) & 1))
|
||||
continue;
|
||||
// even number of points?
|
||||
if (!((boundaries[b_start + j] >> 1) & 1))
|
||||
continue;
|
||||
|
||||
for ( var n = ntris * 3, tri = 0; tri < n; tri++)
|
||||
if (result_triangles[tri] >= start)
|
||||
result_triangles[tri] += 2;
|
||||
for ( var n = ntris * 3, tri = 0; tri < n; tri++)
|
||||
if (result_triangles[tri] >= start)
|
||||
result_triangles[tri] += 2;
|
||||
|
||||
start += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Module._free(pnverts);
|
||||
Module._free(pntris);
|
||||
|
||||
Module._free(ppcoordinates_out);
|
||||
Module._free(pcoordinates_out);
|
||||
|
||||
Module._free(pptris_out);
|
||||
Module._free(ptris_out);
|
||||
start += 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Module._free(pnverts);
|
||||
Module._free(pntris);
|
||||
|
||||
Module._free(ppcoordinates_out);
|
||||
Module._free(pcoordinates_out);
|
||||
|
||||
Module._free(pptris_out);
|
||||
Module._free(ptris_out);
|
||||
|
||||
Module._free(p);
|
||||
Module._free(contours);
|
||||
|
||||
if (mode)
|
||||
return { vertices: result_vertices, triangles: result_triangles };
|
||||
else
|
||||
return result_triangles;
|
||||
|
||||
};
|
||||
Module._free(p);
|
||||
Module._free(contours);
|
||||
|
||||
if (mode)
|
||||
return { vertices: result_vertices, triangles: result_triangles };
|
||||
else
|
||||
return result_triangles;
|
||||
|
||||
};
|
||||
|
||||
return tessellate;
|
||||
return tessellate;
|
||||
|
||||
})();
|
||||
|
||||
@@ -27,15 +27,15 @@ public class Feature extends GeoJsonObject {
|
||||
|
||||
public final native Geometry<?> getGeometry() /*-{
|
||||
return this.geometry;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native String getId() /*-{
|
||||
return this.id;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native void setId(String id) /*-{
|
||||
this.id = id;
|
||||
}-*/;
|
||||
this.id = id;
|
||||
}-*/;
|
||||
|
||||
public final Map<String, Object> getProperties(HashMap<String, Object> map) {
|
||||
map.clear();
|
||||
@@ -45,8 +45,8 @@ public class Feature extends GeoJsonObject {
|
||||
}
|
||||
|
||||
public final native void fromJavascriptObject(HashMap<String, Object> s) /*-{
|
||||
for(var key in this.properties) {
|
||||
s.@java.util.HashMap::put(Ljava/lang/Object;Ljava/lang/Object;)(key, Object(this.properties[key]));
|
||||
}
|
||||
}-*/;
|
||||
for(var key in this.properties) {
|
||||
s.@java.util.HashMap::put(Ljava/lang/Object;Ljava/lang/Object;)(key, Object(this.properties[key]));
|
||||
}
|
||||
}-*/;
|
||||
}
|
||||
|
||||
@@ -33,6 +33,6 @@ public class FeatureCollection extends JavaScriptObject {
|
||||
|
||||
public final native JsArray<Feature> getFeaturesInternal()/*-{
|
||||
return this.features;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
||||
@@ -26,9 +26,9 @@ public abstract class GeoJsonObject extends JavaScriptObject {
|
||||
|
||||
public final native double[] getBbox()/*-{
|
||||
return bbox;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native void setBbox(double[] bbox) /*-{
|
||||
this.bbox = bbox;
|
||||
}-*/;
|
||||
}-*/;
|
||||
}
|
||||
|
||||
@@ -65,12 +65,12 @@ public class GeoJsonTileDecoder implements ITileDecoder {
|
||||
mapElement.clear();
|
||||
mapElement.tags.clear();
|
||||
|
||||
/* add tag information */
|
||||
/* add tag information */
|
||||
mTileSource.decodeTags(mapElement, f.getProperties(mProperties));
|
||||
if (mapElement.tags.numTags == 0)
|
||||
continue;
|
||||
|
||||
/* add geometry information */
|
||||
/* add geometry information */
|
||||
decodeGeometry(f.getGeometry());
|
||||
|
||||
if (mapElement.type == GeometryType.NONE)
|
||||
|
||||
@@ -27,9 +27,9 @@ public abstract class Geometry<T extends JavaScriptObject> extends JsArray<T> {
|
||||
|
||||
public final native String type()/*-{
|
||||
return this.type
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native JsArray<T> getCoordinates() /*-{
|
||||
return this.coordinates;
|
||||
}-*/;
|
||||
}-*/;
|
||||
}
|
||||
|
||||
@@ -83,19 +83,19 @@ public class JsArrayCollection<T> extends AbstractCollection<T> {
|
||||
|
||||
public native final JsArr<T> slice(int start, int end)/*-{
|
||||
return this.slice(start, end);
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public static final native <T> JsArr<T> create() /*-{
|
||||
return [];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native int size() /*-{
|
||||
return this.length;
|
||||
}-*/;
|
||||
return this.length;
|
||||
}-*/;
|
||||
|
||||
public final native T get(int i) /*-{
|
||||
return this[i];
|
||||
}-*/;
|
||||
return this[i];
|
||||
}-*/;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,9 +10,9 @@ public class LngLat extends JavaScriptObject {
|
||||
|
||||
public final native double getLongitude() /*-{
|
||||
return this[0];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native double getLatitude() /*-{
|
||||
return this[1];
|
||||
}-*/;
|
||||
}-*/;
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ public class MultiLineString extends Geometry<LineString> {
|
||||
|
||||
public final native LineString getGeometryN(int i) /*-{
|
||||
return this[i];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native int getNumGeometries() /*-{
|
||||
return this.length;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
||||
@@ -23,10 +23,10 @@ public class MultiPolygon extends Geometry<Polygon> {
|
||||
|
||||
public final native Polygon getGeometryN(int i) /*-{
|
||||
return this[i];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native int getNumGeometries() /*-{
|
||||
return this.length;
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
||||
@@ -23,14 +23,14 @@ public class Polygon extends Geometry<LineString> {
|
||||
|
||||
public final native LineString getExteriorRing()/*-{
|
||||
return this[0];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native LineString getRing(int i) /*-{
|
||||
return this[i];
|
||||
}-*/;
|
||||
}-*/;
|
||||
|
||||
public final native int getNumRings() /*-{
|
||||
return this.length;
|
||||
}-*/;
|
||||
return this.length;
|
||||
}-*/;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user