split up
This commit is contained in:
@@ -0,0 +1,468 @@
|
||||
/*******************************************************************************
|
||||
* 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 com.badlogic.gdx.backends.android;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.oscim.backend.GL20;
|
||||
|
||||
public class AndroidGL20 implements GL20 {
|
||||
static {
|
||||
System.loadLibrary("androidgl20");
|
||||
init();
|
||||
}
|
||||
|
||||
private static native void init ();
|
||||
|
||||
@Override
|
||||
public native void glActiveTexture (int texture);
|
||||
|
||||
@Override
|
||||
public native void glAttachShader (int program, int shader);
|
||||
|
||||
@Override
|
||||
public native void glBindAttribLocation (int program, int index, String name);
|
||||
|
||||
@Override
|
||||
public native void glBindBuffer (int target, int buffer);
|
||||
|
||||
@Override
|
||||
public native void glBindFramebuffer (int target, int framebuffer);
|
||||
|
||||
@Override
|
||||
public native void glBindRenderbuffer (int target, int renderbuffer);
|
||||
|
||||
@Override
|
||||
public native void glBindTexture (int target, int texture);
|
||||
|
||||
@Override
|
||||
public native void glBlendColor (float red, float green, float blue, float alpha);
|
||||
|
||||
@Override
|
||||
public native void glBlendEquation (int mode);
|
||||
|
||||
@Override
|
||||
public native void glBlendEquationSeparate (int modeRGB, int modeAlpha);
|
||||
|
||||
@Override
|
||||
public native void glBlendFunc (int sfactor, int dfactor);
|
||||
|
||||
@Override
|
||||
public native void glBlendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha);
|
||||
|
||||
@Override
|
||||
public native void glBufferData (int target, int size, Buffer data, int usage);
|
||||
|
||||
@Override
|
||||
public native void glBufferSubData (int target, int offset, int size, Buffer data);
|
||||
|
||||
@Override
|
||||
public native int glCheckFramebufferStatus (int target);
|
||||
|
||||
@Override
|
||||
public native void glClear (int mask);
|
||||
|
||||
@Override
|
||||
public native void glClearColor (float red, float green, float blue, float alpha);
|
||||
|
||||
@Override
|
||||
public native void glClearDepthf (float depth);
|
||||
|
||||
@Override
|
||||
public native void glClearStencil (int s);
|
||||
|
||||
@Override
|
||||
public native void glColorMask (boolean red, boolean green, boolean blue, boolean alpha);
|
||||
|
||||
@Override
|
||||
public native void glCompileShader (int shader);
|
||||
|
||||
@Override
|
||||
public native void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border,
|
||||
int imageSize, Buffer data);
|
||||
|
||||
@Override
|
||||
public native void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height,
|
||||
int format, int imageSize, Buffer data);
|
||||
|
||||
@Override
|
||||
public native void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border);
|
||||
|
||||
@Override
|
||||
public native void glCopyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height);
|
||||
|
||||
@Override
|
||||
public native int glCreateProgram ();
|
||||
|
||||
@Override
|
||||
public native int glCreateShader (int type);
|
||||
|
||||
@Override
|
||||
public native void glCullFace (int mode);
|
||||
|
||||
@Override
|
||||
public native void glDeleteBuffers (int n, IntBuffer buffers);
|
||||
|
||||
@Override
|
||||
public native void glDeleteFramebuffers (int n, IntBuffer framebuffers);
|
||||
|
||||
@Override
|
||||
public native void glDeleteProgram (int program);
|
||||
|
||||
@Override
|
||||
public native void glDeleteRenderbuffers (int n, IntBuffer renderbuffers);
|
||||
|
||||
@Override
|
||||
public native void glDeleteShader (int shader);
|
||||
|
||||
@Override
|
||||
public native void glDeleteTextures (int n, IntBuffer textures);
|
||||
|
||||
@Override
|
||||
public native void glDepthFunc (int func);
|
||||
|
||||
@Override
|
||||
public native void glDepthMask (boolean flag);
|
||||
|
||||
@Override
|
||||
public native void glDepthRangef (float zNear, float zFar);
|
||||
|
||||
@Override
|
||||
public native void glDetachShader (int program, int shader);
|
||||
|
||||
@Override
|
||||
public native void glDisable (int cap);
|
||||
|
||||
@Override
|
||||
public native void glDisableVertexAttribArray (int index);
|
||||
|
||||
@Override
|
||||
public native void glDrawArrays (int mode, int first, int count);
|
||||
|
||||
@Override
|
||||
public native void glDrawElements (int mode, int count, int type, Buffer indices);
|
||||
|
||||
@Override
|
||||
public native void glDrawElements (int mode, int count, int type, int indices);
|
||||
|
||||
@Override
|
||||
public native void glEnable (int cap);
|
||||
|
||||
@Override
|
||||
public native void glEnableVertexAttribArray (int index);
|
||||
|
||||
@Override
|
||||
public native void glFinish ();
|
||||
|
||||
@Override
|
||||
public native void glFlush ();
|
||||
|
||||
@Override
|
||||
public native void glFramebufferRenderbuffer (int target, int attachment, int renderbuffertarget, int renderbuffer);
|
||||
|
||||
@Override
|
||||
public native void glFramebufferTexture2D (int target, int attachment, int textarget, int texture, int level);
|
||||
|
||||
@Override
|
||||
public native void glFrontFace (int mode);
|
||||
|
||||
@Override
|
||||
public native void glGenBuffers (int n, IntBuffer buffers);
|
||||
|
||||
@Override
|
||||
public native void glGenerateMipmap (int target);
|
||||
|
||||
@Override
|
||||
public native void glGenFramebuffers (int n, IntBuffer framebuffers);
|
||||
|
||||
@Override
|
||||
public native void glGenRenderbuffers (int n, IntBuffer renderbuffers);
|
||||
|
||||
@Override
|
||||
public native void glGenTextures (int n, IntBuffer textures);
|
||||
|
||||
@Override
|
||||
public native String glGetActiveAttrib (int program, int index, IntBuffer size, Buffer type);
|
||||
|
||||
@Override
|
||||
public native String glGetActiveUniform (int program, int index, IntBuffer size, Buffer type);
|
||||
|
||||
@Override
|
||||
public native void glGetAttachedShaders (int program, int maxcount, Buffer count, IntBuffer shaders);
|
||||
|
||||
@Override
|
||||
public native int glGetAttribLocation (int program, String name);
|
||||
|
||||
@Override
|
||||
public native void glGetBooleanv (int pname, Buffer params);
|
||||
|
||||
@Override
|
||||
public native void glGetBufferParameteriv (int target, int pname, IntBuffer params);
|
||||
|
||||
@Override
|
||||
public native int glGetError ();
|
||||
|
||||
@Override
|
||||
public native void glGetFloatv (int pname, FloatBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glGetFramebufferAttachmentParameteriv (int target, int attachment, int pname, IntBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glGetIntegerv (int pname, IntBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glGetProgramiv (int program, int pname, IntBuffer params);
|
||||
|
||||
@Override
|
||||
public native String glGetProgramInfoLog (int program);
|
||||
|
||||
@Override
|
||||
public native void glGetRenderbufferParameteriv (int target, int pname, IntBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glGetShaderiv (int shader, int pname, IntBuffer params);
|
||||
|
||||
@Override
|
||||
public native String glGetShaderInfoLog (int shader);
|
||||
|
||||
@Override
|
||||
public native void glGetShaderPrecisionFormat (int shadertype, int precisiontype, IntBuffer range, IntBuffer precision);
|
||||
|
||||
@Override
|
||||
public native void glGetShaderSource (int shader, int bufsize, Buffer length, String source);
|
||||
|
||||
@Override
|
||||
public native String glGetString (int name);
|
||||
|
||||
@Override
|
||||
public native void glGetTexParameterfv (int target, int pname, FloatBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glGetTexParameteriv (int target, int pname, IntBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glGetUniformfv (int program, int location, FloatBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glGetUniformiv (int program, int location, IntBuffer params);
|
||||
|
||||
@Override
|
||||
public native int glGetUniformLocation (int program, String name);
|
||||
|
||||
@Override
|
||||
public native void glGetVertexAttribfv (int index, int pname, FloatBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glGetVertexAttribiv (int index, int pname, IntBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glGetVertexAttribPointerv (int index, int pname, Buffer pointer);
|
||||
|
||||
@Override
|
||||
public native void glHint (int target, int mode);
|
||||
|
||||
@Override
|
||||
public native boolean glIsBuffer (int buffer);
|
||||
|
||||
@Override
|
||||
public native boolean glIsEnabled (int cap);
|
||||
|
||||
@Override
|
||||
public native boolean glIsFramebuffer (int framebuffer);
|
||||
|
||||
@Override
|
||||
public native boolean glIsProgram (int program);
|
||||
|
||||
@Override
|
||||
public native boolean glIsRenderbuffer (int renderbuffer);
|
||||
|
||||
@Override
|
||||
public native boolean glIsShader (int shader);
|
||||
|
||||
@Override
|
||||
public native boolean glIsTexture (int texture);
|
||||
|
||||
@Override
|
||||
public native void glLineWidth (float width);
|
||||
|
||||
@Override
|
||||
public native void glLinkProgram (int program);
|
||||
|
||||
@Override
|
||||
public native void glPixelStorei (int pname, int param);
|
||||
|
||||
@Override
|
||||
public native void glPolygonOffset (float factor, float units);
|
||||
|
||||
@Override
|
||||
public native void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels);
|
||||
|
||||
@Override
|
||||
public native void glReleaseShaderCompiler ();
|
||||
|
||||
@Override
|
||||
public native void glRenderbufferStorage (int target, int internalformat, int width, int height);
|
||||
|
||||
@Override
|
||||
public native void glSampleCoverage (float value, boolean invert);
|
||||
|
||||
@Override
|
||||
public native void glScissor (int x, int y, int width, int height);
|
||||
|
||||
@Override
|
||||
public native void glShaderBinary (int n, IntBuffer shaders, int binaryformat, Buffer binary, int length);
|
||||
|
||||
@Override
|
||||
public native void glShaderSource (int shader, String string);
|
||||
|
||||
@Override
|
||||
public native void glStencilFunc (int func, int ref, int mask);
|
||||
|
||||
@Override
|
||||
public native void glStencilFuncSeparate (int face, int func, int ref, int mask);
|
||||
|
||||
@Override
|
||||
public native void glStencilMask (int mask);
|
||||
|
||||
@Override
|
||||
public native void glStencilMaskSeparate (int face, int mask);
|
||||
|
||||
@Override
|
||||
public native void glStencilOp (int fail, int zfail, int zpass);
|
||||
|
||||
@Override
|
||||
public native void glStencilOpSeparate (int face, int fail, int zfail, int zpass);
|
||||
|
||||
@Override
|
||||
public native void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format,
|
||||
int type, Buffer pixels);
|
||||
|
||||
@Override
|
||||
public native void glTexParameterf (int target, int pname, float param);
|
||||
|
||||
@Override
|
||||
public native void glTexParameterfv (int target, int pname, FloatBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glTexParameteri (int target, int pname, int param);
|
||||
|
||||
@Override
|
||||
public native void glTexParameteriv (int target, int pname, IntBuffer params);
|
||||
|
||||
@Override
|
||||
public native void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format,
|
||||
int type, Buffer pixels);
|
||||
|
||||
@Override
|
||||
public native void glUniform1f (int location, float x);
|
||||
|
||||
@Override
|
||||
public native void glUniform1fv (int location, int count, FloatBuffer v);
|
||||
|
||||
@Override
|
||||
public native void glUniform1i (int location, int x);
|
||||
|
||||
@Override
|
||||
public native void glUniform1iv (int location, int count, IntBuffer v);
|
||||
|
||||
@Override
|
||||
public native void glUniform2f (int location, float x, float y);
|
||||
|
||||
@Override
|
||||
public native void glUniform2fv (int location, int count, FloatBuffer v);
|
||||
|
||||
@Override
|
||||
public native void glUniform2i (int location, int x, int y);
|
||||
|
||||
@Override
|
||||
public native void glUniform2iv (int location, int count, IntBuffer v);
|
||||
|
||||
@Override
|
||||
public native void glUniform3f (int location, float x, float y, float z);
|
||||
|
||||
@Override
|
||||
public native void glUniform3fv (int location, int count, FloatBuffer v);
|
||||
|
||||
@Override
|
||||
public native void glUniform3i (int location, int x, int y, int z);
|
||||
|
||||
@Override
|
||||
public native void glUniform3iv (int location, int count, IntBuffer v);
|
||||
|
||||
@Override
|
||||
public native void glUniform4f (int location, float x, float y, float z, float w);
|
||||
|
||||
@Override
|
||||
public native void glUniform4fv (int location, int count, FloatBuffer v);
|
||||
|
||||
@Override
|
||||
public native void glUniform4i (int location, int x, int y, int z, int w);
|
||||
|
||||
@Override
|
||||
public native void glUniform4iv (int location, int count, IntBuffer v);
|
||||
|
||||
@Override
|
||||
public native void glUniformMatrix2fv (int location, int count, boolean transpose, FloatBuffer value);
|
||||
|
||||
@Override
|
||||
public native void glUniformMatrix3fv (int location, int count, boolean transpose, FloatBuffer value);
|
||||
|
||||
@Override
|
||||
public native void glUniformMatrix4fv (int location, int count, boolean transpose, FloatBuffer value);
|
||||
|
||||
@Override
|
||||
public native void glUseProgram (int program);
|
||||
|
||||
@Override
|
||||
public native void glValidateProgram (int program);
|
||||
|
||||
@Override
|
||||
public native void glVertexAttrib1f (int indx, float x);
|
||||
|
||||
@Override
|
||||
public native void glVertexAttrib1fv (int indx, FloatBuffer values);
|
||||
|
||||
@Override
|
||||
public native void glVertexAttrib2f (int indx, float x, float y);
|
||||
|
||||
@Override
|
||||
public native void glVertexAttrib2fv (int indx, FloatBuffer values);
|
||||
|
||||
@Override
|
||||
public native void glVertexAttrib3f (int indx, float x, float y, float z);
|
||||
|
||||
@Override
|
||||
public native void glVertexAttrib3fv (int indx, FloatBuffer values);
|
||||
|
||||
@Override
|
||||
public native void glVertexAttrib4f (int indx, float x, float y, float z, float w);
|
||||
|
||||
@Override
|
||||
public native void glVertexAttrib4fv (int indx, FloatBuffer values);
|
||||
|
||||
@Override
|
||||
public native void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, Buffer ptr);
|
||||
|
||||
@Override
|
||||
public native void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int ptr);
|
||||
|
||||
@Override
|
||||
public native void glViewport (int x, int y, int width, int height);
|
||||
}
|
||||
38
vtm-android/src/org/oscim/android/AndroidAssetAdapter.java
Normal file
38
vtm-android/src/org/oscim/android/AndroidAssetAdapter.java
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2013
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.oscim.backend.AssetAdapter;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class AndroidAssetAdapter extends AssetAdapter {
|
||||
Context mContext;
|
||||
public AndroidAssetAdapter(Context ctx) {
|
||||
mContext = ctx;
|
||||
}
|
||||
@Override
|
||||
public InputStream openFileAsStream(String fileName) {
|
||||
try {
|
||||
return mContext.getAssets().open(fileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
47
vtm-android/src/org/oscim/android/AndroidGLRenderer.java
Normal file
47
vtm-android/src/org/oscim/android/AndroidGLRenderer.java
Normal file
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android;
|
||||
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.opengles.GL10;
|
||||
|
||||
import org.oscim.renderer.GLRenderer;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
import android.opengl.GLSurfaceView;
|
||||
|
||||
public class AndroidGLRenderer extends GLRenderer implements GLSurfaceView.Renderer{
|
||||
|
||||
public AndroidGLRenderer(MapView mapView) {
|
||||
super(mapView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
|
||||
super.onSurfaceCreated();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSurfaceChanged(GL10 gl, int width, int height) {
|
||||
super.onSurfaceChanged(width, height);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDrawFrame(GL10 gl) {
|
||||
super.onDrawFrame();
|
||||
}
|
||||
|
||||
}
|
||||
58
vtm-android/src/org/oscim/android/AndroidGraphics.java
Normal file
58
vtm-android/src/org/oscim/android/AndroidGraphics.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android;
|
||||
|
||||
|
||||
//public class AndroidGraphics {
|
||||
//
|
||||
// public static OverlayMarker makeMarker(Resources res, int id, HotspotPlace place) {
|
||||
//
|
||||
// // if (place == null)
|
||||
// // place = HotspotPlace.CENTER;
|
||||
// //
|
||||
// //Drawable drawable = ;
|
||||
// //
|
||||
// // return new OverlayMarker(drawableToBitmap(drawable), place);
|
||||
// return makeMarker(res.getDrawable(id), place);
|
||||
// }
|
||||
//
|
||||
// public static OverlayMarker makeMarker(Drawable drawable, HotspotPlace place) {
|
||||
//
|
||||
// if (place == null)
|
||||
// place = HotspotPlace.CENTER;
|
||||
//
|
||||
// //Drawable drawable = res.getDrawable(id);
|
||||
//
|
||||
// return new OverlayMarker(drawableToBitmap(drawable), place);
|
||||
// }
|
||||
//
|
||||
//
|
||||
// public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
// if (drawable instanceof BitmapDrawable) {
|
||||
// return ((BitmapDrawable) drawable).getBitmap();
|
||||
// }
|
||||
//
|
||||
// android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap(
|
||||
// drawable.getIntrinsicWidth(),
|
||||
// drawable.getIntrinsicHeight(),
|
||||
// Config.ARGB_8888);
|
||||
//
|
||||
// android.graphics.Canvas canvas = new android.graphics.Canvas(bitmap);
|
||||
// drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
// drawable.draw(canvas);
|
||||
//
|
||||
// return bitmap;
|
||||
// }
|
||||
//}
|
||||
42
vtm-android/src/org/oscim/android/AndroidLog.java
Normal file
42
vtm-android/src/org/oscim/android/AndroidLog.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright 2013
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
|
||||
public class AndroidLog implements org.oscim.backend.Log.Logger{
|
||||
|
||||
@Override
|
||||
public void d(String tag, String msg) {
|
||||
Log.d(tag, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void w(String tag, String msg) {
|
||||
Log.w(tag, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void e(String tag, String msg) {
|
||||
Log.e(tag, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void i(String tag, String msg) {
|
||||
Log.i(tag, msg);
|
||||
}
|
||||
|
||||
}
|
||||
288
vtm-android/src/org/oscim/android/AndroidMapView.java
Normal file
288
vtm-android/src/org/oscim/android/AndroidMapView.java
Normal file
@@ -0,0 +1,288 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
* Copyright 2012 Hannes Janetzek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android;
|
||||
|
||||
import org.oscim.android.canvas.AndroidGraphics;
|
||||
import org.oscim.android.input.AndroidMotionEvent;
|
||||
import org.oscim.backend.AssetAdapter;
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.GLAdapter;
|
||||
import org.oscim.backend.Log;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.view.MapRenderCallback;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.badlogic.gdx.backends.android.AndroidGL20;
|
||||
|
||||
/**
|
||||
* A MapView shows a map on the display of the device. It handles all user input
|
||||
* and touch gestures to move and zoom the map.
|
||||
*/
|
||||
public class AndroidMapView extends RelativeLayout implements MapRenderCallback {
|
||||
|
||||
final static String TAG = AndroidMapView.class.getName();
|
||||
|
||||
public static final boolean debugFrameTime = false;
|
||||
public static final boolean testRegionZoom = false;
|
||||
|
||||
public boolean mRotationEnabled = false;
|
||||
public boolean mCompassEnabled = false;
|
||||
public boolean enablePagedFling = false;
|
||||
|
||||
private final GLView mGLView;
|
||||
private final Compass mCompass;
|
||||
|
||||
private int mWidth;
|
||||
private int mHeight;
|
||||
private boolean mInitialized;
|
||||
|
||||
|
||||
private final MapView mMapView;
|
||||
|
||||
static {
|
||||
System.loadLibrary("glutils");
|
||||
System.loadLibrary("triangle");
|
||||
//System.loadLibrary("tessellate");
|
||||
|
||||
CanvasAdapter.g = AndroidGraphics.INSTANCE;
|
||||
GLAdapter.INSTANCE = new AndroidGL20();
|
||||
Log.logger = new AndroidLog();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* the enclosing MapActivity instance.
|
||||
* @throws IllegalArgumentException
|
||||
* if the context object is not an instance of
|
||||
* {@link MapActivity} .
|
||||
*/
|
||||
public AndroidMapView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param context
|
||||
* the enclosing MapActivity instance.
|
||||
* @param attributeSet
|
||||
* a set of attributes.
|
||||
* @throws IllegalArgumentException
|
||||
* if the context object is not an instance of
|
||||
* {@link MapActivity} .
|
||||
*/
|
||||
|
||||
public AndroidMapView(Context context, AttributeSet attributeSet) {
|
||||
super(context, attributeSet);
|
||||
|
||||
if (!(context instanceof MapActivity)) {
|
||||
throw new IllegalArgumentException(
|
||||
"context is not an instance of MapActivity");
|
||||
}
|
||||
|
||||
AssetAdapter.g = new AndroidAssetAdapter(context);
|
||||
|
||||
|
||||
this.setWillNotDraw(true);
|
||||
|
||||
DisplayMetrics metrics = getResources().getDisplayMetrics();
|
||||
CanvasAdapter.dpi = (int)Math.max(metrics.xdpi, metrics.ydpi);
|
||||
|
||||
// TODO make this dpi dependent
|
||||
Tile.SIZE = 400;
|
||||
|
||||
MapActivity mapActivity = (MapActivity) context;
|
||||
|
||||
mMapView = new MapView(this);
|
||||
|
||||
mGLView = new GLView(context, mMapView);
|
||||
|
||||
mCompass = new Compass(mapActivity, mMapView);
|
||||
|
||||
mapActivity.registerMapView(mMapView);
|
||||
|
||||
LayoutParams params = new LayoutParams(
|
||||
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
android.view.ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
|
||||
addView(mGLView, params);
|
||||
|
||||
clearMap();
|
||||
updateMap(false);
|
||||
}
|
||||
|
||||
public MapView getMap() {
|
||||
return mMapView;
|
||||
}
|
||||
|
||||
public void onStop() {
|
||||
Log.d(TAG, "onStop");
|
||||
//mLayerManager.destroy();
|
||||
}
|
||||
|
||||
private boolean mPausing = false;
|
||||
|
||||
void onPause() {
|
||||
mPausing = true;
|
||||
|
||||
if (this.mCompassEnabled)
|
||||
mCompass.disable();
|
||||
|
||||
}
|
||||
|
||||
void onResume() {
|
||||
if (this.mCompassEnabled)
|
||||
mCompass.enable();
|
||||
|
||||
mPausing = false;
|
||||
}
|
||||
|
||||
AndroidMotionEvent mMotionEvent = new AndroidMotionEvent();
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(android.view.MotionEvent motionEvent) {
|
||||
|
||||
if (!isClickable())
|
||||
return false;
|
||||
|
||||
mMotionEvent.wrap(motionEvent);
|
||||
|
||||
//return mMapView.handleMotionEvent(mMotionEvent);
|
||||
|
||||
return mMapView.getLayerManager().handleMotionEvent(mMotionEvent);
|
||||
}
|
||||
// synchronized ???
|
||||
@Override
|
||||
protected void onSizeChanged(int width, int height,
|
||||
int oldWidth, int oldHeight) {
|
||||
Log.d(TAG, "onSizeChanged: " + width + "x" + height);
|
||||
|
||||
super.onSizeChanged(width, height, oldWidth, oldHeight);
|
||||
|
||||
mWidth = width;
|
||||
mHeight = height;
|
||||
|
||||
mInitialized = (mWidth > 0 && mHeight > 0);
|
||||
|
||||
if (mInitialized)
|
||||
mMapView.getMapViewPosition().setViewport(width, height);
|
||||
}
|
||||
|
||||
/* private */boolean mWaitRedraw;
|
||||
|
||||
private final Runnable mRedrawRequest = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
mWaitRedraw = false;
|
||||
redrawMapInternal(false);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Request to redraw the map when a global state like position,
|
||||
* datasource or theme has changed. This will trigger a call
|
||||
* to onUpdate() for all Layers.
|
||||
*
|
||||
* @param requestRender
|
||||
* also request to draw a frame
|
||||
*/
|
||||
@Override
|
||||
public void updateMap(boolean requestRender) {
|
||||
if (requestRender && !mClearMap && !mPausing && mInitialized)
|
||||
mGLView.requestRender();
|
||||
|
||||
if (!mWaitRedraw) {
|
||||
mWaitRedraw = true;
|
||||
post(mRedrawRequest);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean mClearMap;
|
||||
|
||||
public void clearMap() {
|
||||
mClearMap = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request to render a frame. Use this for animations.
|
||||
*/
|
||||
@Override
|
||||
public void renderMap() {
|
||||
if (mClearMap)
|
||||
updateMap(false);
|
||||
else
|
||||
mGLView.requestRender();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all Layers on Main thread.
|
||||
*
|
||||
* @param forceRedraw also render frame
|
||||
* FIXME (does nothing atm)
|
||||
*/
|
||||
void redrawMapInternal(boolean forceRedraw) {
|
||||
|
||||
if (forceRedraw && !mClearMap)
|
||||
mGLView.requestRender();
|
||||
|
||||
mMapView.updateLayers();
|
||||
|
||||
if (mClearMap) {
|
||||
mGLView.requestRender();
|
||||
mClearMap = false;
|
||||
}
|
||||
}
|
||||
|
||||
public void enableRotation(boolean enable) {
|
||||
mRotationEnabled = enable;
|
||||
|
||||
if (enable) {
|
||||
enableCompass(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void enableCompass(boolean enable) {
|
||||
if (enable == mCompassEnabled)
|
||||
return;
|
||||
|
||||
mCompassEnabled = enable;
|
||||
|
||||
if (enable)
|
||||
enableRotation(false);
|
||||
|
||||
if (enable)
|
||||
mCompass.enable();
|
||||
else
|
||||
mCompass.disable();
|
||||
}
|
||||
|
||||
public boolean getCompassEnabled() {
|
||||
return mCompassEnabled;
|
||||
}
|
||||
|
||||
public boolean getRotationEnabled() {
|
||||
return mRotationEnabled;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
Log.d(TAG, "TODO Auto-generated method stub");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
68
vtm-android/src/org/oscim/android/Compass.java
Normal file
68
vtm-android/src/org/oscim/android/Compass.java
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2012 Hannes Janetzek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android;
|
||||
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.Sensor;
|
||||
import android.hardware.SensorEvent;
|
||||
import android.hardware.SensorEventListener;
|
||||
import android.hardware.SensorManager;
|
||||
|
||||
public class Compass {
|
||||
|
||||
private final SensorEventListener mListener = new SensorEventListener() {
|
||||
@Override
|
||||
public void onSensorChanged(SensorEvent event) {
|
||||
if (Math.abs(event.values[0] - mAngle) > 0.25) {
|
||||
mAngle = event.values[0];
|
||||
|
||||
if (mMapView != null) {
|
||||
mMapView.getMapViewPosition().setRotation(-mAngle);
|
||||
mMapView.updateMap(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAccuracyChanged(Sensor sensor, int accuracy) {
|
||||
}
|
||||
};
|
||||
|
||||
/* package */float mAngle = 0;
|
||||
/* package */MapView mMapView;
|
||||
|
||||
private final SensorManager mSensorManager;
|
||||
private final Sensor mSensor;
|
||||
|
||||
public Compass(MapActivity mapActivity, MapView mapView) {
|
||||
mMapView = mapView;
|
||||
mSensorManager = (SensorManager) mapActivity
|
||||
.getSystemService(Context.SENSOR_SERVICE);
|
||||
|
||||
mSensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
|
||||
}
|
||||
|
||||
public void enable() {
|
||||
mSensorManager.registerListener(mListener, mSensor,
|
||||
SensorManager.SENSOR_DELAY_UI);
|
||||
}
|
||||
|
||||
public void disable() {
|
||||
mSensorManager.unregisterListener(mListener);
|
||||
mMapView.getMapViewPosition().setRotation(0);
|
||||
}
|
||||
}
|
||||
41
vtm-android/src/org/oscim/android/GLView.java
Normal file
41
vtm-android/src/org/oscim/android/GLView.java
Normal file
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright 2012 Hannes Janetzek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android;
|
||||
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
import android.content.Context;
|
||||
import android.opengl.GLSurfaceView;
|
||||
|
||||
public class GLView extends GLSurfaceView {
|
||||
|
||||
MapView mMapView;
|
||||
private final AndroidGLRenderer mRenderer;
|
||||
|
||||
public GLView(Context context, MapView mapView) {
|
||||
super(context);
|
||||
mMapView = mapView;
|
||||
// Log.d(TAG, "init GLSurfaceLayer");
|
||||
setEGLConfigChooser(new GlConfigChooser());
|
||||
setEGLContextClientVersion(2);
|
||||
|
||||
setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS);
|
||||
mRenderer = new AndroidGLRenderer(mMapView);
|
||||
setRenderer(mRenderer);
|
||||
|
||||
//if (!MapView.debugFrameTime)
|
||||
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
|
||||
}
|
||||
}
|
||||
159
vtm-android/src/org/oscim/android/GlConfigChooser.java
Normal file
159
vtm-android/src/org/oscim/android/GlConfigChooser.java
Normal file
@@ -0,0 +1,159 @@
|
||||
package org.oscim.android;
|
||||
|
||||
import javax.microedition.khronos.egl.EGL10;
|
||||
import javax.microedition.khronos.egl.EGLConfig;
|
||||
import javax.microedition.khronos.egl.EGLDisplay;
|
||||
|
||||
import android.opengl.GLSurfaceView;
|
||||
import org.oscim.backend.Log;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class GlConfigChooser implements GLSurfaceView.EGLConfigChooser {
|
||||
static private final String TAG = "ConfigChooser";
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public static int stencilSize = 0;
|
||||
|
||||
@Override
|
||||
public EGLConfig chooseConfig(EGL10 egl, EGLDisplay display) {
|
||||
mValue = new int[1];
|
||||
|
||||
// Try to find a normal multisample configuration first.
|
||||
int[] configSpec = {
|
||||
EGL10.EGL_RED_SIZE, 5,
|
||||
EGL10.EGL_GREEN_SIZE, 6,
|
||||
EGL10.EGL_BLUE_SIZE, 5,
|
||||
EGL10.EGL_ALPHA_SIZE, 8,
|
||||
EGL10.EGL_DEPTH_SIZE, 16,
|
||||
// Requires that setEGLContextClientVersion(2) is called on the view.
|
||||
EGL10.EGL_RENDERABLE_TYPE, 4 /* EGL_OPENGL_ES2_BIT */,
|
||||
EGL10.EGL_STENCIL_SIZE, 8,
|
||||
EGL10.EGL_NONE };
|
||||
|
||||
if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) {
|
||||
throw new IllegalArgumentException("eglChooseConfig failed");
|
||||
}
|
||||
int numConfigs = mValue[0];
|
||||
|
||||
if (numConfigs <= 0) {
|
||||
stencilSize = 4;
|
||||
|
||||
configSpec = new int[] {
|
||||
// EGL10.EGL_RENDERABLE_TYPE, 4, EGL10.EGL_NONE };
|
||||
EGL10.EGL_RED_SIZE, 8,
|
||||
EGL10.EGL_GREEN_SIZE, 8,
|
||||
EGL10.EGL_BLUE_SIZE, 8,
|
||||
EGL10.EGL_ALPHA_SIZE, 8,
|
||||
EGL10.EGL_DEPTH_SIZE, 16,
|
||||
EGL10.EGL_RENDERABLE_TYPE, 4 /* EGL_OPENGL_ES2_BIT */,
|
||||
EGL10.EGL_STENCIL_SIZE, 8,
|
||||
EGL10.EGL_NONE };
|
||||
|
||||
if (!egl.eglChooseConfig(display, configSpec, null, 0, mValue)) {
|
||||
throw new IllegalArgumentException("eglChooseConfig failed");
|
||||
}
|
||||
numConfigs = mValue[0];
|
||||
|
||||
if (numConfigs <= 0) {
|
||||
throw new IllegalArgumentException("No configs match configSpec");
|
||||
}
|
||||
} else {
|
||||
stencilSize = 8;
|
||||
}
|
||||
|
||||
// Get all matching configurations.
|
||||
EGLConfig[] configs = new EGLConfig[numConfigs];
|
||||
if (!egl.eglChooseConfig(display, configSpec, configs, numConfigs, mValue)) {
|
||||
throw new IllegalArgumentException("data eglChooseConfig failed");
|
||||
}
|
||||
|
||||
// CAUTION! eglChooseConfigs returns configs with higher bit depth
|
||||
// first: Even though we asked for rgb565 configurations, rgb888
|
||||
// configurations are considered to be "better" and returned first.
|
||||
// You need to explicitly filter the data returned by eglChooseConfig!
|
||||
|
||||
// for (int i = 0; i < configs.length; ++i) {
|
||||
// Log.i(TAG, printConfig(egl, display, configs[i]));
|
||||
// }
|
||||
|
||||
// int index = -1;
|
||||
// for (int i = 0; i < configs.length; ++i) {
|
||||
// // if (findConfigAttrib(egl, display, configs[i], EGL10.EGL_RED_SIZE, 0) == 8
|
||||
// // &&
|
||||
// // findConfigAttrib(egl, display, configs[i], EGL10.EGL_ALPHA_SIZE, 0) == 0) {
|
||||
// // index = i;
|
||||
// // break;
|
||||
// // }
|
||||
// // else
|
||||
// if (findConfigAttrib(egl, display, configs[i], EGL10.EGL_RED_SIZE, 0) == 8
|
||||
// &&
|
||||
// findConfigAttrib(egl, display, configs[i], EGL10.EGL_ALPHA_SIZE, 0) == 0
|
||||
// &&
|
||||
// findConfigAttrib(egl, display, configs[i], EGL10.EGL_DEPTH_SIZE, 0) == 24) {
|
||||
// index = i;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// if (index == -1) {
|
||||
// Log.w(TAG, "Did not find sane config, using first");
|
||||
// index = 0;
|
||||
// }
|
||||
int index = 0;
|
||||
|
||||
Log.i(TAG, "using: " + printConfig(egl, display, configs[index]));
|
||||
|
||||
EGLConfig config = configs.length > 0 ? configs[index] : null;
|
||||
if (config == null) {
|
||||
throw new IllegalArgumentException("No config chosen");
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
// from quake2android
|
||||
private String printConfig(EGL10 egl, EGLDisplay display,
|
||||
EGLConfig config) {
|
||||
|
||||
int r = findConfigAttrib(egl, display, config, EGL10.EGL_RED_SIZE, 0);
|
||||
int g = findConfigAttrib(egl, display, config, EGL10.EGL_GREEN_SIZE, 0);
|
||||
int b = findConfigAttrib(egl, display, config, EGL10.EGL_BLUE_SIZE, 0);
|
||||
int a = findConfigAttrib(egl, display, config, EGL10.EGL_ALPHA_SIZE, 0);
|
||||
int d = findConfigAttrib(egl, display, config, EGL10.EGL_DEPTH_SIZE, 0);
|
||||
int s = findConfigAttrib(egl, display, config, EGL10.EGL_STENCIL_SIZE, 0);
|
||||
|
||||
/*
|
||||
* EGL_CONFIG_CAVEAT value #define EGL_NONE 0x3038 #define
|
||||
* EGL_SLOW_CONFIG 0x3050 #define
|
||||
* EGL_NON_CONFORMANT_CONFIG 0x3051
|
||||
*/
|
||||
|
||||
return String.format("EGLConfig rgba=%d%d%d%d depth=%d stencil=%d",
|
||||
Integer.valueOf(r), Integer.valueOf(g),
|
||||
Integer.valueOf(b), Integer.valueOf(a), Integer.valueOf(d),
|
||||
Integer.valueOf(s))
|
||||
+ " native="
|
||||
+ findConfigAttrib(egl, display, config, EGL10.EGL_NATIVE_RENDERABLE, 0)
|
||||
+ " buffer="
|
||||
+ findConfigAttrib(egl, display, config, EGL10.EGL_BUFFER_SIZE, 0)
|
||||
+ String.format(
|
||||
" caveat=0x%04x",
|
||||
Integer.valueOf(findConfigAttrib(egl, display, config,
|
||||
EGL10.EGL_CONFIG_CAVEAT, 0)));
|
||||
|
||||
}
|
||||
|
||||
private int findConfigAttrib(EGL10 egl, EGLDisplay display, EGLConfig config,
|
||||
int attribute, int defaultValue) {
|
||||
if (egl.eglGetConfigAttrib(display, config, attribute, mValue)) {
|
||||
return mValue[0];
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
|
||||
private int[] mValue;
|
||||
|
||||
}
|
||||
139
vtm-android/src/org/oscim/android/MapActivity.java
Normal file
139
vtm-android/src/org/oscim/android/MapActivity.java
Normal file
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android;
|
||||
|
||||
import org.oscim.core.GeoPoint;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
|
||||
/**
|
||||
* MapActivity is the abstract base class which must be extended in order to use
|
||||
* a {@link MapView}. There are no abstract methods in this implementation which
|
||||
* subclasses need to override and no API key or registration is required.
|
||||
* <p>
|
||||
* A subclass may create a MapView either via one of the MapView constructors or
|
||||
* by inflating an XML layout file. It is possible to use more than one MapView
|
||||
* at the same time.
|
||||
* <p>
|
||||
* When the MapActivity is shut down, the current center position, zoom level
|
||||
* and map file of the MapView are saved in a preferences file and restored in
|
||||
* the next startup process.
|
||||
*/
|
||||
public abstract class MapActivity extends Activity {
|
||||
private static final String KEY_LATITUDE = "latitude";
|
||||
private static final String KEY_LONGITUDE = "longitude";
|
||||
private static final String KEY_MAP_SCALE = "map_scale";
|
||||
|
||||
private static final String PREFERENCES_FILE = "MapActivity";
|
||||
//private static final String KEY_THEME = "Theme";
|
||||
|
||||
private static boolean containsMapViewPosition(SharedPreferences sharedPreferences) {
|
||||
return sharedPreferences.contains(KEY_LATITUDE)
|
||||
&& sharedPreferences.contains(KEY_LONGITUDE)
|
||||
&& sharedPreferences.contains(KEY_MAP_SCALE);
|
||||
}
|
||||
|
||||
protected MapView mMapView;
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
mMapView.destroy();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mMapView.onPause();
|
||||
|
||||
Editor editor = getSharedPreferences(PREFERENCES_FILE, MODE_PRIVATE).edit();
|
||||
editor.clear();
|
||||
|
||||
// save the map position
|
||||
MapPosition mapPosition = new MapPosition();
|
||||
|
||||
mMapView.getMapViewPosition().getMapPosition(mapPosition);
|
||||
|
||||
GeoPoint geoPoint = mapPosition.getGeoPoint();
|
||||
|
||||
editor.putInt(KEY_LATITUDE, geoPoint.latitudeE6);
|
||||
editor.putInt(KEY_LONGITUDE, geoPoint.longitudeE6);
|
||||
editor.putFloat(KEY_MAP_SCALE, (float)mapPosition.scale);
|
||||
|
||||
//editor.putString(KEY_THEME, mMapView.getRenderTheme());
|
||||
|
||||
editor.commit();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
mMapView.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mMapView.onStop();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method is called once by each MapView during its setup process.
|
||||
*
|
||||
* @param mapView
|
||||
* the calling MapView.
|
||||
*/
|
||||
public final void registerMapView(MapView mapView) {
|
||||
mMapView = mapView;
|
||||
|
||||
SharedPreferences sharedPreferences = getSharedPreferences(PREFERENCES_FILE,
|
||||
MODE_PRIVATE);
|
||||
|
||||
if (containsMapViewPosition(sharedPreferences)) {
|
||||
// get and set the map position and zoom level
|
||||
int latitudeE6 = sharedPreferences.getInt(KEY_LATITUDE, 0);
|
||||
int longitudeE6 = sharedPreferences.getInt(KEY_LONGITUDE, 0);
|
||||
float scale = sharedPreferences.getFloat(KEY_MAP_SCALE, 1);
|
||||
|
||||
|
||||
MapPosition mapPosition = new MapPosition();
|
||||
mapPosition.setPosition(latitudeE6 / 1E6, longitudeE6 / 1E6);
|
||||
mapPosition.setScale(scale);
|
||||
|
||||
mMapView.setMapPosition(mapPosition);
|
||||
}
|
||||
|
||||
//String theme = sharedPreferences.getString(KEY_THEME,
|
||||
// InternalRenderTheme.DEFAULT.name());
|
||||
|
||||
// if (theme.startsWith("/")) {
|
||||
// try {
|
||||
// mapView.setRenderTheme(theme);
|
||||
// } catch (FileNotFoundException e) {
|
||||
// mapView.setRenderTheme(InternalRenderTheme.DEFAULT);
|
||||
// }
|
||||
// } else {
|
||||
// try {
|
||||
// mapView.setRenderTheme(InternalRenderTheme.valueOf(theme));
|
||||
// } catch (IllegalArgumentException e) {
|
||||
// mapView.setRenderTheme(InternalRenderTheme.DEFAULT);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
359
vtm-android/src/org/oscim/android/MapZoomControls.java
Normal file
359
vtm-android/src/org/oscim/android/MapZoomControls.java
Normal file
@@ -0,0 +1,359 @@
|
||||
package org.oscim.android;
|
||||
///*
|
||||
// * Copyright 2010, 2011, 2012 mapsforge.org
|
||||
// *
|
||||
// * This program is free software: you can redistribute it and/or modify it under the
|
||||
// * terms of the GNU Lesser General Public License as published by the Free Software
|
||||
// * Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
// *
|
||||
// * This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
// * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
// * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
// *
|
||||
// * You should have received a copy of the GNU Lesser General Public License along with
|
||||
// * this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
// */
|
||||
//package org.oscim.view;
|
||||
//
|
||||
//import org.oscim.generator.TileGenerator;
|
||||
//
|
||||
//import android.content.Context;
|
||||
//import android.os.Handler;
|
||||
//import android.os.Message;
|
||||
//import android.view.Gravity;
|
||||
//import android.view.MotionEvent;
|
||||
//import android.view.View;
|
||||
//import android.view.ViewConfiguration;
|
||||
//import android.view.ViewGroup.LayoutParams;
|
||||
//import android.widget.ZoomControls;
|
||||
//
|
||||
///**
|
||||
// * A MapZoomControls instance displays buttons for zooming in and out in a map.
|
||||
// */
|
||||
//public class MapZoomControls {
|
||||
// private static class ZoomControlsHideHandler extends Handler {
|
||||
// private final ZoomControls mZoomControls;
|
||||
//
|
||||
// ZoomControlsHideHandler(ZoomControls zoomControls) {
|
||||
// super();
|
||||
// mZoomControls = zoomControls;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void handleMessage(Message message) {
|
||||
// mZoomControls.hide();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static class ZoomInClickListener implements View.OnClickListener {
|
||||
// private final MapZoomControls mMapZoomControls;
|
||||
//
|
||||
// ZoomInClickListener(MapZoomControls mapZoomControls) {
|
||||
// mMapZoomControls = mapZoomControls;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// // if (MapView.testRegionZoom)
|
||||
// // mMapView.mRegionLookup.updateRegion(1, null);
|
||||
// // else
|
||||
// // MapZoomControls.this.zoom((byte) 1);
|
||||
// mMapZoomControls.zoom((byte) 1);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private static class ZoomOutClickListener implements View.OnClickListener {
|
||||
// private final MapZoomControls mMapZoomControls;
|
||||
//
|
||||
// ZoomOutClickListener(MapZoomControls mapZoomControls) {
|
||||
// mMapZoomControls = mapZoomControls;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void onClick(View view) {
|
||||
// // if (MapView.testRegionZoom)
|
||||
// // mMapView.mRegionLookup.updateRegion(-1, null);
|
||||
// // else
|
||||
// mMapZoomControls.zoom((byte) -1);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Default {@link Gravity} of the zoom controls.
|
||||
// */
|
||||
// private static final int DEFAULT_ZOOM_CONTROLS_GRAVITY = Gravity.BOTTOM
|
||||
// | Gravity.RIGHT;
|
||||
//
|
||||
// /**
|
||||
// * Default maximum zoom level.
|
||||
// */
|
||||
// private static final byte DEFAULT_ZOOM_LEVEL_MAX = 18;
|
||||
//
|
||||
// /**
|
||||
// * Default minimum zoom level.
|
||||
// */
|
||||
// private static final byte DEFAULT_ZOOM_LEVEL_MIN = 1;
|
||||
//
|
||||
// /**
|
||||
// * Message code for the handler to hide the zoom controls.
|
||||
// */
|
||||
// private static final int MSG_ZOOM_CONTROLS_HIDE = 0;
|
||||
//
|
||||
// /**
|
||||
// * Horizontal padding for the zoom controls.
|
||||
// */
|
||||
// private static final int ZOOM_CONTROLS_HORIZONTAL_PADDING = 5;
|
||||
//
|
||||
// /**
|
||||
// * Delay in milliseconds after which the zoom controls disappear.
|
||||
// */
|
||||
// private static final long ZOOM_CONTROLS_TIMEOUT = ViewConfiguration
|
||||
// .getZoomControlsTimeout();
|
||||
//
|
||||
// private boolean mGravityChanged;
|
||||
// private boolean mShowMapZoomControls;
|
||||
// private final ZoomControls mZoomControls;
|
||||
// private int mZoomControlsGravity;
|
||||
// private final Handler mZoomControlsHideHandler;
|
||||
// private byte mZoomLevelMax;
|
||||
// private byte mZoomLevelMin;
|
||||
// private final MapView mMapView;
|
||||
//
|
||||
// MapZoomControls(Context context, final MapView mapView) {
|
||||
// mMapView = mapView;
|
||||
// mZoomControls = new ZoomControls(context);
|
||||
// mShowMapZoomControls = true;
|
||||
// mZoomLevelMax = DEFAULT_ZOOM_LEVEL_MAX;
|
||||
// mZoomLevelMin = DEFAULT_ZOOM_LEVEL_MIN;
|
||||
// // if (!MapView.testRegionZoom)
|
||||
// mZoomControls.setVisibility(View.GONE);
|
||||
// mZoomControlsGravity = DEFAULT_ZOOM_CONTROLS_GRAVITY;
|
||||
//
|
||||
// mZoomControls.setOnZoomInClickListener(new ZoomInClickListener(this));
|
||||
// mZoomControls.setOnZoomOutClickListener(new ZoomOutClickListener(this));
|
||||
// mZoomControlsHideHandler = new ZoomControlsHideHandler(mZoomControls);
|
||||
//
|
||||
// int wrapContent = android.view.ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
// LayoutParams layoutParams = new LayoutParams(wrapContent, wrapContent);
|
||||
// mapView.addView(mZoomControls, layoutParams);
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Zooms in or out by the given amount of zoom levels.
|
||||
// *
|
||||
// * @param zoomLevelDiff
|
||||
// * the difference to the current zoom level.
|
||||
// * @return true if the zoom level was changed, false otherwise.
|
||||
// */
|
||||
// boolean zoom(byte zoomLevelDiff) {
|
||||
// MapViewPosition mapViewPosition = mMapView.getMapViewPosition();
|
||||
// int z = mapViewPosition.getZoomLevel() + zoomLevelDiff;
|
||||
// if (zoomLevelDiff > 0) {
|
||||
// // check if zoom in is possible
|
||||
// if (z > mZoomLevelMax) {
|
||||
// return false;
|
||||
// }
|
||||
//
|
||||
// } else if (zoomLevelDiff < 0) {
|
||||
// // check if zoom out is possible
|
||||
// if (z < getZoomLevelMin()) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// mapViewPosition.setZoomLevel((byte) z);
|
||||
// mMapView.redrawMap(true);
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return the current gravity for the placing of the zoom controls.
|
||||
// * @see Gravity
|
||||
// */
|
||||
// public int getZoomControlsGravity() {
|
||||
// return mZoomControlsGravity;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return the maximum zoom level of the map.
|
||||
// */
|
||||
// public byte getZoomLevelMax() {
|
||||
// return mZoomLevelMax;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return the minimum zoom level of the map.
|
||||
// */
|
||||
// public byte getZoomLevelMin() {
|
||||
// return mZoomLevelMin;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @return true if the zoom controls are visible, false otherwise.
|
||||
// */
|
||||
// public boolean isShowMapZoomControls() {
|
||||
// return mShowMapZoomControls;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param show
|
||||
// * true if the zoom controls should be visible, false otherwise.
|
||||
// */
|
||||
// public void setShowMapZoomControls(boolean show) {
|
||||
// mShowMapZoomControls = show;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Sets the gravity for the placing of the zoom controls. Supported values
|
||||
// * are {@link Gravity#TOP}, {@link Gravity#CENTER_VERTICAL},
|
||||
// * {@link Gravity#BOTTOM}, {@link Gravity#LEFT},
|
||||
// * {@link Gravity#CENTER_HORIZONTAL} and {@link Gravity#RIGHT}.
|
||||
// *
|
||||
// * @param zoomControlsGravity
|
||||
// * a combination of {@link Gravity} constants describing the
|
||||
// * desired placement.
|
||||
// */
|
||||
// public void setZoomControlsGravity(int zoomControlsGravity) {
|
||||
// if (mZoomControlsGravity != zoomControlsGravity) {
|
||||
// mZoomControlsGravity = zoomControlsGravity;
|
||||
// mGravityChanged = true;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Sets the maximum zoom level of the map.
|
||||
// * <p>
|
||||
// * The maximum possible zoom level of the MapView depends also on the
|
||||
// * current {@link TileGenerator}. For example, downloading map tiles may
|
||||
// * only be possible up to a certain zoom level. Setting a higher maximum
|
||||
// * zoom level has no effect in this case.
|
||||
// *
|
||||
// * @param zoomLevelMax
|
||||
// * the maximum zoom level.
|
||||
// * @throws IllegalArgumentException
|
||||
// * if the maximum zoom level is smaller than the current minimum
|
||||
// * zoom level.
|
||||
// */
|
||||
// public void setZoomLevelMax(byte zoomLevelMax) {
|
||||
// if (zoomLevelMax < mZoomLevelMin) {
|
||||
// throw new IllegalArgumentException();
|
||||
// }
|
||||
// mZoomLevelMax = zoomLevelMax;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Sets the minimum zoom level of the map.
|
||||
// *
|
||||
// * @param zoomLevelMin
|
||||
// * the minimum zoom level.
|
||||
// * @throws IllegalArgumentException
|
||||
// * if the minimum zoom level is larger than the current maximum
|
||||
// * zoom level.
|
||||
// */
|
||||
// public void setZoomLevelMin(byte zoomLevelMin) {
|
||||
// if (zoomLevelMin > mZoomLevelMax) {
|
||||
// throw new IllegalArgumentException();
|
||||
// }
|
||||
// mZoomLevelMin = zoomLevelMin;
|
||||
// }
|
||||
//
|
||||
// private int calculatePositionLeft(int left, int right, int zoomControlsWidth) {
|
||||
// int gravity = mZoomControlsGravity & Gravity.HORIZONTAL_GRAVITY_MASK;
|
||||
// switch (gravity) {
|
||||
// case Gravity.LEFT:
|
||||
// return ZOOM_CONTROLS_HORIZONTAL_PADDING;
|
||||
//
|
||||
// case Gravity.CENTER_HORIZONTAL:
|
||||
// return (right - left - zoomControlsWidth) / 2;
|
||||
//
|
||||
// case Gravity.RIGHT:
|
||||
// return right - left - zoomControlsWidth
|
||||
// - ZOOM_CONTROLS_HORIZONTAL_PADDING;
|
||||
// }
|
||||
//
|
||||
// throw new IllegalArgumentException("unknown horizontal gravity: " + gravity);
|
||||
// }
|
||||
//
|
||||
// private int calculatePositionTop(int top, int bottom, int zoomControlsHeight) {
|
||||
// int gravity = mZoomControlsGravity & Gravity.VERTICAL_GRAVITY_MASK;
|
||||
// switch (gravity) {
|
||||
// case Gravity.TOP:
|
||||
// return 0;
|
||||
//
|
||||
// case Gravity.CENTER_VERTICAL:
|
||||
// return (bottom - top - zoomControlsHeight) / 2;
|
||||
//
|
||||
// case Gravity.BOTTOM:
|
||||
// return bottom - top - zoomControlsHeight;
|
||||
// }
|
||||
//
|
||||
// throw new IllegalArgumentException("unknown vertical gravity: " + gravity);
|
||||
// }
|
||||
//
|
||||
// private void showZoomControls() {
|
||||
// mZoomControlsHideHandler.removeMessages(MSG_ZOOM_CONTROLS_HIDE);
|
||||
// if (mZoomControls.getVisibility() != View.VISIBLE) {
|
||||
// mZoomControls.show();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// private void showZoomControlsWithTimeout() {
|
||||
// showZoomControls();
|
||||
// mZoomControlsHideHandler.sendEmptyMessageDelayed(MSG_ZOOM_CONTROLS_HIDE,
|
||||
// ZOOM_CONTROLS_TIMEOUT);
|
||||
// }
|
||||
//
|
||||
// int getMeasuredHeight() {
|
||||
// return mZoomControls.getMeasuredHeight();
|
||||
// }
|
||||
//
|
||||
// int getMeasuredWidth() {
|
||||
// return mZoomControls.getMeasuredWidth();
|
||||
// }
|
||||
//
|
||||
// void measure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
// mZoomControls.measure(widthMeasureSpec, heightMeasureSpec);
|
||||
// }
|
||||
//
|
||||
// void onLayout(boolean changed, int left, int top, int right, int bottom) {
|
||||
// if (!changed && !mGravityChanged) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// int zoomControlsWidth = mZoomControls.getMeasuredWidth();
|
||||
// int zoomControlsHeight = mZoomControls.getMeasuredHeight();
|
||||
//
|
||||
// int positionLeft = calculatePositionLeft(left, right, zoomControlsWidth);
|
||||
// int positionTop = calculatePositionTop(top, bottom, zoomControlsHeight);
|
||||
// int positionRight = positionLeft + zoomControlsWidth;
|
||||
// int positionBottom = positionTop + zoomControlsHeight;
|
||||
//
|
||||
// mZoomControls.layout(positionLeft, positionTop, positionRight, positionBottom);
|
||||
// mGravityChanged = false;
|
||||
// }
|
||||
//
|
||||
// void onMapViewTouchEvent(int action) {
|
||||
// if (mShowMapZoomControls) {
|
||||
// switch (action) {
|
||||
// case MotionEvent.ACTION_DOWN:
|
||||
// showZoomControls();
|
||||
// break;
|
||||
// case MotionEvent.ACTION_CANCEL:
|
||||
// showZoomControlsWithTimeout();
|
||||
// break;
|
||||
// case MotionEvent.ACTION_UP:
|
||||
// showZoomControlsWithTimeout();
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// void onZoomLevelChange(int zoomLevel) {
|
||||
// boolean zoomInEnabled = zoomLevel < mZoomLevelMax;
|
||||
// boolean zoomOutEnabled = zoomLevel > mZoomLevelMin;
|
||||
//
|
||||
// mZoomControls.setIsZoomInEnabled(zoomInEnabled);
|
||||
// mZoomControls.setIsZoomOutEnabled(zoomOutEnabled);
|
||||
// }
|
||||
//}
|
||||
86
vtm-android/src/org/oscim/android/canvas/AndroidBitmap.java
Normal file
86
vtm-android/src/org/oscim/android/canvas/AndroidBitmap.java
Normal file
@@ -0,0 +1,86 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.canvas;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLUtils;
|
||||
|
||||
public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
|
||||
final Bitmap mBitmap;
|
||||
|
||||
public AndroidBitmap(InputStream inputStream) {
|
||||
mBitmap = BitmapFactory.decodeStream(inputStream);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param format ignored always ARGB8888
|
||||
*/
|
||||
public AndroidBitmap(int width, int height, int format){
|
||||
mBitmap = android.graphics.Bitmap
|
||||
.createBitmap(width, height, android.graphics.Bitmap.Config.ARGB_8888);
|
||||
}
|
||||
AndroidBitmap(android.graphics.Bitmap bitmap){
|
||||
mBitmap = bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return mBitmap.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return mBitmap.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getPixels() {
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
int[] colors = new int[width * height];
|
||||
mBitmap.getPixels(colors, 0, width, 0, 0, width, height);
|
||||
return colors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseColor(int color) {
|
||||
//int a = android.graphics.Color.TRANSPARENT;
|
||||
mBitmap.eraseColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int uploadToTexture(boolean replace) {
|
||||
|
||||
int format = GLUtils.getInternalFormat(mBitmap);
|
||||
int type = GLUtils.getType(mBitmap);
|
||||
|
||||
if (replace)
|
||||
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, mBitmap, format,
|
||||
type);
|
||||
else
|
||||
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format, mBitmap, type, 0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
mBitmap.recycle();
|
||||
}
|
||||
}
|
||||
29
vtm-android/src/org/oscim/android/canvas/AndroidCanvas.java
Normal file
29
vtm-android/src/org/oscim/android/canvas/AndroidCanvas.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package org.oscim.android.canvas;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
public class AndroidCanvas implements Canvas {
|
||||
final android.graphics.Canvas canvas;
|
||||
|
||||
public AndroidCanvas() {
|
||||
this.canvas = new android.graphics.Canvas();
|
||||
}
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
this.canvas.setBitmap(((AndroidBitmap)bitmap).mBitmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawText(String string, float x, float y, Paint stroke) {
|
||||
this.canvas.drawText(string, x, y, ((AndroidPaint)stroke).mPaint);
|
||||
|
||||
}
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, float x, float y) {
|
||||
this.canvas.drawBitmap(((AndroidBitmap)bitmap).mBitmap, x, y, null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
117
vtm-android/src/org/oscim/android/canvas/AndroidGraphics.java
Normal file
117
vtm-android/src/org/oscim/android/canvas/AndroidGraphics.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.canvas;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
import org.oscim.layers.overlay.OverlayItem.HotspotPlace;
|
||||
import org.oscim.layers.overlay.OverlayMarker;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
public final class AndroidGraphics extends CanvasAdapter {
|
||||
public static final AndroidGraphics INSTANCE = new AndroidGraphics();
|
||||
|
||||
// public static android.graphics.Bitmap getAndroidBitmap(Bitmap bitmap) {
|
||||
// return ((AndroidBitmap) bitmap).bitmap;
|
||||
// }
|
||||
|
||||
public static android.graphics.Paint getAndroidPaint(Paint paint) {
|
||||
return ((AndroidPaint) paint).mPaint;
|
||||
}
|
||||
|
||||
private AndroidGraphics() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap decodeBitmap(InputStream inputStream) {
|
||||
return new AndroidBitmap(inputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor(Color color) {
|
||||
switch (color) {
|
||||
case BLACK:
|
||||
return android.graphics.Color.BLACK;
|
||||
|
||||
case CYAN:
|
||||
return android.graphics.Color.CYAN;
|
||||
|
||||
case TRANSPARENT:
|
||||
return android.graphics.Color.TRANSPARENT;
|
||||
|
||||
case WHITE:
|
||||
return android.graphics.Color.WHITE;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("unknown color value: " + color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paint getPaint() {
|
||||
return new AndroidPaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int parseColor(String colorString) {
|
||||
return android.graphics.Color.parseColor(colorString);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap getBitmap(int width, int height, int format) {
|
||||
return new AndroidBitmap(width, height, format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Canvas getCanvas() {
|
||||
return new AndroidCanvas();
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
|
||||
}
|
||||
|
||||
android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap(
|
||||
drawable.getIntrinsicWidth(),
|
||||
drawable.getIntrinsicHeight(),
|
||||
Config.ARGB_8888);
|
||||
|
||||
android.graphics.Canvas canvas = new android.graphics.Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
|
||||
return new AndroidBitmap(bitmap);
|
||||
}
|
||||
|
||||
public static OverlayMarker makeMarker(Resources res, int id, HotspotPlace place) {
|
||||
|
||||
if (place == null)
|
||||
place = HotspotPlace.CENTER;
|
||||
|
||||
Drawable drawable = res.getDrawable(id);
|
||||
|
||||
return new OverlayMarker(drawableToBitmap(drawable), place);
|
||||
}
|
||||
}
|
||||
165
vtm-android/src/org/oscim/android/canvas/AndroidPaint.java
Normal file
165
vtm-android/src/org/oscim/android/canvas/AndroidPaint.java
Normal file
@@ -0,0 +1,165 @@
|
||||
/*
|
||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.canvas;
|
||||
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.DashPathEffect;
|
||||
import android.graphics.Paint.FontMetrics;
|
||||
import android.graphics.PathEffect;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.Shader;
|
||||
import android.graphics.Shader.TileMode;
|
||||
import android.graphics.Typeface;
|
||||
|
||||
class AndroidPaint implements Paint {
|
||||
private static int getStyle(org.oscim.backend.canvas.Paint.FontStyle fontStyle) {
|
||||
switch (fontStyle) {
|
||||
case BOLD:
|
||||
return 1;
|
||||
case BOLD_ITALIC:
|
||||
return 3;
|
||||
case ITALIC:
|
||||
return 2;
|
||||
case NORMAL:
|
||||
return 0;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("unknown font style: " + fontStyle);
|
||||
}
|
||||
|
||||
private static Typeface getTypeface(org.oscim.backend.canvas.Paint.FontFamily fontFamily) {
|
||||
switch (fontFamily) {
|
||||
case DEFAULT:
|
||||
return Typeface.DEFAULT;
|
||||
case DEFAULT_BOLD:
|
||||
return Typeface.DEFAULT_BOLD;
|
||||
case MONOSPACE:
|
||||
return Typeface.MONOSPACE;
|
||||
case SANS_SERIF:
|
||||
return Typeface.SANS_SERIF;
|
||||
case SERIF:
|
||||
return Typeface.SERIF;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("unknown font family: " + fontFamily);
|
||||
}
|
||||
|
||||
final android.graphics.Paint mPaint;
|
||||
|
||||
AndroidPaint() {
|
||||
mPaint = new android.graphics.Paint(
|
||||
android.graphics.Paint.ANTI_ALIAS_FLAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return mPaint.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextHeight(String text) {
|
||||
Rect rect = new Rect();
|
||||
mPaint.getTextBounds(text, 0, text.length(), rect);
|
||||
return rect.height();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextWidth(String text) {
|
||||
Rect rect = new Rect();
|
||||
mPaint.getTextBounds(text, 0, text.length(), rect);
|
||||
return rect.width();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmapShader(org.oscim.backend.canvas.Bitmap bitmap) {
|
||||
if (bitmap == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
android.graphics.Bitmap androidBitmap = android.graphics.Bitmap
|
||||
.createBitmap(bitmap.getPixels(), bitmap.getWidth(),
|
||||
bitmap.getHeight(), Config.ARGB_8888);
|
||||
Shader shader = new BitmapShader(androidBitmap, TileMode.REPEAT,
|
||||
TileMode.REPEAT);
|
||||
mPaint.setShader(shader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(int color) {
|
||||
mPaint.setColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDashPathEffect(float[] strokeDasharray) {
|
||||
PathEffect pathEffect = new DashPathEffect(strokeDasharray, 0);
|
||||
mPaint.setPathEffect(pathEffect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrokeCap(Cap cap) {
|
||||
android.graphics.Paint.Cap androidCap = android.graphics.Paint.Cap
|
||||
.valueOf(cap.name());
|
||||
mPaint.setStrokeCap(androidCap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrokeWidth(float width) {
|
||||
mPaint.setStrokeWidth(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStyle(Style style) {
|
||||
mPaint.setStyle(android.graphics.Paint.Style.valueOf(style.name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextAlign(Align align) {
|
||||
|
||||
mPaint.setTextAlign(android.graphics.Paint.Align.valueOf(align.name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextSize(float textSize) {
|
||||
mPaint.setTextSize(textSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
|
||||
Typeface typeface = Typeface.create(getTypeface(fontFamily),
|
||||
getStyle(fontStyle));
|
||||
mPaint.setTypeface(typeface);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float measureText(String text) {
|
||||
return mPaint.measureText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFontHeight() {
|
||||
FontMetrics fm = mPaint.getFontMetrics();
|
||||
return (float) Math.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFontDescent() {
|
||||
FontMetrics fm = mPaint.getFontMetrics();
|
||||
// //fontDescent = (float) Math.ceil(Math.abs(fm.descent));
|
||||
return Math.abs(fm.bottom);
|
||||
}
|
||||
}
|
||||
870
vtm-android/src/org/oscim/android/gl/AndroidGL.java
Normal file
870
vtm-android/src/org/oscim/android/gl/AndroidGL.java
Normal file
@@ -0,0 +1,870 @@
|
||||
/*
|
||||
* Copyright 2013
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.gl;
|
||||
|
||||
import java.nio.Buffer;
|
||||
import java.nio.FloatBuffer;
|
||||
import java.nio.IntBuffer;
|
||||
|
||||
import org.oscim.backend.GL20;
|
||||
|
||||
import android.opengl.GLES20;
|
||||
|
||||
public class AndroidGL implements GL20{
|
||||
|
||||
@Override
|
||||
public void glAttachShader(int program, int shader) {
|
||||
GLES20.glAttachShader(program, shader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBindAttribLocation(int program, int index, String name) {
|
||||
GLES20.glBindAttribLocation(program, index, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBindBuffer(int target, int buffer) {
|
||||
GLES20.glBindBuffer(target, buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBindFramebuffer(int target, int framebuffer) {
|
||||
GLES20.glBindFramebuffer(target, framebuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBindRenderbuffer(int target, int renderbuffer) {
|
||||
GLES20.glBindRenderbuffer(target, renderbuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBlendColor(float red, float green, float blue, float alpha) {
|
||||
GLES20.glBlendColor(red, green, blue, alpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBlendEquation(int mode) {
|
||||
GLES20.glBlendEquation(mode);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBlendEquationSeparate(int modeRGB, int modeAlpha) {
|
||||
GLES20.glBlendEquationSeparate(modeRGB, modeAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBlendFuncSeparate(int srcRGB, int dstRGB, int srcAlpha, int dstAlpha) {
|
||||
GLES20.glBlendFuncSeparate(srcRGB, dstRGB, srcAlpha, dstAlpha);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBufferData(int target, int size, Buffer data, int usage) {
|
||||
GLES20.glBufferData(target, size, data, usage);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBufferSubData(int target, int offset, int size, Buffer data) {
|
||||
GLES20.glBufferSubData(target, offset, size, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glCheckFramebufferStatus(int target) {
|
||||
return GLES20.glCheckFramebufferStatus(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glCompileShader(int shader) {
|
||||
GLES20.glCompileShader(shader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glCreateProgram() {
|
||||
return GLES20.glCreateProgram();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glCreateShader(int type) {
|
||||
return GLES20.glCreateShader(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteBuffers(int n, IntBuffer buffers) {
|
||||
GLES20.glDeleteBuffers(n, buffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteFramebuffers(int n, IntBuffer framebuffers) {
|
||||
GLES20.glDeleteFramebuffers(n, framebuffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteProgram(int program) {
|
||||
GLES20.glDeleteProgram(program);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteRenderbuffers(int n, IntBuffer renderbuffers) {
|
||||
GLES20.glDeleteRenderbuffers(n, renderbuffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteShader(int shader) {
|
||||
GLES20.glDeleteShader(shader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDetachShader(int program, int shader) {
|
||||
GLES20.glDetachShader(program, shader);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDisableVertexAttribArray(int index) {
|
||||
GLES20.glDisableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDrawElements(int mode, int count, int type, int indices) {
|
||||
GLES20.glDrawElements(mode, count, type, indices);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glEnableVertexAttribArray(int index) {
|
||||
GLES20.glEnableVertexAttribArray(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glFramebufferRenderbuffer(int target, int attachment, int renderbuffertarget,
|
||||
int renderbuffer) {
|
||||
GLES20.glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glFramebufferTexture2D(int target, int attachment, int textarget, int texture,
|
||||
int level) {
|
||||
GLES20.glFramebufferTexture2D(target, attachment, textarget, texture, level);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGenBuffers(int n, IntBuffer buffers) {
|
||||
GLES20.glGenBuffers(n, buffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGenerateMipmap(int target) {
|
||||
GLES20.glGenerateMipmap(target);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGenFramebuffers(int n, IntBuffer framebuffers) {
|
||||
GLES20.glGenFramebuffers(n, framebuffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGenRenderbuffers(int n, IntBuffer renderbuffers) {
|
||||
GLES20.glGenRenderbuffers(n, renderbuffers);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String glGetActiveAttrib(int program, int index, IntBuffer size, Buffer type) {
|
||||
return GLES20.glGetActiveAttrib(program, index, size, (IntBuffer)type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String glGetActiveUniform(int program, int index, IntBuffer size, Buffer type) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetAttachedShaders(int program, int maxcount, Buffer count, IntBuffer shaders) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glGetAttribLocation(int program, String name) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetBooleanv(int pname, Buffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetBufferParameteriv(int target, int pname, IntBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetFloatv(int pname, FloatBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetFramebufferAttachmentParameteriv(int target, int attachment, int pname,
|
||||
IntBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetProgramiv(int program, int pname, IntBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String glGetProgramInfoLog(int program) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetRenderbufferParameteriv(int target, int pname, IntBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetShaderiv(int shader, int pname, IntBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String glGetShaderInfoLog(int shader) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetShaderPrecisionFormat(int shadertype, int precisiontype, IntBuffer range,
|
||||
IntBuffer precision) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetShaderSource(int shader, int bufsize, Buffer length, String source) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetTexParameterfv(int target, int pname, FloatBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetTexParameteriv(int target, int pname, IntBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetUniformfv(int program, int location, FloatBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetUniformiv(int program, int location, IntBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glGetUniformLocation(int program, String name) {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetVertexAttribfv(int index, int pname, FloatBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetVertexAttribiv(int index, int pname, IntBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetVertexAttribPointerv(int index, int pname, Buffer pointer) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean glIsBuffer(int buffer) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean glIsEnabled(int cap) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean glIsFramebuffer(int framebuffer) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean glIsProgram(int program) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean glIsRenderbuffer(int renderbuffer) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean glIsShader(int shader) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean glIsTexture(int texture) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glLinkProgram(int program) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glReleaseShaderCompiler() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glRenderbufferStorage(int target, int internalformat, int width, int height) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glSampleCoverage(float value, boolean invert) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glShaderBinary(int n, IntBuffer shaders, int binaryformat, Buffer binary, int length) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glShaderSource(int shader, String string) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glStencilFuncSeparate(int face, int func, int ref, int mask) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glStencilMaskSeparate(int face, int mask) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glStencilOpSeparate(int face, int fail, int zfail, int zpass) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glTexParameterfv(int target, int pname, FloatBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glTexParameteri(int target, int pname, int param) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glTexParameteriv(int target, int pname, IntBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform1f(int location, float x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform1fv(int location, int count, FloatBuffer v) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform1i(int location, int x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform1iv(int location, int count, IntBuffer v) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform2f(int location, float x, float y) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform2fv(int location, int count, FloatBuffer v) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform2i(int location, int x, int y) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform2iv(int location, int count, IntBuffer v) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform3f(int location, float x, float y, float z) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform3fv(int location, int count, FloatBuffer v) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform3i(int location, int x, int y, int z) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform3iv(int location, int count, IntBuffer v) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform4f(int location, float x, float y, float z, float w) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform4fv(int location, int count, FloatBuffer v) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform4i(int location, int x, int y, int z, int w) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniform4iv(int location, int count, IntBuffer v) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniformMatrix2fv(int location, int count, boolean transpose, FloatBuffer value) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniformMatrix3fv(int location, int count, boolean transpose, FloatBuffer value) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUniformMatrix4fv(int location, int count, boolean transpose, FloatBuffer value) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glUseProgram(int program) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glValidateProgram(int program) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glVertexAttrib1f(int indx, float x) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glVertexAttrib1fv(int indx, FloatBuffer values) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glVertexAttrib2f(int indx, float x, float y) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glVertexAttrib2fv(int indx, FloatBuffer values) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glVertexAttrib3f(int indx, float x, float y, float z) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glVertexAttrib3fv(int indx, FloatBuffer values) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glVertexAttrib4f(int indx, float x, float y, float z, float w) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glVertexAttrib4fv(int indx, FloatBuffer values) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
|
||||
Buffer ptr) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glVertexAttribPointer(int indx, int size, int type, boolean normalized, int stride,
|
||||
int ptr) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glActiveTexture(int texture) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBindTexture(int target, int texture) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glBlendFunc(int sfactor, int dfactor) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glClear(int mask) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glClearColor(float red, float green, float blue, float alpha) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glClearDepthf(float depth) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glClearStencil(int s) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glColorMask(boolean red, boolean green, boolean blue, boolean alpha) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glCompressedTexImage2D(int target, int level, int internalformat, int width,
|
||||
int height, int border, int imageSize, Buffer data) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glCompressedTexSubImage2D(int target, int level, int xoffset, int yoffset,
|
||||
int width, int height, int format, int imageSize, Buffer data) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glCopyTexImage2D(int target, int level, int internalformat, int x, int y,
|
||||
int width, int height, int border) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y,
|
||||
int width, int height) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glCullFace(int mode) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDeleteTextures(int n, IntBuffer textures) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDepthFunc(int func) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDepthMask(boolean flag) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDepthRangef(float zNear, float zFar) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDisable(int cap) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDrawArrays(int mode, int first, int count) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glDrawElements(int mode, int count, int type, Buffer indices) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glEnable(int cap) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glFinish() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glFlush() {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glFrontFace(int mode) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGenTextures(int n, IntBuffer textures) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int glGetError() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glGetIntegerv(int pname, IntBuffer params) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String glGetString(int name) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glHint(int target, int mode) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glLineWidth(float width) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glPixelStorei(int pname, int param) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glPolygonOffset(float factor, float units) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glReadPixels(int x, int y, int width, int height, int format, int type,
|
||||
Buffer pixels) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glScissor(int x, int y, int width, int height) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glStencilFunc(int func, int ref, int mask) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glStencilMask(int mask) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glStencilOp(int fail, int zfail, int zpass) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glTexImage2D(int target, int level, int internalformat, int width, int height,
|
||||
int border, int format, int type, Buffer pixels) {
|
||||
GLES20.glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glTexParameterf(int target, int pname, float param) {
|
||||
GLES20.glTexParameterf(target, pname, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width,
|
||||
int height, int format, int type, Buffer pixels) {
|
||||
GLES20.glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void glViewport(int x, int y, int width, int height) {
|
||||
GLES20.glViewport(x, y, width, height);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Copyright 2013
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License along with
|
||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package org.oscim.android.input;
|
||||
import org.oscim.backend.input.MotionEvent;
|
||||
|
||||
public class AndroidMotionEvent extends MotionEvent {
|
||||
|
||||
android.view.MotionEvent mEvent;
|
||||
|
||||
public void wrap(android.view.MotionEvent e){
|
||||
mEvent = e;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAction() {
|
||||
return mEvent.getAction();
|
||||
}
|
||||
@Override
|
||||
public float getX() {
|
||||
return mEvent.getX();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getY() {
|
||||
return mEvent.getY();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getX(int pointer) {
|
||||
return mEvent.getX(pointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getY(int pointer) {
|
||||
return mEvent.getY(pointer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPointerCount() {
|
||||
return mEvent.getPointerCount();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user