consistent formatting

This commit is contained in:
Hannes Janetzek 2013-09-23 17:59:51 +02:00
parent 57dfd91378
commit c720cf22aa
188 changed files with 4745 additions and 4470 deletions

View File

@ -23,11 +23,13 @@ import android.content.Context;
public class AndroidAssetAdapter extends AssetAdapter { public class AndroidAssetAdapter extends AssetAdapter {
Context mContext; Context mContext;
public AndroidAssetAdapter(Context ctx) { public AndroidAssetAdapter(Context ctx) {
mContext = ctx; mContext = ctx;
} }
@Override @Override
public InputStream openFileAsStream(String fileName) { public InputStream openFileAsStream(String fileName) {
try { try {
return mContext.getAssets().open(fileName); return mContext.getAssets().open(fileName);
} catch (IOException e) { } catch (IOException e) {

View File

@ -16,8 +16,7 @@ package org.oscim.android;
import android.util.Log; import android.util.Log;
public class AndroidLog implements org.oscim.backend.Log.Logger {
public class AndroidLog implements org.oscim.backend.Log.Logger{
@Override @Override
public void d(String tag, String msg) { public void d(String tag, String msg) {

View File

@ -51,14 +51,14 @@ public class Compass {
public Compass(MapActivity mapActivity, Map map) { public Compass(MapActivity mapActivity, Map map) {
mMap = map; mMap = map;
mSensorManager = (SensorManager) mapActivity mSensorManager = (SensorManager) mapActivity
.getSystemService(Context.SENSOR_SERVICE); .getSystemService(Context.SENSOR_SERVICE);
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION); mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
} }
public void enable() { public void enable() {
mSensorManager.registerListener(mListener, mSensor, mSensorManager.registerListener(mListener, mSensor,
SensorManager.SENSOR_DELAY_UI); SensorManager.SENSOR_DELAY_UI);
} }
public void disable() { public void disable() {

View File

@ -24,7 +24,7 @@ import android.opengl.GLSurfaceView;
public class GLView extends GLSurfaceView { public class GLView extends GLSurfaceView {
class GLRenderer extends org.oscim.renderer.MapRenderer implements GLSurfaceView.Renderer{ class GLRenderer extends org.oscim.renderer.MapRenderer implements GLSurfaceView.Renderer {
public GLRenderer(Map map) { public GLRenderer(Map map) {
super(map); super(map);
@ -47,7 +47,6 @@ public class GLView extends GLSurfaceView {
} }
} }
public GLView(Context context, Map map) { public GLView(Context context, Map map) {
super(context); super(context);
setEGLConfigChooser(new GlConfigChooser()); setEGLConfigChooser(new GlConfigChooser());

View File

@ -25,15 +25,15 @@ public class GlConfigChooser implements GLSurfaceView.EGLConfigChooser {
// Try to find a normal multisample configuration first. // Try to find a normal multisample configuration first.
int[] configSpec = { int[] configSpec = {
EGL10.EGL_RED_SIZE, 5, EGL10.EGL_RED_SIZE, 5,
EGL10.EGL_GREEN_SIZE, 6, EGL10.EGL_GREEN_SIZE, 6,
EGL10.EGL_BLUE_SIZE, 5, EGL10.EGL_BLUE_SIZE, 5,
EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8,
EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_DEPTH_SIZE, 16,
// Requires that setEGLContextClientVersion(2) is called on the view. // Requires that setEGLContextClientVersion(2) is called on the view.
EGL10.EGL_RENDERABLE_TYPE, 4 /* EGL_OPENGL_ES2_BIT */, EGL10.EGL_RENDERABLE_TYPE, 4 /* EGL_OPENGL_ES2_BIT */,
EGL10.EGL_STENCIL_SIZE, 8, EGL10.EGL_STENCIL_SIZE, 8,
EGL10.EGL_NONE }; EGL10.EGL_NONE };
if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) { if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) {
throw new IllegalArgumentException("eglChooseConfig failed"); throw new IllegalArgumentException("eglChooseConfig failed");
@ -44,15 +44,15 @@ public class GlConfigChooser implements GLSurfaceView.EGLConfigChooser {
stencilSize = 4; stencilSize = 4;
configSpec = new int[] { configSpec = new int[] {
// EGL10.EGL_RENDERABLE_TYPE, 4, EGL10.EGL_NONE }; // EGL10.EGL_RENDERABLE_TYPE, 4, EGL10.EGL_NONE };
EGL10.EGL_RED_SIZE, 8, EGL10.EGL_RED_SIZE, 8,
EGL10.EGL_GREEN_SIZE, 8, EGL10.EGL_GREEN_SIZE, 8,
EGL10.EGL_BLUE_SIZE, 8, EGL10.EGL_BLUE_SIZE, 8,
EGL10.EGL_ALPHA_SIZE, 8, EGL10.EGL_ALPHA_SIZE, 8,
EGL10.EGL_DEPTH_SIZE, 16, EGL10.EGL_DEPTH_SIZE, 16,
EGL10.EGL_RENDERABLE_TYPE, 4 /* EGL_OPENGL_ES2_BIT */, EGL10.EGL_RENDERABLE_TYPE, 4 /* EGL_OPENGL_ES2_BIT */,
EGL10.EGL_STENCIL_SIZE, 8, EGL10.EGL_STENCIL_SIZE, 8,
EGL10.EGL_NONE }; EGL10.EGL_NONE };
if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) { if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) {
throw new IllegalArgumentException("eglChooseConfig failed"); throw new IllegalArgumentException("eglChooseConfig failed");
@ -116,7 +116,7 @@ public class GlConfigChooser implements GLSurfaceView.EGLConfigChooser {
// from quake2android // from quake2android
private String printConfig(EGL10 egl, EGLDisplay display, private String printConfig(EGL10 egl, EGLDisplay display,
EGLConfig config) { EGLConfig config) {
int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0); int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0);
int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0); int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0);
@ -132,22 +132,22 @@ public class GlConfigChooser implements GLSurfaceView.EGLConfigChooser {
*/ */
return String.format("EGLConfig rgba=%d%d%d%d depth=%d stencil=%d", return String.format("EGLConfig rgba=%d%d%d%d depth=%d stencil=%d",
Integer.valueOf(r), Integer.valueOf(g), Integer.valueOf(r), Integer.valueOf(g),
Integer.valueOf(b), Integer.valueOf(a), Integer.valueOf(d), Integer.valueOf(b), Integer.valueOf(a), Integer.valueOf(d),
Integer.valueOf(s)) Integer.valueOf(s))
+ " native=" + " native="
+ findConfigAttrib(egl, display, config, EGL10.EGL_NATIVE_RENDERABLE, 0) + findConfigAttrib(egl, display, config, EGL10.EGL_NATIVE_RENDERABLE, 0)
+ " buffer=" + " buffer="
+ findConfigAttrib(egl, display, config, EGL10.EGL_BUFFER_SIZE, 0) + findConfigAttrib(egl, display, config, EGL10.EGL_BUFFER_SIZE, 0)
+ String.format( + String.format(
" caveat=0x%04x", " caveat=0x%04x",
Integer.valueOf(findConfigAttrib(egl, display, config, Integer.valueOf(findConfigAttrib(egl, display, config,
EGL10.EGL_CONFIG_CAVEAT, 0))); EGL10.EGL_CONFIG_CAVEAT, 0)));
} }
private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config, private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config,
int attribute, int defaultValue) { int attribute, int defaultValue) {
if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) { if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
return mValue[0]; return mValue[0];
} }

View File

@ -41,12 +41,13 @@ public abstract class MapActivity extends Activity {
private static final String KEY_MAP_SCALE = "map_scale"; private static final String KEY_MAP_SCALE = "map_scale";
private static final String PREFERENCES_FILE = "MapActivity"; private static final String PREFERENCES_FILE = "MapActivity";
//private static final String KEY_THEME = "Theme"; //private static final String KEY_THEME = "Theme";
private static boolean containsViewport(SharedPreferences sharedPreferences) { private static boolean containsViewport(SharedPreferences sharedPreferences) {
return sharedPreferences.contains(KEY_LATITUDE) return sharedPreferences.contains(KEY_LATITUDE)
&& sharedPreferences.contains(KEY_LONGITUDE) && sharedPreferences.contains(KEY_LONGITUDE)
&& sharedPreferences.contains(KEY_MAP_SCALE); && sharedPreferences.contains(KEY_MAP_SCALE);
} }
protected Map mMap; protected Map mMap;
@ -73,7 +74,7 @@ public abstract class MapActivity extends Activity {
editor.putInt(KEY_LATITUDE, geoPoint.latitudeE6); editor.putInt(KEY_LATITUDE, geoPoint.latitudeE6);
editor.putInt(KEY_LONGITUDE, geoPoint.longitudeE6); editor.putInt(KEY_LONGITUDE, geoPoint.longitudeE6);
editor.putFloat(KEY_MAP_SCALE, (float)mapPosition.scale); editor.putFloat(KEY_MAP_SCALE, (float) mapPosition.scale);
//editor.putString(KEY_THEME, mMap.getRenderTheme()); //editor.putString(KEY_THEME, mMap.getRenderTheme());
@ -92,7 +93,7 @@ public abstract class MapActivity extends Activity {
/** /**
* This method is called once by each MapView during its setup process. * This method is called once by each MapView during its setup process.
* *
* @param map * @param map
* the calling MapView. * the calling MapView.
*/ */
@ -100,7 +101,7 @@ public abstract class MapActivity extends Activity {
mMap = map; mMap = map;
SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_FILE, SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_FILE,
MODE_PRIVATE); MODE_PRIVATE);
if (containsViewport(sharedPreferences)) { if (containsViewport(sharedPreferences)) {
// get and set the map position and zoom level // get and set the map position and zoom level
@ -108,7 +109,6 @@ public abstract class MapActivity extends Activity {
int longitudeE6 = sharedPreferences.getInt(KEY_LONGITUDE, 0); int longitudeE6 = sharedPreferences.getInt(KEY_LONGITUDE, 0);
float scale = sharedPreferences.getFloat(KEY_MAP_SCALE, 1); float scale = sharedPreferences.getFloat(KEY_MAP_SCALE, 1);
MapPosition mapPosition = new MapPosition(); MapPosition mapPosition = new MapPosition();
mapPosition.setPosition(latitudeE6 / 1E6, longitudeE6 / 1E6); mapPosition.setPosition(latitudeE6 / 1E6, longitudeE6 / 1E6);
mapPosition.setScale(scale); mapPosition.setScale(scale);
@ -119,18 +119,18 @@ public abstract class MapActivity extends Activity {
//String theme = sharedPreferences.getString(KEY_THEME, //String theme = sharedPreferences.getString(KEY_THEME,
// InternalRenderTheme.DEFAULT.name()); // InternalRenderTheme.DEFAULT.name());
// if (theme.startsWith("/")) { // if (theme.startsWith("/")) {
// try { // try {
// map.setRenderTheme(theme); // map.setRenderTheme(theme);
// } catch (FileNotFoundException e) { // } catch (FileNotFoundException e) {
// map.setRenderTheme(InternalRenderTheme.DEFAULT); // map.setRenderTheme(InternalRenderTheme.DEFAULT);
// } // }
// } else { // } else {
// try { // try {
// map.setRenderTheme(InternalRenderTheme.valueOf(theme)); // map.setRenderTheme(InternalRenderTheme.valueOf(theme));
// } catch (IllegalArgumentException e) { // } catch (IllegalArgumentException e) {
// map.setRenderTheme(InternalRenderTheme.DEFAULT); // map.setRenderTheme(InternalRenderTheme.DEFAULT);
// } // }
// } // }
} }
} }

View File

@ -1,4 +1,5 @@
package org.oscim.android; package org.oscim.android;
///* ///*
// * Copyright 2010, 2011, 2012 mapsforge.org // * Copyright 2010, 2011, 2012 mapsforge.org
// * Copyright 2013 Hannes Janetzek // * Copyright 2013 Hannes Janetzek

View File

@ -51,7 +51,6 @@ public class MapView extends RelativeLayout {
private int mWidth; private int mWidth;
private int mHeight; private int mHeight;
private final Map mMap; private final Map mMap;
final GLView mGLView; final GLView mGLView;
@ -89,7 +88,7 @@ public class MapView extends RelativeLayout {
if (!(context instanceof MapActivity)) { if (!(context instanceof MapActivity)) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"context is not an instance of MapActivity"); "context is not an instance of MapActivity");
} }
Log.logger = new AndroidLog(); Log.logger = new AndroidLog();
@ -100,7 +99,7 @@ public class MapView extends RelativeLayout {
this.setWillNotDraw(true); this.setWillNotDraw(true);
DisplayMetrics metrics = getResources().getDisplayMetrics(); DisplayMetrics metrics = getResources().getDisplayMetrics();
CanvasAdapter.dpi = (int)Math.max(metrics.xdpi, metrics.ydpi); CanvasAdapter.dpi = (int) Math.max(metrics.xdpi, metrics.ydpi);
// TODO make this dpi dependent // TODO make this dpi dependent
Tile.SIZE = 400; Tile.SIZE = 400;
@ -109,7 +108,7 @@ public class MapView extends RelativeLayout {
final MapView m = this; final MapView m = this;
mMap = new Map(){ mMap = new Map() {
boolean mWaitRedraw; boolean mWaitRedraw;
@ -181,8 +180,8 @@ public class MapView extends RelativeLayout {
mapActivity.registerMapView(mMap); mapActivity.registerMapView(mMap);
LayoutParams params = new LayoutParams( LayoutParams params = new LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT, android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.MATCH_PARENT); android.view.ViewGroup.LayoutParams.MATCH_PARENT);
addView(mGLView, params); addView(mGLView, params);
@ -190,7 +189,7 @@ public class MapView extends RelativeLayout {
mMap.updateMap(false); mMap.updateMap(false);
} }
View getView(){ View getView() {
return this; return this;
} }
@ -203,7 +202,6 @@ public class MapView extends RelativeLayout {
//mMap.destroy(); //mMap.destroy();
} }
void onPause() { void onPause() {
mPausing = true; mPausing = true;
@ -236,7 +234,7 @@ public class MapView extends RelativeLayout {
// synchronized ??? // synchronized ???
@Override @Override
protected void onSizeChanged(int width, int height, protected void onSizeChanged(int width, int height,
int oldWidth, int oldHeight) { int oldWidth, int oldHeight) {
Log.d(TAG, "onSizeChanged: " + width + "x" + height); Log.d(TAG, "onSizeChanged: " + width + "x" + height);
super.onSizeChanged(width, height, oldWidth, oldHeight); super.onSizeChanged(width, height, oldWidth, oldHeight);
@ -250,7 +248,6 @@ public class MapView extends RelativeLayout {
mMap.getViewport().setViewport(width, height); mMap.getViewport().setViewport(width, height);
} }
public void enableRotation(boolean enable) { public void enableRotation(boolean enable) {
mRotationEnabled = enable; mRotationEnabled = enable;

View File

@ -1,4 +1,5 @@
package org.oscim.android; package org.oscim.android;
///* ///*
// * Copyright 2010, 2011, 2012 mapsforge.org // * Copyright 2010, 2011, 2012 mapsforge.org
// * // *

View File

@ -31,11 +31,12 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
/** /**
* @param format ignored always ARGB8888 * @param format ignored always ARGB8888
*/ */
public AndroidBitmap(int width, int height, int format){ public AndroidBitmap(int width, int height, int format) {
mBitmap = android.graphics.Bitmap mBitmap = android.graphics.Bitmap
.createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888); .createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888);
} }
AndroidBitmap(android.graphics.Bitmap bitmap){
AndroidBitmap(android.graphics.Bitmap bitmap) {
mBitmap = bitmap; mBitmap = bitmap;
} }
@ -72,7 +73,7 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
if (replace) if (replace)
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, mBitmap, format, GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, mBitmap, format,
type); type);
else else
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format, mBitmap, type, 0); GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format, mBitmap, type, 0);

View File

@ -10,19 +10,21 @@ public class AndroidCanvas implements Canvas {
public AndroidCanvas() { public AndroidCanvas() {
this.canvas = new android.graphics.Canvas(); this.canvas = new android.graphics.Canvas();
} }
@Override @Override
public void setBitmap(Bitmap bitmap) { public void setBitmap(Bitmap bitmap) {
this.canvas.setBitmap(((AndroidBitmap)bitmap).mBitmap); this.canvas.setBitmap(((AndroidBitmap) bitmap).mBitmap);
} }
@Override @Override
public void drawText(String string, float x, float y, Paint stroke) { public void drawText(String string, float x, float y, Paint stroke) {
this.canvas.drawText(string, x, y, ((AndroidPaint)stroke).mPaint); this.canvas.drawText(string, x, y, ((AndroidPaint) stroke).mPaint);
} }
@Override @Override
public void drawBitmap(Bitmap bitmap, float x, float y) { public void drawBitmap(Bitmap bitmap, float x, float y) {
this.canvas.drawBitmap(((AndroidBitmap)bitmap).mBitmap, x, y, null); this.canvas.drawBitmap(((AndroidBitmap) bitmap).mBitmap, x, y, null);
} }

View File

@ -100,10 +100,10 @@ public final class AndroidGraphics extends CanvasAdapter {
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap()); return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
} }
android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap( android.graphics.Bitmap bitmap = android.graphics.Bitmap
drawable.getIntrinsicWidth(), .createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), drawable.getIntrinsicHeight(),
Config.ARGB_8888); Config.ARGB_8888);
android.graphics.Canvas canvas = new android.graphics.Canvas(bitmap); android.graphics.Canvas canvas = new android.graphics.Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());

View File

@ -63,7 +63,7 @@ class AndroidPaint implements Paint {
AndroidPaint() { AndroidPaint() {
mPaint = new android.graphics.Paint( mPaint = new android.graphics.Paint(
android.graphics.Paint.ANTI_ALIAS_FLAG); android.graphics.Paint.ANTI_ALIAS_FLAG);
} }
@Override @Override
@ -92,10 +92,12 @@ class AndroidPaint implements Paint {
} }
android.graphics.Bitmap androidBitmap = android.graphics.Bitmap android.graphics.Bitmap androidBitmap = android.graphics.Bitmap
.createBitmap(bitmap.getPixels(), bitmap.getWidth(), .createBitmap(bitmap.getPixels(),
bitmap.getHeight(), Config.ARGB_8888); bitmap.getWidth(),
bitmap.getHeight(),
Config.ARGB_8888);
Shader shader = new BitmapShader(androidBitmap, TileMode.REPEAT, Shader shader = new BitmapShader(androidBitmap, TileMode.REPEAT,
TileMode.REPEAT); TileMode.REPEAT);
mPaint.setShader(shader); mPaint.setShader(shader);
} }
@ -113,7 +115,7 @@ class AndroidPaint implements Paint {
@Override @Override
public void setStrokeCap(Cap cap) { public void setStrokeCap(Cap cap) {
android.graphics.Paint.Cap androidCap = android.graphics.Paint.Cap android.graphics.Paint.Cap androidCap = android.graphics.Paint.Cap
.valueOf(cap.name()); .valueOf(cap.name());
mPaint.setStrokeCap(androidCap); mPaint.setStrokeCap(androidCap);
} }
@ -140,7 +142,7 @@ class AndroidPaint implements Paint {
@Override @Override
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) { public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
Typeface typeface = Typeface.create(getTypeface(fontFamily), Typeface typeface = Typeface.create(getTypeface(fontFamily),
getStyle(fontStyle)); getStyle(fontStyle));
mPaint.setTypeface(typeface); mPaint.setTypeface(typeface);
} }

View File

@ -24,7 +24,6 @@ import android.opengl.GLES20;
public class AndroidGL implements GL20 { public class AndroidGL implements GL20 {
@Override @Override
public void glAttachShader(int program, int shader) { public void glAttachShader(int program, int shader) {
GLES20.glAttachShader(program, shader); GLES20.glAttachShader(program, shader);
@ -147,13 +146,13 @@ public class AndroidGL implements GL20 {
@Override @Override
public void glFramebufferRenderbuffer(int target, int attachment, int renderbuffertarget, public void glFramebufferRenderbuffer(int target, int attachment, int renderbuffertarget,
int renderbuffer) { int renderbuffer) {
GLES20.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); GLES20.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
} }
@Override @Override
public void glFramebufferTexture2D(int target, int attachment, int textarget, int texture, public void glFramebufferTexture2D(int target, int attachment, int textarget, int texture,
int level) { int level) {
GLES20.glFramebufferTexture2D(target, attachment, textarget, texture, level); GLES20.glFramebufferTexture2D(target, attachment, textarget, texture, level);
} }
@ -219,7 +218,7 @@ public class AndroidGL implements GL20 {
@Override @Override
public void glGetFramebufferAttachmentParameteriv(int target, int attachment, int pname, public void glGetFramebufferAttachmentParameteriv(int target, int attachment, int pname,
IntBuffer params) { IntBuffer params) {
GLES20.glGetFramebufferAttachmentParameteriv(target, attachment, pname, params); GLES20.glGetFramebufferAttachmentParameteriv(target, attachment, pname, params);
} }
@ -253,7 +252,7 @@ public class AndroidGL implements GL20 {
@Override @Override
public void glGetShaderPrecisionFormat(int shadertype, int precisiontype, IntBuffer range, public void glGetShaderPrecisionFormat(int shadertype, int precisiontype, IntBuffer range,
IntBuffer precision) { IntBuffer precision) {
GLES20.glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision); GLES20.glGetShaderPrecisionFormat(shadertype, precisiontype, range, precision);
} }
@ -590,13 +589,13 @@ public class AndroidGL implements GL20 {
@Override @Override
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
Buffer ptr) { Buffer ptr) {
GLES20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr); GLES20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
} }
@Override @Override
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride, public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
int offset) { int offset) {
// FIXME check implementation! // FIXME check implementation!
GLES20.glVertexAttribPointer(indx, size, type, normalized, stride, offset); GLES20.glVertexAttribPointer(indx, size, type, normalized, stride, offset);
//throw new UnsupportedOperationException("missing implementation"); //throw new UnsupportedOperationException("missing implementation");
@ -652,27 +651,27 @@ public class AndroidGL implements GL20 {
@Override @Override
public void glCompressedTexImage2D(int target, int level, int internalformat, int width, public void glCompressedTexImage2D(int target, int level, int internalformat, int width,
int height, int border, int imageSize, Buffer data) { int height, int border, int imageSize, Buffer data) {
throw new UnsupportedOperationException("missing implementation"); throw new UnsupportedOperationException("missing implementation");
} }
@Override @Override
public void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset, public void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset,
int width, int height, int format, int imageSize, Buffer data) { int width, int height, int format, int imageSize, Buffer data) {
throw new UnsupportedOperationException("missing implementation"); throw new UnsupportedOperationException("missing implementation");
} }
@Override @Override
public void glCopyTexImage2D(int target, int level, int internalformat, int x, int y, public void glCopyTexImage2D(int target, int level, int internalformat, int x, int y,
int width, int height, int border) { int width, int height, int border) {
GLES20.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border); GLES20.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
} }
@Override @Override
public void glCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y, public void glCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y,
int width, int height) { int width, int height) {
GLES20.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); GLES20.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
} }
@ -795,7 +794,7 @@ public class AndroidGL implements GL20 {
@Override @Override
public void glReadPixels(int x, int y, int width, int height, int format, int type, public void glReadPixels(int x, int y, int width, int height, int format, int type,
Buffer pixels) { Buffer pixels) {
GLES20.glReadPixels(x, y, width, height, format, type, pixels); GLES20.glReadPixels(x, y, width, height, format, type, pixels);
} }
@ -821,9 +820,9 @@ public class AndroidGL implements GL20 {
@Override @Override
public void glTexImage2D(int target, int level, int internalformat, int width, int height, public void glTexImage2D(int target, int level, int internalformat, int width, int height,
int border, int format, int type, Buffer pixels) { int border, int format, int type, Buffer pixels) {
GLES20.glTexImage2D(target, level, internalformat, width, height, border, format, type, GLES20.glTexImage2D(target, level, internalformat, width, height, border, format, type,
pixels); pixels);
} }
@Override @Override
@ -833,7 +832,7 @@ public class AndroidGL implements GL20 {
@Override @Override
public void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, public void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width,
int height, int format, int type, Buffer pixels) { int height, int format, int type, Buffer pixels) {
GLES20.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); GLES20.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
} }

View File

@ -13,6 +13,7 @@
* this program. If not, see <http://www.gnu.org/licenses/>. * this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
package org.oscim.android.input; package org.oscim.android.input;
import org.oscim.event.MotionEvent; import org.oscim.event.MotionEvent;
public class AndroidMotionEvent extends MotionEvent { public class AndroidMotionEvent extends MotionEvent {
@ -28,7 +29,7 @@ public class AndroidMotionEvent extends MotionEvent {
android.view.MotionEvent mEvent; android.view.MotionEvent mEvent;
public void wrap(android.view.MotionEvent e){ public void wrap(android.view.MotionEvent e) {
mEvent = e; mEvent = e;
} }
@ -36,6 +37,7 @@ public class AndroidMotionEvent extends MotionEvent {
public int getAction() { public int getAction() {
return mEvent.getAction(); return mEvent.getAction();
} }
@Override @Override
public float getX() { public float getX() {
return mEvent.getX(); return mEvent.getX();
@ -66,5 +68,4 @@ public class AndroidMotionEvent extends MotionEvent {
return mEvent.getEventTime(); return mEvent.getEventTime();
} }
} }

View File

@ -5,7 +5,7 @@ import java.util.ArrayList;
/** /**
* Triangulates a polygon into triangles - duh. Doesn't handle * Triangulates a polygon into triangles - duh. Doesn't handle
* holes in polys * holes in polys
* *
* @author Public Source from FlipCode * @author Public Source from FlipCode
*/ */
public class Triangulator { public class Triangulator {
@ -26,7 +26,7 @@ public class Triangulator {
/** /**
* Add a point describing the polygon to be triangulated * Add a point describing the polygon to be triangulated
* *
* @param x The x coordinate of the point * @param x The x coordinate of the point
* @param y the y coordinate of the point * @param y the y coordinate of the point
*/ */
@ -36,7 +36,7 @@ public class Triangulator {
/** /**
* Cause the triangulator to split the polygon * Cause the triangulator to split the polygon
* *
* @return True if we managed the task * @return True if we managed the task
*/ */
public boolean triangulate() { public boolean triangulate() {
@ -48,7 +48,7 @@ public class Triangulator {
/** /**
* Get a count of the number of triangles produced * Get a count of the number of triangles produced
* *
* @return The number of triangles produced * @return The number of triangles produced
*/ */
public int getTriangleCount() { public int getTriangleCount() {
@ -60,7 +60,7 @@ public class Triangulator {
/** /**
* Get a point on a specified generated triangle * Get a point on a specified generated triangle
* *
* @param tri The index of the triangle to interegate * @param tri The index of the triangle to interegate
* @param i The index of the point within the triangle to retrieve * @param i The index of the point within the triangle to retrieve
* (0 - 2) * (0 - 2)
@ -76,7 +76,7 @@ public class Triangulator {
/** /**
* Find the area of a polygon defined by the series of points * Find the area of a polygon defined by the series of points
* in the list * in the list
* *
* @param contour The list of points defined the contour of the polygon * @param contour The list of points defined the contour of the polygon
* (Vector2f) * (Vector2f)
* @return The area of the polygon defined * @return The area of the polygon defined
@ -91,7 +91,7 @@ public class Triangulator {
Point contourQ = contour.get(q); Point contourQ = contour.get(q);
A += contourP.getX() * contourQ.getY() - contourQ.getX() A += contourP.getX() * contourQ.getY() - contourQ.getX()
* contourP.getY(); * contourP.getY();
} }
return A * 0.5f; return A * 0.5f;
} }
@ -99,7 +99,7 @@ public class Triangulator {
/** /**
* Check if the point P is inside the triangle defined by * Check if the point P is inside the triangle defined by
* the points A,B,C * the points A,B,C
* *
* @param Ax Point A x-coordinate * @param Ax Point A x-coordinate
* @param Ay Point A y-coordinate * @param Ay Point A y-coordinate
* @param Bx Point B x-coordinate * @param Bx Point B x-coordinate
@ -111,7 +111,7 @@ public class Triangulator {
* @return True if the point specified is within the triangle * @return True if the point specified is within the triangle
*/ */
private static boolean insideTriangle(float Ax, float Ay, float Bx, private static boolean insideTriangle(float Ax, float Ay, float Bx,
float By, float Cx, float Cy, float Px, float Py) { float By, float Cx, float Cy, float Px, float Py) {
float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy; float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
float cCROSSap, bCROSScp, aCROSSbp; float cCROSSap, bCROSScp, aCROSSbp;
@ -138,7 +138,7 @@ public class Triangulator {
/** /**
* Cut a the contour and add a triangle into V to describe the * Cut a the contour and add a triangle into V to describe the
* location of the cut * location of the cut
* *
* @param contour The list of points defining the polygon * @param contour The list of points defining the polygon
* @param u The index of the first point * @param u The index of the first point
* @param v The index of the second point * @param v The index of the second point
@ -148,7 +148,7 @@ public class Triangulator {
* @return True if a triangle was found * @return True if a triangle was found
*/ */
private static boolean snip(PointList contour, int u, int v, int w, int n, private static boolean snip(PointList contour, int u, int v, int w, int n,
int[] V) { int[] V) {
int p; int p;
float Ax, Ay, Bx, By, Cx, Cy, Px, Py; float Ax, Ay, Bx, By, Cx, Cy, Px, Py;
@ -183,7 +183,7 @@ public class Triangulator {
/** /**
* Process a list of points defining a polygon * Process a list of points defining a polygon
* *
* @param contour The list of points describing the polygon * @param contour The list of points describing the polygon
* @param result The list of points describing the triangles. Groups * @param result The list of points describing the triangles. Groups
* of 3 describe each triangle * of 3 describe each triangle
@ -263,7 +263,7 @@ public class Triangulator {
/** /**
* A single point handled by the triangulator * A single point handled by the triangulator
* *
* @author Kevin Glass * @author Kevin Glass
*/ */
private class Point { private class Point {
@ -274,7 +274,7 @@ public class Triangulator {
/** /**
* Create a new point * Create a new point
* *
* @param x The x coordindate of the point * @param x The x coordindate of the point
* @param y The y coordindate of the point * @param y The y coordindate of the point
*/ */
@ -285,7 +285,7 @@ public class Triangulator {
/** /**
* Get the x coordinate of the point * Get the x coordinate of the point
* *
* @return The x coordinate of the point * @return The x coordinate of the point
*/ */
public float getX() { public float getX() {
@ -294,7 +294,7 @@ public class Triangulator {
/** /**
* Get the y coordinate of the point * Get the y coordinate of the point
* *
* @return The y coordinate of the point * @return The y coordinate of the point
*/ */
public float getY() { public float getY() {
@ -303,7 +303,7 @@ public class Triangulator {
/** /**
* Convert this point into a float array * Convert this point into a float array
* *
* @return The contents of this point as a float array * @return The contents of this point as a float array
*/ */
public float[] toArray() { public float[] toArray() {
@ -313,7 +313,7 @@ public class Triangulator {
/** /**
* A list of type <code>Point</code> * A list of type <code>Point</code>
* *
* @author Kevin Glass * @author Kevin Glass
*/ */
private class PointList { private class PointList {
@ -328,7 +328,7 @@ public class Triangulator {
/** /**
* Add a point to the list * Add a point to the list
* *
* @param point The point to add * @param point The point to add
*/ */
public void add(Point point) { public void add(Point point) {
@ -346,7 +346,7 @@ public class Triangulator {
/** /**
* Get the size of the list * Get the size of the list
* *
* @return The size of the list * @return The size of the list
*/ */
public int size() { public int size() {
@ -355,7 +355,7 @@ public class Triangulator {
/** /**
* Get a point a specific index in the list * Get a point a specific index in the list
* *
* @param i The index of the point to retrieve * @param i The index of the point to retrieve
* @return The point * @return The point
*/ */

View File

@ -27,7 +27,7 @@ public class OSMData {
private final Collection<OSMRelation> relations; private final Collection<OSMRelation> relations;
public OSMData(Collection<Bound> bounds, Collection<OSMNode> nodes, public OSMData(Collection<Bound> bounds, Collection<OSMNode> nodes,
Collection<OSMWay> ways, Collection<OSMRelation> relations) { Collection<OSMWay> ways, Collection<OSMRelation> relations) {
this.bounds = bounds; this.bounds = bounds;
this.nodes = nodes; this.nodes = nodes;

View File

@ -15,11 +15,12 @@
package org.oscim.utils.osm; package org.oscim.utils.osm;
public class OSMMember { public class OSMMember {
public enum MemberType{ public enum MemberType {
NODE, NODE,
WAY, WAY,
RELATIOM RELATIOM
} }
static final boolean useDebugLabels = true; static final boolean useDebugLabels = true;
public final String role; public final String role;

View File

@ -28,7 +28,7 @@ public class OSMRelation extends OSMElement {
public OSMRelation(TagSet tags, long id, int initialMemberSize) { public OSMRelation(TagSet tags, long id, int initialMemberSize) {
super(tags, id); super(tags, id);
this.relationMembers = this.relationMembers =
new ArrayList<OSMMember>(initialMemberSize); new ArrayList<OSMMember>(initialMemberSize);
} }
@Override @Override

View File

@ -29,7 +29,7 @@ public class OSMWay extends OSMElement {
public boolean isClosed() { public boolean isClosed() {
return nodes.size() > 0 && return nodes.size() > 0 &&
nodes.get(0).equals(nodes.get(nodes.size() - 1)); nodes.get(0).equals(nodes.get(nodes.size() - 1));
} }
@Override @Override

View File

@ -16,9 +16,6 @@ import org.oscim.utils.osm.OSMNode;
import org.oscim.utils.osm.OSMRelation; import org.oscim.utils.osm.OSMRelation;
import org.oscim.utils.osm.OSMWay; import org.oscim.utils.osm.OSMWay;
/** /**
* Class that reads and parses binary files and sends the contained entities to * Class that reads and parses binary files and sends the contained entities to
* the sink. * the sink.
@ -205,32 +202,31 @@ public class OsmPbfParser extends BinaryParser {
for (int j = 0; j < tagCnt; j++) for (int j = 0; j < tagCnt; j++)
tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j)))); tags.add(new Tag(getStringById(i.getKeys(j)), getStringById(i.getVals(j))));
long id = i.getId(); long id = i.getId();
long lastMid = 0; long lastMid = 0;
List<OSMMember> nodes = new ArrayList<OSMMember>(); List<OSMMember> nodes = new ArrayList<OSMMember>();
int memberCnt = i.getMemidsCount(); int memberCnt = i.getMemidsCount();
// for (int j = 0; j < memberCnt; j++) { // for (int j = 0; j < memberCnt; j++) {
// long mid = lastMid + i.getMemids(j); // long mid = lastMid + i.getMemids(j);
// lastMid = mid; // lastMid = mid;
// String role = getStringById(i.getRolesSid(j)); // String role = getStringById(i.getRolesSid(j));
// //
// Osmformat.Relation.MemberType t = i.getTypes(j); // Osmformat.Relation.MemberType t = i.getTypes(j);
// //
// if (t == Osmformat.Relation.MemberType.NODE) { // if (t == Osmformat.Relation.MemberType.NODE) {
// etype = EntityType.Node; // etype = EntityType.Node;
// } else if (t == Osmformat.Relation.MemberType.WAY) { // } else if (t == Osmformat.Relation.MemberType.WAY) {
// etype = EntityType.Way; // etype = EntityType.Way;
// } else if (t == Osmformat.Relation.MemberType.RELATION) { // } else if (t == Osmformat.Relation.MemberType.RELATION) {
// etype = EntityType.Relation; // etype = EntityType.Relation;
// } else { // } else {
// assert false; // TODO; Illegal file? // assert false; // TODO; Illegal file?
// } // }
// //
// nodes.add(new OSMMember(mid, etype, role)); // nodes.add(new OSMMember(mid, etype, role));
// } // }
// long id, int version, TimestampContainer timestampContainer, // long id, int version, TimestampContainer timestampContainer,
// OsmUser user, // OsmUser user,
@ -246,7 +242,7 @@ public class OsmPbfParser extends BinaryParser {
// tmp = new Relation(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE, // tmp = new Relation(new CommonEntityData(id, NOVERSION, NODATE, OsmUser.NONE,
// NOCHANGESET, tags), nodes); // NOCHANGESET, tags), nodes);
// } // }
// sink.process(new RelationContainer(tmp)); // sink.process(new RelationContainer(tmp));
} }
} }
@ -281,43 +277,42 @@ public class OsmPbfParser extends BinaryParser {
public OSMData getData() { public OSMData getData() {
// for (Entry<OSMRelation, List<TmpRelation>> entry : relationMembersForRelation // for (Entry<OSMRelation, List<TmpRelation>> entry : relationMembersForRelation
// .entrySet()) { // .entrySet()) {
// //
// OSMRelation relation = entry.getKey(); // OSMRelation relation = entry.getKey();
// //
// for (TmpRelation member : entry.getValue()) { // for (TmpRelation member : entry.getValue()) {
// //
// OSMElement memberObject = null; // OSMElement memberObject = null;
// //
// if ("node".equals(member)) { // if ("node".equals(member)) {
// memberObject = nodesById.get(member.id); // memberObject = nodesById.get(member.id);
// } else if ("way".equals(member)) { // } else if ("way".equals(member)) {
// memberObject = waysById.get(member.id); // memberObject = waysById.get(member.id);
// } else if ("relation".equals(member)) { // } else if ("relation".equals(member)) {
// memberObject = relationsById.get(member.id); // memberObject = relationsById.get(member.id);
// } else { // } else {
// // log("missing relation " + member.id); // // log("missing relation " + member.id);
// continue; // continue;
// } // }
// //
// if (memberObject != null) { // if (memberObject != null) {
// OSMMember ownMember = new OSMMember(member.role, // OSMMember ownMember = new OSMMember(member.role,
// memberObject); // memberObject);
// //
// relation.relationMembers.add(ownMember); // relation.relationMembers.add(ownMember);
// } // }
// } // }
// } // }
// give up references to original collections // give up references to original collections
ArrayList<OSMWay> ways = new ArrayList<OSMWay> (mWayMap.values()); ArrayList<OSMWay> ways = new ArrayList<OSMWay>(mWayMap.values());
ArrayList<OSMNode> nodes= new ArrayList<OSMNode> (mNodeMap.values()); ArrayList<OSMNode> nodes = new ArrayList<OSMNode>(mNodeMap.values());
Log.d("..", "nodes: " + nodes.size() + " ways: " + ways.size()); Log.d("..", "nodes: " + nodes.size() + " ways: " + ways.size());
return new OSMData(null, nodes, ways, null); return new OSMData(null, nodes, ways, null);
} }
} }

View File

@ -22,7 +22,7 @@ import org.oscim.utils.osm.OSMData;
public class OsmPbfReader { public class OsmPbfReader {
public static OSMData process(InputStream is){ public static OSMData process(InputStream is) {
OsmPbfParser parser = new OsmPbfParser(); OsmPbfParser parser = new OsmPbfParser();
try { try {

View File

@ -46,7 +46,7 @@ import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonParser; import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonToken; import com.fasterxml.jackson.core.JsonToken;
public class OverpassAPIReader { public class OverpassAPIReader {
private static final String OVERPASS_API = "http://city.informatik.uni-bremen.de/oapi/interpreter"; private static final String OVERPASS_API = "http://city.informatik.uni-bremen.de/oapi/interpreter";
private static final int RESPONSECODE_OK = 200; private static final int RESPONSECODE_OK = 200;
@ -75,7 +75,7 @@ public class OverpassAPIReader {
/** /**
* Creates a new instance with the specified geographical coordinates. * Creates a new instance with the specified geographical coordinates.
* *
* @param left * @param left
* The longitude marking the left edge of the bounding box. * The longitude marking the left edge of the bounding box.
* @param right * @param right
@ -89,12 +89,12 @@ public class OverpassAPIReader {
* http://www.openstreetmap.org/api/0.5). * http://www.openstreetmap.org/api/0.5).
*/ */
public OverpassAPIReader(final double left, final double right, public OverpassAPIReader(final double left, final double right,
final double top, final double bottom, final String baseUrl, final double top, final double bottom, final String baseUrl,
final String query) { final String query) {
String bbox = "(" + Math.min(top, bottom) + "," + Math.min(left, right) String bbox = "(" + Math.min(top, bottom) + "," + Math.min(left, right)
+ "," + Math.max(top, bottom) + "," + Math.max(left, right) + "," + Math.max(top, bottom) + "," + Math.max(left, right)
+ ")"; + ")";
this.query = query.replaceAll("\\{\\{bbox\\}\\}", bbox); this.query = query.replaceAll("\\{\\{bbox\\}\\}", bbox);
@ -103,7 +103,7 @@ public class OverpassAPIReader {
/** /**
* Open a connection to the given url and return a reader on the input * Open a connection to the given url and return a reader on the input
* stream from that connection. * stream from that connection.
* *
* @param pUrlStr * @param pUrlStr
* The exact url to connect to. * The exact url to connect to.
* @return An reader reading the input stream (servers answer) or * @return An reader reading the input stream (servers answer) or
@ -120,7 +120,7 @@ public class OverpassAPIReader {
myActiveConnection = (HttpURLConnection) url.openConnection(); myActiveConnection = (HttpURLConnection) url.openConnection();
myActiveConnection.setRequestProperty("Accept-Encoding", myActiveConnection.setRequestProperty("Accept-Encoding",
"gzip, deflate"); "gzip, deflate");
responseCode = myActiveConnection.getResponseCode(); responseCode = myActiveConnection.getResponseCode();
@ -132,11 +132,11 @@ public class OverpassAPIReader {
if (apiErrorMessage != null) { if (apiErrorMessage != null) {
message = "Received API HTTP response code " + responseCode message = "Received API HTTP response code " + responseCode
+ " with message \"" + apiErrorMessage + " with message \"" + apiErrorMessage
+ "\" for URL \"" + pUrlStr + "\"."; + "\" for URL \"" + pUrlStr + "\".";
} else { } else {
message = "Received API HTTP response code " + responseCode message = "Received API HTTP response code " + responseCode
+ " for URL \"" + pUrlStr + "\"."; + " for URL \"" + pUrlStr + "\".";
} }
throw new IOException(message); throw new IOException(message);
@ -151,7 +151,7 @@ public class OverpassAPIReader {
responseStream = new GZIPInputStream(responseStream); responseStream = new GZIPInputStream(responseStream);
} else if (encoding != null && encoding.equalsIgnoreCase("deflate")) { } else if (encoding != null && encoding.equalsIgnoreCase("deflate")) {
responseStream = new InflaterInputStream(responseStream, responseStream = new InflaterInputStream(responseStream,
new Inflater(true)); new Inflater(true));
} }
return responseStream; return responseStream;
@ -168,12 +168,12 @@ public class OverpassAPIReader {
private Map<Long, OSMWay> waysById = new HashMap<Long, OSMWay>(); private Map<Long, OSMWay> waysById = new HashMap<Long, OSMWay>();
private Map<Long, OSMRelation> relationsById = new HashMap<Long, OSMRelation>(); private Map<Long, OSMRelation> relationsById = new HashMap<Long, OSMRelation>();
private Map<OSMRelation, List<TmpRelation>> relationMembersForRelation = private Map<OSMRelation, List<TmpRelation>> relationMembersForRelation =
new HashMap<OSMRelation, List<TmpRelation>>(); new HashMap<OSMRelation, List<TmpRelation>>();
private final Collection<OSMNode> ownNodes = new ArrayList<OSMNode>(10000); private final Collection<OSMNode> ownNodes = new ArrayList<OSMNode>(10000);
private final Collection<OSMWay> ownWays = new ArrayList<OSMWay>(1000); private final Collection<OSMWay> ownWays = new ArrayList<OSMWay>(1000);
private final Collection<OSMRelation> ownRelations = new ArrayList<OSMRelation>( private final Collection<OSMRelation> ownRelations = new ArrayList<OSMRelation>(
100); 100);
public void parse(InputStream in) throws IOException { public void parse(InputStream in) throws IOException {
JsonFactory jsonFactory = new JsonFactory(); JsonFactory jsonFactory = new JsonFactory();
@ -208,7 +208,7 @@ public class OverpassAPIReader {
} }
private void parseNode(JsonParser jp) throws JsonParseException, private void parseNode(JsonParser jp) throws JsonParseException,
IOException { IOException {
long id = 0; long id = 0;
double lat = 0, lon = 0; double lat = 0, lon = 0;
@ -274,7 +274,7 @@ public class OverpassAPIReader {
} }
private void parseRelation(JsonParser jp) throws JsonParseException, private void parseRelation(JsonParser jp) throws JsonParseException,
IOException { IOException {
long id = 0; long id = 0;
TagSet tags = TagSet.EMPTY_TAG_SET; TagSet tags = TagSet.EMPTY_TAG_SET;
@ -318,22 +318,21 @@ public class OverpassAPIReader {
} }
private static TagSet parseTags(JsonParser jp) throws JsonParseException, private static TagSet parseTags(JsonParser jp) throws JsonParseException,
IOException { IOException {
TagSet tags = null; TagSet tags = null;
while (jp.nextToken() != JsonToken.END_OBJECT) { while (jp.nextToken() != JsonToken.END_OBJECT) {
String key = jp.getCurrentName(); String key = jp.getCurrentName();
jp.nextToken(); jp.nextToken();
String val = jp.getText(); String val = jp.getText();
if (tags== null) if (tags == null)
tags= new TagSet(4); tags = new TagSet(4);
tags.add(new Tag(key, val, false)); tags.add(new Tag(key, val, false));
} }
if (tags== null) if (tags == null)
return TagSet.EMPTY_TAG_SET; return TagSet.EMPTY_TAG_SET;
return tags; return tags;
@ -343,7 +342,6 @@ public class OverpassAPIReader {
System.out.println(msg); System.out.println(msg);
} }
public OSMData getData() { public OSMData getData() {
String encoded; String encoded;
@ -374,7 +372,7 @@ public class OverpassAPIReader {
} }
for (Entry<OSMRelation, List<TmpRelation>> entry : relationMembersForRelation for (Entry<OSMRelation, List<TmpRelation>> entry : relationMembersForRelation
.entrySet()) { .entrySet()) {
OSMRelation relation = entry.getKey(); OSMRelation relation = entry.getKey();
@ -395,14 +393,14 @@ public class OverpassAPIReader {
if (memberObject != null) { if (memberObject != null) {
OSMMember ownMember = new OSMMember(member.role, OSMMember ownMember = new OSMMember(member.role,
memberObject); memberObject);
relation.relationMembers.add(ownMember); relation.relationMembers.add(ownMember);
} }
} }
} }
log("nodes: " + ownNodes.size() + " ways: " + ownWays.size() log("nodes: " + ownNodes.size() + " ways: " + ownWays.size()
+ " relations: " + ownRelations.size()); + " relations: " + ownRelations.size());
// give up references to original collections // give up references to original collections
nodesById = null; nodesById = null;

View File

@ -75,14 +75,14 @@ abstract class Geometry implements Serializable {
static final int GEOMETRYCOLLECTION = 7; static final int GEOMETRYCOLLECTION = 7;
static final String[] ALLTYPES = new String[] { static final String[] ALLTYPES = new String[] {
"", // internally used LinearRing does not have any text in front of "", // internally used LinearRing does not have any text in front of
// it // it
"POINT", "LINESTRING", "POLYGON", "MULTIPOINT", "MULTILINESTRING", "POINT", "LINESTRING", "POLYGON", "MULTIPOINT", "MULTILINESTRING",
"MULTIPOLYGON", "GEOMETRYCOLLECTION" }; "MULTIPOLYGON", "GEOMETRYCOLLECTION" };
/** /**
* The Text representations of the geometry types * The Text representations of the geometry types
* *
* @param type * @param type
* ... * ...
* @return ... * @return ...
@ -125,7 +125,7 @@ abstract class Geometry implements Serializable {
/** /**
* Parse a SRID value, anything <= 0 is unknown * Parse a SRID value, anything <= 0 is unknown
* *
* @param srid * @param srid
* ... * ...
* @return ... * @return ...
@ -140,7 +140,7 @@ abstract class Geometry implements Serializable {
/** /**
* Constructor for subclasses * Constructor for subclasses
* *
* @param type * @param type
* has to be given by all subclasses. * has to be given by all subclasses.
*/ */
@ -162,30 +162,30 @@ abstract class Geometry implements Serializable {
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
return (other != null) && (other instanceof Geometry) return (other != null) && (other instanceof Geometry)
&& equals((Geometry) other); && equals((Geometry) other);
} }
/** /**
* geometry specific equals implementation - only defined for non-null * geometry specific equals implementation - only defined for non-null
* values * values
* *
* @param other * @param other
* ... * ...
* @return ... * @return ...
*/ */
public boolean equals(Geometry other) { public boolean equals(Geometry other) {
return (other != null) && (this.dimension == other.dimension) return (other != null) && (this.dimension == other.dimension)
&& (this.type == other.type) && (this.srid == other.srid) && (this.type == other.type) && (this.srid == other.srid)
&& (this.haveMeasure == other.haveMeasure) && (this.haveMeasure == other.haveMeasure)
&& other.getClass().equals(this.getClass()) && other.getClass().equals(this.getClass())
&& this.equalsintern(other); && this.equalsintern(other);
} }
/** /**
* Whether test coordinates for geometry - subclass specific code * Whether test coordinates for geometry - subclass specific code
* Implementors can assume that dimensin, type, srid * Implementors can assume that dimensin, type, srid
* and haveMeasure are equal, other != null and other is the same subclass. * and haveMeasure are equal, other != null and other is the same subclass.
* *
* @param other * @param other
* ... * ...
* @return ... * @return ...
@ -194,14 +194,14 @@ abstract class Geometry implements Serializable {
/** /**
* Return the number of Points of the geometry * Return the number of Points of the geometry
* *
* @return ... * @return ...
*/ */
abstract int numPoints(); abstract int numPoints();
/** /**
* Get the nth Point of the geometry * Get the nth Point of the geometry
* *
* @param n * @param n
* the index of the point, from 0 to numPoints()-1; * the index of the point, from 0 to numPoints()-1;
* @throws ArrayIndexOutOfBoundsException * @throws ArrayIndexOutOfBoundsException
@ -222,7 +222,7 @@ abstract class Geometry implements Serializable {
/** /**
* The OGIS geometry type number of this geometry. * The OGIS geometry type number of this geometry.
* *
* @return ... * @return ...
*/ */
int getType() { int getType() {
@ -231,7 +231,7 @@ abstract class Geometry implements Serializable {
/** /**
* Return the Type as String * Return the Type as String
* *
* @return ... * @return ...
*/ */
String getTypeString() { String getTypeString() {
@ -240,7 +240,7 @@ abstract class Geometry implements Serializable {
/** /**
* Returns whether we have a measure * Returns whether we have a measure
* *
* @return .... * @return ....
*/ */
boolean isMeasured() { boolean isMeasured() {
@ -251,7 +251,7 @@ abstract class Geometry implements Serializable {
* Queries the number of geometric dimensions of this geometry. This does * Queries the number of geometric dimensions of this geometry. This does
* not include measures, as opposed to the * not include measures, as opposed to the
* server. * server.
* *
* @return The dimensionality (eg, 2D or 3D) of this geometry. * @return The dimensionality (eg, 2D or 3D) of this geometry.
*/ */
int getDimension() { int getDimension() {
@ -260,7 +260,7 @@ abstract class Geometry implements Serializable {
/** /**
* The OGIS geometry type number of this geometry. * The OGIS geometry type number of this geometry.
* *
* @return ... * @return ...
*/ */
int getSrid() { int getSrid() {
@ -270,7 +270,7 @@ abstract class Geometry implements Serializable {
/** /**
* Recursively sets the srid on this geometry and all contained * Recursively sets the srid on this geometry and all contained
* subgeometries * subgeometries
* *
* @param srid * @param srid
* ... * ...
*/ */
@ -293,7 +293,7 @@ abstract class Geometry implements Serializable {
/** /**
* Render the WKT version of this Geometry (without SRID) into the given * Render the WKT version of this Geometry (without SRID) into the given
* StringBuffer. * StringBuffer.
* *
* @param sb * @param sb
* ... * ...
* @param putM * @param putM
@ -314,7 +314,7 @@ abstract class Geometry implements Serializable {
/** /**
* Render the WKT without the type name, but including the brackets into the * Render the WKT without the type name, but including the brackets into the
* StringBuffer * StringBuffer
* *
* @param sb * @param sb
* ... * ...
*/ */
@ -327,7 +327,7 @@ abstract class Geometry implements Serializable {
/** /**
* Render the "inner" part of the WKT (inside the brackets) into the * Render the "inner" part of the WKT (inside the brackets) into the
* StringBuffer. * StringBuffer.
* *
* @param SB * @param SB
* ... * ...
*/ */
@ -335,7 +335,7 @@ abstract class Geometry implements Serializable {
/** /**
* backwards compatibility method * backwards compatibility method
* *
* @return ... * @return ...
*/ */
String getValue() { String getValue() {
@ -354,7 +354,7 @@ abstract class Geometry implements Serializable {
* NULL or inconsistent subgeometries. BinaryParser and WKTParser should * NULL or inconsistent subgeometries. BinaryParser and WKTParser should
* only generate consistent geometries. * only generate consistent geometries.
* BinaryWriter may produce invalid results on inconsistent geometries. * BinaryWriter may produce invalid results on inconsistent geometries.
* *
* @return true if all checks are passed. * @return true if all checks are passed.
*/ */
boolean checkConsistency() { boolean checkConsistency() {
@ -363,7 +363,7 @@ abstract class Geometry implements Serializable {
/** /**
* Splits the SRID=4711; part of a EWKT rep if present and sets the srid. * Splits the SRID=4711; part of a EWKT rep if present and sets the srid.
* *
* @param value * @param value
* ... * ...
* @return value without the SRID=4711; part * @return value without the SRID=4711; part
@ -374,7 +374,7 @@ abstract class Geometry implements Serializable {
int index = v.indexOf(';', 5); // sridprefix length is 5 int index = v.indexOf(';', 5); // sridprefix length is 5
if (index == -1) { if (index == -1) {
throw new IllegalArgumentException( throw new IllegalArgumentException(
"Error parsing Geometry - SRID not delimited with ';' "); "Error parsing Geometry - SRID not delimited with ';' ");
} }
this.srid = Integer.parseInt(v.substring(5, index)); this.srid = Integer.parseInt(v.substring(5, index));
return v.substring(index + 1).trim(); return v.substring(index + 1).trim();

View File

@ -37,7 +37,7 @@ abstract class ValueGetter {
/** /**
* Get a byte, should be equal for all endians * Get a byte, should be equal for all endians
* *
* @return ... * @return ...
*/ */
byte getByte() { byte getByte() {
@ -58,7 +58,7 @@ abstract class ValueGetter {
/** /**
* Get a 32-Bit integer * Get a 32-Bit integer
* *
* @param index * @param index
* ... * ...
* @return ... * @return ...
@ -68,7 +68,7 @@ abstract class ValueGetter {
/** /**
* Get a long value. This is not needed directly, but as a nice side-effect * Get a long value. This is not needed directly, but as a nice side-effect
* from GetDouble. * from GetDouble.
* *
* @param index * @param index
* ... * ...
* @return ... * @return ...
@ -77,7 +77,7 @@ abstract class ValueGetter {
/** /**
* Get a double. * Get a double.
* *
* @return ... * @return ...
*/ */
double getDouble() { double getDouble() {
@ -95,19 +95,19 @@ abstract class ValueGetter {
@Override @Override
protected int getInt(int index) { protected int getInt(int index) {
return ((data[index] & 0xFF) << 24) + ((data[index + 1] & 0xFF) << 16) return ((data[index] & 0xFF) << 24) + ((data[index + 1] & 0xFF) << 16)
+ ((data[index + 2] & 0xFF) << 8) + (data[index + 3] & 0xFF); + ((data[index + 2] & 0xFF) << 8) + (data[index + 3] & 0xFF);
} }
@Override @Override
protected long getLong(int index) { protected long getLong(int index) {
return ((long) (data[index] & 0xFF) << 56) | ((long) (data[index + 1] & 0xFF) << 48) return ((long) (data[index] & 0xFF) << 56) | ((long) (data[index + 1] & 0xFF) << 48)
| ((long) (data[index + 2] & 0xFF) << 40) | ((long) (data[index + 2] & 0xFF) << 40)
| ((long) (data[index + 3] & 0xFF) << 32) | ((long) (data[index + 3] & 0xFF) << 32)
| ((long) (data[index + 4] & 0xFF) << 24) | ((long) (data[index + 4] & 0xFF) << 24)
| ((long) (data[index + 5] & 0xFF) << 16) | ((long) (data[index + 5] & 0xFF) << 16)
| ((long) (data[index + 6] & 0xFF) << 8) | ((long) (data[index + 6] & 0xFF) << 8)
| ((long) (data[index + 7] & 0xFF) << 0); | ((long) (data[index + 7] & 0xFF) << 0);
} }
} }
@ -121,18 +121,18 @@ abstract class ValueGetter {
@Override @Override
protected int getInt(int index) { protected int getInt(int index) {
return ((data[index + 3] & 0xFF) << 24) + ((data[index + 2] & 0xFF) << 16) return ((data[index + 3] & 0xFF) << 24) + ((data[index + 2] & 0xFF) << 16)
+ ((data[index + 1] & 0xFF) << 8) + (data[index] & 0xFF); + ((data[index + 1] & 0xFF) << 8) + (data[index] & 0xFF);
} }
@Override @Override
protected long getLong(int index) { protected long getLong(int index) {
return ((long) (data[index + 7] & 0xFF) << 56) return ((long) (data[index + 7] & 0xFF) << 56)
| ((long) (data[index + 6] & 0xFF) << 48) | ((long) (data[index + 6] & 0xFF) << 48)
| ((long) (data[index + 5] & 0xFF) << 40) | ((long) (data[index + 5] & 0xFF) << 40)
| ((long) (data[index + 4] & 0xFF) << 32) | ((long) (data[index + 4] & 0xFF) << 32)
| ((long) (data[index + 3] & 0xFF) << 24) | ((long) (data[index + 3] & 0xFF) << 24)
| ((long) (data[index + 2] & 0xFF) << 16) | ((long) (data[index + 2] & 0xFF) << 16)
| ((long) (data[index + 1] & 0xFF) << 8) | ((long) (data[index] & 0xFF) << 0); | ((long) (data[index + 1] & 0xFF) << 8) | ((long) (data[index] & 0xFF) << 0);
} }
} }

View File

@ -73,35 +73,35 @@ public class WKBReader {
data.getInt(); data.getInt();
} }
switch (realtype) { switch (realtype) {
case Geometry.POINT: case Geometry.POINT:
mGeom.startPoints(); mGeom.startPoints();
parsePoint(data, haveZ, haveM); parsePoint(data, haveZ, haveM);
break; break;
case Geometry.LINESTRING: case Geometry.LINESTRING:
mGeom.startLine(); mGeom.startLine();
parseLineString(data, haveZ, haveM); parseLineString(data, haveZ, haveM);
break; break;
case Geometry.POLYGON: case Geometry.POLYGON:
mGeom.startPolygon(); mGeom.startPolygon();
parsePolygon(data, haveZ, haveM); parsePolygon(data, haveZ, haveM);
break; break;
case Geometry.MULTIPOINT: case Geometry.MULTIPOINT:
mGeom.startPoints(); mGeom.startPoints();
parseMultiPoint(data); parseMultiPoint(data);
break; break;
case Geometry.MULTILINESTRING: case Geometry.MULTILINESTRING:
mGeom.startLine(); mGeom.startLine();
parseMultiLineString(data); parseMultiLineString(data);
break; break;
case Geometry.MULTIPOLYGON: case Geometry.MULTIPOLYGON:
mGeom.startPolygon(); mGeom.startPolygon();
parseMultiPolygon(data); parseMultiPolygon(data);
break; break;
case Geometry.GEOMETRYCOLLECTION: case Geometry.GEOMETRYCOLLECTION:
parseCollection(data); parseCollection(data);
break; break;
default: default:
throw new IllegalArgumentException("Unknown Geometry Type: " + realtype); throw new IllegalArgumentException("Unknown Geometry Type: " + realtype);
} }
if (count == 0) { if (count == 0) {
@ -132,7 +132,7 @@ public class WKBReader {
/** /**
* Parse an Array of "full" Geometries * Parse an Array of "full" Geometries
* *
* @param data * @param data
* ... * ...
* @param count * @param count
@ -193,7 +193,6 @@ public class WKBReader {
if (i > 0) if (i > 0)
mGeom.startHole(); mGeom.startHole();
int points = data.getInt(); int points = data.getInt();
for (int j = 0; j < points; j++) { for (int j = 0; j < points; j++) {
@ -254,7 +253,7 @@ public class WKBReader {
/** /**
* Converting a string of hex character to bytes * Converting a string of hex character to bytes
* *
* from http://stackoverflow.com/questions/140131/convert-a-string- * from http://stackoverflow.com/questions/140131/convert-a-string-
* representation-of-a-hex-dump-to-a-byte-array-using-java * representation-of-a-hex-dump-to-a-byte-array-using-java
*/ */

View File

@ -16,8 +16,7 @@ package org.oscim.android;
import android.util.Log; import android.util.Log;
public class AndroidLog implements org.oscim.backend.Log.Logger {
public class AndroidLog implements org.oscim.backend.Log.Logger{
@Override @Override
public void d(String tag, String msg) { public void d(String tag, String msg) {

View File

@ -31,11 +31,12 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
/** /**
* @param format ignored always ARGB8888 * @param format ignored always ARGB8888
*/ */
public AndroidBitmap(int width, int height, int format){ public AndroidBitmap(int width, int height, int format) {
mBitmap = android.graphics.Bitmap mBitmap = android.graphics.Bitmap
.createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888); .createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888);
} }
AndroidBitmap(android.graphics.Bitmap bitmap){
AndroidBitmap(android.graphics.Bitmap bitmap) {
mBitmap = bitmap; mBitmap = bitmap;
} }
@ -72,7 +73,7 @@ public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
if (replace) if (replace)
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, mBitmap, format, GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, mBitmap, format,
type); type);
else else
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format, mBitmap, type, 0); GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format, mBitmap, type, 0);

View File

@ -10,19 +10,21 @@ public class AndroidCanvas implements Canvas {
public AndroidCanvas() { public AndroidCanvas() {
this.canvas = new android.graphics.Canvas(); this.canvas = new android.graphics.Canvas();
} }
@Override @Override
public void setBitmap(Bitmap bitmap) { public void setBitmap(Bitmap bitmap) {
this.canvas.setBitmap(((AndroidBitmap)bitmap).mBitmap); this.canvas.setBitmap(((AndroidBitmap) bitmap).mBitmap);
} }
@Override @Override
public void drawText(String string, float x, float y, Paint stroke) { public void drawText(String string, float x, float y, Paint stroke) {
this.canvas.drawText(string, x, y, ((AndroidPaint)stroke).mPaint); this.canvas.drawText(string, x, y, ((AndroidPaint) stroke).mPaint);
} }
@Override @Override
public void drawBitmap(Bitmap bitmap, float x, float y) { public void drawBitmap(Bitmap bitmap, float x, float y) {
this.canvas.drawBitmap(((AndroidBitmap)bitmap).mBitmap, x, y, null); this.canvas.drawBitmap(((AndroidBitmap) bitmap).mBitmap, x, y, null);
} }

View File

@ -94,10 +94,10 @@ public final class AndroidGraphics extends CanvasAdapter {
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap()); return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
} }
android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap( android.graphics.Bitmap bitmap = android.graphics.Bitmap
drawable.getIntrinsicWidth(), .createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), drawable.getIntrinsicHeight(),
Config.ARGB_8888); Config.ARGB_8888);
android.graphics.Canvas canvas = new android.graphics.Canvas(bitmap); android.graphics.Canvas canvas = new android.graphics.Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());

View File

@ -62,8 +62,7 @@ class AndroidPaint implements Paint {
final android.graphics.Paint mPaint; final android.graphics.Paint mPaint;
AndroidPaint() { AndroidPaint() {
mPaint = new android.graphics.Paint( mPaint = new android.graphics.Paint(android.graphics.Paint.ANTI_ALIAS_FLAG);
android.graphics.Paint.ANTI_ALIAS_FLAG);
} }
@Override @Override
@ -92,10 +91,10 @@ class AndroidPaint implements Paint {
} }
android.graphics.Bitmap androidBitmap = android.graphics.Bitmap android.graphics.Bitmap androidBitmap = android.graphics.Bitmap
.createBitmap(bitmap.getPixels(), bitmap.getWidth(), .createBitmap(bitmap.getPixels(), bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888); bitmap.getHeight(), Config.ARGB_8888);
Shader shader = new BitmapShader(androidBitmap, TileMode.REPEAT, Shader shader = new BitmapShader(androidBitmap, TileMode.REPEAT,
TileMode.REPEAT); TileMode.REPEAT);
mPaint.setShader(shader); mPaint.setShader(shader);
} }
@ -113,7 +112,7 @@ class AndroidPaint implements Paint {
@Override @Override
public void setStrokeCap(Cap cap) { public void setStrokeCap(Cap cap) {
android.graphics.Paint.Cap androidCap = android.graphics.Paint.Cap android.graphics.Paint.Cap androidCap = android.graphics.Paint.Cap
.valueOf(cap.name()); .valueOf(cap.name());
mPaint.setStrokeCap(androidCap); mPaint.setStrokeCap(androidCap);
} }
@ -141,7 +140,7 @@ class AndroidPaint implements Paint {
@Override @Override
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) { public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
Typeface typeface = Typeface.create(getTypeface(fontFamily), Typeface typeface = Typeface.create(getTypeface(fontFamily),
getStyle(fontStyle)); getStyle(fontStyle));
mPaint.setTypeface(typeface); mPaint.setTypeface(typeface);
} }

View File

@ -56,4 +56,4 @@ public class MainActivity extends AndroidApplication {
initDefaultLayers(ts, true, true, true); initDefaultLayers(ts, true, true, true);
} }
} }
} }

View File

@ -37,7 +37,7 @@ public class AwtBitmap implements Bitmap {
this.width = this.bitmap.getWidth(); this.width = this.bitmap.getWidth();
this.height = this.bitmap.getHeight(); this.height = this.bitmap.getHeight();
if (!this.bitmap.isAlphaPremultiplied() if (!this.bitmap.isAlphaPremultiplied()
&& this.bitmap.getType() == BufferedImage.TYPE_INT_ARGB) && this.bitmap.getType() == BufferedImage.TYPE_INT_ARGB)
this.bitmap.coerceData(true); this.bitmap.coerceData(true);
} }
@ -97,13 +97,13 @@ public class AwtBitmap implements Bitmap {
for (int i = 0, n = width * height; i < n; i++) { for (int i = 0, n = width * height; i < n; i++) {
int c = pixels[i]; int c = pixels[i];
//if (internal) { //if (internal) {
float alpha = (c >>> 24) / 255f; float alpha = (c >>> 24) / 255f;
int r = (int) ((c & 0x000000ff) * alpha); int r = (int) ((c & 0x000000ff) * alpha);
int b = (int) (((c & 0x00ff0000) >>> 16) * alpha); int b = (int) (((c & 0x00ff0000) >>> 16) * alpha);
int g = (int) (((c & 0x0000ff00) >>> 8) * alpha); int g = (int) (((c & 0x0000ff00) >>> 8) * alpha);
pixels[i] = (c & 0xff000000) | r << 16 | g << 8 | b; pixels[i] = (c & 0xff000000) | r << 16 | g << 8 | b;
//} else { //} else {
// flip blue with red - silly Java // flip blue with red - silly Java
// pixels[i] = (c & 0xff00ff00) | (c & 0x00ff0000) >>> 16 | (c & 0x000000ff) << 16; // pixels[i] = (c & 0xff00ff00) | (c & 0x00ff0000) >>> 16 | (c & 0x000000ff) << 16;
//} //}
} }

View File

@ -39,7 +39,7 @@ public class AwtCanvas implements Canvas {
if (canvas != null) if (canvas != null)
canvas.dispose(); canvas.dispose();
AwtBitmap awtBitamp = (AwtBitmap)bitmap; AwtBitmap awtBitamp = (AwtBitmap) bitmap;
canvas = awtBitamp.bitmap.createGraphics(); canvas = awtBitamp.bitmap.createGraphics();
@ -48,22 +48,22 @@ public class AwtCanvas implements Canvas {
canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f)); canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
canvas.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON ); canvas.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
//canvas.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); //canvas.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
canvas.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); canvas.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
canvas.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); canvas.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
} }
@Override @Override
public void drawText(String text, float x, float y, Paint paint) { public void drawText(String text, float x, float y, Paint paint) {
// if (paint.isTransparent()) { // if (paint.isTransparent()) {
// return; // return;
// } // }
AwtPaint awtPaint = (AwtPaint)paint; AwtPaint awtPaint = (AwtPaint) paint;
//AwtPaint awtPaint = AwtGraphicFactory.getAwtPaint(paint); //AwtPaint awtPaint = AwtGraphicFactory.getAwtPaint(paint);
@ -73,7 +73,9 @@ public class AwtCanvas implements Canvas {
canvas.drawString(text, x + 2, y); canvas.drawString(text, x + 2, y);
} else { } else {
setColorAndStroke(awtPaint); setColorAndStroke(awtPaint);
TextLayout textLayout = new TextLayout(text, awtPaint.font, canvas.getFontRenderContext()); TextLayout textLayout = new TextLayout(text,
awtPaint.font,
canvas.getFontRenderContext());
AffineTransform affineTransform = new AffineTransform(); AffineTransform affineTransform = new AffineTransform();
affineTransform.translate(x + 2, y); affineTransform.translate(x + 2, y);
canvas.draw(textLayout.getOutline(affineTransform)); canvas.draw(textLayout.getOutline(affineTransform));
@ -87,19 +89,19 @@ public class AwtCanvas implements Canvas {
} }
} }
// @Override // @Override
// public void drawText(String string, float x, float y, Paint stroke) { // public void drawText(String string, float x, float y, Paint stroke) {
// AwtPaint p = (AwtPaint)stroke; // AwtPaint p = (AwtPaint)stroke;
// //
// canvas.setFont(p.font); // canvas.setFont(p.font);
// canvas.setColor(p.color); // canvas.setColor(p.color);
// //
// canvas.drawString(string, (int)x, (int)y); // canvas.drawString(string, (int)x, (int)y);
// } // }
@Override @Override
public void drawBitmap(Bitmap bitmap, float x, float y) { public void drawBitmap(Bitmap bitmap, float x, float y) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
throw new UnknownError("not implemented"); throw new UnknownError("not implemented");
} }
} }

View File

@ -52,12 +52,14 @@ public class AwtGraphics extends CanvasAdapter {
static final Graphics2D canvas; static final Graphics2D canvas;
static { static {
image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); image = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
canvas = image.createGraphics(); canvas = image.createGraphics();
canvas.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON ); canvas.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
//canvas.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON); //canvas.setRenderingHint(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
//canvas.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); //canvas.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
} }
static synchronized FontMetrics getFontMetrics(Font font) { static synchronized FontMetrics getFontMetrics(Font font) {
canvas.setFont(font); canvas.setFont(font);
// get character measurements // get character measurements
@ -77,13 +79,13 @@ public class AwtGraphics extends CanvasAdapter {
} }
@Override @Override
public Bitmap decodeBitmap(InputStream inputStream) { public Bitmap decodeBitmap(InputStream inputStream) {
try { try {
return new AwtBitmap(inputStream); return new AwtBitmap(inputStream);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
} }
@Override @Override

View File

@ -32,12 +32,12 @@ public class AwtPaint implements Paint {
private static int getCap(Cap cap) { private static int getCap(Cap cap) {
switch (cap) { switch (cap) {
case BUTT: case BUTT:
return BasicStroke.CAP_BUTT; return BasicStroke.CAP_BUTT;
case ROUND: case ROUND:
return BasicStroke.CAP_ROUND; return BasicStroke.CAP_ROUND;
case SQUARE: case SQUARE:
return BasicStroke.CAP_SQUARE; return BasicStroke.CAP_SQUARE;
} }
throw new IllegalArgumentException("unknown cap: " + cap); throw new IllegalArgumentException("unknown cap: " + cap);
@ -60,6 +60,7 @@ public class AwtPaint implements Paint {
private int cap; private int cap;
private float strokeWidth; private float strokeWidth;
//private Align mAlign; //private Align mAlign;
@Override @Override

View File

@ -0,0 +1,890 @@
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* 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.
******************************************************************************/
package org.oscim.gdx;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.EXTFramebufferObject;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.utils.GdxRuntimeException;
/**
* An implementation of the {@link GL20} interface based on LWJGL. Note that
* LWJGL shaders and OpenGL ES shaders will not be 100%
* compatible. Some glGetXXX methods are not implemented.
*
* @author mzechner
*/
public final class GdxGL20 implements org.oscim.backend.GL20 {
public void glActiveTexture(int texture) {
GL13.glActiveTexture(texture);
}
public void glAttachShader(int program, int shader) {
GL20.glAttachShader(program, shader);
}
public void glBindAttribLocation(int program, int index, String name) {
GL20.glBindAttribLocation(program, index, name);
}
public void glBindBuffer(int target, int buffer) {
GL15.glBindBuffer(target, buffer);
}
public void glBindFramebuffer(int target, int framebuffer) {
EXTFramebufferObject.glBindFramebufferEXT(target, framebuffer);
}
public void glBindRenderbuffer(int target, int renderbuffer) {
EXTFramebufferObject.glBindRenderbufferEXT(target, renderbuffer);
}
public void glBindTexture(int target, int texture) {
GL11.glBindTexture(target, texture);
}
public void glBlendColor(float red, float green, float blue, float alpha) {
GL14.glBlendColor(red, green, blue, alpha);
}
public void glBlendEquation(int mode) {
GL14.glBlendEquation(mode);
}
public void glBlendEquationSeparate(int modeRGB, int modeAlpha) {
GL20.glBlendEquationSeparate(modeRGB, modeAlpha);
}
public void glBlendFunc(int sfactor, int dfactor) {
GL11.glBlendFunc(sfactor, dfactor);
}
public void glBlendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
GL14.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
public void glBufferData(int target, int size, Buffer data, int usage) {
if (data == null)
throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
else if (data instanceof ByteBuffer)
GL15.glBufferData(target, (ByteBuffer) data, usage);
else if (data instanceof IntBuffer)
GL15.glBufferData(target, (IntBuffer) data, usage);
else if (data instanceof FloatBuffer)
GL15.glBufferData(target, (FloatBuffer) data, usage);
else if (data instanceof DoubleBuffer)
GL15.glBufferData(target, (DoubleBuffer) data, usage);
else if (data instanceof ShortBuffer) //
GL15.glBufferData(target, (ShortBuffer) data, usage);
}
public void glBufferSubData(int target, int offset, int size, Buffer data) {
if (data == null)
throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
else if (data instanceof ByteBuffer)
GL15.glBufferSubData(target, offset, (ByteBuffer) data);
else if (data instanceof IntBuffer)
GL15.glBufferSubData(target, offset, (IntBuffer) data);
else if (data instanceof FloatBuffer)
GL15.glBufferSubData(target, offset, (FloatBuffer) data);
else if (data instanceof DoubleBuffer)
GL15.glBufferSubData(target, offset, (DoubleBuffer) data);
else if (data instanceof ShortBuffer) //
GL15.glBufferSubData(target, offset, (ShortBuffer) data);
}
public int glCheckFramebufferStatus(int target) {
return EXTFramebufferObject.glCheckFramebufferStatusEXT(target);
}
public void glClear(int mask) {
GL11.glClear(mask);
}
public void glClearColor(float red, float green, float blue, float alpha) {
GL11.glClearColor(red, green, blue, alpha);
}
public void glClearDepthf(float depth) {
GL11.glClearDepth(depth);
}
public void glClearStencil(int s) {
GL11.glClearStencil(s);
}
public void glColorMask(boolean red, boolean green, boolean blue, boolean alpha) {
GL11.glColorMask(red, green, blue, alpha);
}
public void glCompileShader(int shader) {
GL20.glCompileShader(shader);
}
public void glCompressedTexImage2D(int target, int level, int internalformat, int width,
int height, int border,
int imageSize, Buffer data) {
if (data instanceof ByteBuffer) {
GL13.glCompressedTexImage2D(target,
level,
internalformat,
width,
height,
border,
(ByteBuffer) data);
} else {
throw new GdxRuntimeException("Can't use " + data.getClass().getName()
+ " with this method. Use ByteBuffer instead.");
}
}
public void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset,
int width, int height, int format,
int imageSize, Buffer data) {
throw new GdxRuntimeException("not implemented");
}
public void glCopyTexImage2D(int target, int level, int internalformat, int x, int y,
int width, int height, int border) {
GL11.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
}
public void glCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y,
int width, int height) {
GL11.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
}
public int glCreateProgram() {
return GL20.glCreateProgram();
}
public int glCreateShader(int type) {
return GL20.glCreateShader(type);
}
public void glCullFace(int mode) {
GL11.glCullFace(mode);
}
public void glDeleteBuffers(int n, IntBuffer buffers) {
GL15.glDeleteBuffers(buffers);
}
public void glDeleteFramebuffers(int n, IntBuffer framebuffers) {
EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffers);
}
public void glDeleteProgram(int program) {
GL20.glDeleteProgram(program);
}
public void glDeleteRenderbuffers(int n, IntBuffer renderbuffers) {
EXTFramebufferObject.glDeleteRenderbuffersEXT(renderbuffers);
}
public void glDeleteShader(int shader) {
GL20.glDeleteShader(shader);
}
public void glDeleteTextures(int n, IntBuffer textures) {
GL11.glDeleteTextures(textures);
}
public void glDepthFunc(int func) {
GL11.glDepthFunc(func);
}
public void glDepthMask(boolean flag) {
GL11.glDepthMask(flag);
}
public void glDepthRangef(float zNear, float zFar) {
GL11.glDepthRange(zNear, zFar);
}
public void glDetachShader(int program, int shader) {
GL20.glDetachShader(program, shader);
}
public void glDisable(int cap) {
GL11.glDisable(cap);
}
public void glDisableVertexAttribArray(int index) {
GL20.glDisableVertexAttribArray(index);
}
public void glDrawArrays(int mode, int first, int count) {
GL11.glDrawArrays(mode, first, count);
}
public void glDrawElements(int mode, int count, int type, Buffer indices) {
if (indices instanceof ShortBuffer && type == GL10.GL_UNSIGNED_SHORT)
GL11.glDrawElements(mode, (ShortBuffer) indices);
else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_SHORT)
GL11.glDrawElements(mode, ((ByteBuffer) indices).asShortBuffer()); // FIXME yay...
else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_BYTE)
GL11.glDrawElements(mode, (ByteBuffer) indices);
else
throw new GdxRuntimeException("Can't use " + indices.getClass().getName()
+ " with this method. Use ShortBuffer or ByteBuffer instead. Blame LWJGL");
}
public void glEnable(int cap) {
GL11.glEnable(cap);
}
public void glEnableVertexAttribArray(int index) {
GL20.glEnableVertexAttribArray(index);
}
public void glFinish() {
GL11.glFinish();
}
public void glFlush() {
GL11.glFlush();
}
public void glFramebufferRenderbuffer(int target, int attachment, int renderbuffertarget,
int renderbuffer) {
EXTFramebufferObject.glFramebufferRenderbufferEXT(target,
attachment,
renderbuffertarget,
renderbuffer);
}
public void glFramebufferTexture2D(int target, int attachment, int textarget, int texture,
int level) {
EXTFramebufferObject.glFramebufferTexture2DEXT(target,
attachment,
textarget,
texture,
level);
}
public void glFrontFace(int mode) {
GL11.glFrontFace(mode);
}
public void glGenBuffers(int n, IntBuffer buffers) {
GL15.glGenBuffers(buffers);
}
public void glGenFramebuffers(int n, IntBuffer framebuffers) {
EXTFramebufferObject.glGenFramebuffersEXT(framebuffers);
}
public void glGenRenderbuffers(int n, IntBuffer renderbuffers) {
EXTFramebufferObject.glGenRenderbuffersEXT(renderbuffers);
}
public void glGenTextures(int n, IntBuffer textures) {
GL11.glGenTextures(textures);
}
public void glGenerateMipmap(int target) {
EXTFramebufferObject.glGenerateMipmapEXT(target);
}
public String glGetActiveAttrib(int program, int index, IntBuffer size, Buffer type) {
// FIXME this is less than ideal of course...
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
String name = GL20.glGetActiveAttrib(program, index, 256, typeTmp);
if (type instanceof IntBuffer)
((IntBuffer) type).put(typeTmp.get(0));
return name;
}
public String glGetActiveUniform(int program, int index, IntBuffer size, Buffer type) {
// FIXME this is less than ideal of course...
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
String name = GL20.glGetActiveUniform(program, index, 256, typeTmp);
if (type instanceof IntBuffer)
((IntBuffer) type).put(typeTmp.get(0));
return name;
}
public void glGetAttachedShaders(int program, int maxcount, Buffer count, IntBuffer shaders) {
GL20.glGetAttachedShaders(program, (IntBuffer) count, shaders);
}
public int glGetAttribLocation(int program, String name) {
return GL20.glGetAttribLocation(program, name);
}
public void glGetBooleanv(int pname, Buffer params) {
GL11.glGetBoolean(pname, (ByteBuffer) params);
}
public void glGetBufferParameteriv(int target, int pname, IntBuffer params) {
GL15.glGetBufferParameter(target, pname, params);
}
public int glGetError() {
return GL11.glGetError();
}
public void glGetFloatv(int pname, FloatBuffer params) {
GL11.glGetFloat(pname, params);
}
public void glGetFramebufferAttachmentParameteriv(int target, int attachment, int pname,
IntBuffer params) {
EXTFramebufferObject.glGetFramebufferAttachmentParameterEXT(target,
attachment,
pname,
params);
}
public void glGetIntegerv(int pname, IntBuffer params) {
GL11.glGetInteger(pname, params);
}
public String glGetProgramInfoLog(int program) {
ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10);
buffer.order(ByteOrder.nativeOrder());
ByteBuffer tmp = ByteBuffer.allocateDirect(4);
tmp.order(ByteOrder.nativeOrder());
IntBuffer intBuffer = tmp.asIntBuffer();
GL20.glGetProgramInfoLog(program, intBuffer, buffer);
int numBytes = intBuffer.get(0);
byte[] bytes = new byte[numBytes];
buffer.get(bytes);
return new String(bytes);
}
public void glGetProgramiv(int program, int pname, IntBuffer params) {
GL20.glGetProgram(program, pname, params);
}
public void glGetRenderbufferParameteriv(int target, int pname, IntBuffer params) {
EXTFramebufferObject.glGetRenderbufferParameterEXT(target, pname, params);
}
public String glGetShaderInfoLog(int shader) {
ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10);
buffer.order(ByteOrder.nativeOrder());
ByteBuffer tmp = ByteBuffer.allocateDirect(4);
tmp.order(ByteOrder.nativeOrder());
IntBuffer intBuffer = tmp.asIntBuffer();
GL20.glGetShaderInfoLog(shader, intBuffer, buffer);
int numBytes = intBuffer.get(0);
byte[] bytes = new byte[numBytes];
buffer.get(bytes);
return new String(bytes);
}
public void glGetShaderPrecisionFormat(int shadertype, int precisiontype, IntBuffer range,
IntBuffer precision) {
throw new UnsupportedOperationException("unsupported, won't implement");
}
public void glGetShaderSource(int shader, int bufsize, Buffer length, String source) {
throw new UnsupportedOperationException("unsupported, won't implement.");
}
public void glGetShaderiv(int shader, int pname, IntBuffer params) {
GL20.glGetShader(shader, pname, params);
}
public String glGetString(int name) {
return GL11.glGetString(name);
}
public void glGetTexParameterfv(int target, int pname, FloatBuffer params) {
GL11.glGetTexParameter(target, pname, params);
}
public void glGetTexParameteriv(int target, int pname, IntBuffer params) {
GL11.glGetTexParameter(target, pname, params);
}
public int glGetUniformLocation(int program, String name) {
return GL20.glGetUniformLocation(program, name);
}
public void glGetUniformfv(int program, int location, FloatBuffer params) {
GL20.glGetUniform(program, location, params);
}
public void glGetUniformiv(int program, int location, IntBuffer params) {
GL20.glGetUniform(program, location, params);
}
public void glGetVertexAttribPointerv(int index, int pname, Buffer pointer) {
throw new UnsupportedOperationException("unsupported, won't implement");
}
public void glGetVertexAttribfv(int index, int pname, FloatBuffer params) {
GL20.glGetVertexAttrib(index, pname, params);
}
public void glGetVertexAttribiv(int index, int pname, IntBuffer params) {
GL20.glGetVertexAttrib(index, pname, params);
}
public void glHint(int target, int mode) {
GL11.glHint(target, mode);
}
public boolean glIsBuffer(int buffer) {
return GL15.glIsBuffer(buffer);
}
public boolean glIsEnabled(int cap) {
return GL11.glIsEnabled(cap);
}
public boolean glIsFramebuffer(int framebuffer) {
return EXTFramebufferObject.glIsFramebufferEXT(framebuffer);
}
public boolean glIsProgram(int program) {
return GL20.glIsProgram(program);
}
public boolean glIsRenderbuffer(int renderbuffer) {
return EXTFramebufferObject.glIsRenderbufferEXT(renderbuffer);
}
public boolean glIsShader(int shader) {
return GL20.glIsShader(shader);
}
public boolean glIsTexture(int texture) {
return GL11.glIsTexture(texture);
}
public void glLineWidth(float width) {
GL11.glLineWidth(width);
}
public void glLinkProgram(int program) {
GL20.glLinkProgram(program);
}
public void glPixelStorei(int pname, int param) {
GL11.glPixelStorei(pname, param);
}
public void glPolygonOffset(float factor, float units) {
GL11.glPolygonOffset(factor, units);
}
public void glReadPixels(int x, int y, int width, int height, int format, int type,
Buffer pixels) {
if (pixels instanceof ByteBuffer)
GL11.glReadPixels(x, y, width, height, format, type, (ByteBuffer) pixels);
else if (pixels instanceof ShortBuffer)
GL11.glReadPixels(x, y, width, height, format, type, (ShortBuffer) pixels);
else if (pixels instanceof IntBuffer)
GL11.glReadPixels(x, y, width, height, format, type, (IntBuffer) pixels);
else if (pixels instanceof FloatBuffer)
GL11.glReadPixels(x, y, width, height, format, type, (FloatBuffer) pixels);
else
throw new GdxRuntimeException("Can't use "
+ pixels.getClass().getName()
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer or FloatBuffer instead. Blame LWJGL");
}
public void glReleaseShaderCompiler() {
// nothing to do here
}
public void glRenderbufferStorage(int target, int internalformat, int width, int height) {
EXTFramebufferObject.glRenderbufferStorageEXT(target, internalformat, width, height);
}
public void glSampleCoverage(float value, boolean invert) {
GL13.glSampleCoverage(value, invert);
}
public void glScissor(int x, int y, int width, int height) {
GL11.glScissor(x, y, width, height);
}
public void glShaderBinary(int n, IntBuffer shaders, int binaryformat, Buffer binary, int length) {
throw new UnsupportedOperationException("unsupported, won't implement");
}
public void glShaderSource(int shader, String string) {
GL20.glShaderSource(shader, string);
}
public void glStencilFunc(int func, int ref, int mask) {
GL11.glStencilFunc(func, ref, mask);
}
public void glStencilFuncSeparate(int face, int func, int ref, int mask) {
GL20.glStencilFuncSeparate(face, func, ref, mask);
}
public void glStencilMask(int mask) {
GL11.glStencilMask(mask);
}
public void glStencilMaskSeparate(int face, int mask) {
GL20.glStencilMaskSeparate(face, mask);
}
public void glStencilOp(int fail, int zfail, int zpass) {
GL11.glStencilOp(fail, zfail, zpass);
}
public void glStencilOpSeparate(int face, int fail, int zfail, int zpass) {
GL20.glStencilOpSeparate(face, fail, zfail, zpass);
}
public void glTexImage2D(int target, int level, int internalformat, int width, int height,
int border, int format, int type,
Buffer pixels) {
if (pixels == null)
GL11.glTexImage2D(target,
level,
internalformat,
width,
height,
border,
format,
type,
(ByteBuffer) null);
else if (pixels instanceof ByteBuffer)
GL11.glTexImage2D(target,
level,
internalformat,
width,
height,
border,
format,
type,
(ByteBuffer) pixels);
else if (pixels instanceof ShortBuffer)
GL11.glTexImage2D(target,
level,
internalformat,
width,
height,
border,
format,
type,
(ShortBuffer) pixels);
else if (pixels instanceof IntBuffer)
GL11.glTexImage2D(target,
level,
internalformat,
width,
height,
border,
format,
type,
(IntBuffer) pixels);
else if (pixels instanceof FloatBuffer)
GL11.glTexImage2D(target,
level,
internalformat,
width,
height,
border,
format,
type,
(FloatBuffer) pixels);
else if (pixels instanceof DoubleBuffer)
GL11.glTexImage2D(target,
level,
internalformat,
width,
height,
border,
format,
type,
(DoubleBuffer) pixels);
else
throw new GdxRuntimeException("Can't use "
+ pixels.getClass().getName()
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. Blame LWJGL");
}
public void glTexParameterf(int target, int pname, float param) {
GL11.glTexParameterf(target, pname, param);
}
public void glTexParameterfv(int target, int pname, FloatBuffer params) {
GL11.glTexParameter(target, pname, params);
}
public void glTexParameteri(int target, int pname, int param) {
GL11.glTexParameteri(target, pname, param);
}
public void glTexParameteriv(int target, int pname, IntBuffer params) {
GL11.glTexParameter(target, pname, params);
}
public void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width,
int height, int format, int type,
Buffer pixels) {
if (pixels instanceof ByteBuffer)
GL11.glTexSubImage2D(target,
level,
xoffset,
yoffset,
width,
height,
format,
type,
(ByteBuffer) pixels);
else if (pixels instanceof ShortBuffer)
GL11.glTexSubImage2D(target,
level,
xoffset,
yoffset,
width,
height,
format,
type,
(ShortBuffer) pixels);
else if (pixels instanceof IntBuffer)
GL11.glTexSubImage2D(target,
level,
xoffset,
yoffset,
width,
height,
format,
type,
(IntBuffer) pixels);
else if (pixels instanceof FloatBuffer)
GL11.glTexSubImage2D(target,
level,
xoffset,
yoffset,
width,
height,
format,
type,
(FloatBuffer) pixels);
else if (pixels instanceof DoubleBuffer)
GL11.glTexSubImage2D(target,
level,
xoffset,
yoffset,
width,
height,
format,
type,
(DoubleBuffer) pixels);
else
throw new GdxRuntimeException("Can't use "
+ pixels.getClass().getName()
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. Blame LWJGL");
}
public void glUniform1f(int location, float x) {
GL20.glUniform1f(location, x);
}
public void glUniform1fv(int location, int count, FloatBuffer v) {
GL20.glUniform1(location, v);
}
public void glUniform1i(int location, int x) {
GL20.glUniform1i(location, x);
}
public void glUniform1iv(int location, int count, IntBuffer v) {
GL20.glUniform1(location, v);
}
public void glUniform2f(int location, float x, float y) {
GL20.glUniform2f(location, x, y);
}
public void glUniform2fv(int location, int count, FloatBuffer v) {
GL20.glUniform2(location, v);
}
public void glUniform2i(int location, int x, int y) {
GL20.glUniform2i(location, x, y);
}
public void glUniform2iv(int location, int count, IntBuffer v) {
GL20.glUniform2(location, v);
}
public void glUniform3f(int location, float x, float y, float z) {
GL20.glUniform3f(location, x, y, z);
}
public void glUniform3fv(int location, int count, FloatBuffer v) {
GL20.glUniform3(location, v);
}
public void glUniform3i(int location, int x, int y, int z) {
GL20.glUniform3i(location, x, y, z);
}
public void glUniform3iv(int location, int count, IntBuffer v) {
GL20.glUniform3(location, v);
}
public void glUniform4f(int location, float x, float y, float z, float w) {
GL20.glUniform4f(location, x, y, z, w);
}
public void glUniform4fv(int location, int count, FloatBuffer v) {
GL20.glUniform4(location, v);
}
public void glUniform4i(int location, int x, int y, int z, int w) {
GL20.glUniform4i(location, x, y, z, w);
}
public void glUniform4iv(int location, int count, IntBuffer v) {
GL20.glUniform4(location, v);
}
public void glUniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer value) {
GL20.glUniformMatrix2(location, transpose, value);
}
public void glUniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer value) {
GL20.glUniformMatrix3(location, transpose, value);
}
public void glUniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer value) {
GL20.glUniformMatrix4(location, transpose, value);
}
public void glUseProgram(int program) {
GL20.glUseProgram(program);
}
public void glValidateProgram(int program) {
GL20.glValidateProgram(program);
}
public void glVertexAttrib1f(int indx, float x) {
GL20.glVertexAttrib1f(indx, x);
}
public void glVertexAttrib1fv(int indx, FloatBuffer values) {
GL20.glVertexAttrib1f(indx, values.get());
}
public void glVertexAttrib2f(int indx, float x, float y) {
GL20.glVertexAttrib2f(indx, x, y);
}
public void glVertexAttrib2fv(int indx, FloatBuffer values) {
GL20.glVertexAttrib2f(indx, values.get(), values.get());
}
public void glVertexAttrib3f(int indx, float x, float y, float z) {
GL20.glVertexAttrib3f(indx, x, y, z);
}
public void glVertexAttrib3fv(int indx, FloatBuffer values) {
GL20.glVertexAttrib3f(indx, values.get(), values.get(), values.get());
}
public void glVertexAttrib4f(int indx, float x, float y, float z, float w) {
GL20.glVertexAttrib4f(indx, x, y, z, w);
}
public void glVertexAttrib4fv(int indx, FloatBuffer values) {
GL20.glVertexAttrib4f(indx, values.get(), values.get(), values.get(), values.get());
}
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
Buffer buffer) {
if (buffer instanceof ByteBuffer) {
if (type == GL_BYTE)
GL20.glVertexAttribPointer(indx,
size,
false,
normalized,
stride,
(ByteBuffer) buffer);
else if (type == GL_UNSIGNED_BYTE)
GL20.glVertexAttribPointer(indx,
size,
true,
normalized,
stride,
(ByteBuffer) buffer);
else if (type == GL_SHORT)
GL20.glVertexAttribPointer(indx,
size,
false,
normalized,
stride,
((ByteBuffer) buffer).asShortBuffer());
else if (type == GL_UNSIGNED_SHORT)
GL20.glVertexAttribPointer(indx,
size,
true,
normalized,
stride,
((ByteBuffer) buffer).asShortBuffer());
else if (type == GL_FLOAT)
GL20.glVertexAttribPointer(indx,
size,
normalized,
stride,
((ByteBuffer) buffer).asFloatBuffer());
else
throw new GdxRuntimeException("Can't use "
+ buffer.getClass().getName()
+ " with type "
+ type
+ " with this method. Use ByteBuffer and one of GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT or GL_FLOAT for type. Blame LWJGL");
} else
throw new GdxRuntimeException("Can't use " + buffer.getClass().getName()
+ " with this method. Use ByteBuffer instead. Blame LWJGL");
}
public void glViewport(int x, int y, int width, int height) {
GL11.glViewport(x, y, width, height);
}
public void glDrawElements(int mode, int count, int type, int indices) {
GL11.glDrawElements(mode, count, type, indices);
}
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
int ptr) {
GL20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
}
}

View File

@ -1,742 +0,0 @@
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* 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.
******************************************************************************/
package org.oscim.gdx;
import java.nio.Buffer;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.DoubleBuffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import org.lwjgl.BufferUtils;
import org.lwjgl.opengl.EXTFramebufferObject;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL13;
import org.lwjgl.opengl.GL14;
import org.lwjgl.opengl.GL15;
import org.lwjgl.opengl.GL20;
import com.badlogic.gdx.graphics.GL10;
import com.badlogic.gdx.utils.GdxRuntimeException;
/** An implementation of the {@link GL20} interface based on LWJGL. Note that LWJGL shaders and OpenGL ES shaders will not be 100%
* compatible. Some glGetXXX methods are not implemented.
*
* @author mzechner */
public final class GdxGLAdapter implements org.oscim.backend.GL20 {
public void glActiveTexture (int texture) {
GL13.glActiveTexture(texture);
}
public void glAttachShader (int program, int shader) {
GL20.glAttachShader(program, shader);
}
public void glBindAttribLocation (int program, int index, String name) {
GL20.glBindAttribLocation(program, index, name);
}
public void glBindBuffer (int target, int buffer) {
GL15.glBindBuffer(target, buffer);
}
public void glBindFramebuffer (int target, int framebuffer) {
EXTFramebufferObject.glBindFramebufferEXT(target, framebuffer);
}
public void glBindRenderbuffer (int target, int renderbuffer) {
EXTFramebufferObject.glBindRenderbufferEXT(target, renderbuffer);
}
public void glBindTexture (int target, int texture) {
GL11.glBindTexture(target, texture);
}
public void glBlendColor (float red, float green, float blue, float alpha) {
GL14.glBlendColor(red, green, blue, alpha);
}
public void glBlendEquation (int mode) {
GL14.glBlendEquation(mode);
}
public void glBlendEquationSeparate (int modeRGB, int modeAlpha) {
GL20.glBlendEquationSeparate(modeRGB, modeAlpha);
}
public void glBlendFunc (int sfactor, int dfactor) {
GL11.glBlendFunc(sfactor, dfactor);
}
public void glBlendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
GL14.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
}
public void glBufferData (int target, int size, Buffer data, int usage) {
if(data == null)
throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
else if (data instanceof ByteBuffer)
GL15.glBufferData(target, (ByteBuffer)data, usage);
else if (data instanceof IntBuffer)
GL15.glBufferData(target, (IntBuffer)data, usage);
else if (data instanceof FloatBuffer)
GL15.glBufferData(target, (FloatBuffer)data, usage);
else if (data instanceof DoubleBuffer)
GL15.glBufferData(target, (DoubleBuffer)data, usage);
else if (data instanceof ShortBuffer) //
GL15.glBufferData(target, (ShortBuffer)data, usage);
}
public void glBufferSubData (int target, int offset, int size, Buffer data) {
if(data == null)
throw new GdxRuntimeException("Using null for the data not possible, blame LWJGL");
else if (data instanceof ByteBuffer)
GL15.glBufferSubData(target, offset, (ByteBuffer)data);
else if (data instanceof IntBuffer)
GL15.glBufferSubData(target, offset, (IntBuffer)data);
else if (data instanceof FloatBuffer)
GL15.glBufferSubData(target, offset, (FloatBuffer)data);
else if (data instanceof DoubleBuffer)
GL15.glBufferSubData(target, offset, (DoubleBuffer)data);
else if (data instanceof ShortBuffer) //
GL15.glBufferSubData(target, offset, (ShortBuffer)data);
}
public int glCheckFramebufferStatus (int target) {
return EXTFramebufferObject.glCheckFramebufferStatusEXT(target);
}
public void glClear (int mask) {
GL11.glClear(mask);
}
public void glClearColor (float red, float green, float blue, float alpha) {
GL11.glClearColor(red, green, blue, alpha);
}
public void glClearDepthf (float depth) {
GL11.glClearDepth(depth);
}
public void glClearStencil (int s) {
GL11.glClearStencil(s);
}
public void glColorMask (boolean red, boolean green, boolean blue, boolean alpha) {
GL11.glColorMask(red, green, blue, alpha);
}
public void glCompileShader (int shader) {
GL20.glCompileShader(shader);
}
public void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border,
int imageSize, Buffer data) {
if (data instanceof ByteBuffer) {
GL13.glCompressedTexImage2D(target, level, internalformat, width, height, border, (ByteBuffer)data);
} else {
throw new GdxRuntimeException("Can't use " + data.getClass().getName()
+ " with this method. Use ByteBuffer instead.");
}
}
public void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format,
int imageSize, Buffer data) {
throw new GdxRuntimeException("not implemented");
}
public void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border) {
GL11.glCopyTexImage2D(target, level, internalformat, x, y, width, height, border);
}
public void glCopyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height) {
GL11.glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
}
public int glCreateProgram () {
return GL20.glCreateProgram();
}
public int glCreateShader (int type) {
return GL20.glCreateShader(type);
}
public void glCullFace (int mode) {
GL11.glCullFace(mode);
}
public void glDeleteBuffers (int n, IntBuffer buffers) {
GL15.glDeleteBuffers(buffers);
}
public void glDeleteFramebuffers (int n, IntBuffer framebuffers) {
EXTFramebufferObject.glDeleteFramebuffersEXT(framebuffers);
}
public void glDeleteProgram (int program) {
GL20.glDeleteProgram(program);
}
public void glDeleteRenderbuffers (int n, IntBuffer renderbuffers) {
EXTFramebufferObject.glDeleteRenderbuffersEXT(renderbuffers);
}
public void glDeleteShader (int shader) {
GL20.glDeleteShader(shader);
}
public void glDeleteTextures (int n, IntBuffer textures) {
GL11.glDeleteTextures(textures);
}
public void glDepthFunc (int func) {
GL11.glDepthFunc(func);
}
public void glDepthMask (boolean flag) {
GL11.glDepthMask(flag);
}
public void glDepthRangef (float zNear, float zFar) {
GL11.glDepthRange(zNear, zFar);
}
public void glDetachShader (int program, int shader) {
GL20.glDetachShader(program, shader);
}
public void glDisable (int cap) {
GL11.glDisable(cap);
}
public void glDisableVertexAttribArray (int index) {
GL20.glDisableVertexAttribArray(index);
}
public void glDrawArrays (int mode, int first, int count) {
GL11.glDrawArrays(mode, first, count);
}
public void glDrawElements (int mode, int count, int type, Buffer indices) {
if (indices instanceof ShortBuffer && type == GL10.GL_UNSIGNED_SHORT)
GL11.glDrawElements(mode, (ShortBuffer)indices);
else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_SHORT)
GL11.glDrawElements(mode, ((ByteBuffer)indices).asShortBuffer()); // FIXME yay...
else if (indices instanceof ByteBuffer && type == GL10.GL_UNSIGNED_BYTE)
GL11.glDrawElements(mode, (ByteBuffer)indices);
else
throw new GdxRuntimeException("Can't use " + indices.getClass().getName()
+ " with this method. Use ShortBuffer or ByteBuffer instead. Blame LWJGL");
}
public void glEnable (int cap) {
GL11.glEnable(cap);
}
public void glEnableVertexAttribArray (int index) {
GL20.glEnableVertexAttribArray(index);
}
public void glFinish () {
GL11.glFinish();
}
public void glFlush () {
GL11.glFlush();
}
public void glFramebufferRenderbuffer (int target, int attachment, int renderbuffertarget, int renderbuffer) {
EXTFramebufferObject.glFramebufferRenderbufferEXT(target, attachment, renderbuffertarget, renderbuffer);
}
public void glFramebufferTexture2D (int target, int attachment, int textarget, int texture, int level) {
EXTFramebufferObject.glFramebufferTexture2DEXT(target, attachment, textarget, texture, level);
}
public void glFrontFace (int mode) {
GL11.glFrontFace(mode);
}
public void glGenBuffers (int n, IntBuffer buffers) {
GL15.glGenBuffers(buffers);
}
public void glGenFramebuffers (int n, IntBuffer framebuffers) {
EXTFramebufferObject.glGenFramebuffersEXT(framebuffers);
}
public void glGenRenderbuffers (int n, IntBuffer renderbuffers) {
EXTFramebufferObject.glGenRenderbuffersEXT(renderbuffers);
}
public void glGenTextures (int n, IntBuffer textures) {
GL11.glGenTextures(textures);
}
public void glGenerateMipmap (int target) {
EXTFramebufferObject.glGenerateMipmapEXT(target);
}
public String glGetActiveAttrib (int program, int index, IntBuffer size, Buffer type) {
// FIXME this is less than ideal of course...
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
String name = GL20.glGetActiveAttrib(program, index, 256, typeTmp);
if (type instanceof IntBuffer) ((IntBuffer)type).put(typeTmp.get(0));
return name;
}
public String glGetActiveUniform (int program, int index, IntBuffer size, Buffer type) {
// FIXME this is less than ideal of course...
IntBuffer typeTmp = BufferUtils.createIntBuffer(2);
String name = GL20.glGetActiveUniform(program, index, 256, typeTmp);
if (type instanceof IntBuffer) ((IntBuffer)type).put(typeTmp.get(0));
return name;
}
public void glGetAttachedShaders (int program, int maxcount, Buffer count, IntBuffer shaders) {
GL20.glGetAttachedShaders(program, (IntBuffer)count, shaders);
}
public int glGetAttribLocation (int program, String name) {
return GL20.glGetAttribLocation(program, name);
}
public void glGetBooleanv (int pname, Buffer params) {
GL11.glGetBoolean(pname, (ByteBuffer)params);
}
public void glGetBufferParameteriv (int target, int pname, IntBuffer params) {
GL15.glGetBufferParameter(target, pname, params);
}
public int glGetError () {
return GL11.glGetError();
}
public void glGetFloatv (int pname, FloatBuffer params) {
GL11.glGetFloat(pname, params);
}
public void glGetFramebufferAttachmentParameteriv (int target, int attachment, int pname, IntBuffer params) {
EXTFramebufferObject.glGetFramebufferAttachmentParameterEXT(target, attachment, pname, params);
}
public void glGetIntegerv (int pname, IntBuffer params) {
GL11.glGetInteger(pname, params);
}
public String glGetProgramInfoLog (int program) {
ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10);
buffer.order(ByteOrder.nativeOrder());
ByteBuffer tmp = ByteBuffer.allocateDirect(4);
tmp.order(ByteOrder.nativeOrder());
IntBuffer intBuffer = tmp.asIntBuffer();
GL20.glGetProgramInfoLog(program, intBuffer, buffer);
int numBytes = intBuffer.get(0);
byte[] bytes = new byte[numBytes];
buffer.get(bytes);
return new String(bytes);
}
public void glGetProgramiv (int program, int pname, IntBuffer params) {
GL20.glGetProgram(program, pname, params);
}
public void glGetRenderbufferParameteriv (int target, int pname, IntBuffer params) {
EXTFramebufferObject.glGetRenderbufferParameterEXT(target, pname, params);
}
public String glGetShaderInfoLog (int shader) {
ByteBuffer buffer = ByteBuffer.allocateDirect(1024 * 10);
buffer.order(ByteOrder.nativeOrder());
ByteBuffer tmp = ByteBuffer.allocateDirect(4);
tmp.order(ByteOrder.nativeOrder());
IntBuffer intBuffer = tmp.asIntBuffer();
GL20.glGetShaderInfoLog(shader, intBuffer, buffer);
int numBytes = intBuffer.get(0);
byte[] bytes = new byte[numBytes];
buffer.get(bytes);
return new String(bytes);
}
public void glGetShaderPrecisionFormat (int shadertype, int precisiontype, IntBuffer range, IntBuffer precision) {
throw new UnsupportedOperationException("unsupported, won't implement");
}
public void glGetShaderSource (int shader, int bufsize, Buffer length, String source) {
throw new UnsupportedOperationException("unsupported, won't implement.");
}
public void glGetShaderiv (int shader, int pname, IntBuffer params) {
GL20.glGetShader(shader, pname, params);
}
public String glGetString (int name) {
return GL11.glGetString(name);
}
public void glGetTexParameterfv (int target, int pname, FloatBuffer params) {
GL11.glGetTexParameter(target, pname, params);
}
public void glGetTexParameteriv (int target, int pname, IntBuffer params) {
GL11.glGetTexParameter(target, pname, params);
}
public int glGetUniformLocation (int program, String name) {
return GL20.glGetUniformLocation(program, name);
}
public void glGetUniformfv (int program, int location, FloatBuffer params) {
GL20.glGetUniform(program, location, params);
}
public void glGetUniformiv (int program, int location, IntBuffer params) {
GL20.glGetUniform(program, location, params);
}
public void glGetVertexAttribPointerv (int index, int pname, Buffer pointer) {
throw new UnsupportedOperationException("unsupported, won't implement");
}
public void glGetVertexAttribfv (int index, int pname, FloatBuffer params) {
GL20.glGetVertexAttrib(index, pname, params);
}
public void glGetVertexAttribiv (int index, int pname, IntBuffer params) {
GL20.glGetVertexAttrib(index, pname, params);
}
public void glHint (int target, int mode) {
GL11.glHint(target, mode);
}
public boolean glIsBuffer (int buffer) {
return GL15.glIsBuffer(buffer);
}
public boolean glIsEnabled (int cap) {
return GL11.glIsEnabled(cap);
}
public boolean glIsFramebuffer (int framebuffer) {
return EXTFramebufferObject.glIsFramebufferEXT(framebuffer);
}
public boolean glIsProgram (int program) {
return GL20.glIsProgram(program);
}
public boolean glIsRenderbuffer (int renderbuffer) {
return EXTFramebufferObject.glIsRenderbufferEXT(renderbuffer);
}
public boolean glIsShader (int shader) {
return GL20.glIsShader(shader);
}
public boolean glIsTexture (int texture) {
return GL11.glIsTexture(texture);
}
public void glLineWidth (float width) {
GL11.glLineWidth(width);
}
public void glLinkProgram (int program) {
GL20.glLinkProgram(program);
}
public void glPixelStorei (int pname, int param) {
GL11.glPixelStorei(pname, param);
}
public void glPolygonOffset (float factor, float units) {
GL11.glPolygonOffset(factor, units);
}
public void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels) {
if (pixels instanceof ByteBuffer)
GL11.glReadPixels(x, y, width, height, format, type, (ByteBuffer)pixels);
else if (pixels instanceof ShortBuffer)
GL11.glReadPixels(x, y, width, height, format, type, (ShortBuffer)pixels);
else if (pixels instanceof IntBuffer)
GL11.glReadPixels(x, y, width, height, format, type, (IntBuffer)pixels);
else if (pixels instanceof FloatBuffer)
GL11.glReadPixels(x, y, width, height, format, type, (FloatBuffer)pixels);
else
throw new GdxRuntimeException("Can't use " + pixels.getClass().getName()
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer or FloatBuffer instead. Blame LWJGL");
}
public void glReleaseShaderCompiler () {
// nothing to do here
}
public void glRenderbufferStorage (int target, int internalformat, int width, int height) {
EXTFramebufferObject.glRenderbufferStorageEXT(target, internalformat, width, height);
}
public void glSampleCoverage (float value, boolean invert) {
GL13.glSampleCoverage(value, invert);
}
public void glScissor (int x, int y, int width, int height) {
GL11.glScissor(x, y, width, height);
}
public void glShaderBinary (int n, IntBuffer shaders, int binaryformat, Buffer binary, int length) {
throw new UnsupportedOperationException("unsupported, won't implement");
}
public void glShaderSource (int shader, String string) {
GL20.glShaderSource(shader, string);
}
public void glStencilFunc (int func, int ref, int mask) {
GL11.glStencilFunc(func, ref, mask);
}
public void glStencilFuncSeparate (int face, int func, int ref, int mask) {
GL20.glStencilFuncSeparate(face, func, ref, mask);
}
public void glStencilMask (int mask) {
GL11.glStencilMask(mask);
}
public void glStencilMaskSeparate (int face, int mask) {
GL20.glStencilMaskSeparate(face, mask);
}
public void glStencilOp (int fail, int zfail, int zpass) {
GL11.glStencilOp(fail, zfail, zpass);
}
public void glStencilOpSeparate (int face, int fail, int zfail, int zpass) {
GL20.glStencilOpSeparate(face, fail, zfail, zpass);
}
public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type,
Buffer pixels) {
if (pixels == null)
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (ByteBuffer)null);
else if (pixels instanceof ByteBuffer)
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (ByteBuffer)pixels);
else if (pixels instanceof ShortBuffer)
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (ShortBuffer)pixels);
else if (pixels instanceof IntBuffer)
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (IntBuffer)pixels);
else if (pixels instanceof FloatBuffer)
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (FloatBuffer)pixels);
else if (pixels instanceof DoubleBuffer)
GL11.glTexImage2D(target, level, internalformat, width, height, border, format, type, (DoubleBuffer)pixels);
else
throw new GdxRuntimeException("Can't use " + pixels.getClass().getName()
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. Blame LWJGL");
}
public void glTexParameterf (int target, int pname, float param) {
GL11.glTexParameterf(target, pname, param);
}
public void glTexParameterfv (int target, int pname, FloatBuffer params) {
GL11.glTexParameter(target, pname, params);
}
public void glTexParameteri (int target, int pname, int param) {
GL11.glTexParameteri(target, pname, param);
}
public void glTexParameteriv (int target, int pname, IntBuffer params) {
GL11.glTexParameter(target, pname, params);
}
public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type,
Buffer pixels) {
if (pixels instanceof ByteBuffer)
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (ByteBuffer)pixels);
else if (pixels instanceof ShortBuffer)
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (ShortBuffer)pixels);
else if (pixels instanceof IntBuffer)
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (IntBuffer)pixels);
else if (pixels instanceof FloatBuffer)
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (FloatBuffer)pixels);
else if (pixels instanceof DoubleBuffer)
GL11.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, (DoubleBuffer)pixels);
else
throw new GdxRuntimeException("Can't use " + pixels.getClass().getName()
+ " with this method. Use ByteBuffer, ShortBuffer, IntBuffer, FloatBuffer or DoubleBuffer instead. Blame LWJGL");
}
public void glUniform1f (int location, float x) {
GL20.glUniform1f(location, x);
}
public void glUniform1fv (int location, int count, FloatBuffer v) {
GL20.glUniform1(location, v);
}
public void glUniform1i (int location, int x) {
GL20.glUniform1i(location, x);
}
public void glUniform1iv (int location, int count, IntBuffer v) {
GL20.glUniform1(location, v);
}
public void glUniform2f (int location, float x, float y) {
GL20.glUniform2f(location, x, y);
}
public void glUniform2fv (int location, int count, FloatBuffer v) {
GL20.glUniform2(location, v);
}
public void glUniform2i (int location, int x, int y) {
GL20.glUniform2i(location, x, y);
}
public void glUniform2iv (int location, int count, IntBuffer v) {
GL20.glUniform2(location, v);
}
public void glUniform3f (int location, float x, float y, float z) {
GL20.glUniform3f(location, x, y, z);
}
public void glUniform3fv (int location, int count, FloatBuffer v) {
GL20.glUniform3(location, v);
}
public void glUniform3i (int location, int x, int y, int z) {
GL20.glUniform3i(location, x, y, z);
}
public void glUniform3iv (int location, int count, IntBuffer v) {
GL20.glUniform3(location, v);
}
public void glUniform4f (int location, float x, float y, float z, float w) {
GL20.glUniform4f(location, x, y, z, w);
}
public void glUniform4fv (int location, int count, FloatBuffer v) {
GL20.glUniform4(location, v);
}
public void glUniform4i (int location, int x, int y, int z, int w) {
GL20.glUniform4i(location, x, y, z, w);
}
public void glUniform4iv (int location, int count, IntBuffer v) {
GL20.glUniform4(location, v);
}
public void glUniformMatrix2fv (int location, int count, boolean transpose, FloatBuffer value) {
GL20.glUniformMatrix2(location, transpose, value);
}
public void glUniformMatrix3fv (int location, int count, boolean transpose, FloatBuffer value) {
GL20.glUniformMatrix3(location, transpose, value);
}
public void glUniformMatrix4fv (int location, int count, boolean transpose, FloatBuffer value) {
GL20.glUniformMatrix4(location, transpose, value);
}
public void glUseProgram (int program) {
GL20.glUseProgram(program);
}
public void glValidateProgram (int program) {
GL20.glValidateProgram(program);
}
public void glVertexAttrib1f (int indx, float x) {
GL20.glVertexAttrib1f(indx, x);
}
public void glVertexAttrib1fv (int indx, FloatBuffer values) {
GL20.glVertexAttrib1f(indx, values.get());
}
public void glVertexAttrib2f (int indx, float x, float y) {
GL20.glVertexAttrib2f(indx, x, y);
}
public void glVertexAttrib2fv (int indx, FloatBuffer values) {
GL20.glVertexAttrib2f(indx, values.get(), values.get());
}
public void glVertexAttrib3f (int indx, float x, float y, float z) {
GL20.glVertexAttrib3f(indx, x, y, z);
}
public void glVertexAttrib3fv (int indx, FloatBuffer values) {
GL20.glVertexAttrib3f(indx, values.get(), values.get(), values.get());
}
public void glVertexAttrib4f (int indx, float x, float y, float z, float w) {
GL20.glVertexAttrib4f(indx, x, y, z, w);
}
public void glVertexAttrib4fv (int indx, FloatBuffer values) {
GL20.glVertexAttrib4f(indx, values.get(), values.get(), values.get(), values.get());
}
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, Buffer buffer) {
if (buffer instanceof ByteBuffer) {
if (type == GL_BYTE)
GL20.glVertexAttribPointer(indx, size, false, normalized, stride, (ByteBuffer)buffer);
else if (type == GL_UNSIGNED_BYTE)
GL20.glVertexAttribPointer(indx, size, true, normalized, stride, (ByteBuffer)buffer);
else if (type == GL_SHORT)
GL20.glVertexAttribPointer(indx, size, false, normalized, stride, ((ByteBuffer)buffer).asShortBuffer());
else if (type == GL_UNSIGNED_SHORT)
GL20.glVertexAttribPointer(indx, size, true, normalized, stride, ((ByteBuffer)buffer).asShortBuffer());
else if (type == GL_FLOAT)
GL20.glVertexAttribPointer(indx, size, normalized, stride, ((ByteBuffer)buffer).asFloatBuffer());
else
throw new GdxRuntimeException(
"Can't use "
+ buffer.getClass().getName()
+ " with type "
+ type
+ " with this method. Use ByteBuffer and one of GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT or GL_FLOAT for type. Blame LWJGL");
} else
throw new GdxRuntimeException("Can't use " + buffer.getClass().getName()
+ " with this method. Use ByteBuffer instead. Blame LWJGL");
}
public void glViewport (int x, int y, int width, int height) {
GL11.glViewport(x, y, width, height);
}
public void glDrawElements (int mode, int count, int type, int indices) {
GL11.glDrawElements(mode, count, type, indices);
}
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int ptr) {
GL20.glVertexAttribPointer(indx, size, type, normalized, stride, ptr);
}
}

View File

@ -18,7 +18,7 @@ public class GdxMapApp extends GdxMap {
// set our globals // set our globals
new SharedLibraryLoader().load("vtm-jni"); new SharedLibraryLoader().load("vtm-jni");
CanvasAdapter.g = AwtGraphics.INSTANCE; CanvasAdapter.g = AwtGraphics.INSTANCE;
GLAdapter.g = new GdxGLAdapter(); GLAdapter.g = new GdxGL20();
GLAdapter.GDX_DESKTOP_QUIRKS = true; GLAdapter.GDX_DESKTOP_QUIRKS = true;
} }

View File

@ -15,6 +15,7 @@ public class GwtBitmap implements Bitmap {
Pixmap pixmap; Pixmap pixmap;
Image image; Image image;
boolean disposable; boolean disposable;
public GwtBitmap(Image data) { public GwtBitmap(Image data) {
ImageElement imageElement = ImageElement.as(data.getElement()); ImageElement imageElement = ImageElement.as(data.getElement());
pixmap = new Pixmap(imageElement); pixmap = new Pixmap(imageElement);
@ -60,12 +61,11 @@ public class GwtBitmap implements Bitmap {
public int uploadToTexture(boolean replace) { public int uploadToTexture(boolean replace) {
Gdx.gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(), Gdx.gl.glTexImage2D(GL10.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(), pixmap.getWidth(),
pixmap.getHeight(), 0, pixmap.getHeight(), 0,
pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels()); pixmap.getGLFormat(), pixmap.getGLType(), pixmap.getPixels());
if (disposable || image != null) {
if (disposable || image != null){ Log.d("", "dispose pixmap " + getWidth() + "/" + getHeight());
Log.d("", "dispose pixmap " +getWidth() +"/" + getHeight());
pixmap.dispose(); pixmap.dispose();
if (image != null) if (image != null)

View File

@ -119,7 +119,7 @@ class GwtGdxMap extends GdxMap {
//rot = rot < 0 ? -rot : rot; //rot = rot < 0 ? -rot : rot;
if (curZoom != pos.zoomLevel || curLat != lat || curLon != lon if (curZoom != pos.zoomLevel || curLat != lat || curLon != lon
|| curTilt != rot || curRot != (int) (pos.angle)) { || curTilt != rot || curRot != (int) (pos.angle)) {
curLat = lat; curLat = lat;
curLon = lon; curLon = lon;
@ -128,11 +128,11 @@ class GwtGdxMap extends GdxMap {
curRot = rot; curRot = rot;
String newURL = Window.Location String newURL = Window.Location
.createUrlBuilder() .createUrlBuilder()
.setHash("scale=" + pos.zoomLevel + ",rot=" + curRot .setHash("scale=" + pos.zoomLevel + ",rot=" + curRot
+ ",tilt=" + curTilt + ",lat=" + (curLat / 1000f) + ",tilt=" + curTilt + ",lat=" + (curLat / 1000f)
+ ",lon=" + (curLon / 1000f)) + ",lon=" + (curLon / 1000f))
.buildString(); .buildString();
Window.Location.replace(newURL); Window.Location.replace(newURL);
} }
} }

View File

@ -19,9 +19,9 @@ public class GwtLauncher extends GwtApplication {
@Override @Override
public GwtApplicationConfiguration getConfig() { public GwtApplicationConfiguration getConfig() {
GwtApplicationConfiguration cfg = new GwtApplicationConfiguration( GwtApplicationConfiguration cfg =
GwtGraphics.getWindowWidthJSNI(), new GwtApplicationConfiguration(GwtGraphics.getWindowWidthJSNI(),
GwtGraphics.getWindowHeightJSNI()); GwtGraphics.getWindowHeightJSNI());
DockLayoutPanel p = new DockLayoutPanel(Unit.EM); DockLayoutPanel p = new DockLayoutPanel(Unit.EM);
p.setHeight("100%"); p.setHeight("100%");

View File

@ -47,7 +47,7 @@ public class GwtPaint implements Paint {
float a = ((color >>> 24) & 0xff) / 255f; float a = ((color >>> 24) & 0xff) / 255f;
int r = (color >>> 16) & 0xff; int r = (color >>> 16) & 0xff;
int g = (color >>> 8) & 0xff; int g = (color >>> 8) & 0xff;
int b = (color & 0xff) ; int b = (color & 0xff);
this.color = Pixmap.make(r, g, b, a); this.color = Pixmap.make(r, g, b, a);
} }
@ -105,7 +105,7 @@ public class GwtPaint implements Paint {
return 4 + strokeWidth; return 4 + strokeWidth;
} }
void buildFont(){ void buildFont() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
if (this.fontStyle == FontStyle.BOLD) if (this.fontStyle == FontStyle.BOLD)

View File

@ -34,4 +34,3 @@ class MapConfig extends JavaScriptObject {
return this.background; return this.background;
}-*/; }-*/;
} }

View File

@ -66,7 +66,7 @@ public class SearchBox {
} }
final static class NominatimData extends JavaScriptObject implements final static class NominatimData extends JavaScriptObject implements
PoiData { PoiData {
protected NominatimData() { protected NominatimData() {
} }
@ -83,7 +83,8 @@ public class SearchBox {
} }
@Override @Override
public final native String getId() /*-{ public final native String getId()
/*-{
return this.osm_id; return this.osm_id;
}-*/; }-*/;
@ -155,7 +156,7 @@ public class SearchBox {
@Override @Override
public void render(com.google.gwt.cell.client.Cell.Context context, public void render(com.google.gwt.cell.client.Cell.Context context,
PoiData value, SafeHtmlBuilder sb) { PoiData value, SafeHtmlBuilder sb) {
// Value can be null, so do a null check.. // Value can be null, so do a null check..
if (value == null) { if (value == null) {
@ -203,10 +204,10 @@ public class SearchBox {
// Create a CellList that uses the cell. // Create a CellList that uses the cell.
final CellList<PoiData> cellList = new CellList<PoiData>(poiCell, final CellList<PoiData> cellList = new CellList<PoiData>(poiCell,
PoiData.KEY_PROVIDER); PoiData.KEY_PROVIDER);
final SingleSelectionModel<PoiData> selectionModel = new SingleSelectionModel<PoiData>( final SingleSelectionModel<PoiData> selectionModel = new SingleSelectionModel<PoiData>(
PoiData.KEY_PROVIDER); PoiData.KEY_PROVIDER);
cellList.setSelectionModel(selectionModel); cellList.setSelectionModel(selectionModel);
final ScrollPanel scroller = new ScrollPanel(cellList); final ScrollPanel scroller = new ScrollPanel(cellList);
@ -235,7 +236,7 @@ public class SearchBox {
BoundingBox b = d.getBoundingBox(); BoundingBox b = d.getBoundingBox();
if (b != null) { if (b != null) {
if (b.maxLatitudeE6 - b.minLatitudeE6 < 100 && if (b.maxLatitudeE6 - b.minLatitudeE6 < 100 &&
b.maxLongitudeE6 - b.minLongitudeE6 < 100) b.maxLongitudeE6 - b.minLongitudeE6 < 100)
// for small bbox use zoom=16 to get an overview // for small bbox use zoom=16 to get an overview
map.getAnimator().animateTo(500, b.getCenterPoint(), 1 << 16, false); map.getAnimator().animateTo(500, b.getCenterPoint(), 1 << 16, false);
else else
@ -311,8 +312,8 @@ public class SearchBox {
searchButton.setEnabled(false); searchButton.setEnabled(false);
String url = URL String url = URL
.encode(NOMINATIM_GLOBAL .encode(NOMINATIM_GLOBAL
+ textToServer); + textToServer);
JsonpRequestBuilder builder = new JsonpRequestBuilder(); JsonpRequestBuilder builder = new JsonpRequestBuilder();
builder.setCallbackParam("json_callback"); builder.setCallbackParam("json_callback");

View File

@ -88,7 +88,7 @@ public class WKTReader {
} }
private static void parsePoly(GeometryBuffer geom, String wkt, int len, int[] adv) private static void parsePoly(GeometryBuffer geom, String wkt, int len, int[] adv)
throws Exception { throws Exception {
// outer ring // outer ring
ensure(wkt, adv, '('); ensure(wkt, adv, '(');
parseLine(geom, wkt, len, adv); parseLine(geom, wkt, len, adv);
@ -102,7 +102,7 @@ public class WKTReader {
} }
private static void parseLine(GeometryBuffer geom, String wkt, int len, int[] adv) private static void parseLine(GeometryBuffer geom, String wkt, int len, int[] adv)
throws Exception { throws Exception {
ensure(wkt, adv, '('); ensure(wkt, adv, '(');
parsePoint(geom, wkt, len, adv); parsePoint(geom, wkt, len, adv);
@ -204,21 +204,21 @@ public class WKTReader {
return neg ? -val : val; return neg ? -val : val;
} }
// public static void main(String[] args) { // public static void main(String[] args) {
// WKTReader r = new WKTReader(); // WKTReader r = new WKTReader();
// GeometryBuffer geom = new GeometryBuffer(10, 10); // GeometryBuffer geom = new GeometryBuffer(10, 10);
// try { // try {
// String wkt = "MULTIPOINT(0 0,1 0)"; // String wkt = "MULTIPOINT(0 0,1 0)";
// r.parse(wkt, geom); // r.parse(wkt, geom);
// for (int i = 0; i < geom.index.length; i++) { // for (int i = 0; i < geom.index.length; i++) {
// int len = geom.index[i]; // int len = geom.index[i];
// if (len < 0) // if (len < 0)
// break; // break;
// for (int p = 0; p < len; p += 2) // for (int p = 0; p < len; p += 2)
// System.out.println(len + ": " + geom.points[p] + "," + geom.points[p + 1]); // System.out.println(len + ": " + geom.points[p] + "," + geom.points[p + 1]);
// } // }
// } catch (Exception e) { // } catch (Exception e) {
// e.printStackTrace(); // e.printStackTrace();
// } // }
// } // }
} }

View File

@ -5,7 +5,6 @@ public class MalformedURLException extends Exception {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -7,6 +7,6 @@ public class CopyOnWriteArrayList<E> extends ArrayList<E> {
/** /**
* *
*/ */
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
} }

View File

@ -5,10 +5,10 @@ import org.xml.sax.Attributes;
import com.google.gwt.xml.client.NamedNodeMap; import com.google.gwt.xml.client.NamedNodeMap;
import com.google.gwt.xml.client.Node; import com.google.gwt.xml.client.Node;
public class MyAttributes implements Attributes{ public class MyAttributes implements Attributes {
private NamedNodeMap map; private NamedNodeMap map;
public MyAttributes(Node n){ public MyAttributes(Node n) {
map = n.getAttributes(); map = n.getAttributes();
} }

View File

@ -7,10 +7,10 @@ import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler; import org.xml.sax.helpers.DefaultHandler;
public class XMLReaderAdapter { public class XMLReaderAdapter {
public void parse(DefaultHandler handler, InputStream is) throws IOException, SAXException { public void parse(DefaultHandler handler, InputStream is) throws IOException, SAXException {
MyXMLReader xmlReader = new MyXMLReader(); MyXMLReader xmlReader = new MyXMLReader();
xmlReader.setContentHandler(handler); xmlReader.setContentHandler(handler);
xmlReader.parse(is); xmlReader.parse(is);
} }
} }

View File

@ -137,8 +137,8 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
mLatScaleFactor = 0.4f + 0.6f * ((float) Math.sin(Math.abs(latitude) * (Math.PI / 180))); mLatScaleFactor = 0.4f + 0.6f * ((float) Math.sin(Math.abs(latitude) * (Math.PI / 180)));
mGroundResolution = (float) (Math.cos(latitude * (Math.PI / 180)) mGroundResolution = (float) (Math.cos(latitude * (Math.PI / 180))
* MercatorProjection.EARTH_CIRCUMFERENCE * MercatorProjection.EARTH_CIRCUMFERENCE
/ ((long) Tile.SIZE << mTile.zoomLevel)); / ((long) Tile.SIZE << mTile.zoomLevel));
mTile.layers = new ElementLayers(); mTile.layers = new ElementLayers();
@ -173,7 +173,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
/** /**
* Sets the scale stroke factor for the given zoom level. * Sets the scale stroke factor for the given zoom level.
* *
* @param zoomLevel * @param zoomLevel
* the zoom level for which the scale stroke factor should be * the zoom level for which the scale stroke factor should be
* set. * set.
@ -327,7 +327,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
} }
lineLayer.addLine(mElement.points, mElement.index, lineLayer.addLine(mElement.points, mElement.index,
mElement.type == GeometryType.POLY); mElement.type == GeometryType.POLY);
// keep reference for outline layer // keep reference for outline layer
mCurLineLayer = lineLayer; mCurLineLayer = lineLayer;
@ -431,7 +431,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
break; break;
WayDecorator.renderText(mClipper, mElement.points, value, text, WayDecorator.renderText(mClipper, mElement.points, value, text,
offset, length, mTile); offset, length, mTile);
offset += length; offset += length;
} }
} }

View File

@ -21,7 +21,6 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder; import java.nio.ByteOrder;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
public class GLMatrix { public class GLMatrix {
public static final int M00 = 0;// 0; public static final int M00 = 0;// 0;
@ -41,21 +40,27 @@ public class GLMatrix {
public static final int M32 = 11;// 14; public static final int M32 = 11;// 14;
public static final int M33 = 15;// 15; public static final int M33 = 15;// 15;
private final FloatBuffer buffer = ByteBuffer.allocateDirect(16 * 4).order(ByteOrder.nativeOrder()).asFloatBuffer(); private final FloatBuffer buffer = ByteBuffer.allocateDirect(16 * 4)
.order(ByteOrder.nativeOrder())
.asFloatBuffer();
private final static String INVALID_INPUT = "Bad Array!"; private final static String INVALID_INPUT = "Bad Array!";
public final float tmp[] = new float[16]; public final float tmp[] = new float[16];
public final float val[] = new float[16]; public final float val[] = new float[16];
/** Sets the matrix to the given matrix as a float array. The float array must have at least 16 elements; the first 16 will be /**
* Sets the matrix to the given matrix as a float array. The float array
* must have at least 16 elements; the first 16 will be
* copied. * copied.
* *
* @param values The matrix, in float form, that is to be copied. Remember that this matrix is in <a * @param values The matrix, in float form, that is to be copied. Remember
* href="http://en.wikipedia.org/wiki/Row-major_order">column major</a> order. * that this matrix is in <a
* @return This matrix for the purpose of chaining methods together. */ * href="http://en.wikipedia.org/wiki/Row-major_order">column
public void set (float[] values) { * major</a> order.
* @return This matrix for the purpose of chaining methods together.
*/
public void set(float[] values) {
val[M00] = values[M00]; val[M00] = values[M00];
val[M10] = values[M10]; val[M10] = values[M10];
val[M20] = values[M20]; val[M20] = values[M20];
@ -73,9 +78,10 @@ public class GLMatrix {
val[M23] = values[M23]; val[M23] = values[M23];
val[M33] = values[M33]; val[M33] = values[M33];
} }
/** /**
* Get the Matrix as float array * Get the Matrix as float array
* *
* @param m float array to store Matrix * @param m float array to store Matrix
*/ */
public void get(float[] m) { public void get(float[] m) {
@ -88,7 +94,7 @@ public class GLMatrix {
/** /**
* Copy values from mat * Copy values from mat
* *
* @param mat Matrix to copy * @param mat Matrix to copy
*/ */
public void copy(GLMatrix m) { public void copy(GLMatrix m) {
@ -100,7 +106,7 @@ public class GLMatrix {
/** /**
* Project Vector with Matrix * Project Vector with Matrix
* *
* @param vec3 Vector to project * @param vec3 Vector to project
*/ */
public void prj(float[] vec3) { public void prj(float[] vec3) {
@ -110,7 +116,7 @@ public class GLMatrix {
matrix4_proj(val, vec3); matrix4_proj(val, vec3);
} }
static void matrix4_proj (float[] mat, float[] vec) { static void matrix4_proj(float[] mat, float[] vec) {
float inv_w = 1.0f / (vec[0] * mat[M30] + vec[1] * mat[M31] + vec[2] * mat[M32] + mat[M33]); float inv_w = 1.0f / (vec[0] * mat[M30] + vec[1] * mat[M31] + vec[2] * mat[M32] + mat[M33]);
float x = (vec[0] * mat[M00] + vec[1] * mat[M01] + vec[2] * mat[M02] + mat[M03]) * inv_w; float x = (vec[0] * mat[M00] + vec[1] * mat[M01] + vec[2] * mat[M02] + mat[M03]) * inv_w;
float y = (vec[0] * mat[M10] + vec[1] * mat[M11] + vec[2] * mat[M12] + mat[M13]) * inv_w; float y = (vec[0] * mat[M10] + vec[1] * mat[M11] + vec[2] * mat[M12] + mat[M13]) * inv_w;
@ -122,7 +128,7 @@ public class GLMatrix {
/** /**
* Multiply rhs onto Matrix. * Multiply rhs onto Matrix.
* *
* @param rhs right hand side * @param rhs right hand side
*/ */
public void multiplyRhs(GLMatrix rhs) { public void multiplyRhs(GLMatrix rhs) {
@ -131,7 +137,7 @@ public class GLMatrix {
/** /**
* Use this matrix as rhs, multiply it on lhs and store result. * Use this matrix as rhs, multiply it on lhs and store result.
* *
* @param lhs right hand side * @param lhs right hand side
*/ */
public void multiplyLhs(GLMatrix lhs) { public void multiplyLhs(GLMatrix lhs) {
@ -142,12 +148,12 @@ public class GLMatrix {
/** /**
* Multiply rhs onto lhs and store result in Matrix. * Multiply rhs onto lhs and store result in Matrix.
* *
* This matrix MUST be different from lhs and rhs! * This matrix MUST be different from lhs and rhs!
* *
* As you know, when combining matrices for vector projection * As you know, when combining matrices for vector projection
* this has the same effect first as applying rhs then lhs. * this has the same effect first as applying rhs then lhs.
* *
* @param lhs left hand side * @param lhs left hand side
* @param rhs right hand side * @param rhs right hand side
*/ */
@ -159,7 +165,7 @@ public class GLMatrix {
/** /**
* Transpose mat and store result in Matrix * Transpose mat and store result in Matrix
* *
* @param mat to transpose * @param mat to transpose
*/ */
public void transposeM(GLMatrix mat) { public void transposeM(GLMatrix mat) {
@ -183,7 +189,7 @@ public class GLMatrix {
/** /**
* Set rotation * Set rotation
* *
* @param a angle in degree * @param a angle in degree
* @param x around x-axis * @param x around x-axis
* @param y around y-axis * @param y around y-axis
@ -195,7 +201,7 @@ public class GLMatrix {
/** /**
* Set translation * Set translation
* *
* @param x along x-axis * @param x along x-axis
* @param y along y-axis * @param y along y-axis
* @param z along z-axis * @param z along z-axis
@ -209,7 +215,7 @@ public class GLMatrix {
/** /**
* Set scale factor * Set scale factor
* *
* @param x axis * @param x axis
* @param y axis * @param y axis
* @param z axis * @param z axis
@ -223,7 +229,7 @@ public class GLMatrix {
/** /**
* Set translation and x,y scale * Set translation and x,y scale
* *
* @param tx translate x * @param tx translate x
* @param ty translate y * @param ty translate y
* @param scale factor x,y * @param scale factor x,y
@ -239,7 +245,7 @@ public class GLMatrix {
/** /**
* Set Matrix with glUniformMatrix * Set Matrix with glUniformMatrix
* *
* @param location GL location id * @param location GL location id
*/ */
public void setAsUniform(int location) { public void setAsUniform(int location) {
@ -251,21 +257,23 @@ public class GLMatrix {
/** /**
* Set single value * Set single value
* *
* @param pos at position * @param pos at position
* @param value value to set * @param value value to set
*/ */
public void setValue(int pos, float value) { public void setValue(int pos, float value) {
val[pos] = value; val[pos] = value;
} }
static float PiTimesThumb = 1.0f / (1 << 11); static float PiTimesThumb = 1.0f / (1 << 11);
/** /**
* add some offset (similar to glDepthOffset) * add some offset (similar to glDepthOffset)
* *
* @param delta offset * @param delta offset
*/ */
public void addDepthOffset(int delta) { public void addDepthOffset(int delta) {
val[10] *= 1.0f + PiTimesThumb * delta; val[10] *= 1.0f + PiTimesThumb * delta;
} }
/** /**
@ -290,42 +298,58 @@ public class GLMatrix {
val[M33] = 1; val[M33] = 1;
} }
static void matrix4_mul (float[] mata, float[] matb) { static void matrix4_mul(float[] mata, float[] matb) {
float tmp[] = new float[16]; float tmp[] = new float[16];
tmp[M00] = mata[M00] * matb[M00] + mata[M01] * matb[M10] + mata[M02] * matb[M20] + mata[M03] * matb[M30]; tmp[M00] = mata[M00] * matb[M00] + mata[M01] * matb[M10] + mata[M02] * matb[M20]
tmp[M01] = mata[M00] * matb[M01] + mata[M01] * matb[M11] + mata[M02] * matb[M21] + mata[M03] * matb[M31]; + mata[M03] * matb[M30];
tmp[M02] = mata[M00] * matb[M02] + mata[M01] * matb[M12] + mata[M02] * matb[M22] + mata[M03] * matb[M32]; tmp[M01] = mata[M00] * matb[M01] + mata[M01] * matb[M11] + mata[M02] * matb[M21]
tmp[M03] = mata[M00] * matb[M03] + mata[M01] * matb[M13] + mata[M02] * matb[M23] + mata[M03] * matb[M33]; + mata[M03] * matb[M31];
tmp[M10] = mata[M10] * matb[M00] + mata[M11] * matb[M10] + mata[M12] * matb[M20] + mata[M13] * matb[M30]; tmp[M02] = mata[M00] * matb[M02] + mata[M01] * matb[M12] + mata[M02] * matb[M22]
tmp[M11] = mata[M10] * matb[M01] + mata[M11] * matb[M11] + mata[M12] * matb[M21] + mata[M13] * matb[M31]; + mata[M03] * matb[M32];
tmp[M12] = mata[M10] * matb[M02] + mata[M11] * matb[M12] + mata[M12] * matb[M22] + mata[M13] * matb[M32]; tmp[M03] = mata[M00] * matb[M03] + mata[M01] * matb[M13] + mata[M02] * matb[M23]
tmp[M13] = mata[M10] * matb[M03] + mata[M11] * matb[M13] + mata[M12] * matb[M23] + mata[M13] * matb[M33]; + mata[M03] * matb[M33];
tmp[M20] = mata[M20] * matb[M00] + mata[M21] * matb[M10] + mata[M22] * matb[M20] + mata[M23] * matb[M30]; tmp[M10] = mata[M10] * matb[M00] + mata[M11] * matb[M10] + mata[M12] * matb[M20]
tmp[M21] = mata[M20] * matb[M01] + mata[M21] * matb[M11] + mata[M22] * matb[M21] + mata[M23] * matb[M31]; + mata[M13] * matb[M30];
tmp[M22] = mata[M20] * matb[M02] + mata[M21] * matb[M12] + mata[M22] * matb[M22] + mata[M23] * matb[M32]; tmp[M11] = mata[M10] * matb[M01] + mata[M11] * matb[M11] + mata[M12] * matb[M21]
tmp[M23] = mata[M20] * matb[M03] + mata[M21] * matb[M13] + mata[M22] * matb[M23] + mata[M23] * matb[M33]; + mata[M13] * matb[M31];
tmp[M30] = mata[M30] * matb[M00] + mata[M31] * matb[M10] + mata[M32] * matb[M20] + mata[M33] * matb[M30]; tmp[M12] = mata[M10] * matb[M02] + mata[M11] * matb[M12] + mata[M12] * matb[M22]
tmp[M31] = mata[M30] * matb[M01] + mata[M31] * matb[M11] + mata[M32] * matb[M21] + mata[M33] * matb[M31]; + mata[M13] * matb[M32];
tmp[M32] = mata[M30] * matb[M02] + mata[M31] * matb[M12] + mata[M32] * matb[M22] + mata[M33] * matb[M32]; tmp[M13] = mata[M10] * matb[M03] + mata[M11] * matb[M13] + mata[M12] * matb[M23]
tmp[M33] = mata[M30] * matb[M03] + mata[M31] * matb[M13] + mata[M32] * matb[M23] + mata[M33] * matb[M33]; + mata[M13] * matb[M33];
tmp[M20] = mata[M20] * matb[M00] + mata[M21] * matb[M10] + mata[M22] * matb[M20]
+ mata[M23] * matb[M30];
tmp[M21] = mata[M20] * matb[M01] + mata[M21] * matb[M11] + mata[M22] * matb[M21]
+ mata[M23] * matb[M31];
tmp[M22] = mata[M20] * matb[M02] + mata[M21] * matb[M12] + mata[M22] * matb[M22]
+ mata[M23] * matb[M32];
tmp[M23] = mata[M20] * matb[M03] + mata[M21] * matb[M13] + mata[M22] * matb[M23]
+ mata[M23] * matb[M33];
tmp[M30] = mata[M30] * matb[M00] + mata[M31] * matb[M10] + mata[M32] * matb[M20]
+ mata[M33] * matb[M30];
tmp[M31] = mata[M30] * matb[M01] + mata[M31] * matb[M11] + mata[M32] * matb[M21]
+ mata[M33] * matb[M31];
tmp[M32] = mata[M30] * matb[M02] + mata[M31] * matb[M12] + mata[M32] * matb[M22]
+ mata[M33] * matb[M32];
tmp[M33] = mata[M30] * matb[M03] + mata[M31] * matb[M13] + mata[M32] * matb[M23]
+ mata[M33] * matb[M33];
System.arraycopy(tmp, 0, mata, 0, 16); System.arraycopy(tmp, 0, mata, 0, 16);
} }
// @Override // @Override
// public void finalize() { // public void finalize() {
// if (pointer != 0) // if (pointer != 0)
// delete(pointer); // 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
* You may obtain a copy of the License at * You may obtain a copy of the License at
* *
* http://www.apache.org/licenses/LICENSE-2.0 * http://www.apache.org/licenses/LICENSE-2.0
* *
* Unless required by applicable law or agreed to in writing, software * Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, * distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@ -334,262 +358,263 @@ public class GLMatrix {
*/ */
/** /**
* Define a projection matrix in terms of six clip planes * Define a projection matrix in terms of six clip planes
* @param m the float array that holds the perspective matrix *
* @param offset the offset into float array m where the perspective * @param m the float array that holds the perspective matrix
* matrix data is written * @param offset the offset into float array m where the perspective
*/ * matrix data is written
public static void frustumM(float[] m, int offset, */
float left, float right, float bottom, float top, public static void frustumM(float[] m, int offset,
float near, float far) { float left, float right, float bottom, float top,
if (left == right) { float near, float far) {
throw new IllegalArgumentException("left == right"); if (left == right) {
} throw new IllegalArgumentException("left == right");
if (top == bottom) { }
throw new IllegalArgumentException("top == bottom"); if (top == bottom) {
} throw new IllegalArgumentException("top == bottom");
if (near == far) { }
throw new IllegalArgumentException("near == far"); if (near == far) {
} throw new IllegalArgumentException("near == far");
if (near <= 0.0f) { }
throw new IllegalArgumentException("near <= 0.0f"); if (near <= 0.0f) {
} throw new IllegalArgumentException("near <= 0.0f");
if (far <= 0.0f) { }
throw new IllegalArgumentException("far <= 0.0f"); if (far <= 0.0f) {
} throw new IllegalArgumentException("far <= 0.0f");
final float r_width = 1.0f / (right - left); }
final float r_height = 1.0f / (top - bottom); final float r_width = 1.0f / (right - left);
final float r_depth = 1.0f / (near - far); final float r_height = 1.0f / (top - bottom);
final float x = 2.0f * (near * r_width); final float r_depth = 1.0f / (near - far);
final float y = 2.0f * (near * r_height); final float x = 2.0f * (near * r_width);
final float A = (right + left) * r_width; final float y = 2.0f * (near * r_height);
final float B = (top + bottom) * r_height; final float A = (right + left) * r_width;
final float C = (far + near) * r_depth; final float B = (top + bottom) * r_height;
final float D = 2.0f * (far * near * r_depth); final float C = (far + near) * r_depth;
m[offset + 0] = x; final float D = 2.0f * (far * near * r_depth);
m[offset + 5] = y; m[offset + 0] = x;
m[offset + 8] = A; m[offset + 5] = y;
m[offset + 9] = B; m[offset + 8] = A;
m[offset + 10] = C; m[offset + 9] = B;
m[offset + 14] = D; m[offset + 10] = C;
m[offset + 11] = -1.0f; m[offset + 14] = D;
m[offset + 1] = 0.0f; m[offset + 11] = -1.0f;
m[offset + 2] = 0.0f; m[offset + 1] = 0.0f;
m[offset + 3] = 0.0f; m[offset + 2] = 0.0f;
m[offset + 4] = 0.0f; m[offset + 3] = 0.0f;
m[offset + 6] = 0.0f; m[offset + 4] = 0.0f;
m[offset + 7] = 0.0f; m[offset + 6] = 0.0f;
m[offset + 12] = 0.0f; m[offset + 7] = 0.0f;
m[offset + 13] = 0.0f; m[offset + 12] = 0.0f;
m[offset + 15] = 0.0f; m[offset + 13] = 0.0f;
} m[offset + 15] = 0.0f;
}
/** /**
* Inverts a 4 x 4 matrix. * Inverts a 4 x 4 matrix.
* *
* @param mInv the array that holds the output inverted matrix * @param mInv the array that holds the output inverted matrix
* @param mInvOffset an offset into mInv where the inverted matrix is * @param mInvOffset an offset into mInv where the inverted matrix is
* stored. * stored.
* @param m the input array * @param m the input array
* @param mOffset an offset into m where the matrix is stored. * @param mOffset an offset into m where the matrix is stored.
* @return true if the matrix could be inverted, false if it could not. * @return true if the matrix could be inverted, false if it could not.
*/ */
public static boolean invertM(float[] mInv, int mInvOffset, float[] m, public static boolean invertM(float[] mInv, int mInvOffset, float[] m,
int mOffset) { int mOffset) {
// Invert a 4 x 4 matrix using Cramer's Rule // Invert a 4 x 4 matrix using Cramer's Rule
// transpose matrix // transpose matrix
final float src0 = m[mOffset + 0]; final float src0 = m[mOffset + 0];
final float src4 = m[mOffset + 1]; final float src4 = m[mOffset + 1];
final float src8 = m[mOffset + 2]; final float src8 = m[mOffset + 2];
final float src12 = m[mOffset + 3]; final float src12 = m[mOffset + 3];
final float src1 = m[mOffset + 4]; final float src1 = m[mOffset + 4];
final float src5 = m[mOffset + 5]; final float src5 = m[mOffset + 5];
final float src9 = m[mOffset + 6]; final float src9 = m[mOffset + 6];
final float src13 = m[mOffset + 7]; final float src13 = m[mOffset + 7];
final float src2 = m[mOffset + 8]; final float src2 = m[mOffset + 8];
final float src6 = m[mOffset + 9]; final float src6 = m[mOffset + 9];
final float src10 = m[mOffset + 10]; final float src10 = m[mOffset + 10];
final float src14 = m[mOffset + 11]; final float src14 = m[mOffset + 11];
final float src3 = m[mOffset + 12]; final float src3 = m[mOffset + 12];
final float src7 = m[mOffset + 13]; final float src7 = m[mOffset + 13];
final float src11 = m[mOffset + 14]; final float src11 = m[mOffset + 14];
final float src15 = m[mOffset + 15]; final float src15 = m[mOffset + 15];
// calculate pairs for first 8 elements (cofactors) // calculate pairs for first 8 elements (cofactors)
final float atmp0 = src10 * src15; final float atmp0 = src10 * src15;
final float atmp1 = src11 * src14; final float atmp1 = src11 * src14;
final float atmp2 = src9 * src15; final float atmp2 = src9 * src15;
final float atmp3 = src11 * src13; final float atmp3 = src11 * src13;
final float atmp4 = src9 * src14; final float atmp4 = src9 * src14;
final float atmp5 = src10 * src13; final float atmp5 = src10 * src13;
final float atmp6 = src8 * src15; final float atmp6 = src8 * src15;
final float atmp7 = src11 * src12; final float atmp7 = src11 * src12;
final float atmp8 = src8 * src14; final float atmp8 = src8 * src14;
final float atmp9 = src10 * src12; final float atmp9 = src10 * src12;
final float atmp10 = src8 * src13; final float atmp10 = src8 * src13;
final float atmp11 = src9 * src12; final float atmp11 = src9 * src12;
// calculate first 8 elements (cofactors) // calculate first 8 elements (cofactors)
final float dst0 = (atmp0 * src5 + atmp3 * src6 + atmp4 * src7) final float dst0 = (atmp0 * src5 + atmp3 * src6 + atmp4 * src7)
- (atmp1 * src5 + atmp2 * src6 + atmp5 * src7); - (atmp1 * src5 + atmp2 * src6 + atmp5 * src7);
final float dst1 = (atmp1 * src4 + atmp6 * src6 + atmp9 * src7) final float dst1 = (atmp1 * src4 + atmp6 * src6 + atmp9 * src7)
- (atmp0 * src4 + atmp7 * src6 + atmp8 * src7); - (atmp0 * src4 + atmp7 * src6 + atmp8 * src7);
final float dst2 = (atmp2 * src4 + atmp7 * src5 + atmp10 * src7) final float dst2 = (atmp2 * src4 + atmp7 * src5 + atmp10 * src7)
- (atmp3 * src4 + atmp6 * src5 + atmp11 * src7); - (atmp3 * src4 + atmp6 * src5 + atmp11 * src7);
final float dst3 = (atmp5 * src4 + atmp8 * src5 + atmp11 * src6) final float dst3 = (atmp5 * src4 + atmp8 * src5 + atmp11 * src6)
- (atmp4 * src4 + atmp9 * src5 + atmp10 * src6); - (atmp4 * src4 + atmp9 * src5 + atmp10 * src6);
final float dst4 = (atmp1 * src1 + atmp2 * src2 + atmp5 * src3) final float dst4 = (atmp1 * src1 + atmp2 * src2 + atmp5 * src3)
- (atmp0 * src1 + atmp3 * src2 + atmp4 * src3); - (atmp0 * src1 + atmp3 * src2 + atmp4 * src3);
final float dst5 = (atmp0 * src0 + atmp7 * src2 + atmp8 * src3) final float dst5 = (atmp0 * src0 + atmp7 * src2 + atmp8 * src3)
- (atmp1 * src0 + atmp6 * src2 + atmp9 * src3); - (atmp1 * src0 + atmp6 * src2 + atmp9 * src3);
final float dst6 = (atmp3 * src0 + atmp6 * src1 + atmp11 * src3) final float dst6 = (atmp3 * src0 + atmp6 * src1 + atmp11 * src3)
- (atmp2 * src0 + atmp7 * src1 + atmp10 * src3); - (atmp2 * src0 + atmp7 * src1 + atmp10 * src3);
final float dst7 = (atmp4 * src0 + atmp9 * src1 + atmp10 * src2) final float dst7 = (atmp4 * src0 + atmp9 * src1 + atmp10 * src2)
- (atmp5 * src0 + atmp8 * src1 + atmp11 * src2); - (atmp5 * src0 + atmp8 * src1 + atmp11 * src2);
// calculate pairs for second 8 elements (cofactors) // calculate pairs for second 8 elements (cofactors)
final float btmp0 = src2 * src7; final float btmp0 = src2 * src7;
final float btmp1 = src3 * src6; final float btmp1 = src3 * src6;
final float btmp2 = src1 * src7; final float btmp2 = src1 * src7;
final float btmp3 = src3 * src5; final float btmp3 = src3 * src5;
final float btmp4 = src1 * src6; final float btmp4 = src1 * src6;
final float btmp5 = src2 * src5; final float btmp5 = src2 * src5;
final float btmp6 = src0 * src7; final float btmp6 = src0 * src7;
final float btmp7 = src3 * src4; final float btmp7 = src3 * src4;
final float btmp8 = src0 * src6; final float btmp8 = src0 * src6;
final float btmp9 = src2 * src4; final float btmp9 = src2 * src4;
final float btmp10 = src0 * src5; final float btmp10 = src0 * src5;
final float btmp11 = src1 * src4; final float btmp11 = src1 * src4;
// calculate second 8 elements (cofactors) // calculate second 8 elements (cofactors)
final float dst8 = (btmp0 * src13 + btmp3 * src14 + btmp4 * src15) final float dst8 = (btmp0 * src13 + btmp3 * src14 + btmp4 * src15)
- (btmp1 * src13 + btmp2 * src14 + btmp5 * src15); - (btmp1 * src13 + btmp2 * src14 + btmp5 * src15);
final float dst9 = (btmp1 * src12 + btmp6 * src14 + btmp9 * src15) final float dst9 = (btmp1 * src12 + btmp6 * src14 + btmp9 * src15)
- (btmp0 * src12 + btmp7 * src14 + btmp8 * src15); - (btmp0 * src12 + btmp7 * src14 + btmp8 * src15);
final float dst10 = (btmp2 * src12 + btmp7 * src13 + btmp10 * src15) final float dst10 = (btmp2 * src12 + btmp7 * src13 + btmp10 * src15)
- (btmp3 * src12 + btmp6 * src13 + btmp11 * src15); - (btmp3 * src12 + btmp6 * src13 + btmp11 * src15);
final float dst11 = (btmp5 * src12 + btmp8 * src13 + btmp11 * src14) final float dst11 = (btmp5 * src12 + btmp8 * src13 + btmp11 * src14)
- (btmp4 * src12 + btmp9 * src13 + btmp10 * src14); - (btmp4 * src12 + btmp9 * src13 + btmp10 * src14);
final float dst12 = (btmp2 * src10 + btmp5 * src11 + btmp1 * src9 ) final float dst12 = (btmp2 * src10 + btmp5 * src11 + btmp1 * src9)
- (btmp4 * src11 + btmp0 * src9 + btmp3 * src10); - (btmp4 * src11 + btmp0 * src9 + btmp3 * src10);
final float dst13 = (btmp8 * src11 + btmp0 * src8 + btmp7 * src10) final float dst13 = (btmp8 * src11 + btmp0 * src8 + btmp7 * src10)
- (btmp6 * src10 + btmp9 * src11 + btmp1 * src8 ); - (btmp6 * src10 + btmp9 * src11 + btmp1 * src8);
final float dst14 = (btmp6 * src9 + btmp11 * src11 + btmp3 * src8 ) final float dst14 = (btmp6 * src9 + btmp11 * src11 + btmp3 * src8)
- (btmp10 * src11 + btmp2 * src8 + btmp7 * src9 ); - (btmp10 * src11 + btmp2 * src8 + btmp7 * src9);
final float dst15 = (btmp10 * src10 + btmp4 * src8 + btmp9 * src9 ) final float dst15 = (btmp10 * src10 + btmp4 * src8 + btmp9 * src9)
- (btmp8 * src9 + btmp11 * src10 + btmp5 * src8 ); - (btmp8 * src9 + btmp11 * src10 + btmp5 * src8);
// calculate determinant // calculate determinant
final float det = final float det =
src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3; src0 * dst0 + src1 * dst1 + src2 * dst2 + src3 * dst3;
if (det == 0.0f) { if (det == 0.0f) {
return false; return false;
} }
// calculate matrix inverse // calculate matrix inverse
final float invdet = 1.0f / det; final float invdet = 1.0f / det;
mInv[ mInvOffset] = dst0 * invdet; mInv[mInvOffset] = dst0 * invdet;
mInv[ 1 + mInvOffset] = dst1 * invdet; mInv[1 + mInvOffset] = dst1 * invdet;
mInv[ 2 + mInvOffset] = dst2 * invdet; mInv[2 + mInvOffset] = dst2 * invdet;
mInv[ 3 + mInvOffset] = dst3 * invdet; mInv[3 + mInvOffset] = dst3 * invdet;
mInv[ 4 + mInvOffset] = dst4 * invdet; mInv[4 + mInvOffset] = dst4 * invdet;
mInv[ 5 + mInvOffset] = dst5 * invdet; mInv[5 + mInvOffset] = dst5 * invdet;
mInv[ 6 + mInvOffset] = dst6 * invdet; mInv[6 + mInvOffset] = dst6 * invdet;
mInv[ 7 + mInvOffset] = dst7 * invdet; mInv[7 + mInvOffset] = dst7 * invdet;
mInv[ 8 + mInvOffset] = dst8 * invdet; mInv[8 + mInvOffset] = dst8 * invdet;
mInv[ 9 + mInvOffset] = dst9 * invdet; mInv[9 + mInvOffset] = dst9 * invdet;
mInv[10 + mInvOffset] = dst10 * invdet; mInv[10 + mInvOffset] = dst10 * invdet;
mInv[11 + mInvOffset] = dst11 * invdet; mInv[11 + mInvOffset] = dst11 * invdet;
mInv[12 + mInvOffset] = dst12 * invdet; mInv[12 + mInvOffset] = dst12 * invdet;
mInv[13 + mInvOffset] = dst13 * invdet; mInv[13 + mInvOffset] = dst13 * invdet;
mInv[14 + mInvOffset] = dst14 * invdet; mInv[14 + mInvOffset] = dst14 * invdet;
mInv[15 + mInvOffset] = dst15 * invdet; mInv[15 + mInvOffset] = dst15 * invdet;
return true; return true;
} }
void setRotateM(float[] rm, int rmOffset, float a, float x, float y, float z) void setRotateM(float[] rm, int rmOffset, float a, float x, float y, float z)
{ {
rm[rmOffset + 3] = 0; rm[rmOffset + 3] = 0;
rm[rmOffset + 7] = 0; rm[rmOffset + 7] = 0;
rm[rmOffset + 11] = 0; rm[rmOffset + 11] = 0;
rm[rmOffset + 12] = 0; rm[rmOffset + 12] = 0;
rm[rmOffset + 13] = 0; rm[rmOffset + 13] = 0;
rm[rmOffset + 14] = 0; rm[rmOffset + 14] = 0;
rm[rmOffset + 15] = 1; rm[rmOffset + 15] = 1;
a *= (float) (Math.PI / 180.0f); a *= (float) (Math.PI / 180.0f);
float s = (float) Math.sin(a); float s = (float) Math.sin(a);
float c = (float) Math.cos(a); float c = (float) Math.cos(a);
if (1.0f == x && 0.0f == y && 0.0f == z) if (1.0f == x && 0.0f == y && 0.0f == z)
{ {
rm[rmOffset + 5] = c; rm[rmOffset + 5] = c;
rm[rmOffset + 10] = c; rm[rmOffset + 10] = c;
rm[rmOffset + 6] = s; rm[rmOffset + 6] = s;
rm[rmOffset + 9] = -s; rm[rmOffset + 9] = -s;
rm[rmOffset + 1] = 0; rm[rmOffset + 1] = 0;
rm[rmOffset + 2] = 0; rm[rmOffset + 2] = 0;
rm[rmOffset + 4] = 0; rm[rmOffset + 4] = 0;
rm[rmOffset + 8] = 0; rm[rmOffset + 8] = 0;
rm[rmOffset + 0] = 1; rm[rmOffset + 0] = 1;
} }
else if (0.0f == x && 1.0f == y && 0.0f == z) else if (0.0f == x && 1.0f == y && 0.0f == z)
{ {
rm[rmOffset + 0] = c; rm[rmOffset + 0] = c;
rm[rmOffset + 10] = c; rm[rmOffset + 10] = c;
rm[rmOffset + 8] = s; rm[rmOffset + 8] = s;
rm[rmOffset + 2] = -s; rm[rmOffset + 2] = -s;
rm[rmOffset + 1] = 0; rm[rmOffset + 1] = 0;
rm[rmOffset + 4] = 0; rm[rmOffset + 4] = 0;
rm[rmOffset + 6] = 0; rm[rmOffset + 6] = 0;
rm[rmOffset + 9] = 0; rm[rmOffset + 9] = 0;
rm[rmOffset + 5] = 1; rm[rmOffset + 5] = 1;
} }
else if (0.0f == x && 0.0f == y && 1.0f == z) else if (0.0f == x && 0.0f == y && 1.0f == z)
{ {
rm[rmOffset + 0] = c; rm[rmOffset + 0] = c;
rm[rmOffset + 5] = c; rm[rmOffset + 5] = c;
rm[rmOffset + 1] = s; rm[rmOffset + 1] = s;
rm[rmOffset + 4] = -s; rm[rmOffset + 4] = -s;
rm[rmOffset + 2] = 0; rm[rmOffset + 2] = 0;
rm[rmOffset + 6] = 0; rm[rmOffset + 6] = 0;
rm[rmOffset + 8] = 0; rm[rmOffset + 8] = 0;
rm[rmOffset + 9] = 0; rm[rmOffset + 9] = 0;
rm[rmOffset + 10] = 1; rm[rmOffset + 10] = 1;
} }
else else
{ {
float len = (float) Math.sqrt(x * x + y * y + z * z); float len = (float) Math.sqrt(x * x + y * y + z * z);
if (1.0f != len) if (1.0f != len)
{ {
float recipLen = 1.0f / len; float recipLen = 1.0f / len;
x *= recipLen; x *= recipLen;
y *= recipLen; y *= recipLen;
z *= recipLen; z *= recipLen;
} }
float nc = 1.0f - c; float nc = 1.0f - c;
float xy = x * y; float xy = x * y;
float yz = y * z; float yz = y * z;
float zx = z * x; float zx = z * x;
float xs = x * s; float xs = x * s;
float ys = y * s; float ys = y * s;
float zs = z * s; float zs = z * s;
rm[rmOffset + 0] = x * x * nc + c; rm[rmOffset + 0] = x * x * nc + c;
rm[rmOffset + 4] = xy * nc - zs; rm[rmOffset + 4] = xy * nc - zs;
rm[rmOffset + 8] = zx * nc + ys; rm[rmOffset + 8] = zx * nc + ys;
rm[rmOffset + 1] = xy * nc + zs; rm[rmOffset + 1] = xy * nc + zs;
rm[rmOffset + 5] = y * y * nc + c; rm[rmOffset + 5] = y * y * nc + c;
rm[rmOffset + 9] = yz * nc - xs; rm[rmOffset + 9] = yz * nc - xs;
rm[rmOffset + 2] = zx * nc - ys; rm[rmOffset + 2] = zx * nc - ys;
rm[rmOffset + 6] = yz * nc + xs; rm[rmOffset + 6] = yz * nc + xs;
rm[rmOffset + 10] = z * z * nc + c; rm[rmOffset + 10] = z * z * nc + c;
} }
} }
} }

View File

@ -14,7 +14,7 @@ public class RenderThemeHandler2 {
private final static int LINE_HIGHWAY = 2; private final static int LINE_HIGHWAY = 2;
private final static Tag TAG_WATER = new Tag("natural", "water"); private final static Tag TAG_WATER = new Tag("natural", "water");
private final static Tag TAG_WOOD = new Tag("natural", "wood"); private final static Tag TAG_WOOD = new Tag("natural", "wood");
private final static Tag TAG_FOREST= new Tag("landuse", "forest"); private final static Tag TAG_FOREST = new Tag("landuse", "forest");
private static RenderInstruction[][] instructions = { private static RenderInstruction[][] instructions = {
// water // water
@ -38,7 +38,7 @@ public class RenderThemeHandler2 {
if (e.tags.contains(TAG_WATER)) if (e.tags.contains(TAG_WATER))
return instructions[AREA_WATER]; return instructions[AREA_WATER];
if (e.tags.contains(TAG_WOOD) ||e.tags.contains(TAG_FOREST)) if (e.tags.contains(TAG_WOOD) || e.tags.contains(TAG_FOREST))
return instructions[AREA_WOOD]; return instructions[AREA_WOOD];
} else if (e.isLine()) { } else if (e.isLine()) {

View File

@ -172,7 +172,7 @@ public class LwHttp {
/** /**
* Write custom tile url * Write custom tile url
* *
* @param tile Tile * @param tile Tile
* @param path to write url string * @param path to write url string
* @param curPos current position * @param curPos current position

View File

@ -54,6 +54,7 @@ public final class IOUtils {
Log.d(IOUtils.class.getName(), e.getMessage() + " " + e); Log.d(IOUtils.class.getName(), e.getMessage() + " " + e);
} }
} }
private IOUtils() { private IOUtils() {
} }
} }

View File

@ -12,14 +12,14 @@ import com.google.gwt.typedarrays.shared.Int32Array;
public class Tessellator { public class Tessellator {
public static synchronized int triangulate(float[] points, int ppos, int plen, short[] index, public static synchronized int triangulate(float[] points, int ppos, int plen, short[] index,
int ipos, int rings, int vertexOffset, VertexItem outTris) { int ipos, int rings, int vertexOffset, VertexItem outTris) {
//JavaScriptObject o; //JavaScriptObject o;
Int32Array io; Int32Array io;
try{ try {
io = tessellate(JsArrayUtils.readOnlyJsArray(points), ppos, plen, io = tessellate(JsArrayUtils.readOnlyJsArray(points), ppos, plen,
JsArrayUtils.readOnlyJsArray(index), ipos, rings); JsArrayUtils.readOnlyJsArray(index), ipos, rings);
} catch(JavaScriptException e){ } catch (JavaScriptException e) {
e.printStackTrace(); e.printStackTrace();
return 0; return 0;
} }
@ -27,22 +27,22 @@ public class Tessellator {
//Float32Array vo = getPoints(o); //Float32Array vo = getPoints(o);
//Int32Array io = getIndices(o); //Int32Array io = getIndices(o);
if (io == null){ if (io == null) {
Log.d("Triangulator", "building tessellation failed"); Log.d("Triangulator", "building tessellation failed");
return 0; return 0;
} }
// if (vo.length() != plen) { // if (vo.length() != plen) {
// // TODO handle different output points // // TODO handle different output points
// Log.d("", "other points out" + plen + ":" + vo.length() + ", " + io.length()); // Log.d("", "other points out" + plen + ":" + vo.length() + ", " + io.length());
// //
// //for (int i = 0; i < vo.length(); i += 2) // //for (int i = 0; i < vo.length(); i += 2)
// // Log.d("<", vo.get(i) + " " + vo.get(i + 1)); // // Log.d("<", vo.get(i) + " " + vo.get(i + 1));
// //for (int i = ppos; i < ppos + plen; i += 2) // //for (int i = ppos; i < ppos + plen; i += 2)
// // Log.d(">", points[i]+ " " + points[i + 1]); // // Log.d(">", points[i]+ " " + points[i + 1]);
// //
// return 0; // return 0;
// } // }
int numIndices = io.length(); int numIndices = io.length();
@ -58,7 +58,7 @@ public class Tessellator {
if (k + cnt > numIndices) if (k + cnt > numIndices)
cnt = numIndices - k; cnt = numIndices - k;
for (int i = 0; i < cnt; i++){ for (int i = 0; i < cnt; i++) {
int idx = (vertexOffset + io.get(k + i)); int idx = (vertexOffset + io.get(k + i));
outTris.vertices[outTris.used + i] = (short) idx; outTris.vertices[outTris.used + i] = (short) idx;
} }
@ -69,25 +69,25 @@ public class Tessellator {
} }
static native Int32Array tessellate(JsArrayNumber points, int pOffset, int pLength, static native Int32Array tessellate(JsArrayNumber points, int pOffset, int pLength,
JsArrayInteger bounds, int bOffset, int bLength)/*-{ JsArrayInteger bounds, int bOffset, int bLength)/*-{
return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds, return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
bOffset, bOffset + bLength); bOffset, bOffset + bLength);
}-*/; }-*/;
// static native JavaScriptObject tessellate(JsArrayNumber points, int pOffset, int pLength, // static native JavaScriptObject tessellate(JsArrayNumber points, int pOffset, int pLength,
// JsArrayInteger bounds, int bOffset, int bLength)/*-{ // JsArrayInteger bounds, int bOffset, int bLength)/*-{
// //
// return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds, // return $wnd.tessellate(points, pOffset, pOffset + pLength, bounds,
// bOffset, bOffset + bLength); // bOffset, bOffset + bLength);
// }-*/; // }-*/;
// static native Float32Array getPoints(JavaScriptObject result)/*-{ // static native Float32Array getPoints(JavaScriptObject result)/*-{
// return result.vertices; // return result.vertices;
// }-*/; // }-*/;
// static native Int32Array getIndices(JavaScriptObject result)/*-{ // static native Int32Array getIndices(JavaScriptObject result)/*-{
// return result.triangles; // return result.triangles;
// }-*/; // }-*/;
} }

View File

@ -5,14 +5,16 @@ import com.badlogic.gdx.utils.Disposable;
/** /**
* GWT emulation of AsynchExecutor, will call tasks immediately :D * GWT emulation of AsynchExecutor, will call tasks immediately :D
*
* @author badlogic * @author badlogic
* *
*/ */
public class AsyncExecutor implements Disposable { public class AsyncExecutor implements Disposable {
/** /**
* Creates a new AsynchExecutor that allows maxConcurrent * Creates a new AsynchExecutor that allows maxConcurrent {@link Runnable}
* {@link Runnable} instances to run in parallel. * instances to run in parallel.
*
* @param maxConcurrent * @param maxConcurrent
*/ */
public AsyncExecutor(int maxConcurrent) { public AsyncExecutor(int maxConcurrent) {
@ -23,6 +25,7 @@ public class AsyncExecutor implements Disposable {
* Submits a {@link Runnable} to be executed asynchronously. If * Submits a {@link Runnable} to be executed asynchronously. If
* maxConcurrent runnables are already running, the runnable * maxConcurrent runnables are already running, the runnable
* will be queued. * will be queued.
*
* @param task the task to execute asynchronously * @param task the task to execute asynchronously
*/ */
@SuppressWarnings({ "unchecked", "rawtypes" }) @SuppressWarnings({ "unchecked", "rawtypes" })
@ -33,7 +36,7 @@ public class AsyncExecutor implements Disposable {
try { try {
task.run(); task.run();
result = task.getResult(); result = task.getResult();
} catch(Throwable t) { } catch (Throwable t) {
error = true; error = true;
} }
if (error) if (error)
@ -46,17 +49,19 @@ public class AsyncExecutor implements Disposable {
* Submits a {@link Runnable} to be executed asynchronously. If * Submits a {@link Runnable} to be executed asynchronously. If
* maxConcurrent runnables are already running, the runnable * maxConcurrent runnables are already running, the runnable
* will be queued. * will be queued.
*
* @param task the task to execute asynchronously * @param task the task to execute asynchronously
*/ */
public void post(Runnable task) { public void post(Runnable task) {
Gdx.app.postRunnable(task); Gdx.app.postRunnable(task);
} }
/** /**
* Waits for running {@link AsyncTask} instances to finish, * Waits for running {@link AsyncTask} instances to finish,
* then destroys any resources like threads. Can not be used * then destroys any resources like threads. Can not be used
* after this method is called. * after this method is called.
*/ */
@Override @Override
public void dispose () { public void dispose() {
} }
} }

View File

@ -19,12 +19,12 @@ package org.oscim.utils.async;
//import java.util.concurrent.ExecutionException; //import java.util.concurrent.ExecutionException;
//import java.util.concurrent.Future; //import java.util.concurrent.Future;
/** /**
* Returned by {@link AsyncExecutor#submit(AsyncTask)}, allows to poll * Returned by {@link AsyncExecutor#submit(AsyncTask)}, allows to poll
* for the result of the asynch workload. * for the result of the asynch workload.
*
* @author badlogic * @author badlogic
* *
*/ */
public class AsyncResult<T> { public class AsyncResult<T> {
private final T result; private final T result;
@ -41,7 +41,8 @@ public class AsyncResult<T> {
} }
/** /**
* @return the result, or null if there was an error, no result, or the task is still running * @return the result, or null if there was an error, no result, or the task
* is still running
*/ */
public T get() { public T get() {
return result; return result;

View File

@ -16,13 +16,15 @@
package org.oscim.utils.async; package org.oscim.utils.async;
/** /**
* Task to be submitted to an {@link AsyncExecutor}, returning a result of type T. * Task to be submitted to an {@link AsyncExecutor}, returning a result of type
* T.
*
* @author badlogic * @author badlogic
* *
*/ */
public interface AsyncTask<T> extends Runnable{ public interface AsyncTask<T> extends Runnable {
public boolean cancel(); public boolean cancel();
public T getResult() throws Exception; public T getResult() throws Exception;
} }

View File

@ -18,8 +18,9 @@ package org.oscim.utils.async;
/** /**
* GWT emulation of ThreadUtils, does nothing. * GWT emulation of ThreadUtils, does nothing.
*
* @author badlogic * @author badlogic
* *
*/ */
public class ThreadUtils { public class ThreadUtils {
public static void yield() { public static void yield() {

View File

@ -1,6 +1,5 @@
package org.xml.sax; package org.xml.sax;
public abstract interface Attributes { public abstract interface Attributes {
public abstract int getLength(); public abstract int getLength();
@ -25,4 +24,4 @@ public abstract interface Attributes {
public abstract String getValue(String paramString1, String paramString2); public abstract String getValue(String paramString1, String paramString2);
public abstract String getValue(String paramString); public abstract String getValue(String paramString);
} }

View File

@ -12,6 +12,7 @@ public class SAXException extends IOException {
public SAXException(String str) { public SAXException(String str) {
super(str); super(str);
} }
public SAXException(String str, Throwable throwable) public SAXException(String str, Throwable throwable)
{ {
super(str); super(str);

View File

@ -10,6 +10,7 @@ public class SAXParseException extends SAXException {
public SAXParseException(String str) { public SAXParseException(String str) {
super(str); super(str);
} }
public SAXParseException(String str, Throwable throwable) public SAXParseException(String str, Throwable throwable)
{ {
super(str); super(str);

View File

@ -12,12 +12,13 @@ public class DefaultHandler {
public void error(SAXParseException exception) { public void error(SAXParseException exception) {
} }
public void warning(SAXParseException exception) { public void warning(SAXParseException exception) {
} }
public void startElement(String uri, String localName, String qName, public void startElement(String uri, String localName, String qName,
Attributes attributes) throws SAXException { Attributes attributes) throws SAXException {
} }
@ -25,5 +26,4 @@ public class DefaultHandler {
} }
} }

View File

@ -85,7 +85,7 @@ public abstract class GdxMap implements ApplicationListener {
/** /**
* Update all Layers on Main thread. * Update all Layers on Main thread.
* *
* @param forceRedraw * @param forceRedraw
* also render frame FIXME (does nothing atm) * also render frame FIXME (does nothing atm)
*/ */
@ -116,24 +116,24 @@ public abstract class GdxMap implements ApplicationListener {
} }
protected void initDefaultLayers(TileSource tileSource, boolean tileGrid, boolean labels, protected void initDefaultLayers(TileSource tileSource, boolean tileGrid, boolean labels,
boolean buildings) { boolean buildings) {
if (tileSource != null) { if (tileSource != null) {
mMapLayer = mMap.setBaseMap(tileSource); mMapLayer = mMap.setBaseMap(tileSource);
mMap.setTheme(InternalRenderTheme.DEFAULT); mMap.setTheme(InternalRenderTheme.DEFAULT);
if (buildings) if (buildings)
mMap.getLayers().add( mMap.getLayers()
new BuildingLayer(mMap, mMapLayer.getTileLayer())); .add(new BuildingLayer(mMap, mMapLayer.getTileLayer()));
if (labels) if (labels)
mMap.getLayers().add(new LabelLayer(mMap, mMap.getLayers()
mMapLayer.getTileLayer())); .add(new LabelLayer(mMap, mMapLayer.getTileLayer()));
} }
if (tileGrid) if (tileGrid)
mMap.getLayers().add(new GenericLayer(mMap, mMap.getLayers()
new GridRenderer())); .add(new GenericLayer(mMap, new GridRenderer()));
} }
// Stage ui; // Stage ui;
@ -227,7 +227,6 @@ public abstract class GdxMap implements ApplicationListener {
public void resume() { public void resume() {
} }
class TouchHandler implements InputProcessor { class TouchHandler implements InputProcessor {
private Viewport mMapPosition; private Viewport mMapPosition;
@ -446,7 +445,7 @@ public abstract class GdxMap implements ApplicationListener {
@Override @Override
public boolean fling(final float velocityX, final float velocityY, public boolean fling(final float velocityX, final float velocityY,
int button) { int button) {
//Log.d("", "fling " + button + " " + velocityX + "/" + velocityY); //Log.d("", "fling " + button + " " + velocityX + "/" + velocityY);
if (mayFling && button == Buttons.LEFT) { if (mayFling && button == Buttons.LEFT) {
int m = Tile.SIZE * 4; int m = Tile.SIZE * 4;
@ -474,7 +473,7 @@ public abstract class GdxMap implements ApplicationListener {
@Override @Override
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2,
Vector2 pointer1, Vector2 pointer2) { Vector2 pointer1, Vector2 pointer2) {
mayFling = false; mayFling = false;
if (!mPinch) { if (!mPinch) {
@ -533,13 +532,12 @@ public abstract class GdxMap implements ApplicationListener {
// decrease change of scale by the change of rotation // decrease change of scale by the change of rotation
// * 20 is just arbitrary // * 20 is just arbitrary
if (mBeginRotate) if (mBeginRotate)
scale = 1 + ((scale - 1) * Math.max( scale = 1 + ((scale - 1) * Math.max((1 - (float) Math.abs(r) * 20), 0));
(1 - (float) Math.abs(r) * 20), 0));
mSumScale *= scale; mSumScale *= scale;
if ((mSumScale < 0.99 || mSumScale > 1.01) if ((mSumScale < 0.99 || mSumScale > 1.01)
&& mSumRotate < Math.abs(0.02)) && mSumRotate < Math.abs(0.02))
mBeginRotate = false; mBeginRotate = false;
float fx = (x2 + x1) / 2 - mWidth / 2; float fx = (x2 + x1) / 2 - mWidth / 2;
@ -557,14 +555,14 @@ public abstract class GdxMap implements ApplicationListener {
// Log.d(TAG, r + " " + slope + " m1:" + my + " m2:" + my2); // Log.d(TAG, r + " " + slope + " m1:" + my + " m2:" + my2);
if ((my > threshold && my2 > threshold) if ((my > threshold && my2 > threshold)
|| (my < -threshold && my2 < -threshold)) { || (my < -threshold && my2 < -threshold)) {
mBeginTilt = true; mBeginTilt = true;
changed = mMapPosition.tiltMap(my / 5); changed = mMapPosition.tiltMap(my / 5);
} }
} }
if (!mBeginTilt if (!mBeginTilt
&& (mBeginRotate || (Math.abs(slope) > 1 && Math.abs(r) > PINCH_ROTATE_THRESHOLD))) { && (mBeginRotate || (Math.abs(slope) > 1 && Math.abs(r) > PINCH_ROTATE_THRESHOLD))) {
// Log.d(TAG, "rotate: " + mBeginRotate + " " + // Log.d(TAG, "rotate: " + mBeginRotate + " " +
// Math.toDegrees(rad)); // Math.toDegrees(rad));
if (!mBeginRotate) { if (!mBeginRotate) {

View File

@ -4,7 +4,7 @@ import org.oscim.event.MotionEvent;
import com.badlogic.gdx.InputProcessor; import com.badlogic.gdx.InputProcessor;
public class GdxMotionEvent extends MotionEvent implements InputProcessor{ public class GdxMotionEvent extends MotionEvent implements InputProcessor {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -20,9 +20,12 @@ import java.nio.Buffer;
import java.nio.FloatBuffer; import java.nio.FloatBuffer;
import java.nio.IntBuffer; import java.nio.IntBuffer;
/** Interface wrapping all the methods of OpenGL ES 2.0 /**
* @author mzechner */ * Interface wrapping all the methods of OpenGL ES 2.0
public interface GL20 { *
* @author mzechner
*/
public interface GL20 {
public static final int GL_ES_VERSION_2_0 = 1; public static final int GL_ES_VERSION_2_0 = 1;
public static final int GL_DEPTH_BUFFER_BIT = 0x00000100; public static final int GL_DEPTH_BUFFER_BIT = 0x00000100;
public static final int GL_STENCIL_BUFFER_BIT = 0x00000400; public static final int GL_STENCIL_BUFFER_BIT = 0x00000400;
@ -332,217 +335,222 @@ public interface GL20 {
// Extensions // Extensions
public static final int GL_COVERAGE_BUFFER_BIT_NV = 0x8000; public static final int GL_COVERAGE_BUFFER_BIT_NV = 0x8000;
public void glAttachShader (int program, int shader); public void glAttachShader(int program, int shader);
public void glBindAttribLocation (int program, int index, String name); public void glBindAttribLocation(int program, int index, String name);
public void glBindBuffer (int target, int buffer); public void glBindBuffer(int target, int buffer);
public void glBindFramebuffer (int target, int framebuffer); public void glBindFramebuffer(int target, int framebuffer);
public void glBindRenderbuffer (int target, int renderbuffer); public void glBindRenderbuffer(int target, int renderbuffer);
public void glBlendColor (float red, float green, float blue, float alpha); public void glBlendColor(float red, float green, float blue, float alpha);
public void glBlendEquation (int mode); public void glBlendEquation(int mode);
public void glBlendEquationSeparate (int modeRGB, int modeAlpha); public void glBlendEquationSeparate(int modeRGB, int modeAlpha);
public void glBlendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha); public void glBlendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha);
public void glBufferData (int target, int size, Buffer data, int usage); public void glBufferData(int target, int size, Buffer data, int usage);
public void glBufferSubData (int target, int offset, int size, Buffer data); public void glBufferSubData(int target, int offset, int size, Buffer data);
public int glCheckFramebufferStatus (int target); public int glCheckFramebufferStatus(int target);
public void glCompileShader (int shader); public void glCompileShader(int shader);
public int glCreateProgram (); public int glCreateProgram();
public int glCreateShader (int type); public int glCreateShader(int type);
public void glDeleteBuffers (int n, IntBuffer buffers); public void glDeleteBuffers(int n, IntBuffer buffers);
public void glDeleteFramebuffers (int n, IntBuffer framebuffers); public void glDeleteFramebuffers(int n, IntBuffer framebuffers);
public void glDeleteProgram (int program); public void glDeleteProgram(int program);
public void glDeleteRenderbuffers (int n, IntBuffer renderbuffers); public void glDeleteRenderbuffers(int n, IntBuffer renderbuffers);
public void glDeleteShader (int shader); public void glDeleteShader(int shader);
public void glDetachShader (int program, int shader); public void glDetachShader(int program, int shader);
public void glDisableVertexAttribArray (int index); public void glDisableVertexAttribArray(int index);
public void glDrawElements (int mode, int count, int type, int indices); public void glDrawElements(int mode, int count, int type, int indices);
public void glEnableVertexAttribArray (int index); public void glEnableVertexAttribArray(int index);
public void glFramebufferRenderbuffer (int target, int attachment, int renderbuffertarget, int renderbuffer); public void glFramebufferRenderbuffer(int target, int attachment, int renderbuffertarget,
int renderbuffer);
public void glFramebufferTexture2D (int target, int attachment, int textarget, int texture, int level); public void glFramebufferTexture2D(int target, int attachment, int textarget, int texture,
int level);
public void glGenBuffers (int n, IntBuffer buffers); public void glGenBuffers(int n, IntBuffer buffers);
public void glGenerateMipmap (int target); public void glGenerateMipmap(int target);
public void glGenFramebuffers (int n, IntBuffer framebuffers); public void glGenFramebuffers(int n, IntBuffer framebuffers);
public void glGenRenderbuffers (int n, IntBuffer renderbuffers); public void glGenRenderbuffers(int n, IntBuffer renderbuffers);
// deviates // deviates
public String glGetActiveAttrib (int program, int index, IntBuffer size, Buffer type); public String glGetActiveAttrib(int program, int index, IntBuffer size, Buffer type);
// deviates // deviates
public String glGetActiveUniform (int program, int index, IntBuffer size, Buffer type); public String glGetActiveUniform(int program, int index, IntBuffer size, Buffer type);
public void glGetAttachedShaders (int program, int maxcount, Buffer count, IntBuffer shaders); public void glGetAttachedShaders(int program, int maxcount, Buffer count, IntBuffer shaders);
public int glGetAttribLocation (int program, String name); public int glGetAttribLocation(int program, String name);
public void glGetBooleanv (int pname, Buffer params); public void glGetBooleanv(int pname, Buffer params);
public void glGetBufferParameteriv (int target, int pname, IntBuffer params); public void glGetBufferParameteriv(int target, int pname, IntBuffer params);
public void glGetFloatv (int pname, FloatBuffer params); public void glGetFloatv(int pname, FloatBuffer params);
public void glGetFramebufferAttachmentParameteriv (int target, int attachment, int pname, IntBuffer params); public void glGetFramebufferAttachmentParameteriv(int target, int attachment, int pname,
IntBuffer params);
public void glGetProgramiv (int program, int pname, IntBuffer params); public void glGetProgramiv(int program, int pname, IntBuffer params);
// deviates // deviates
public String glGetProgramInfoLog (int program); public String glGetProgramInfoLog(int program);
public void glGetRenderbufferParameteriv (int target, int pname, IntBuffer params); public void glGetRenderbufferParameteriv(int target, int pname, IntBuffer params);
public void glGetShaderiv (int shader, int pname, IntBuffer params); public void glGetShaderiv(int shader, int pname, IntBuffer params);
// deviates // deviates
public String glGetShaderInfoLog (int shader); public String glGetShaderInfoLog(int shader);
public void glGetShaderPrecisionFormat (int shadertype, int precisiontype, IntBuffer range, IntBuffer precision); public void glGetShaderPrecisionFormat(int shadertype, int precisiontype, IntBuffer range,
IntBuffer precision);
public void glGetShaderSource (int shader, int bufsize, Buffer length, String source); public void glGetShaderSource(int shader, int bufsize, Buffer length, String source);
public void glGetTexParameterfv (int target, int pname, FloatBuffer params); public void glGetTexParameterfv(int target, int pname, FloatBuffer params);
public void glGetTexParameteriv (int target, int pname, IntBuffer params); public void glGetTexParameteriv(int target, int pname, IntBuffer params);
public void glGetUniformfv (int program, int location, FloatBuffer params); public void glGetUniformfv(int program, int location, FloatBuffer params);
public void glGetUniformiv (int program, int location, IntBuffer params); public void glGetUniformiv(int program, int location, IntBuffer params);
public int glGetUniformLocation (int program, String name); public int glGetUniformLocation(int program, String name);
public void glGetVertexAttribfv (int index, int pname, FloatBuffer params); public void glGetVertexAttribfv(int index, int pname, FloatBuffer params);
public void glGetVertexAttribiv (int index, int pname, IntBuffer params); public void glGetVertexAttribiv(int index, int pname, IntBuffer params);
public void glGetVertexAttribPointerv (int index, int pname, Buffer pointer); public void glGetVertexAttribPointerv(int index, int pname, Buffer pointer);
public boolean glIsBuffer (int buffer); public boolean glIsBuffer(int buffer);
public boolean glIsEnabled (int cap); public boolean glIsEnabled(int cap);
public boolean glIsFramebuffer (int framebuffer); public boolean glIsFramebuffer(int framebuffer);
public boolean glIsProgram (int program); public boolean glIsProgram(int program);
public boolean glIsRenderbuffer (int renderbuffer); public boolean glIsRenderbuffer(int renderbuffer);
public boolean glIsShader (int shader); public boolean glIsShader(int shader);
public boolean glIsTexture (int texture); public boolean glIsTexture(int texture);
public void glLinkProgram (int program); public void glLinkProgram(int program);
public void glReleaseShaderCompiler (); public void glReleaseShaderCompiler();
public void glRenderbufferStorage (int target, int internalformat, int width, int height); public void glRenderbufferStorage(int target, int internalformat, int width, int height);
public void glSampleCoverage (float value, boolean invert); public void glSampleCoverage(float value, boolean invert);
public void glShaderBinary (int n, IntBuffer shaders, int binaryformat, Buffer binary, int length); public void glShaderBinary(int n, IntBuffer shaders, int binaryformat, Buffer binary, int length);
// Deviates // Deviates
public void glShaderSource (int shader, String string); public void glShaderSource(int shader, String string);
public void glStencilFuncSeparate (int face, int func, int ref, int mask); public void glStencilFuncSeparate(int face, int func, int ref, int mask);
public void glStencilMaskSeparate (int face, int mask); public void glStencilMaskSeparate(int face, int mask);
public void glStencilOpSeparate (int face, int fail, int zfail, int zpass); public void glStencilOpSeparate(int face, int fail, int zfail, int zpass);
public void glTexParameterfv (int target, int pname, FloatBuffer params); public void glTexParameterfv(int target, int pname, FloatBuffer params);
public void glTexParameteri (int target, int pname, int param); public void glTexParameteri(int target, int pname, int param);
public void glTexParameteriv (int target, int pname, IntBuffer params); public void glTexParameteriv(int target, int pname, IntBuffer params);
public void glUniform1f (int location, float x); public void glUniform1f(int location, float x);
public void glUniform1fv (int location, int count, FloatBuffer v); public void glUniform1fv(int location, int count, FloatBuffer v);
public void glUniform1i (int location, int x); public void glUniform1i(int location, int x);
public void glUniform1iv (int location, int count, IntBuffer v); public void glUniform1iv(int location, int count, IntBuffer v);
public void glUniform2f (int location, float x, float y); public void glUniform2f(int location, float x, float y);
public void glUniform2fv (int location, int count, FloatBuffer v); public void glUniform2fv(int location, int count, FloatBuffer v);
public void glUniform2i (int location, int x, int y); public void glUniform2i(int location, int x, int y);
public void glUniform2iv (int location, int count, IntBuffer v); public void glUniform2iv(int location, int count, IntBuffer v);
public void glUniform3f (int location, float x, float y, float z); public void glUniform3f(int location, float x, float y, float z);
public void glUniform3fv (int location, int count, FloatBuffer v); public void glUniform3fv(int location, int count, FloatBuffer v);
public void glUniform3i (int location, int x, int y, int z); public void glUniform3i(int location, int x, int y, int z);
public void glUniform3iv (int location, int count, IntBuffer v); public void glUniform3iv(int location, int count, IntBuffer v);
public void glUniform4f (int location, float x, float y, float z, float w); public void glUniform4f(int location, float x, float y, float z, float w);
public void glUniform4fv (int location, int count, FloatBuffer v); public void glUniform4fv(int location, int count, FloatBuffer v);
public void glUniform4i (int location, int x, int y, int z, int w); public void glUniform4i(int location, int x, int y, int z, int w);
public void glUniform4iv (int location, int count, IntBuffer v); public void glUniform4iv(int location, int count, IntBuffer v);
public void glUniformMatrix2fv (int location, int count, boolean transpose, FloatBuffer value); public void glUniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer value);
public void glUniformMatrix3fv (int location, int count, boolean transpose, FloatBuffer value); public void glUniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer value);
public void glUniformMatrix4fv (int location, int count, boolean transpose, FloatBuffer value); public void glUniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer value);
public void glUseProgram (int program); public void glUseProgram(int program);
public void glValidateProgram (int program); public void glValidateProgram(int program);
public void glVertexAttrib1f (int indx, float x); public void glVertexAttrib1f(int indx, float x);
public void glVertexAttrib1fv (int indx, FloatBuffer values); public void glVertexAttrib1fv(int indx, FloatBuffer values);
public void glVertexAttrib2f (int indx, float x, float y); public void glVertexAttrib2f(int indx, float x, float y);
public void glVertexAttrib2fv (int indx, FloatBuffer values); public void glVertexAttrib2fv(int indx, FloatBuffer values);
public void glVertexAttrib3f (int indx, float x, float y, float z); public void glVertexAttrib3f(int indx, float x, float y, float z);
public void glVertexAttrib3fv (int indx, FloatBuffer values); public void glVertexAttrib3fv(int indx, FloatBuffer values);
public void glVertexAttrib4f (int indx, float x, float y, float z, float w); public void glVertexAttrib4f(int indx, float x, float y, float z, float w);
public void glVertexAttrib4fv (int indx, FloatBuffer values); public void glVertexAttrib4fv(int indx, FloatBuffer values);
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, Buffer ptr); public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
Buffer ptr);
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int ptr);
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
int ptr);
//------------------------ //------------------------
@ -550,89 +558,96 @@ public interface GL20 {
public static final int GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE; public static final int GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
public static final int GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF; public static final int GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
public void glActiveTexture (int texture); public void glActiveTexture(int texture);
public void glBindTexture (int target, int texture); public void glBindTexture(int target, int texture);
public void glBlendFunc (int sfactor, int dfactor); public void glBlendFunc(int sfactor, int dfactor);
public void glClear (int mask); public void glClear(int mask);
public void glClearColor (float red, float green, float blue, float alpha); public void glClearColor(float red, float green, float blue, float alpha);
public void glClearDepthf (float depth); public void glClearDepthf(float depth);
public void glClearStencil (int s); public void glClearStencil(int s);
public void glColorMask (boolean red, boolean green, boolean blue, boolean alpha); public void glColorMask(boolean red, boolean green, boolean blue, boolean alpha);
public void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border, public void glCompressedTexImage2D(int target, int level, int internalformat, int width,
int imageSize, Buffer data); int height, int border,
int imageSize, Buffer data);
public void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, public void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset,
int imageSize, Buffer data); int width, int height, int format,
int imageSize, Buffer data);
public void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border); public void glCopyTexImage2D(int target, int level, int internalformat, int x, int y,
int width, int height, int border);
public void glCopyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height); public void glCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y,
int width, int height);
public void glCullFace (int mode); public void glCullFace(int mode);
public void glDeleteTextures (int n, IntBuffer textures); public void glDeleteTextures(int n, IntBuffer textures);
public void glDepthFunc (int func); public void glDepthFunc(int func);
public void glDepthMask (boolean flag); public void glDepthMask(boolean flag);
public void glDepthRangef (float zNear, float zFar); public void glDepthRangef(float zNear, float zFar);
public void glDisable (int cap); public void glDisable(int cap);
public void glDrawArrays (int mode, int first, int count); public void glDrawArrays(int mode, int first, int count);
public void glDrawElements (int mode, int count, int type, Buffer indices); public void glDrawElements(int mode, int count, int type, Buffer indices);
public void glEnable (int cap); public void glEnable(int cap);
public void glFinish (); public void glFinish();
public void glFlush (); public void glFlush();
public void glFrontFace (int mode); public void glFrontFace(int mode);
public void glGenTextures (int n, IntBuffer textures); public void glGenTextures(int n, IntBuffer textures);
public int glGetError (); public int glGetError();
public void glGetIntegerv (int pname, IntBuffer params); public void glGetIntegerv(int pname, IntBuffer params);
public String glGetString (int name); public String glGetString(int name);
public void glHint (int target, int mode); public void glHint(int target, int mode);
public void glLineWidth (float width); public void glLineWidth(float width);
public void glPixelStorei (int pname, int param); public void glPixelStorei(int pname, int param);
public void glPolygonOffset (float factor, float units); public void glPolygonOffset(float factor, float units);
public void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels); public void glReadPixels(int x, int y, int width, int height, int format, int type,
Buffer pixels);
public void glScissor (int x, int y, int width, int height); public void glScissor(int x, int y, int width, int height);
public void glStencilFunc (int func, int ref, int mask); public void glStencilFunc(int func, int ref, int mask);
public void glStencilMask (int mask); public void glStencilMask(int mask);
public void glStencilOp (int fail, int zfail, int zpass); public void glStencilOp(int fail, int zfail, int zpass);
public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type, public void glTexImage2D(int target, int level, int internalformat, int width, int height,
Buffer pixels); int border, int format, int type,
Buffer pixels);
public void glTexParameterf (int target, int pname, float param); public void glTexParameterf(int target, int pname, float param);
public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, public void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width,
Buffer pixels); int height, int format, int type,
Buffer pixels);
public void glViewport (int x, int y, int width, int height); public void glViewport(int x, int y, int width, int height);
} }

View File

@ -15,45 +15,45 @@
*/ */
package org.oscim.backend.canvas; package org.oscim.backend.canvas;
public class Color { public class Color {
public static final int BLACK = 0xFF000000; public static final int BLACK = 0xFF000000;
public static final int DKGRAY = 0xFF444444; public static final int DKGRAY = 0xFF444444;
public static final int GRAY = 0xFF888888; public static final int GRAY = 0xFF888888;
public static final int LTGRAY = 0xFFCCCCCC; public static final int LTGRAY = 0xFFCCCCCC;
public static final int WHITE = 0xFFFFFFFF; public static final int WHITE = 0xFFFFFFFF;
public static final int RED = 0xFFFF0000; public static final int RED = 0xFFFF0000;
public static final int GREEN = 0xFF00FF00; public static final int GREEN = 0xFF00FF00;
public static final int BLUE = 0xFF0000FF; public static final int BLUE = 0xFF0000FF;
public static final int YELLOW = 0xFFFFFF00; public static final int YELLOW = 0xFFFFFF00;
public static final int CYAN = 0xFF00FFFF; public static final int CYAN = 0xFF00FFFF;
public static final int MAGENTA = 0xFFFF00FF; public static final int MAGENTA = 0xFFFF00FF;
public static final int TRANSPARENT = 0; public static final int TRANSPARENT = 0;
public static int get(int r, int g ,int b){ public static int get(int r, int g, int b) {
return 0xff << 24 | r << 16 | g << 8 | b; return 0xff << 24 | r << 16 | g << 8 | b;
} }
/** /**
* Parse the color string, and return the corresponding color-int. * Parse the color string, and return the corresponding color-int.
* If the string cannot be parsed, throws an IllegalArgumentException * If the string cannot be parsed, throws an IllegalArgumentException
* exception. Supported formats are: * exception. Supported formats are:
* #RRGGBB * #RRGGBB
* #AARRGGBB * #AARRGGBB
* 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta', * 'red', 'blue', 'green', 'black', 'white', 'gray', 'cyan', 'magenta',
* 'yellow', 'lightgray', 'darkgray' * 'yellow', 'lightgray', 'darkgray'
*/ */
public static int parseColor(String colorString) { public static int parseColor(String colorString) {
if (colorString.charAt(0) == '#') { if (colorString.charAt(0) == '#') {
// Use a long to avoid rollovers on #ffXXXXXX // Use a long to avoid rollovers on #ffXXXXXX
long color = Long.parseLong(colorString.substring(1), 16); long color = Long.parseLong(colorString.substring(1), 16);
if (colorString.length() == 7) { if (colorString.length() == 7) {
// Set the alpha value // Set the alpha value
color |= 0x00000000ff000000; color |= 0x00000000ff000000;
} else if (colorString.length() != 9) { } else if (colorString.length() != 9) {
throw new IllegalArgumentException("Unknown color"); throw new IllegalArgumentException("Unknown color");
} }
return (int)color; return (int) color;
} }
throw new IllegalArgumentException("Unknown color"); throw new IllegalArgumentException("Unknown color");
} }
} }

View File

@ -74,7 +74,7 @@ public class BoundingBox {
} }
public BoundingBox(double minLatitude, double minLongitude, double maxLatitude, public BoundingBox(double minLatitude, double minLongitude, double maxLatitude,
double maxLongitude) { double maxLongitude) {
this.minLatitudeE6 = (int) (minLatitude * 1E6); this.minLatitudeE6 = (int) (minLatitude * 1E6);
this.minLongitudeE6 = (int) (minLongitude * 1E6); this.minLongitudeE6 = (int) (minLongitude * 1E6);
this.maxLatitudeE6 = (int) (maxLatitude * 1E6); this.maxLatitudeE6 = (int) (maxLatitude * 1E6);
@ -90,9 +90,9 @@ public class BoundingBox {
*/ */
public boolean contains(GeoPoint geoPoint) { public boolean contains(GeoPoint geoPoint) {
return geoPoint.latitudeE6 <= maxLatitudeE6 return geoPoint.latitudeE6 <= maxLatitudeE6
&& geoPoint.latitudeE6 >= minLatitudeE6 && geoPoint.latitudeE6 >= minLatitudeE6
&& geoPoint.longitudeE6 <= maxLongitudeE6 && geoPoint.longitudeE6 <= maxLongitudeE6
&& geoPoint.longitudeE6 >= minLongitudeE6; && geoPoint.longitudeE6 >= minLongitudeE6;
} }
@Override @Override
@ -123,7 +123,7 @@ public class BoundingBox {
int latitudeOffset = (maxLatitudeE6 - minLatitudeE6) / 2; int latitudeOffset = (maxLatitudeE6 - minLatitudeE6) / 2;
int longitudeOffset = (maxLongitudeE6 - minLongitudeE6) / 2; int longitudeOffset = (maxLongitudeE6 - minLongitudeE6) / 2;
return new GeoPoint(minLatitudeE6 + latitudeOffset, minLongitudeE6 return new GeoPoint(minLatitudeE6 + latitudeOffset, minLongitudeE6
+ longitudeOffset); + longitudeOffset);
} }
/** /**

View File

@ -40,7 +40,7 @@ public class Box {
/** /**
* Instantiates a new Box. * Instantiates a new Box.
* *
* @param minX the min x * @param minX the min x
* @param minY the min y * @param minY the min y
* @param maxX the max x * @param maxX the max x
@ -55,7 +55,7 @@ public class Box {
/** /**
* Check if Box contains point defined by coordinates x and y. * Check if Box contains point defined by coordinates x and y.
* *
* @param x the x ordinate * @param x the x ordinate
* @param y the y ordinate * @param y the y ordinate
* @return true, if point is inside box. * @return true, if point is inside box.
@ -66,7 +66,7 @@ public class Box {
/** /**
* Check if Box contains Point. * Check if Box contains Point.
* *
* @param p the point * @param p the point
* @return true, if point is inside box. * @return true, if point is inside box.
*/ */

View File

@ -56,7 +56,7 @@ public class MapPosition {
this.scale = scale; this.scale = scale;
} }
public void setPosition(GeoPoint geoPoint){ public void setPosition(GeoPoint geoPoint) {
setPosition(geoPoint.getLatitude(), geoPoint.getLongitude()); setPosition(geoPoint.getLatitude(), geoPoint.getLongitude());
} }
@ -81,7 +81,7 @@ public class MapPosition {
public GeoPoint getGeoPoint() { public GeoPoint getGeoPoint() {
return new GeoPoint(MercatorProjection.toLatitude(y), return new GeoPoint(MercatorProjection.toLatitude(y),
MercatorProjection.toLongitude(x)); MercatorProjection.toLongitude(x));
} }
public double getLatitude() { public double getLatitude() {

View File

@ -47,7 +47,7 @@ public final class MercatorProjection {
/** /**
* Calculates the distance on the ground that is represented by a single * Calculates the distance on the ground that is represented by a single
* pixel on the map. * pixel on the map.
* *
* @param latitude * @param latitude
* the latitude coordinate at which the resolution should be * the latitude coordinate at which the resolution should be
* calculated. * calculated.
@ -57,12 +57,12 @@ public final class MercatorProjection {
*/ */
public static double calculateGroundResolution(double latitude, double scale) { public static double calculateGroundResolution(double latitude, double scale) {
return Math.cos(latitude * (Math.PI / 180)) * EARTH_CIRCUMFERENCE return Math.cos(latitude * (Math.PI / 180)) * EARTH_CIRCUMFERENCE
/ (Tile.SIZE * scale); / (Tile.SIZE * scale);
} }
/** /**
* Projects a longitude coordinate (in degrees) to the range [0.0,1.0] * Projects a longitude coordinate (in degrees) to the range [0.0,1.0]
* *
* @param latitude * @param latitude
* the latitude coordinate that should be converted. * the latitude coordinate that should be converted.
* @return the position . * @return the position .
@ -78,7 +78,7 @@ public final class MercatorProjection {
/** /**
* Projects a longitude coordinate (in degrees) to the range [0.0,1.0] * Projects a longitude coordinate (in degrees) to the range [0.0,1.0]
* *
* @param longitude * @param longitude
* the longitude coordinate that should be converted. * the longitude coordinate that should be converted.
* @return the position . * @return the position .
@ -108,7 +108,8 @@ public final class MercatorProjection {
out[pos * 2] = ((p.longitudeE6 / 1E6) + 180.0) / 360.0; out[pos * 2] = ((p.longitudeE6 / 1E6) + 180.0) / 360.0;
double sinLatitude = Math.sin((p.latitudeE6 / 1E6) * (Math.PI / 180.0)); double sinLatitude = Math.sin((p.latitudeE6 / 1E6) * (Math.PI / 180.0));
out[pos * 2 +1] = 0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude)) / (4.0 * Math.PI); out[pos * 2 + 1] = 0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude))
/ (4.0 * Math.PI);
} }
public static void project(double latitude, double longitude, double[] out, int pos) { public static void project(double latitude, double longitude, double[] out, int pos) {
@ -116,7 +117,8 @@ public final class MercatorProjection {
out[pos * 2] = (longitude + 180.0) / 360.0; out[pos * 2] = (longitude + 180.0) / 360.0;
double sinLatitude = Math.sin(latitude * (Math.PI / 180.0)); double sinLatitude = Math.sin(latitude * (Math.PI / 180.0));
out[pos * 2 +1] = 0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude)) / (4.0 * Math.PI); out[pos * 2 + 1] = 0.5 - Math.log((1.0 + sinLatitude) / (1.0 - sinLatitude))
/ (4.0 * Math.PI);
} }
/** /**

View File

@ -17,21 +17,25 @@ package org.oscim.core;
public class Point { public class Point {
public double x; public double x;
public double y; public double y;
public Point() { public Point() {
} }
public Point(double x, double y){
public Point(double x, double y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
} }
public double getX(){
public double getX() {
return x; return x;
} }
public double getY(){
public double getY() {
return y; return y;
} }
@Override @Override
public String toString(){ public String toString() {
return x + " " + y; return x + " " + y;
} }
} }

View File

@ -16,7 +16,6 @@ package org.oscim.core;
import java.util.Arrays; import java.util.Arrays;
public class TagSet { public class TagSet {
public static TagSet EMPTY_TAG_SET = new TagSet(); public static TagSet EMPTY_TAG_SET = new TagSet();
@ -37,6 +36,7 @@ public class TagSet {
/** /**
* null out current tags * null out current tags
*
* @param nulltags ... * @param nulltags ...
*/ */
public void clear(boolean nulltags) { public void clear(boolean nulltags) {
@ -44,7 +44,7 @@ public class TagSet {
numTags = 0; numTags = 0;
} }
public Tag[] asArray(){ public Tag[] asArray() {
Tag[] result = new Tag[numTags]; Tag[] result = new Tag[numTags];
System.arraycopy(tags, 0, result, 0, numTags); System.arraycopy(tags, 0, result, 0, numTags);
return result; return result;
@ -58,7 +58,8 @@ public class TagSet {
} }
return null; return null;
} }
public boolean containsKey(String key){
public boolean containsKey(String key) {
for (int i = 0; i < numTags; i++) { for (int i = 0; i < numTags; i++) {
if (tags[i].key == key) if (tags[i].key == key)
return true; return true;
@ -66,7 +67,7 @@ public class TagSet {
return false; return false;
} }
public String getValue(String key){ public String getValue(String key) {
for (int i = 0; i < numTags; i++) { for (int i = 0; i < numTags; i++) {
if (tags[i].key == key) if (tags[i].key == key)
return tags[i].value; return tags[i].value;
@ -74,7 +75,7 @@ public class TagSet {
return null; return null;
} }
public boolean contains(String key, String value){ public boolean contains(String key, String value) {
for (int i = 0; i < numTags; i++) { for (int i = 0; i < numTags; i++) {
if (tags[i].key == key) if (tags[i].key == key)
return value.equals(tags[i].value); return value.equals(tags[i].value);
@ -91,7 +92,7 @@ public class TagSet {
tags[numTags++] = tag; tags[numTags++] = tag;
} }
public void set(Tag[] tagArray){ public void set(Tag[] tagArray) {
int newTags = tagArray.length; int newTags = tagArray.length;
if (newTags > tags.length) if (newTags > tags.length)
tags = new Tag[tagArray.length]; tags = new Tag[tagArray.length];
@ -147,7 +148,7 @@ public class TagSet {
return false; return false;
} }
public String asString(){ public String asString() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int i = 0; i < numTags; i++) for (int i = 0; i < numTags; i++)
sb.append(tags[i]); sb.append(tags[i]);

View File

@ -79,7 +79,7 @@ public class Tile {
Tile o = (Tile) obj; Tile o = (Tile) obj;
if (o.tileX == this.tileX && o.tileY == this.tileY if (o.tileX == this.tileX && o.tileY == this.tileY
&& o.zoomLevel == this.zoomLevel) && o.zoomLevel == this.zoomLevel)
return true; return true;
return false; return false;

View File

@ -3,5 +3,6 @@ package org.oscim.event;
public interface EventDispatcher { public interface EventDispatcher {
public void addListener(String type, EventListener listener); public void addListener(String type, EventListener listener);
public void removeListener(String type, EventListener listener); public void removeListener(String type, EventListener listener);
} }

View File

@ -14,7 +14,7 @@
*/ */
package org.oscim.event; package org.oscim.event;
public class KeyEvent extends MapEvent{ public class KeyEvent extends MapEvent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -6,7 +6,6 @@ public class MapEvent extends EventObject {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
public MapEvent(Object source) { public MapEvent(Object source) {
super(source); super(source);
} }

View File

@ -14,7 +14,6 @@
*/ */
package org.oscim.event; package org.oscim.event;
public abstract class MotionEvent extends MapEvent { public abstract class MotionEvent extends MapEvent {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@ -4,6 +4,8 @@ import org.oscim.core.MapPosition;
public interface TouchListener { public interface TouchListener {
boolean onPress(MotionEvent e, MapPosition pos); boolean onPress(MotionEvent e, MapPosition pos);
boolean onLongPress(MotionEvent e, MapPosition pos); boolean onLongPress(MotionEvent e, MapPosition pos);
boolean onTap(MotionEvent e, MapPosition pos); boolean onTap(MotionEvent e, MapPosition pos);
} }

View File

@ -3,16 +3,16 @@ package org.oscim.layers;
import org.oscim.backend.Log; import org.oscim.backend.Log;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
import org.oscim.map.Map; import org.oscim.map.Map;
import org.oscim.map.Map.UpdateListener;
import org.oscim.renderer.LayerRenderer; import org.oscim.renderer.LayerRenderer;
import org.oscim.renderer.MapRenderer.Matrices; import org.oscim.renderer.MapRenderer.Matrices;
public class CustomRenderLayer extends Layer { public class CustomRenderLayer extends Layer implements UpdateListener {
private static final String TAG = CustomRenderLayer.class.getName(); private static final String TAG = CustomRenderLayer.class.getName();
class CustomRenderer extends LayerRenderer { class CustomRenderer extends LayerRenderer {
// functions running on MapRender Thread // functions running on MapRender Thread
@Override @Override
protected void update(MapPosition pos, boolean changed, Matrices matrices) { protected void update(MapPosition pos, boolean changed, Matrices matrices) {
@ -33,7 +33,6 @@ public class CustomRenderLayer extends Layer {
@Override @Override
protected void render(MapPosition pos, Matrices m) { protected void render(MapPosition pos, Matrices m) {
} }
} }
public CustomRenderLayer(Map map, LayerRenderer renderer) { public CustomRenderLayer(Map map, LayerRenderer renderer) {
@ -44,14 +43,11 @@ public class CustomRenderLayer extends Layer {
private int someConccurentVariable; private int someConccurentVariable;
// @Override @Override
// public void onUpdate(MapPosition mapPosition, boolean changed, boolean clear) { public void onMapUpdate(MapPosition mapPosition, boolean changed, boolean clear) {
//
// synchronized (mRenderer) {
// // chang
// someConccurentVariable++;
// }
//
// }
synchronized (mRenderer) {
someConccurentVariable++;
}
}
} }

View File

@ -24,7 +24,7 @@ import org.oscim.map.Viewport;
/** /**
* Changes Viewport for scroll, fling, scale, rotation and tilt gestures * Changes Viewport for scroll, fling, scale, rotation and tilt gestures
* *
* @TODO: * @TODO:
* - better recognition of tilt/rotate/scale state * - better recognition of tilt/rotate/scale state
* one could check change of rotation / scale within a * one could check change of rotation / scale within a
@ -78,10 +78,11 @@ public class MapEventLayer extends Layer implements EventListener {
} }
@Override @Override
public void handleEvent(MapEvent event){ public void handleEvent(MapEvent event) {
if (event instanceof MotionEvent) if (event instanceof MotionEvent)
onTouchEvent((MotionEvent)event); onTouchEvent((MotionEvent) event);
} }
//private long mPrevTime; //private long mPrevTime;
private boolean mEnableRotation = true; private boolean mEnableRotation = true;
@ -243,13 +244,13 @@ public class MapEventLayer extends Layer implements EventListener {
//Log.d(TAG, r + " " + slope + " m1:" + my + " m2:" + my2); //Log.d(TAG, r + " " + slope + " m1:" + my + " m2:" + my2);
if ((my > threshold && my2 > threshold) if ((my > threshold && my2 > threshold)
|| (my < -threshold && my2 < -threshold)) || (my < -threshold && my2 < -threshold))
{ {
mBeginTilt = true; mBeginTilt = true;
changed = mMapPosition.tiltMap(my / 5); changed = mMapPosition.tiltMap(my / 5);
} }
} else if (mEnableRotation && !mBeginTilt && } else if (mEnableRotation && !mBeginTilt &&
(mBeginRotate || Math.abs(r) > PINCH_ROTATE_THRESHOLD)) { (mBeginRotate || Math.abs(r) > PINCH_ROTATE_THRESHOLD)) {
//Log.d(TAG, "rotate: " + mBeginRotate + " " + Math.toDegrees(rad)); //Log.d(TAG, "rotate: " + mBeginRotate + " " + Math.toDegrees(rad));
if (!mBeginRotate) { if (!mBeginRotate) {
mAngle = rad; mAngle = rad;
@ -312,10 +313,9 @@ public class MapEventLayer extends Layer implements EventListener {
int w = Tile.SIZE * 3; int w = Tile.SIZE * 3;
int h = Tile.SIZE * 3; int h = Tile.SIZE * 3;
mMap.getAnimator().animateFling( mMap.getAnimator().animateFling(Math.round(velocityX),
Math.round(velocityX), Math.round(velocityY),
Math.round(velocityY), -w, w, -h, h);
-w, w, -h, h);
return true; return true;
} }

View File

@ -249,7 +249,7 @@ public class PathLayer extends Layer {
/** /**
* Draw a great circle. Calculate a point for every 100km along the path. * Draw a great circle. Calculate a point for every 100km along the path.
* *
* @param startPoint * @param startPoint
* start point of the great circle * start point of the great circle
* @param endPoint * @param endPoint
@ -270,7 +270,7 @@ public class PathLayer extends Layer {
/** /**
* Draw a great circle. * Draw a great circle.
* *
* @param startPoint * @param startPoint
* start point of the great circle * start point of the great circle
* @param endPoint * @param endPoint
@ -279,7 +279,7 @@ public class PathLayer extends Layer {
* number of points to calculate along the path * number of points to calculate along the path
*/ */
public void addGreatCircle(GeoPoint startPoint, GeoPoint endPoint, public void addGreatCircle(GeoPoint startPoint, GeoPoint endPoint,
final int numberOfPoints) { final int numberOfPoints) {
// adapted from page // adapted from page
// http://compastic.blogspot.co.uk/2011/07/how-to-draw-great-circle-on-map-in.html // http://compastic.blogspot.co.uk/2011/07/how-to-draw-great-circle-on-map-in.html
// which was adapted from page http://maps.forum.nu/gm_flight_path.html // which was adapted from page http://maps.forum.nu/gm_flight_path.html
@ -291,13 +291,14 @@ public class PathLayer extends Layer {
final double lon2 = endPoint.getLongitude() * Math.PI / 180; final double lon2 = endPoint.getLongitude() * Math.PI / 180;
final double d = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin((lat1 - lat2) / 2), 2) final double d = 2 * Math.asin(Math.sqrt(Math.pow(Math.sin((lat1 - lat2) / 2), 2)
+ Math.cos(lat1) * Math.cos(lat2) + Math.cos(lat1) * Math.cos(lat2)
* Math.pow(Math.sin((lon1 - lon2) / 2), 2))); * Math.pow(Math.sin((lon1 - lon2) / 2), 2)));
double bearing = Math.atan2( double bearing = Math.atan2(
Math.sin(lon1 - lon2) * Math.cos(lat2), Math.sin(lon1 - lon2) * Math.cos(lat2),
Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1) * Math.cos(lat2) Math.cos(lat1) * Math.sin(lat2) - Math.sin(lat1)
* Math.cos(lon1 - lon2)) * Math.cos(lat2)
/ -(Math.PI / 180); * Math.cos(lon1 - lon2))
/ -(Math.PI / 180);
bearing = bearing < 0 ? 360 + bearing : bearing; bearing = bearing < 0 ? 360 + bearing : bearing;
for (int i = 0, j = numberOfPoints + 1; i < j; i++) { for (int i = 0, j = numberOfPoints + 1; i < j; i++) {
@ -305,9 +306,9 @@ public class PathLayer extends Layer {
final double A = Math.sin((1 - f) * d) / Math.sin(d); final double A = Math.sin((1 - f) * d) / Math.sin(d);
final double B = Math.sin(f * d) / Math.sin(d); final double B = Math.sin(f * d) / Math.sin(d);
final double x = A * Math.cos(lat1) * Math.cos(lon1) + B * Math.cos(lat2) final double x = A * Math.cos(lat1) * Math.cos(lon1) + B * Math.cos(lat2)
* Math.cos(lon2); * Math.cos(lon2);
final double y = A * Math.cos(lat1) * Math.sin(lon1) + B * Math.cos(lat2) final double y = A * Math.cos(lat1) * Math.sin(lon1) + B * Math.cos(lat2)
* Math.sin(lon2); * Math.sin(lon2);
final double z = A * Math.sin(lat1) + B * Math.sin(lat2); final double z = A * Math.sin(lat1) + B * Math.sin(lat2);
final double latN = Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2))); final double latN = Math.atan2(z, Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2)));

View File

@ -26,7 +26,7 @@ import org.oscim.map.Map;
import org.oscim.map.Viewport; import org.oscim.map.Viewport;
public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<Item> public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<Item>
implements TouchListener { implements TouchListener {
//private static final String TAG = ItemizedIconOverlay.class.getName(); //private static final String TAG = ItemizedIconOverlay.class.getName();
protected final List<Item> mItemList; protected final List<Item> mItemList;
@ -36,8 +36,8 @@ public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<It
private final Point mTmpPoint = new Point(); private final Point mTmpPoint = new Point();
public ItemizedIconLayer(Map map, List<Item> list, public ItemizedIconLayer(Map map, List<Item> list,
MarkerSymbol defaultMarker, MarkerSymbol defaultMarker,
ItemizedIconLayer.OnItemGestureListener<Item> onItemGestureListener) { ItemizedIconLayer.OnItemGestureListener<Item> onItemGestureListener) {
super(map, defaultMarker); super(map, defaultMarker);
@ -157,6 +157,7 @@ public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<It
* When a content sensitive action is performed the content item needs to be * When a content sensitive action is performed the content item needs to be
* identified. This method does that and then performs the assigned task on * identified. This method does that and then performs the assigned task on
* that item. * that item.
*
* @param event * @param event
* ... * ...
* @param task * @param task
@ -218,6 +219,7 @@ public class ItemizedIconLayer<Item extends MarkerItem> extends ItemizedLayer<It
* When the item is touched one of these methods may be invoked depending on * When the item is touched one of these methods may be invoked depending on
* the type of touch. Each of them returns true if the event was completely * the type of touch. Each of them returns true if the event was completely
* handled. * handled.
*
* @param <T> * @param <T>
* .... * ....
*/ */

View File

@ -43,12 +43,12 @@ import org.oscim.utils.GeometryUtils;
* lowest index is drawn as last and therefore the 'topmost' marker. It also * lowest index is drawn as last and therefore the 'topmost' marker. It also
* gets checked for onTap first. This class is generic, because you then you get * gets checked for onTap first. This class is generic, because you then you get
* your custom item-class passed back in onTap(). * your custom item-class passed back in onTap().
* *
* @param <Item> * @param <Item>
* ... * ...
*/ */
public abstract class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer implements public abstract class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer implements
MarkerLayer.Snappable { MarkerLayer.Snappable {
//private final static String TAG = ItemizedOverlay.class.getName(); //private final static String TAG = ItemizedOverlay.class.getName();
@ -183,7 +183,7 @@ public abstract class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer
/** /**
* Method by which subclasses create the actual Items. This will only be * Method by which subclasses create the actual Items. This will only be
* called from populate() we'll cache them for later use. * called from populate() we'll cache them for later use.
* *
* @param i * @param i
* ... * ...
* @return ... * @return ...
@ -192,7 +192,7 @@ public abstract class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer
/** /**
* The number of items in this overlay. * The number of items in this overlay.
* *
* @return ... * @return ...
*/ */
public abstract int size(); public abstract int size();
@ -249,7 +249,7 @@ public abstract class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer
/** /**
* Returns the Item at the given index. * Returns the Item at the given index.
* *
* @param position * @param position
* the position of the item to return * the position of the item to return
* @return the Item of the given index. * @return the Item of the given index.
@ -274,7 +274,7 @@ public abstract class ItemizedLayer<Item extends MarkerItem> extends MarkerLayer
* move the map, so if the Item isn't already centered, the user may get * move the map, so if the Item isn't already centered, the user may get
* confused. If the Item is not found, this is a no-op. You can also pass * confused. If the Item is not found, this is a no-op. You can also pass
* null to remove focus. * null to remove focus.
* *
* @param item * @param item
* ... * ...
*/ */

View File

@ -21,7 +21,7 @@ import org.oscim.core.GeoPoint;
/** /**
* Immutable class describing a GeoPoint with a Title and a Description. * Immutable class describing a GeoPoint with a Title and a Description.
* *
* @author Nicolas Gramlich * @author Nicolas Gramlich
* @author Theodore Hong * @author Theodore Hong
* @author Fred Eisele * @author Fred Eisele
@ -64,7 +64,7 @@ public class MarkerItem {
} }
public MarkerItem(String uid, String title, String description, public MarkerItem(String uid, String title, String description,
GeoPoint geoPoint) { GeoPoint geoPoint) {
mTitle = title; mTitle = title;
mDescription = description; mDescription = description;
mGeoPoint = geoPoint; mGeoPoint = geoPoint;

View File

@ -28,18 +28,18 @@ public abstract class MarkerLayer extends Layer {
/** /**
* TBD * TBD
* *
* Interface definition for overlays that contain items that can be snapped * Interface definition for overlays that contain items that can be snapped
* to (for example, when the user invokes a zoom, this could be called * to (for example, when the user invokes a zoom, this could be called
* allowing the user to snap the zoom to an interesting point.) * allowing the user to snap the zoom to an interesting point.)
* *
*/ */
public interface Snappable { public interface Snappable {
/** /**
* Checks to see if the given x and y are close enough to an item * Checks to see if the given x and y are close enough to an item
* resulting in snapping the current action (e.g. zoom) to the item. * resulting in snapping the current action (e.g. zoom) to the item.
* *
* @param x * @param x
* The x in screen coordinates. * The x in screen coordinates.
* @param y * @param y

View File

@ -20,8 +20,10 @@ import java.net.URL;
import org.oscim.core.Tile; import org.oscim.core.Tile;
//http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/5/14/14 //http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/5/14/14
//http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer //http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer
public class ArcGISWorldShaded extends AbstractTileSource { public class ArcGISWorldShaded extends AbstractTileSource {
public static final ArcGISWorldShaded INSTANCE = new ArcGISWorldShaded("server.arcgisonline.com", 80); public static final ArcGISWorldShaded INSTANCE = new ArcGISWorldShaded("server.arcgisonline.com",
80);
private static final int PARALLEL_REQUESTS_LIMIT = 4; private static final int PARALLEL_REQUESTS_LIMIT = 4;
private static final String PROTOCOL = "http"; private static final String PROTOCOL = "http";
private static final int ZOOM_LEVEL_MAX = 6; private static final int ZOOM_LEVEL_MAX = 6;

View File

@ -34,8 +34,7 @@ import org.oscim.tiling.TileLoader;
import org.oscim.tiling.TileManager; import org.oscim.tiling.TileManager;
import org.oscim.utils.FastMath; import org.oscim.utils.FastMath;
public class BitmapTileLayer extends TileLayer<TileLoader> {
public class BitmapTileLayer extends TileLayer<TileLoader> {
private static final int TIMEOUT_CONNECT = 5000; private static final int TIMEOUT_CONNECT = 5000;
private static final int TIMEOUT_READ = 10000; private static final int TIMEOUT_READ = 10000;
protected static final String TAG = BitmapTileLayer.class.getName(); protected static final String TAG = BitmapTileLayer.class.getName();
@ -50,7 +49,6 @@ public class BitmapTileLayer extends TileLayer<TileLoader> {
} }
@Override @Override
public void onMapUpdate(MapPosition pos, boolean changed, boolean clear) { public void onMapUpdate(MapPosition pos, boolean changed, boolean clear) {
super.onMapUpdate(pos, changed, clear); super.onMapUpdate(pos, changed, clear);
@ -70,7 +68,7 @@ public class BitmapTileLayer extends TileLayer<TileLoader> {
break; break;
} }
double range = f.scaleEnd / f.scaleStart; double range = f.scaleEnd / f.scaleStart;
float a = (float)((range - (pos.scale / f.scaleStart)) / range); float a = (float) ((range - (pos.scale / f.scaleStart)) / range);
a = FastMath.clamp(a, 0, 1); a = FastMath.clamp(a, 0, 1);
// interpolate alpha between start and end // interpolate alpha between start and end
alpha = a * f.alphaStart + (1 - a) * f.alphaEnd; alpha = a * f.alphaStart + (1 - a) * f.alphaEnd;

View File

@ -21,7 +21,7 @@ import org.oscim.core.Tile;
public class NaturalEarth extends AbstractTileSource { public class NaturalEarth extends AbstractTileSource {
public static final NaturalEarth INSTANCE = new NaturalEarth("city.informatik.uni-bremen.de", public static final NaturalEarth INSTANCE = new NaturalEarth("city.informatik.uni-bremen.de",
80); 80);
private static final int PARALLEL_REQUESTS_LIMIT = 4; private static final int PARALLEL_REQUESTS_LIMIT = 4;
private static final String PROTOCOL = "http"; private static final String PROTOCOL = "http";
private static final int ZOOM_LEVEL_MAX = 8; private static final int ZOOM_LEVEL_MAX = 8;
@ -65,10 +65,10 @@ public class NaturalEarth extends AbstractTileSource {
@Override @Override
public FadeStep[] getFadeSteps() { public FadeStep[] getFadeSteps() {
return new FadeStep[] { return new FadeStep[] {
new FadeStep(ZOOM_LEVEL_MIN, ZOOM_LEVEL_MAX - 1, 1, 0.7f), new FadeStep(ZOOM_LEVEL_MIN, ZOOM_LEVEL_MAX - 1, 1, 0.7f),
// dont fade between zoom-min/max // dont fade between zoom-min/max
// fade above zoom max + 2, interpolate 1 to 0 // fade above zoom max + 2, interpolate 1 to 0
new FadeStep(ZOOM_LEVEL_MAX - 1, ZOOM_LEVEL_MAX + 1, 0.7f, 0) new FadeStep(ZOOM_LEVEL_MAX - 1, ZOOM_LEVEL_MAX + 1, 0.7f, 0)
}; };
} }
} }

View File

@ -21,7 +21,8 @@ import org.oscim.core.Tile;
public interface TileSource { public interface TileSource {
/** /**
* @return the maximum number of parallel requests which this {@code TileSource} supports. * @return the maximum number of parallel requests which this
* {@code TileSource} supports.
*/ */
int getParallelRequestsLimit(); int getParallelRequestsLimit();
@ -42,7 +43,7 @@ public interface TileSource {
FadeStep[] getFadeSteps(); FadeStep[] getFadeSteps();
public class FadeStep{ public class FadeStep {
public final double scaleStart, scaleEnd; public final double scaleStart, scaleEnd;
public final float alphaStart, alphaEnd; public final float alphaStart, alphaEnd;

View File

@ -45,7 +45,7 @@ public class VectorTileLayer extends TileLayer<VectorTileLoader> {
/** /**
* Sets the {@link TileSource} used by {@link TileLoader}. * Sets the {@link TileSource} used by {@link TileLoader}.
* *
* @return true when new TileSource was set (has changed) * @return true when new TileSource was set (has changed)
*/ */
public boolean setTileSource(TileSource tileSource) { public boolean setTileSource(TileSource tileSource) {

View File

@ -124,8 +124,8 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
mLineScale *= 0.4f + 0.6f * ((float) Math.sin(Math.abs(lat) * (Math.PI / 180))); mLineScale *= 0.4f + 0.6f * ((float) Math.sin(Math.abs(lat) * (Math.PI / 180)));
mGroundScale = (float) (Math.cos(lat * (Math.PI / 180)) mGroundScale = (float) (Math.cos(lat * (Math.PI / 180))
* MercatorProjection.EARTH_CIRCUMFERENCE * MercatorProjection.EARTH_CIRCUMFERENCE
/ ((long) Tile.SIZE << tile.zoomLevel)); / ((long) Tile.SIZE << tile.zoomLevel));
mTile = tile; mTile = tile;
mTile.layers = new ElementLayers(); mTile.layers = new ElementLayers();

View File

@ -25,7 +25,7 @@ class Debug {
private final static float[] mDebugPoints = new float[4]; private final static float[] mDebugPoints = new float[4];
static void addDebugBox(ElementLayers dbg, Label l, TextItem ti, int overlaps, boolean prev, static void addDebugBox(ElementLayers dbg, Label l, TextItem ti, int overlaps, boolean prev,
float scale) { float scale) {
LineLayer ll; LineLayer ll;
if (prev) { if (prev) {

View File

@ -52,9 +52,8 @@ class Label extends TextItem {
this.y2 = y + text.fontHeight / 2; this.y2 = y + text.fontHeight / 2;
} }
static int comparePriority(Label l1, Label l2){ static int comparePriority(Label l1, Label l2) {
return 0; return 0;
} }
} }

View File

@ -49,7 +49,7 @@ public class LabelLayer extends Layer implements EventListener, Map.UpdateListen
@Override @Override
public void handleEvent(MapEvent event) { public void handleEvent(MapEvent event) {
if (event instanceof MotionEvent) { if (event instanceof MotionEvent) {
MotionEvent e = (MotionEvent) event; MotionEvent e = (MotionEvent) event;
int action = e.getAction() & MotionEvent.ACTION_MASK; int action = e.getAction() & MotionEvent.ACTION_MASK;
@ -68,11 +68,11 @@ public class LabelLayer extends Layer implements EventListener, Map.UpdateListen
} }
} }
@Override @Override
public void onMapUpdate(MapPosition mapPosition, boolean changed, boolean clear) { public void onMapUpdate(MapPosition mapPosition, boolean changed, boolean clear) {
if (clear) if (clear)
mTextRenderer.clearLabels(); mTextRenderer.clearLabels();
} }
// @Override // @Override
// public boolean onTouchEvent(MotionEvent e) { // public boolean onTouchEvent(MotionEvent e) {

View File

@ -163,12 +163,12 @@ class TextRenderer extends ElementRenderer {
// find other label with same text style // find other label with same text style
if (l.text == ll.text) { if (l.text == ll.text) {
while (ll.next != null while (ll.next != null
// break if next item uses different text style // break if next item uses different text style
&& l.text == ll.next.text && l.text == ll.next.text
// check same string instance // check same string instance
&& l.string != ll.string && l.string != ll.string
// check same string // check same string
&& !l.string.equals(ll.string)) && !l.string.equals(ll.string))
ll = ll.next; ll = ll.next;
// Note: this is required for 'packing test' in prepare to work! // Note: this is required for 'packing test' in prepare to work!
@ -219,7 +219,7 @@ class TextRenderer extends ElementRenderer {
// + " at " + ti.x + ":" + ti.y); // + " at " + ti.x + ":" + ti.y);
if (!ll.text.caption if (!ll.text.caption
&& (ll.text.priority > l.text.priority || ll.length < l.length)) { && (ll.text.priority > l.text.priority || ll.length < l.length)) {
ll = removeLabel(ll); ll = removeLabel(ll);
continue; continue;
@ -379,8 +379,8 @@ class TextRenderer extends ElementRenderer {
} }
l.bbox.set(l.x, l.y, l.x1, l.y1, l.bbox.set(l.x, l.y, l.x1, l.y1,
l.width + MIN_WAY_DIST, l.width + MIN_WAY_DIST,
l.text.fontHeight + MIN_WAY_DIST); l.text.fontHeight + MIN_WAY_DIST);
byte overlaps = checkOverlap(l); byte overlaps = checkOverlap(l);
@ -443,12 +443,12 @@ class TextRenderer extends ElementRenderer {
if (l.bbox == null) if (l.bbox == null)
l.bbox = new OBB2D(l.x, l.y, l.x1, l.y1, l.bbox = new OBB2D(l.x, l.y, l.x1, l.y1,
l.width + MIN_WAY_DIST, l.width + MIN_WAY_DIST,
l.text.fontHeight + MIN_WAY_DIST); l.text.fontHeight + MIN_WAY_DIST);
else else
l.bbox.set(l.x, l.y, l.x1, l.y1, l.bbox.set(l.x, l.y, l.x1, l.y1,
l.width + MIN_WAY_DIST, l.width + MIN_WAY_DIST,
l.text.fontHeight + MIN_WAY_DIST); l.text.fontHeight + MIN_WAY_DIST);
if (dbg == null || ti.width < ti.length * scale) if (dbg == null || ti.width < ti.length * scale)
overlaps = checkOverlap(l); overlaps = checkOverlap(l);
@ -495,9 +495,9 @@ class TextRenderer extends ElementRenderer {
l.bbox = new OBB2D(); l.bbox = new OBB2D();
l.bbox.setNormalized(l.x, l.y, cos, -sin, l.bbox.setNormalized(l.x, l.y, cos, -sin,
l.width + MIN_CAPTION_DIST, l.width + MIN_CAPTION_DIST,
l.text.fontHeight + MIN_CAPTION_DIST, l.text.fontHeight + MIN_CAPTION_DIST,
l.text.dy); l.text.dy);
boolean overlaps = false; boolean overlaps = false;
@ -525,7 +525,7 @@ class TextRenderer extends ElementRenderer {
} }
for (Label ti = mLabels; ti != null; ti = (Label) ti.next) { for (Label ti = mLabels; ti != null; ti = (Label) ti.next) {
if (ti.text.caption){ if (ti.text.caption) {
if (ti.text.texture != null) { if (ti.text.texture != null) {
SymbolItem s = SymbolItem.pool.get(); SymbolItem s = SymbolItem.pool.get();
s.texRegion = ti.text.texture; s.texRegion = ti.text.texture;
@ -595,7 +595,7 @@ class TextRenderer extends ElementRenderer {
@Override @Override
public synchronized void update(MapPosition pos, boolean changed, public synchronized void update(MapPosition pos, boolean changed,
Matrices matrices) { Matrices matrices) {
//if (System.currentTimeMillis() - lastDraw > 1000){ //if (System.currentTimeMillis() - lastDraw > 1000){
// updateLabels(); // updateLabels();

View File

@ -25,7 +25,7 @@ import org.oscim.utils.LineClipper;
public final class WayDecorator { public final class WayDecorator {
public static void renderText(LineClipper clipper, float[] coordinates, String string, public static void renderText(LineClipper clipper, float[] coordinates, String string,
Text text, int pos, int len, MapTile tile) { Text text, int pos, int len, MapTile tile) {
//TextItem items = textItems; //TextItem items = textItems;
TextItem t = null; TextItem t = null;

View File

@ -128,6 +128,7 @@ public abstract class Map implements EventDispatcher {
* Request call to onUpdate for all layers. This function can * Request call to onUpdate for all layers. This function can
* be called from any thread. Request will be handled on main * be called from any thread. Request will be handled on main
* thread. * thread.
*
* @param forceRedraw pass true to render next frame * @param forceRedraw pass true to render next frame
*/ */
public abstract void updateMap(boolean forceRedraw); public abstract void updateMap(boolean forceRedraw);
@ -192,6 +193,7 @@ public abstract class Map implements EventDispatcher {
/** /**
* Get current {@link MapPosition}. * Get current {@link MapPosition}.
*
* @param mapPosition * @param mapPosition
*/ */
public boolean getMapPosition(MapPosition mapPosition) { public boolean getMapPosition(MapPosition mapPosition) {

View File

@ -48,10 +48,10 @@ public class MapAnimator {
// calculate the maximum scale at which the bbox is completely visible // calculate the maximum scale at which the bbox is completely visible
double dx = Math.abs(MercatorProjection.longitudeToX(bbox.getMaxLongitude()) double dx = Math.abs(MercatorProjection.longitudeToX(bbox.getMaxLongitude())
- MercatorProjection.longitudeToX(bbox.getMinLongitude())); - MercatorProjection.longitudeToX(bbox.getMinLongitude()));
double dy = Math.abs(MercatorProjection.latitudeToY(bbox.getMinLatitude()) double dy = Math.abs(MercatorProjection.latitudeToY(bbox.getMinLatitude())
- MercatorProjection.latitudeToY(bbox.getMaxLatitude())); - MercatorProjection.latitudeToY(bbox.getMaxLatitude()));
double zx = mMap.getWidth() / (dx * Tile.SIZE); double zx = mMap.getWidth() / (dx * Tile.SIZE);
double zy = mMap.getHeight() / (dy * Tile.SIZE); double zy = mMap.getHeight() / (dy * Tile.SIZE);

Some files were not shown because too many files have changed in this diff Show More