start to extract android dependency

This commit is contained in:
Hannes Janetzek 2013-08-05 00:06:35 +02:00
parent 58942dbf59
commit 10425ff232
101 changed files with 4692 additions and 1070 deletions

View File

@ -80,6 +80,10 @@ jlong JNI(alloc)(JNIEnv *env, jclass* clazz)
return (long) calloc(16, sizeof(float));
}
jobject JNI(getBuffer)(JNIEnv *env, jclass* clazz,jlong ptr){
return (*env)->NewDirectByteBuffer(env,(char*)(uintptr_t)ptr, 16*sizeof(float));
}
void JNI(delete)(JNIEnv* env, jclass* clazz, jlong ptr)
{
free(CAST(ptr));

View 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();
}
}

View File

@ -14,53 +14,45 @@
*/
package org.oscim.android;
import org.oscim.layers.overlay.OverlayItem.HotspotPlace;
import org.oscim.layers.overlay.OverlayMarker;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
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;
}
}
//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;
// }
//}

View File

@ -0,0 +1,271 @@
/*
* 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.input.AndroidMotionEvent;
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;
/**
* 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;
public static float dpi;
private final MapView mMapView;
/**
* @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");
}
//CanvasAdapter.g = AndroidCanvas;
this.setWillNotDraw(true);
DisplayMetrics metrics = getResources().getDisplayMetrics();
dpi = 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);
}
@Override
protected synchronized 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");
}
}

View File

@ -32,7 +32,7 @@ public class Compass {
if (mMapView != null) {
mMapView.getMapViewPosition().setRotation(-mAngle);
mMapView.redrawMap(true);
mMapView.updateMap(true);
}
}
}

View File

@ -12,7 +12,7 @@
* 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.renderer;
package org.oscim.android;
import org.oscim.utils.GlConfigChooser;
import org.oscim.view.MapView;
@ -23,7 +23,7 @@ import android.opengl.GLSurfaceView;
public class GLView extends GLSurfaceView {
MapView mMapView;
private GLRenderer mRenderer;
private final AndroidGLRenderer mRenderer;
public GLView(Context context, MapView mapView) {
super(context);
@ -33,10 +33,10 @@ public class GLView extends GLSurfaceView {
setEGLContextClientVersion(2);
setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS);
mRenderer = new GLRenderer(mMapView);
mRenderer = new AndroidGLRenderer(mMapView);
setRenderer(mRenderer);
if (!MapView.debugFrameTime)
//if (!MapView.debugFrameTime)
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
}
}

View File

@ -116,7 +116,7 @@ public abstract class MapActivity extends Activity {
mapPosition.setPosition(latitudeE6 / 1E6, longitudeE6 / 1E6);
mapPosition.setScale(scale);
mMapView.getMapViewPosition().setMapPosition(mapPosition);
mMapView.setMapPosition(mapPosition);
}
//String theme = sharedPreferences.getString(KEY_THEME,

View 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();
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View 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);
}
}

View File

@ -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();
}
}

View File

@ -12,7 +12,7 @@
* 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.theme.renderinstruction;
package org.oscim.backend;
import java.io.File;
import java.io.FileInputStream;
@ -20,10 +20,8 @@ import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.BitmapShader;
import android.graphics.Shader.TileMode;
import org.oscim.backend.canvas.Bitmap;
public final class BitmapUtils {
private static final String PREFIX_FILE = "file:";
@ -59,19 +57,12 @@ public final class BitmapUtils {
}
InputStream inputStream = createInputStream(src);
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
Bitmap bitmap = CanvasAdapter.g.decodeBitmap(inputStream);
inputStream.close();
return bitmap;
}
static BitmapShader createBitmapShader(String src) throws IOException {
Bitmap bitmap = BitmapUtils.createBitmap(src);
if (bitmap == null) {
return null;
}
return new BitmapShader(bitmap, TileMode.REPEAT, TileMode.REPEAT);
}
private BitmapUtils() {
throw new IllegalStateException();

View File

@ -0,0 +1,44 @@
/*
* 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.backend;
import java.io.InputStream;
import org.oscim.android.canvas.AndroidGraphics;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint;
public abstract class CanvasAdapter {
public static CanvasAdapter g = AndroidGraphics.INSTANCE;
public enum Color {
BLACK, CYAN, TRANSPARENT, WHITE;
}
public abstract Bitmap decodeBitmap(InputStream inputStream);
public abstract int getColor(Color color);
public abstract Paint getPaint();
public abstract int parseColor(String colorString);
public abstract Bitmap getBitmap(int width, int height, int format);
public abstract Canvas getCanvas();
}

View File

@ -0,0 +1,638 @@
/*******************************************************************************
* Copyright 2011 See AUTHORS file.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
******************************************************************************/
package org.oscim.backend;
import java.nio.Buffer;
import java.nio.FloatBuffer;
import java.nio.IntBuffer;
/** Interface wrapping all the methods of OpenGL ES 2.0
* @author mzechner */
public interface GL20 {
public static final int GL_ES_VERSION_2_0 = 1;
public static final int GL_DEPTH_BUFFER_BIT = 0x00000100;
public static final int GL_STENCIL_BUFFER_BIT = 0x00000400;
public static final int GL_COLOR_BUFFER_BIT = 0x00004000;
public static final int GL_FALSE = 0;
public static final int GL_TRUE = 1;
public static final int GL_POINTS = 0x0000;
public static final int GL_LINES = 0x0001;
public static final int GL_LINE_LOOP = 0x0002;
public static final int GL_LINE_STRIP = 0x0003;
public static final int GL_TRIANGLES = 0x0004;
public static final int GL_TRIANGLE_STRIP = 0x0005;
public static final int GL_TRIANGLE_FAN = 0x0006;
public static final int GL_ZERO = 0;
public static final int GL_ONE = 1;
public static final int GL_SRC_COLOR = 0x0300;
public static final int GL_ONE_MINUS_SRC_COLOR = 0x0301;
public static final int GL_SRC_ALPHA = 0x0302;
public static final int GL_ONE_MINUS_SRC_ALPHA = 0x0303;
public static final int GL_DST_ALPHA = 0x0304;
public static final int GL_ONE_MINUS_DST_ALPHA = 0x0305;
public static final int GL_DST_COLOR = 0x0306;
public static final int GL_ONE_MINUS_DST_COLOR = 0x0307;
public static final int GL_SRC_ALPHA_SATURATE = 0x0308;
public static final int GL_FUNC_ADD = 0x8006;
public static final int GL_BLEND_EQUATION = 0x8009;
public static final int GL_BLEND_EQUATION_RGB = 0x8009;
public static final int GL_BLEND_EQUATION_ALPHA = 0x883D;
public static final int GL_FUNC_SUBTRACT = 0x800A;
public static final int GL_FUNC_REVERSE_SUBTRACT = 0x800B;
public static final int GL_BLEND_DST_RGB = 0x80C8;
public static final int GL_BLEND_SRC_RGB = 0x80C9;
public static final int GL_BLEND_DST_ALPHA = 0x80CA;
public static final int GL_BLEND_SRC_ALPHA = 0x80CB;
public static final int GL_CONSTANT_COLOR = 0x8001;
public static final int GL_ONE_MINUS_CONSTANT_COLOR = 0x8002;
public static final int GL_CONSTANT_ALPHA = 0x8003;
public static final int GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004;
public static final int GL_BLEND_COLOR = 0x8005;
public static final int GL_ARRAY_BUFFER = 0x8892;
public static final int GL_ELEMENT_ARRAY_BUFFER = 0x8893;
public static final int GL_ARRAY_BUFFER_BINDING = 0x8894;
public static final int GL_ELEMENT_ARRAY_BUFFER_BINDING = 0x8895;
public static final int GL_STREAM_DRAW = 0x88E0;
public static final int GL_STATIC_DRAW = 0x88E4;
public static final int GL_DYNAMIC_DRAW = 0x88E8;
public static final int GL_BUFFER_SIZE = 0x8764;
public static final int GL_BUFFER_USAGE = 0x8765;
public static final int GL_CURRENT_VERTEX_ATTRIB = 0x8626;
public static final int GL_FRONT = 0x0404;
public static final int GL_BACK = 0x0405;
public static final int GL_FRONT_AND_BACK = 0x0408;
public static final int GL_TEXTURE_2D = 0x0DE1;
public static final int GL_CULL_FACE = 0x0B44;
public static final int GL_BLEND = 0x0BE2;
public static final int GL_DITHER = 0x0BD0;
public static final int GL_STENCIL_TEST = 0x0B90;
public static final int GL_DEPTH_TEST = 0x0B71;
public static final int GL_SCISSOR_TEST = 0x0C11;
public static final int GL_POLYGON_OFFSET_FILL = 0x8037;
public static final int GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
public static final int GL_SAMPLE_COVERAGE = 0x80A0;
public static final int GL_NO_ERROR = 0;
public static final int GL_INVALID_ENUM = 0x0500;
public static final int GL_INVALID_VALUE = 0x0501;
public static final int GL_INVALID_OPERATION = 0x0502;
public static final int GL_OUT_OF_MEMORY = 0x0505;
public static final int GL_CW = 0x0900;
public static final int GL_CCW = 0x0901;
public static final int GL_LINE_WIDTH = 0x0B21;
public static final int GL_ALIASED_POINT_SIZE_RANGE = 0x846D;
public static final int GL_ALIASED_LINE_WIDTH_RANGE = 0x846E;
public static final int GL_CULL_FACE_MODE = 0x0B45;
public static final int GL_FRONT_FACE = 0x0B46;
public static final int GL_DEPTH_RANGE = 0x0B70;
public static final int GL_DEPTH_WRITEMASK = 0x0B72;
public static final int GL_DEPTH_CLEAR_VALUE = 0x0B73;
public static final int GL_DEPTH_FUNC = 0x0B74;
public static final int GL_STENCIL_CLEAR_VALUE = 0x0B91;
public static final int GL_STENCIL_FUNC = 0x0B92;
public static final int GL_STENCIL_FAIL = 0x0B94;
public static final int GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95;
public static final int GL_STENCIL_PASS_DEPTH_PASS = 0x0B96;
public static final int GL_STENCIL_REF = 0x0B97;
public static final int GL_STENCIL_VALUE_MASK = 0x0B93;
public static final int GL_STENCIL_WRITEMASK = 0x0B98;
public static final int GL_STENCIL_BACK_FUNC = 0x8800;
public static final int GL_STENCIL_BACK_FAIL = 0x8801;
public static final int GL_STENCIL_BACK_PASS_DEPTH_FAIL = 0x8802;
public static final int GL_STENCIL_BACK_PASS_DEPTH_PASS = 0x8803;
public static final int GL_STENCIL_BACK_REF = 0x8CA3;
public static final int GL_STENCIL_BACK_VALUE_MASK = 0x8CA4;
public static final int GL_STENCIL_BACK_WRITEMASK = 0x8CA5;
public static final int GL_VIEWPORT = 0x0BA2;
public static final int GL_SCISSOR_BOX = 0x0C10;
public static final int GL_COLOR_CLEAR_VALUE = 0x0C22;
public static final int GL_COLOR_WRITEMASK = 0x0C23;
public static final int GL_UNPACK_ALIGNMENT = 0x0CF5;
public static final int GL_PACK_ALIGNMENT = 0x0D05;
public static final int GL_MAX_TEXTURE_SIZE = 0x0D33;
public static final int GL_MAX_TEXTURE_UNITS = 0x84E2;
public static final int GL_MAX_VIEWPORT_DIMS = 0x0D3A;
public static final int GL_SUBPIXEL_BITS = 0x0D50;
public static final int GL_RED_BITS = 0x0D52;
public static final int GL_GREEN_BITS = 0x0D53;
public static final int GL_BLUE_BITS = 0x0D54;
public static final int GL_ALPHA_BITS = 0x0D55;
public static final int GL_DEPTH_BITS = 0x0D56;
public static final int GL_STENCIL_BITS = 0x0D57;
public static final int GL_POLYGON_OFFSET_UNITS = 0x2A00;
public static final int GL_POLYGON_OFFSET_FACTOR = 0x8038;
public static final int GL_TEXTURE_BINDING_2D = 0x8069;
public static final int GL_SAMPLE_BUFFERS = 0x80A8;
public static final int GL_SAMPLES = 0x80A9;
public static final int GL_SAMPLE_COVERAGE_VALUE = 0x80AA;
public static final int GL_SAMPLE_COVERAGE_INVERT = 0x80AB;
public static final int GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
public static final int GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3;
public static final int GL_DONT_CARE = 0x1100;
public static final int GL_FASTEST = 0x1101;
public static final int GL_NICEST = 0x1102;
public static final int GL_GENERATE_MIPMAP_HINT = 0x8192;
public static final int GL_BYTE = 0x1400;
public static final int GL_UNSIGNED_BYTE = 0x1401;
public static final int GL_SHORT = 0x1402;
public static final int GL_UNSIGNED_SHORT = 0x1403;
public static final int GL_INT = 0x1404;
public static final int GL_UNSIGNED_INT = 0x1405;
public static final int GL_FLOAT = 0x1406;
public static final int GL_FIXED = 0x140C;
public static final int GL_DEPTH_COMPONENT = 0x1902;
public static final int GL_ALPHA = 0x1906;
public static final int GL_RGB = 0x1907;
public static final int GL_RGBA = 0x1908;
public static final int GL_LUMINANCE = 0x1909;
public static final int GL_LUMINANCE_ALPHA = 0x190A;
public static final int GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033;
public static final int GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034;
public static final int GL_UNSIGNED_SHORT_5_6_5 = 0x8363;
public static final int GL_FRAGMENT_SHADER = 0x8B30;
public static final int GL_VERTEX_SHADER = 0x8B31;
public static final int GL_MAX_VERTEX_ATTRIBS = 0x8869;
public static final int GL_MAX_VERTEX_UNIFORM_VECTORS = 0x8DFB;
public static final int GL_MAX_VARYING_VECTORS = 0x8DFC;
public static final int GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 0x8B4D;
public static final int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 0x8B4C;
public static final int GL_MAX_TEXTURE_IMAGE_UNITS = 0x8872;
public static final int GL_MAX_FRAGMENT_UNIFORM_VECTORS = 0x8DFD;
public static final int GL_SHADER_TYPE = 0x8B4F;
public static final int GL_DELETE_STATUS = 0x8B80;
public static final int GL_LINK_STATUS = 0x8B82;
public static final int GL_VALIDATE_STATUS = 0x8B83;
public static final int GL_ATTACHED_SHADERS = 0x8B85;
public static final int GL_ACTIVE_UNIFORMS = 0x8B86;
public static final int GL_ACTIVE_UNIFORM_MAX_LENGTH = 0x8B87;
public static final int GL_ACTIVE_ATTRIBUTES = 0x8B89;
public static final int GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 0x8B8A;
public static final int GL_SHADING_LANGUAGE_VERSION = 0x8B8C;
public static final int GL_CURRENT_PROGRAM = 0x8B8D;
public static final int GL_NEVER = 0x0200;
public static final int GL_LESS = 0x0201;
public static final int GL_EQUAL = 0x0202;
public static final int GL_LEQUAL = 0x0203;
public static final int GL_GREATER = 0x0204;
public static final int GL_NOTEQUAL = 0x0205;
public static final int GL_GEQUAL = 0x0206;
public static final int GL_ALWAYS = 0x0207;
public static final int GL_KEEP = 0x1E00;
public static final int GL_REPLACE = 0x1E01;
public static final int GL_INCR = 0x1E02;
public static final int GL_DECR = 0x1E03;
public static final int GL_INVERT = 0x150A;
public static final int GL_INCR_WRAP = 0x8507;
public static final int GL_DECR_WRAP = 0x8508;
public static final int GL_VENDOR = 0x1F00;
public static final int GL_RENDERER = 0x1F01;
public static final int GL_VERSION = 0x1F02;
public static final int GL_EXTENSIONS = 0x1F03;
public static final int GL_NEAREST = 0x2600;
public static final int GL_LINEAR = 0x2601;
public static final int GL_NEAREST_MIPMAP_NEAREST = 0x2700;
public static final int GL_LINEAR_MIPMAP_NEAREST = 0x2701;
public static final int GL_NEAREST_MIPMAP_LINEAR = 0x2702;
public static final int GL_LINEAR_MIPMAP_LINEAR = 0x2703;
public static final int GL_TEXTURE_MAG_FILTER = 0x2800;
public static final int GL_TEXTURE_MIN_FILTER = 0x2801;
public static final int GL_TEXTURE_WRAP_S = 0x2802;
public static final int GL_TEXTURE_WRAP_T = 0x2803;
public static final int GL_TEXTURE = 0x1702;
public static final int GL_TEXTURE_CUBE_MAP = 0x8513;
public static final int GL_TEXTURE_BINDING_CUBE_MAP = 0x8514;
public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
public static final int GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
public static final int GL_TEXTURE0 = 0x84C0;
public static final int GL_TEXTURE1 = 0x84C1;
public static final int GL_TEXTURE2 = 0x84C2;
public static final int GL_TEXTURE3 = 0x84C3;
public static final int GL_TEXTURE4 = 0x84C4;
public static final int GL_TEXTURE5 = 0x84C5;
public static final int GL_TEXTURE6 = 0x84C6;
public static final int GL_TEXTURE7 = 0x84C7;
public static final int GL_TEXTURE8 = 0x84C8;
public static final int GL_TEXTURE9 = 0x84C9;
public static final int GL_TEXTURE10 = 0x84CA;
public static final int GL_TEXTURE11 = 0x84CB;
public static final int GL_TEXTURE12 = 0x84CC;
public static final int GL_TEXTURE13 = 0x84CD;
public static final int GL_TEXTURE14 = 0x84CE;
public static final int GL_TEXTURE15 = 0x84CF;
public static final int GL_TEXTURE16 = 0x84D0;
public static final int GL_TEXTURE17 = 0x84D1;
public static final int GL_TEXTURE18 = 0x84D2;
public static final int GL_TEXTURE19 = 0x84D3;
public static final int GL_TEXTURE20 = 0x84D4;
public static final int GL_TEXTURE21 = 0x84D5;
public static final int GL_TEXTURE22 = 0x84D6;
public static final int GL_TEXTURE23 = 0x84D7;
public static final int GL_TEXTURE24 = 0x84D8;
public static final int GL_TEXTURE25 = 0x84D9;
public static final int GL_TEXTURE26 = 0x84DA;
public static final int GL_TEXTURE27 = 0x84DB;
public static final int GL_TEXTURE28 = 0x84DC;
public static final int GL_TEXTURE29 = 0x84DD;
public static final int GL_TEXTURE30 = 0x84DE;
public static final int GL_TEXTURE31 = 0x84DF;
public static final int GL_ACTIVE_TEXTURE = 0x84E0;
public static final int GL_REPEAT = 0x2901;
public static final int GL_CLAMP_TO_EDGE = 0x812F;
public static final int GL_MIRRORED_REPEAT = 0x8370;
public static final int GL_FLOAT_VEC2 = 0x8B50;
public static final int GL_FLOAT_VEC3 = 0x8B51;
public static final int GL_FLOAT_VEC4 = 0x8B52;
public static final int GL_INT_VEC2 = 0x8B53;
public static final int GL_INT_VEC3 = 0x8B54;
public static final int GL_INT_VEC4 = 0x8B55;
public static final int GL_BOOL = 0x8B56;
public static final int GL_BOOL_VEC2 = 0x8B57;
public static final int GL_BOOL_VEC3 = 0x8B58;
public static final int GL_BOOL_VEC4 = 0x8B59;
public static final int GL_FLOAT_MAT2 = 0x8B5A;
public static final int GL_FLOAT_MAT3 = 0x8B5B;
public static final int GL_FLOAT_MAT4 = 0x8B5C;
public static final int GL_SAMPLER_2D = 0x8B5E;
public static final int GL_SAMPLER_CUBE = 0x8B60;
public static final int GL_VERTEX_ATTRIB_ARRAY_ENABLED = 0x8622;
public static final int GL_VERTEX_ATTRIB_ARRAY_SIZE = 0x8623;
public static final int GL_VERTEX_ATTRIB_ARRAY_STRIDE = 0x8624;
public static final int GL_VERTEX_ATTRIB_ARRAY_TYPE = 0x8625;
public static final int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = 0x886A;
public static final int GL_VERTEX_ATTRIB_ARRAY_POINTER = 0x8645;
public static final int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 0x889F;
public static final int GL_IMPLEMENTATION_COLOR_READ_TYPE = 0x8B9A;
public static final int GL_IMPLEMENTATION_COLOR_READ_FORMAT = 0x8B9B;
public static final int GL_COMPILE_STATUS = 0x8B81;
public static final int GL_INFO_LOG_LENGTH = 0x8B84;
public static final int GL_SHADER_SOURCE_LENGTH = 0x8B88;
public static final int GL_SHADER_COMPILER = 0x8DFA;
public static final int GL_SHADER_BINARY_FORMATS = 0x8DF8;
public static final int GL_NUM_SHADER_BINARY_FORMATS = 0x8DF9;
public static final int GL_LOW_FLOAT = 0x8DF0;
public static final int GL_MEDIUM_FLOAT = 0x8DF1;
public static final int GL_HIGH_FLOAT = 0x8DF2;
public static final int GL_LOW_INT = 0x8DF3;
public static final int GL_MEDIUM_INT = 0x8DF4;
public static final int GL_HIGH_INT = 0x8DF5;
public static final int GL_FRAMEBUFFER = 0x8D40;
public static final int GL_RENDERBUFFER = 0x8D41;
public static final int GL_RGBA4 = 0x8056;
public static final int GL_RGB5_A1 = 0x8057;
public static final int GL_RGB565 = 0x8D62;
public static final int GL_DEPTH_COMPONENT16 = 0x81A5;
public static final int GL_STENCIL_INDEX = 0x1901;
public static final int GL_STENCIL_INDEX8 = 0x8D48;
public static final int GL_RENDERBUFFER_WIDTH = 0x8D42;
public static final int GL_RENDERBUFFER_HEIGHT = 0x8D43;
public static final int GL_RENDERBUFFER_INTERNAL_FORMAT = 0x8D44;
public static final int GL_RENDERBUFFER_RED_SIZE = 0x8D50;
public static final int GL_RENDERBUFFER_GREEN_SIZE = 0x8D51;
public static final int GL_RENDERBUFFER_BLUE_SIZE = 0x8D52;
public static final int GL_RENDERBUFFER_ALPHA_SIZE = 0x8D53;
public static final int GL_RENDERBUFFER_DEPTH_SIZE = 0x8D54;
public static final int GL_RENDERBUFFER_STENCIL_SIZE = 0x8D55;
public static final int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE = 0x8CD0;
public static final int GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME = 0x8CD1;
public static final int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL = 0x8CD2;
public static final int GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE = 0x8CD3;
public static final int GL_COLOR_ATTACHMENT0 = 0x8CE0;
public static final int GL_DEPTH_ATTACHMENT = 0x8D00;
public static final int GL_STENCIL_ATTACHMENT = 0x8D20;
public static final int GL_NONE = 0;
public static final int GL_FRAMEBUFFER_COMPLETE = 0x8CD5;
public static final int GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = 0x8CD6;
public static final int GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = 0x8CD7;
public static final int GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS = 0x8CD9;
public static final int GL_FRAMEBUFFER_UNSUPPORTED = 0x8CDD;
public static final int GL_FRAMEBUFFER_BINDING = 0x8CA6;
public static final int GL_RENDERBUFFER_BINDING = 0x8CA7;
public static final int GL_MAX_RENDERBUFFER_SIZE = 0x84E8;
public static final int GL_INVALID_FRAMEBUFFER_OPERATION = 0x0506;
public static final int GL_VERTEX_PROGRAM_POINT_SIZE = 0x8642;
// Extensions
public static final int GL_COVERAGE_BUFFER_BIT_NV = 0x8000;
public void glAttachShader (int program, int shader);
public void glBindAttribLocation (int program, int index, String name);
public void glBindBuffer (int target, int buffer);
public void glBindFramebuffer (int target, int framebuffer);
public void glBindRenderbuffer (int target, int renderbuffer);
public void glBlendColor (float red, float green, float blue, float alpha);
public void glBlendEquation (int mode);
public void glBlendEquationSeparate (int modeRGB, int modeAlpha);
public void glBlendFuncSeparate (int srcRGB, int dstRGB, int srcAlpha, int dstAlpha);
public void glBufferData (int target, int size, Buffer data, int usage);
public void glBufferSubData (int target, int offset, int size, Buffer data);
public int glCheckFramebufferStatus (int target);
public void glCompileShader (int shader);
public int glCreateProgram ();
public int glCreateShader (int type);
public void glDeleteBuffers (int n, IntBuffer buffers);
public void glDeleteFramebuffers (int n, IntBuffer framebuffers);
public void glDeleteProgram (int program);
public void glDeleteRenderbuffers (int n, IntBuffer renderbuffers);
public void glDeleteShader (int shader);
public void glDetachShader (int program, int shader);
public void glDisableVertexAttribArray (int index);
public void glDrawElements (int mode, int count, int type, int indices);
public void glEnableVertexAttribArray (int index);
public void glFramebufferRenderbuffer (int target, int attachment, int renderbuffertarget, int renderbuffer);
public void glFramebufferTexture2D (int target, int attachment, int textarget, int texture, int level);
public void glGenBuffers (int n, IntBuffer buffers);
public void glGenerateMipmap (int target);
public void glGenFramebuffers (int n, IntBuffer framebuffers);
public void glGenRenderbuffers (int n, IntBuffer renderbuffers);
// deviates
public String glGetActiveAttrib (int program, int index, IntBuffer size, Buffer type);
// deviates
public String glGetActiveUniform (int program, int index, IntBuffer size, Buffer type);
public void glGetAttachedShaders (int program, int maxcount, Buffer count, IntBuffer shaders);
public int glGetAttribLocation (int program, String name);
public void glGetBooleanv (int pname, Buffer params);
public void glGetBufferParameteriv (int target, int pname, IntBuffer params);
public void glGetFloatv (int pname, FloatBuffer params);
public void glGetFramebufferAttachmentParameteriv (int target, int attachment, int pname, IntBuffer params);
public void glGetProgramiv (int program, int pname, IntBuffer params);
// deviates
public String glGetProgramInfoLog (int program);
public void glGetRenderbufferParameteriv (int target, int pname, IntBuffer params);
public void glGetShaderiv (int shader, int pname, IntBuffer params);
// deviates
public String glGetShaderInfoLog (int shader);
public void glGetShaderPrecisionFormat (int shadertype, int precisiontype, IntBuffer range, IntBuffer precision);
public void glGetShaderSource (int shader, int bufsize, Buffer length, String source);
public void glGetTexParameterfv (int target, int pname, FloatBuffer params);
public void glGetTexParameteriv (int target, int pname, IntBuffer params);
public void glGetUniformfv (int program, int location, FloatBuffer params);
public void glGetUniformiv (int program, int location, IntBuffer params);
public int glGetUniformLocation (int program, String name);
public void glGetVertexAttribfv (int index, int pname, FloatBuffer params);
public void glGetVertexAttribiv (int index, int pname, IntBuffer params);
public void glGetVertexAttribPointerv (int index, int pname, Buffer pointer);
public boolean glIsBuffer (int buffer);
public boolean glIsEnabled (int cap);
public boolean glIsFramebuffer (int framebuffer);
public boolean glIsProgram (int program);
public boolean glIsRenderbuffer (int renderbuffer);
public boolean glIsShader (int shader);
public boolean glIsTexture (int texture);
public void glLinkProgram (int program);
public void glReleaseShaderCompiler ();
public void glRenderbufferStorage (int target, int internalformat, int width, int height);
public void glSampleCoverage (float value, boolean invert);
public void glShaderBinary (int n, IntBuffer shaders, int binaryformat, Buffer binary, int length);
// Deviates
public void glShaderSource (int shader, String string);
public void glStencilFuncSeparate (int face, int func, int ref, int mask);
public void glStencilMaskSeparate (int face, int mask);
public void glStencilOpSeparate (int face, int fail, int zfail, int zpass);
public void glTexParameterfv (int target, int pname, FloatBuffer params);
public void glTexParameteri (int target, int pname, int param);
public void glTexParameteriv (int target, int pname, IntBuffer params);
public void glUniform1f (int location, float x);
public void glUniform1fv (int location, int count, FloatBuffer v);
public void glUniform1i (int location, int x);
public void glUniform1iv (int location, int count, IntBuffer v);
public void glUniform2f (int location, float x, float y);
public void glUniform2fv (int location, int count, FloatBuffer v);
public void glUniform2i (int location, int x, int y);
public void glUniform2iv (int location, int count, IntBuffer v);
public void glUniform3f (int location, float x, float y, float z);
public void glUniform3fv (int location, int count, FloatBuffer v);
public void glUniform3i (int location, int x, int y, int z);
public void glUniform3iv (int location, int count, IntBuffer v);
public void glUniform4f (int location, float x, float y, float z, float w);
public void glUniform4fv (int location, int count, FloatBuffer v);
public void glUniform4i (int location, int x, int y, int z, int w);
public void glUniform4iv (int location, int count, IntBuffer v);
public void glUniformMatrix2fv (int location, int count, boolean transpose, FloatBuffer value);
public void glUniformMatrix3fv (int location, int count, boolean transpose, FloatBuffer value);
public void glUniformMatrix4fv (int location, int count, boolean transpose, FloatBuffer value);
public void glUseProgram (int program);
public void glValidateProgram (int program);
public void glVertexAttrib1f (int indx, float x);
public void glVertexAttrib1fv (int indx, FloatBuffer values);
public void glVertexAttrib2f (int indx, float x, float y);
public void glVertexAttrib2fv (int indx, FloatBuffer values);
public void glVertexAttrib3f (int indx, float x, float y, float z);
public void glVertexAttrib3fv (int indx, FloatBuffer values);
public void glVertexAttrib4f (int indx, float x, float y, float z, float w);
public void glVertexAttrib4fv (int indx, FloatBuffer values);
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, Buffer ptr);
public void glVertexAttribPointer (int indx, int size, int type, boolean normalized, int stride, int ptr);
//------------------------
public static final int GL_GENERATE_MIPMAP = 0x8191;
public static final int GL_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FE;
public static final int GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
public void glActiveTexture (int texture);
public void glBindTexture (int target, int texture);
public void glBlendFunc (int sfactor, int dfactor);
public void glClear (int mask);
public void glClearColor (float red, float green, float blue, float alpha);
public void glClearDepthf (float depth);
public void glClearStencil (int s);
public void glColorMask (boolean red, boolean green, boolean blue, boolean alpha);
public void glCompressedTexImage2D (int target, int level, int internalformat, int width, int height, int border,
int imageSize, Buffer data);
public void glCompressedTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format,
int imageSize, Buffer data);
public void glCopyTexImage2D (int target, int level, int internalformat, int x, int y, int width, int height, int border);
public void glCopyTexSubImage2D (int target, int level, int xoffset, int yoffset, int x, int y, int width, int height);
public void glCullFace (int mode);
public void glDeleteTextures (int n, IntBuffer textures);
public void glDepthFunc (int func);
public void glDepthMask (boolean flag);
public void glDepthRangef (float zNear, float zFar);
public void glDisable (int cap);
public void glDrawArrays (int mode, int first, int count);
public void glDrawElements (int mode, int count, int type, Buffer indices);
public void glEnable (int cap);
public void glFinish ();
public void glFlush ();
public void glFrontFace (int mode);
public void glGenTextures (int n, IntBuffer textures);
public int glGetError ();
public void glGetIntegerv (int pname, IntBuffer params);
public String glGetString (int name);
public void glHint (int target, int mode);
public void glLineWidth (float width);
public void glPixelStorei (int pname, int param);
public void glPolygonOffset (float factor, float units);
public void glReadPixels (int x, int y, int width, int height, int format, int type, Buffer pixels);
public void glScissor (int x, int y, int width, int height);
public void glStencilFunc (int func, int ref, int mask);
public void glStencilMask (int mask);
public void glStencilOp (int fail, int zfail, int zpass);
public void glTexImage2D (int target, int level, int internalformat, int width, int height, int border, int format, int type,
Buffer pixels);
public void glTexParameterf (int target, int pname, float param);
public void glTexSubImage2D (int target, int level, int xoffset, int yoffset, int width, int height, int format, int type,
Buffer pixels);
public void glViewport (int x, int y, int width, int height);
}

View File

@ -0,0 +1,19 @@
/*
* 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.backend;
public class GLAdapter {
}

View File

@ -0,0 +1,19 @@
/*
* 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.backend;
public class InputAdapter {
}

View File

@ -0,0 +1,31 @@
/*
* 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.backend;
public class Log {
public static void d(String tag, String msg){
android.util.Log.d(tag, msg);
}
public static void w(String tag, String msg){
android.util.Log.w(tag, msg);
}
public static void e(String tag, String msg){
android.util.Log.e(tag, msg);
}
public static void i(String tag, String msg){
android.util.Log.i(tag, msg);
}
}

View File

@ -0,0 +1,25 @@
/*
* 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.backend.canvas;
public interface Bitmap {
int getWidth();
int getHeight();
void recycle();
int[] getPixels();
void eraseColor(int color);
int uploadToTexture(boolean replace);
}

View File

@ -0,0 +1,12 @@
package org.oscim.backend.canvas;
public interface Canvas {
void setBitmap(Bitmap bitmap);
void drawText(String string, float f, float yy, Paint stroke);
void drawBitmap(Bitmap bitmap, float x, float y);
}

View File

@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.oscim.graphics;
package org.oscim.backend.canvas;
public class Color {
public static final int BLACK = 0xFF000000;
@ -29,6 +29,9 @@ public class Color {
public static final int MAGENTA = 0xFFFF00FF;
public static final int TRANSPARENT = 0;
public static int get(int r, int g ,int b){
return 0xff << 24 | r << 16 | g << 8 | b;
}
/**
* Parse the color string, and return the corresponding color-int.

View File

@ -12,7 +12,7 @@
* 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.graphics;
package org.oscim.backend.canvas;
public interface Paint {
@ -36,33 +36,33 @@ public interface Paint {
BOLD, BOLD_ITALIC, ITALIC, NORMAL;
}
// int getColor();
//
// int getTextHeight(String text);
//
// int getTextWidth(String text);
//
// void setBitmapShader(Bitmap bitmap);
//
// void setColor(int color);
//
// void setDashPathEffect(float[] strokeDasharray);
//
// void setStrokeCap(Cap cap);
//
// void setStrokeWidth(float width);
//
// void setStyle(Style style);
//
// void setTextAlign(Align align);
//
// void setTextSize(float textSize);
//
// void setTypeface(FontFamily fontFamily, FontStyle fontStyle);
//
// float measureText(String text);
//
// float getFontHeight();
//
// float getFontDescent();
int getColor();
int getTextHeight(String text);
int getTextWidth(String text);
void setBitmapShader(Bitmap bitmap);
void setColor(int color);
void setDashPathEffect(float[] strokeDasharray);
void setStrokeCap(Cap cap);
void setStrokeWidth(float width);
void setStyle(Style style);
void setTextAlign(Align align);
void setTextSize(float textSize);
void setTypeface(FontFamily fontFamily, FontStyle fontStyle);
float measureText(String text);
float getFontHeight();
float getFontDescent();
}

View File

@ -0,0 +1,19 @@
/*
* 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.backend.input;
public class KeyEvent {
}

View File

@ -0,0 +1,61 @@
/*
* 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.backend.input;
public class MotionEvent {
public static final int ACTION_DOWN = 0;
public static final int ACTION_UP = 1;
public static final int ACTION_MOVE = 2;
public static final int ACTION_CANCEL = 3;
public static final int ACTION_POINTER_DOWN = 5;
public static final int ACTION_POINTER_UP = 6;
public static final int ACTION_MASK = 0xff;
public static final int ACTION_POINTER_INDEX_MASK = 0xff00;
public static final int ACTION_POINTER_INDEX_SHIFT = 8;
public int getAction() {
// TODO Auto-generated method stub
return 0;
}
public float getX() {
// TODO Auto-generated method stub
return 0;
}
public float getY() {
// TODO Auto-generated method stub
return 0;
}
public float getX(int idx) {
// TODO Auto-generated method stub
return 0;
}
public float getY(int idx) {
// TODO Auto-generated method stub
return 0;
}
public int getPointerCount() {
// TODO Auto-generated method stub
return 0;
}
}

View File

@ -23,6 +23,13 @@ public class PointD {
this.x = x;
this.y = y;
}
public double getX(){
return x;
}
public double getY(){
return y;
}
@Override
public String toString(){
return x + " " + y;

View File

@ -15,11 +15,10 @@
*/
package org.oscim.layers;
import org.oscim.backend.input.KeyEvent;
import org.oscim.backend.input.MotionEvent;
import org.oscim.view.MapView;
import android.view.KeyEvent;
import android.view.MotionEvent;
public abstract class InputLayer extends Layer {
public InputLayer(MapView mapView) {
@ -65,11 +64,11 @@ public abstract class InputLayer extends Layer {
* you returned <code>true</code> none of the following Overlays or the
* underlying {@link MapView} has the chance to handle this event.
*
* @param e
* @param event
* ...
* @return ...
*/
public boolean onTouchEvent(MotionEvent e) {
public boolean onTouchEvent(MotionEvent event) {
return false;
}

View File

@ -14,9 +14,9 @@
*/
package org.oscim.layers;
import org.oscim.view.MapView;
import org.oscim.core.MapPosition;
import org.oscim.renderer.RenderLayer;
import org.oscim.view.MapView;
public abstract class Layer {
public Layer(MapView mapView) {

View File

@ -14,12 +14,12 @@
*/
package org.oscim.layers;
import org.oscim.backend.input.MotionEvent;
import org.oscim.core.Tile;
import org.oscim.view.MapView;
import org.oscim.view.MapViewPosition;
import android.util.Log;
import android.view.MotionEvent;
import org.oscim.backend.Log;
/**
* Changes MapViewPosition for scroll, fling, scale, rotation and tilt gestures
@ -125,7 +125,7 @@ public class MapEventLayer extends InputLayer {
if (debug)
Log.d(TAG, "tap scale: " + mx + " " + my);
mMapPosition.scaleMap(1 - my / (height / 8), 0, 0);
mMapView.redrawMap(true);
mMapView.updateMap(true);
mPrevX = x1;
mPrevY = y1;
@ -214,7 +214,7 @@ public class MapEventLayer extends InputLayer {
}
if (changed) {
mMapView.redrawMap(true);
mMapView.updateMap(true);
mPrevPinchWidth = pinchWidth;
mPrevX2 = x2;
@ -266,7 +266,7 @@ public class MapEventLayer extends InputLayer {
if (e2.getPointerCount() == 1) {
mMapPosition.moveMap(-distanceX, -distanceY);
mMapView.redrawMap(true);
mMapView.updateMap(true);
return true;
}

View File

@ -14,7 +14,7 @@
*/
package org.oscim.layers.labeling;
import org.oscim.graphics.Color;
import org.oscim.backend.canvas.Color;
import org.oscim.renderer.sublayers.Layers;
import org.oscim.renderer.sublayers.LineLayer;
import org.oscim.renderer.sublayers.TextItem;

View File

@ -14,13 +14,13 @@
*/
package org.oscim.layers.labeling;
import org.oscim.backend.input.MotionEvent;
import org.oscim.core.MapPosition;
import org.oscim.layers.InputLayer;
import org.oscim.layers.tile.TileRenderLayer;
import org.oscim.view.MapView;
import android.util.Log;
import android.view.MotionEvent;
import org.oscim.backend.Log;
public class LabelLayer extends InputLayer {
private final static String TAG = LabelLayer.class.getName();

View File

@ -14,13 +14,13 @@
*/
package org.oscim.layers.overlay;
import org.oscim.backend.input.MotionEvent;
import org.oscim.core.MapPosition;
import org.oscim.renderer.layers.ExtrusionRenderLayer;
import org.oscim.view.MapView;
import android.os.CountDownTimer;
import android.util.Log;
import android.view.MotionEvent;
import org.oscim.backend.Log;
/**
* @author Hannes Janetzek

View File

@ -14,8 +14,8 @@
*/
package org.oscim.layers.overlay;
import org.oscim.renderer.RenderLayer;
import org.oscim.view.MapView;
import org.oscim.renderer.RenderLayer;
public class GenericOverlay extends Overlay {
/**

View File

@ -17,13 +17,12 @@ package org.oscim.layers.overlay;
import java.util.List;
import org.oscim.backend.input.MotionEvent;
import org.oscim.core.BoundingBox;
import org.oscim.core.PointF;
import org.oscim.view.MapView;
import org.oscim.view.MapViewPosition;
import android.view.MotionEvent;
public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverlay<Item> {
//private static final String TAG = ItemizedIconOverlay.class.getName();
@ -31,18 +30,31 @@ public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverl
protected OnItemGestureListener<Item> mOnItemGestureListener;
private int mDrawnItemsLimit = Integer.MAX_VALUE;
private final PointF mItemPoint = new PointF();
private final PointF mTmpPoint = new PointF();
public ItemizedIconOverlay(MapView mapView, List<Item> list, OverlayMarker defaultMarker,
ItemizedIconOverlay.OnItemGestureListener<Item> onItemGestureListener) {
public ItemizedIconOverlay(
final MapView mapView,
final List<Item> pList,
final OverlayMarker pDefaultMarker,
final ItemizedIconOverlay.OnItemGestureListener<Item> pOnItemGestureListener) {
super(mapView, defaultMarker);
super(mapView, pDefaultMarker);
this.mItemList = list;
this.mOnItemGestureListener = onItemGestureListener;
this.mItemList = pList;
this.mOnItemGestureListener = pOnItemGestureListener;
populate();
}
// public ItemizedIconOverlay(
// final MapView mapView,
// final Context pContext,
// final List<Item> pList,
// final ItemizedIconOverlay.OnItemGestureListener<Item> pOnItemGestureListener) {
// this(mapView, pList,
// null, //pContext.getResources().getDrawable(R.drawable.marker_default),
// pOnItemGestureListener);
// }
@Override
public boolean onSnapToItem(final int pX, final int pY, final PointF pSnapPoint) {
// TODO Implement this!
@ -124,7 +136,6 @@ public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverl
return onSingleTapUpHelper(index, that.mItemList.get(index));
}
};
@Override
public boolean onLongPress(final MotionEvent event) {
return activateSelectedItems(event, mActiveItemLongPress) || super.onLongPress(event);
@ -172,23 +183,17 @@ public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverl
for (int i = 0; i < size; i++) {
Item item = getItem(i);
if (!bbox.contains(item.mGeoPoint)) {
//Log.d(TAG, "skip: " + item.getTitle());
if (!bbox.contains(item.mGeoPoint))
continue;
}
// final Drawable marker = (item.getMarker(0) == null) ? this.mDefaultMarker : item
// .getMarker(0);
// TODO use intermediate projection
mapViewPosition.project(item.getPoint(), mItemPoint);
mapViewPosition.project(item.getPoint(), mTmpPoint);
float dx = mItemPoint.x - eventX;
float dy = mItemPoint.y - eventY;
//Log.d(TAG, item.getTitle() + " " + mItemPoint + " " + dx + "/" + dy);
float dx = mTmpPoint.x - eventX;
float dy = mTmpPoint.y - eventY;
double d = dx * dx + dy * dy;
// squared dist: 50*50 pixel
if (d < 2500) {
if (d < dist) {
@ -205,10 +210,6 @@ public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverl
return false;
}
// ===========================================================
// Getter & Setter
// ===========================================================
public int getDrawnItemsLimit() {
return this.mDrawnItemsLimit;
}
@ -217,10 +218,6 @@ public class ItemizedIconOverlay<Item extends OverlayItem> extends ItemizedOverl
this.mDrawnItemsLimit = aLimit;
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
/**
* When the item is touched one of these methods may be invoked depending on
* the type of touch. Each of them returns true if the event was completely

View File

@ -21,8 +21,6 @@ package org.oscim.layers.overlay;
// - and to make this work for multiple overlays
// a global scenegraph is probably required.
import org.oscim.android.AndroidGraphics;
import org.oscim.app.R;
import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection;
import org.oscim.core.PointD;
@ -164,7 +162,7 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
state = OverlayItem.ITEM_STATE_FOCUSED_MASK;
//Drawable marker = it.item.getDrawable();
OverlayMarker marker = it.item.getMarker(0);
OverlayMarker marker = it.item.getMarker();
if (marker == null)
marker = mDefaultMarker;
@ -218,11 +216,11 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
public ItemizedOverlay(MapView mapView, OverlayMarker defaultMarker) {
super(mapView);
if (defaultMarker == null) {
defaultMarker = AndroidGraphics.makeMarker(mapView.getContext().getResources()
.getDrawable(R.drawable.marker_default), null);
//throw new IllegalArgumentException("You must pass a default marker to ItemizedOverlay.");
}
// if (defaultMarker == null) {
// defaultMarker = AndroidGraphics.makeMarker(mapView.getContext().getResources()
// .getDrawable(R.drawable.marker_default), null);
// //throw new IllegalArgumentException("You must pass a default marker to ItemizedOverlay.");
// }
//this.mDefaultMarker = OverlayMarker.makeMarker(pDefaultMarker, null);
mDefaultMarker = defaultMarker;

View File

@ -1,271 +1,271 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
* 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.layers.overlay;
import java.util.HashMap;
import java.util.Map;
import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection;
import org.oscim.layers.Layer;
import org.oscim.renderer.layers.BitmapRenderLayer;
import org.oscim.view.MapView;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Typeface;
/**
* A MapScaleBar displays the ratio of a distance on the map to the
* corresponding distance on the ground.
*/
public class MapScaleBar extends Layer {
private static final int BITMAP_HEIGHT = 64;
private static final int BITMAP_WIDTH = 128;
private static final double LATITUDE_REDRAW_THRESHOLD = 0.2;
// private static final int MARGIN_BOTTOM = 5;
// private static final int MARGIN_LEFT = 5;
private static final double METER_FOOT_RATIO = 0.3048;
private static final int ONE_KILOMETER = 1000;
private static final int ONE_MILE = 5280;
private static final Paint SCALE_BAR = new Paint(Paint.ANTI_ALIAS_FLAG);
private static final Paint SCALE_BAR_STROKE = new Paint(Paint.ANTI_ALIAS_FLAG);
private static final Paint SCALE_TEXT = new Paint(Paint.ANTI_ALIAS_FLAG);
private static final Paint SCALE_TEXT_STROKE = new Paint(Paint.ANTI_ALIAS_FLAG);
private static final int[] SCALE_BAR_VALUES_IMPERIAL = {
26400000, 10560000, 5280000,
2640000, 1056000, 528000,
264000, 105600, 52800, 26400,
10560, 5280, 2000, 1000, 500,
200, 100, 50, 20,
10, 5, 2, 1 };
private static final int[] SCALE_BAR_VALUES_METRIC = {
10000000, 5000000, 2000000, 1000000,
500000, 200000, 100000, 50000,
20000, 10000, 5000, 2000, 1000,
500, 200, 100, 50, 20, 10, 5, 2, 1 };
private boolean mImperialUnits;
private final Canvas mMapScaleCanvas;
private boolean mRedrawNeeded;
private double mPrevLatitude = -1;
private final double mPrevScale = -1;
private final Map<TextField, String> mTextFields;
private final Bitmap mMapScaleBitmap;
private final BitmapRenderLayer mBitmapLayer;
public MapScaleBar(MapView mapView) {
super(mapView);
mMapScaleBitmap = Bitmap.createBitmap(
BITMAP_WIDTH, BITMAP_HEIGHT,
Bitmap.Config.ARGB_8888);
mMapScaleCanvas = new Canvas(mMapScaleBitmap);
mTextFields = new HashMap<TextField, String>();
setDefaultTexts();
configurePaints();
mRedrawNeeded = true;
mLayer = mBitmapLayer = new BitmapRenderLayer(mapView);
mBitmapLayer.setBitmap(mMapScaleBitmap, 0, 0,
(int)(BITMAP_WIDTH * 1.2f),
(int)(BITMAP_HEIGHT * 1.2f));
}
@Override
public void onUpdate(MapPosition mapPosition, boolean changed, boolean clear) {
double latitude = MercatorProjection.toLatitude(mapPosition.y);
if (!mRedrawNeeded) {
double scaleDiff = mPrevScale / mapPosition.scale;
if (scaleDiff < 1.1 && scaleDiff > 0.9) {
double latitudeDiff = Math.abs(mPrevLatitude - latitude);
if (latitudeDiff < LATITUDE_REDRAW_THRESHOLD)
return;
}
}
mPrevLatitude = latitude;
double groundResolution = MercatorProjection.calculateGroundResolution(
latitude, mapPosition.scale);
int[] scaleBarValues;
if (mImperialUnits) {
groundResolution = groundResolution / METER_FOOT_RATIO;
scaleBarValues = SCALE_BAR_VALUES_IMPERIAL;
} else {
scaleBarValues = SCALE_BAR_VALUES_METRIC;
}
float scaleBarLength = 0;
int mapScaleValue = 0;
for (int i = 0; i < scaleBarValues.length; ++i) {
mapScaleValue = scaleBarValues[i];
scaleBarLength = mapScaleValue / (float) groundResolution;
if (scaleBarLength < (BITMAP_WIDTH - 10)) {
break;
}
}
synchronized (mMapScaleBitmap) {
redrawMapScaleBitmap(scaleBarLength, mapScaleValue);
}
mBitmapLayer.updateBitmap();
mRedrawNeeded = false;
}
/**
* @return true if imperial units are used, false otherwise.
*/
public boolean isImperialUnits() {
return mImperialUnits;
}
/**
* @param imperialUnits
* true if imperial units should be used rather than metric
* units.
*/
public void setImperialUnits(boolean imperialUnits) {
mImperialUnits = imperialUnits;
mRedrawNeeded = true;
}
/**
* Overrides the specified text field with the given string.
*
* @param textField
* the text field to override.
* @param value
* the new value of the text field.
*/
public void setText(TextField textField, String value) {
mTextFields.put(textField, value);
mRedrawNeeded = true;
}
private void drawScaleBar(float scaleBarLength, Paint paint) {
mMapScaleCanvas.drawLine(7, 25, scaleBarLength + 3, 25, paint);
mMapScaleCanvas.drawLine(5, 10, 5, 40, paint);
mMapScaleCanvas.drawLine(scaleBarLength + 5, 10, scaleBarLength + 5, 40, paint);
}
private void drawScaleText(int scaleValue, String unitSymbol, Paint paint) {
mMapScaleCanvas.drawText(scaleValue + unitSymbol, 12, 18, paint);
}
/**
* Redraws the map scale bitmap with the given parameters.
*
* @param scaleBarLength
* the length of the map scale bar in pixels.
* @param mapScaleValue
* the map scale value in meters.
*/
private void redrawMapScaleBitmap(float scaleBarLength, int mapScaleValue) {
mMapScaleBitmap.eraseColor(Color.TRANSPARENT);
// draw the scale bar
drawScaleBar(scaleBarLength, SCALE_BAR_STROKE);
drawScaleBar(scaleBarLength, SCALE_BAR);
int scaleValue;
String unitSymbol;
if (mImperialUnits) {
if (mapScaleValue < ONE_MILE) {
scaleValue = mapScaleValue;
unitSymbol = mTextFields.get(TextField.FOOT);
} else {
scaleValue = mapScaleValue / ONE_MILE;
unitSymbol = mTextFields.get(TextField.MILE);
}
} else {
if (mapScaleValue < ONE_KILOMETER) {
scaleValue = mapScaleValue;
unitSymbol = mTextFields.get(TextField.METER);
} else {
scaleValue = mapScaleValue / ONE_KILOMETER;
unitSymbol = mTextFields.get(TextField.KILOMETER);
}
}
// draw the scale text
drawScaleText(scaleValue, unitSymbol, SCALE_TEXT_STROKE);
drawScaleText(scaleValue, unitSymbol, SCALE_TEXT);
}
private void setDefaultTexts() {
mTextFields.put(TextField.FOOT, " ft");
mTextFields.put(TextField.MILE, " mi");
mTextFields.put(TextField.METER, " m");
mTextFields.put(TextField.KILOMETER, " km");
}
private static void configurePaints() {
SCALE_BAR.setStrokeWidth(2);
SCALE_BAR.setStrokeCap(Paint.Cap.SQUARE);
SCALE_BAR.setColor(Color.BLACK);
SCALE_BAR_STROKE.setStrokeWidth(5);
SCALE_BAR_STROKE.setStrokeCap(Paint.Cap.SQUARE);
SCALE_BAR_STROKE.setColor(Color.WHITE);
SCALE_TEXT.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
SCALE_TEXT.setTextSize(17);
SCALE_TEXT.setColor(Color.BLACK);
SCALE_TEXT_STROKE.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
SCALE_TEXT_STROKE.setStyle(Paint.Style.STROKE);
SCALE_TEXT_STROKE.setColor(Color.WHITE);
SCALE_TEXT_STROKE.setStrokeWidth(2);
SCALE_TEXT_STROKE.setTextSize(17);
}
/**
* Enumeration of all text fields.
*/
public enum TextField {
/**
* Unit symbol for one foot.
*/
FOOT,
/**
* Unit symbol for one kilometer.
*/
KILOMETER,
/**
* Unit symbol for one meter.
*/
METER,
/**
* Unit symbol for one mile.
*/
MILE;
}
}
///*
// * Copyright 2010, 2011, 2012 mapsforge.org
// * 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.layers.overlay;
//
//import java.util.HashMap;
//import java.util.Map;
//
//import org.oscim.core.MapPosition;
//import org.oscim.core.MercatorProjection;
//import org.oscim.layers.Layer;
//import org.oscim.renderer.layers.BitmapRenderLayer;
//import org.oscim.view.MapView;
//
//import android.graphics.Bitmap;
//import android.graphics.Canvas;
//import android.graphics.Color;
//import android.graphics.Paint;
//import android.graphics.Typeface;
//
///**
// * A MapScaleBar displays the ratio of a distance on the map to the
// * corresponding distance on the ground.
// */
//public class MapScaleBar extends Layer {
//
// private static final int BITMAP_HEIGHT = 64;
// private static final int BITMAP_WIDTH = 128;
// private static final double LATITUDE_REDRAW_THRESHOLD = 0.2;
// // private static final int MARGIN_BOTTOM = 5;
// // private static final int MARGIN_LEFT = 5;
//
// private static final double METER_FOOT_RATIO = 0.3048;
// private static final int ONE_KILOMETER = 1000;
// private static final int ONE_MILE = 5280;
//
// private static final Paint SCALE_BAR = new Paint(Paint.ANTI_ALIAS_FLAG);
// private static final Paint SCALE_BAR_STROKE = new Paint(Paint.ANTI_ALIAS_FLAG);
// private static final Paint SCALE_TEXT = new Paint(Paint.ANTI_ALIAS_FLAG);
// private static final Paint SCALE_TEXT_STROKE = new Paint(Paint.ANTI_ALIAS_FLAG);
//
// private static final int[] SCALE_BAR_VALUES_IMPERIAL = {
// 26400000, 10560000, 5280000,
// 2640000, 1056000, 528000,
// 264000, 105600, 52800, 26400,
// 10560, 5280, 2000, 1000, 500,
// 200, 100, 50, 20,
// 10, 5, 2, 1 };
// private static final int[] SCALE_BAR_VALUES_METRIC = {
// 10000000, 5000000, 2000000, 1000000,
// 500000, 200000, 100000, 50000,
// 20000, 10000, 5000, 2000, 1000,
// 500, 200, 100, 50, 20, 10, 5, 2, 1 };
//
// private boolean mImperialUnits;
// private final Canvas mMapScaleCanvas;
// private boolean mRedrawNeeded;
// private double mPrevLatitude = -1;
// private final double mPrevScale = -1;
// private final Map<TextField, String> mTextFields;
//
// private final Bitmap mMapScaleBitmap;
// private final BitmapRenderLayer mBitmapLayer;
//
// public MapScaleBar(MapView mapView) {
// super(mapView);
//
// mMapScaleBitmap = Bitmap.createBitmap(
// BITMAP_WIDTH, BITMAP_HEIGHT,
// Bitmap.Config.ARGB_8888);
//
// mMapScaleCanvas = new Canvas(mMapScaleBitmap);
// mTextFields = new HashMap<TextField, String>();
//
// setDefaultTexts();
// configurePaints();
//
// mRedrawNeeded = true;
// mLayer = mBitmapLayer = new BitmapRenderLayer(mapView);
// mBitmapLayer.setBitmap(mMapScaleBitmap, 0, 0,
// (int)(BITMAP_WIDTH * 1.2f),
// (int)(BITMAP_HEIGHT * 1.2f));
// }
//
// @Override
// public void onUpdate(MapPosition mapPosition, boolean changed, boolean clear) {
// double latitude = MercatorProjection.toLatitude(mapPosition.y);
//
// if (!mRedrawNeeded) {
// double scaleDiff = mPrevScale / mapPosition.scale;
// if (scaleDiff < 1.1 && scaleDiff > 0.9) {
// double latitudeDiff = Math.abs(mPrevLatitude - latitude);
// if (latitudeDiff < LATITUDE_REDRAW_THRESHOLD)
// return;
// }
// }
// mPrevLatitude = latitude;
//
// double groundResolution = MercatorProjection.calculateGroundResolution(
// latitude, mapPosition.scale);
//
// int[] scaleBarValues;
// if (mImperialUnits) {
// groundResolution = groundResolution / METER_FOOT_RATIO;
// scaleBarValues = SCALE_BAR_VALUES_IMPERIAL;
// } else {
// scaleBarValues = SCALE_BAR_VALUES_METRIC;
// }
//
// float scaleBarLength = 0;
// int mapScaleValue = 0;
//
// for (int i = 0; i < scaleBarValues.length; ++i) {
// mapScaleValue = scaleBarValues[i];
// scaleBarLength = mapScaleValue / (float) groundResolution;
// if (scaleBarLength < (BITMAP_WIDTH - 10)) {
// break;
// }
// }
// synchronized (mMapScaleBitmap) {
// redrawMapScaleBitmap(scaleBarLength, mapScaleValue);
// }
//
// mBitmapLayer.updateBitmap();
//
// mRedrawNeeded = false;
// }
//
// /**
// * @return true if imperial units are used, false otherwise.
// */
// public boolean isImperialUnits() {
// return mImperialUnits;
// }
//
// /**
// * @param imperialUnits
// * true if imperial units should be used rather than metric
// * units.
// */
// public void setImperialUnits(boolean imperialUnits) {
// mImperialUnits = imperialUnits;
// mRedrawNeeded = true;
// }
//
// /**
// * Overrides the specified text field with the given string.
// *
// * @param textField
// * the text field to override.
// * @param value
// * the new value of the text field.
// */
// public void setText(TextField textField, String value) {
// mTextFields.put(textField, value);
// mRedrawNeeded = true;
// }
//
// private void drawScaleBar(float scaleBarLength, Paint paint) {
// mMapScaleCanvas.drawLine(7, 25, scaleBarLength + 3, 25, paint);
// mMapScaleCanvas.drawLine(5, 10, 5, 40, paint);
// mMapScaleCanvas.drawLine(scaleBarLength + 5, 10, scaleBarLength + 5, 40, paint);
// }
//
// private void drawScaleText(int scaleValue, String unitSymbol, Paint paint) {
// mMapScaleCanvas.drawText(scaleValue + unitSymbol, 12, 18, paint);
// }
//
// /**
// * Redraws the map scale bitmap with the given parameters.
// *
// * @param scaleBarLength
// * the length of the map scale bar in pixels.
// * @param mapScaleValue
// * the map scale value in meters.
// */
// private void redrawMapScaleBitmap(float scaleBarLength, int mapScaleValue) {
// mMapScaleBitmap.eraseColor(Color.TRANSPARENT);
//
// // draw the scale bar
// drawScaleBar(scaleBarLength, SCALE_BAR_STROKE);
// drawScaleBar(scaleBarLength, SCALE_BAR);
//
// int scaleValue;
// String unitSymbol;
// if (mImperialUnits) {
// if (mapScaleValue < ONE_MILE) {
// scaleValue = mapScaleValue;
// unitSymbol = mTextFields.get(TextField.FOOT);
// } else {
// scaleValue = mapScaleValue / ONE_MILE;
// unitSymbol = mTextFields.get(TextField.MILE);
// }
// } else {
// if (mapScaleValue < ONE_KILOMETER) {
// scaleValue = mapScaleValue;
// unitSymbol = mTextFields.get(TextField.METER);
// } else {
// scaleValue = mapScaleValue / ONE_KILOMETER;
// unitSymbol = mTextFields.get(TextField.KILOMETER);
// }
// }
//
// // draw the scale text
// drawScaleText(scaleValue, unitSymbol, SCALE_TEXT_STROKE);
// drawScaleText(scaleValue, unitSymbol, SCALE_TEXT);
// }
//
// private void setDefaultTexts() {
// mTextFields.put(TextField.FOOT, " ft");
// mTextFields.put(TextField.MILE, " mi");
//
// mTextFields.put(TextField.METER, " m");
// mTextFields.put(TextField.KILOMETER, " km");
// }
//
// private static void configurePaints() {
// SCALE_BAR.setStrokeWidth(2);
// SCALE_BAR.setStrokeCap(Paint.Cap.SQUARE);
// SCALE_BAR.setColor(Color.BLACK);
// SCALE_BAR_STROKE.setStrokeWidth(5);
// SCALE_BAR_STROKE.setStrokeCap(Paint.Cap.SQUARE);
// SCALE_BAR_STROKE.setColor(Color.WHITE);
//
// SCALE_TEXT.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
// SCALE_TEXT.setTextSize(17);
// SCALE_TEXT.setColor(Color.BLACK);
// SCALE_TEXT_STROKE.setTypeface(Typeface.defaultFromStyle(Typeface.BOLD));
// SCALE_TEXT_STROKE.setStyle(Paint.Style.STROKE);
// SCALE_TEXT_STROKE.setColor(Color.WHITE);
// SCALE_TEXT_STROKE.setStrokeWidth(2);
// SCALE_TEXT_STROKE.setTextSize(17);
// }
//
// /**
// * Enumeration of all text fields.
// */
// public enum TextField {
// /**
// * Unit symbol for one foot.
// */
// FOOT,
//
// /**
// * Unit symbol for one kilometer.
// */
// KILOMETER,
//
// /**
// * Unit symbol for one meter.
// */
// METER,
//
// /**
// * Unit symbol for one mile.
// */
// MILE;
// }
//}

View File

@ -16,9 +16,9 @@
package org.oscim.layers.overlay;
import org.oscim.view.MapView;
import org.oscim.core.PointF;
import org.oscim.layers.InputLayer;
import org.oscim.view.MapView;
/**
* Base class representing an overlay which may be displayed on top of a

View File

@ -19,7 +19,6 @@ package org.oscim.layers.overlay;
import org.oscim.core.GeoPoint;
import android.graphics.Point;
/**
* Immutable class describing a GeoPoint with a Title and a Description.
@ -30,14 +29,11 @@ import android.graphics.Point;
*/
public class OverlayItem {
// ===========================================================
// Constants
// ===========================================================
public static final int ITEM_STATE_FOCUSED_MASK = 4;
public static final int ITEM_STATE_PRESSED_MASK = 1;
public static final int ITEM_STATE_SELECTED_MASK = 2;
protected static final Point DEFAULT_MARKER_SIZE = new Point(26, 94);
//protected static final Point DEFAULT_MARKER_SIZE = new Point(26, 94);
/**
* Indicates a hotspot for an area. This is where the origin (0,0) of a
@ -45,13 +41,12 @@ public class OverlayItem {
* offset. NONE indicates that no adjustment should be made.
*/
public enum HotspotPlace {
NONE, CENTER, BOTTOM_CENTER, TOP_CENTER, RIGHT_CENTER, LEFT_CENTER, UPPER_RIGHT_CORNER, LOWER_RIGHT_CORNER, UPPER_LEFT_CORNER, LOWER_LEFT_CORNER
NONE, CENTER, BOTTOM_CENTER,
TOP_CENTER, RIGHT_CENTER, LEFT_CENTER,
UPPER_RIGHT_CORNER, LOWER_RIGHT_CORNER,
UPPER_LEFT_CORNER, LOWER_LEFT_CORNER
}
// ===========================================================
// Fields
// ===========================================================
public final String mUid;
public final String mTitle;
public final String mDescription;
@ -59,10 +54,6 @@ public class OverlayItem {
protected OverlayMarker mMarker;
protected HotspotPlace mHotspotPlace;
// ===========================================================
// Constructors
// ===========================================================
/**
* @param aTitle
* this should be <b>singleLine</b> (no <code>'\n'</code> )
@ -77,15 +68,12 @@ public class OverlayItem {
public OverlayItem(final String aUid, final String aTitle, final String aDescription,
final GeoPoint aGeoPoint) {
this.mTitle = aTitle;
this.mDescription = aDescription;
this.mGeoPoint = aGeoPoint;
this.mUid = aUid;
mTitle = aTitle;
mDescription = aDescription;
mGeoPoint = aGeoPoint;
mUid = aUid;
}
// ===========================================================
// Getter & Setter
// ===========================================================
public String getUid() {
return mUid;
}
@ -113,36 +101,31 @@ public class OverlayItem {
* @return The marker for the current state, or null if the default marker
* for the overlay should be used.
*/
public OverlayMarker getMarker(int stateBitset) {
// marker not specified
if (mMarker == null) {
return null;
}
// set marker state appropriately
// setState(mMarker, stateBitset);
public OverlayMarker getMarker() {
return mMarker;
// // marker not specified
// if (mMarker == null) {
// return null;
// }
//
// // set marker state appropriately
// setState(mMarker, stateBitset);
// return mMarker;
}
public void setMarker(OverlayMarker marker) {
this.mMarker = marker;
mMarker = marker;
}
public void setMarkerHotspot(final HotspotPlace place) {
this.mHotspotPlace = (place == null) ? HotspotPlace.BOTTOM_CENTER : place;
mHotspotPlace = (place == null) ? HotspotPlace.BOTTOM_CENTER : place;
}
public HotspotPlace getMarkerHotspot() {
return this.mHotspotPlace;
return mHotspotPlace;
}
// ===========================================================
// Methods from SuperClass/Interfaces
// ===========================================================
// ===========================================================
// Methods
// ===========================================================
/*
* (copied from the Google API docs) Sets the state of a drawable to match a
* given state bitset. This is done by converting the state bitset bits
@ -163,16 +146,16 @@ public class OverlayItem {
//
// drawable.setState(states);
// }
//
// public Drawable getDrawable() {
// return this.mMarker;
// return mMarker;
// }
//
// public int getWidth() {
// return this.mMarker.getIntrinsicWidth();
// return mMarker.getIntrinsicWidth();
// }
//
// public int getHeight() {
// return this.mMarker.getIntrinsicHeight();
// return mMarker.getIntrinsicHeight();
// }
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2013
* 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
@ -14,15 +14,10 @@
*/
package org.oscim.layers.overlay;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.core.PointF;
import org.oscim.layers.overlay.OverlayItem.HotspotPlace;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.Bitmap.Config;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
public class OverlayMarker {
final Bitmap[] mBitmap;
// Hotspot offset
@ -93,32 +88,5 @@ public class OverlayMarker {
return mBitmap[0];
}
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;
}
public static OverlayMarker makeMarker(Resources res, int id, HotspotPlace place) {
return makeMarker(res.getDrawable(id), place);
}
public static OverlayMarker makeMarker(Drawable drawable, HotspotPlace place) {
if (place == null)
place = HotspotPlace.CENTER;
return new OverlayMarker(drawableToBitmap(drawable), place);
}
}

View File

@ -19,11 +19,12 @@ package org.oscim.layers.overlay;
import java.util.ArrayList;
import java.util.List;
import org.oscim.view.MapView;
import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.core.GeoPoint;
import org.oscim.core.MapPosition;
import org.oscim.core.MercatorProjection;
import org.oscim.core.Tile;
import org.oscim.graphics.Paint.Cap;
import org.oscim.layers.Layer;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.layers.BasicRenderLayer;
@ -31,7 +32,6 @@ import org.oscim.renderer.sublayers.LineLayer;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.utils.FastMath;
import org.oscim.utils.LineClipper;
import org.oscim.view.MapView;
/** This class draws a path line in given color. */
public class PathOverlay extends Layer {

View File

@ -22,6 +22,7 @@ import static org.oscim.layers.tile.MapTile.STATE_NONE;
import java.util.ArrayList;
import java.util.Arrays;
import org.oscim.backend.Log;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.renderer.GLRenderer;
@ -32,8 +33,6 @@ import org.oscim.utils.quadtree.QuadTreeIndex;
import org.oscim.view.MapView;
import org.oscim.view.MapViewPosition;
import android.util.Log;
/**
* @TODO
* - prefetching to cache file
@ -608,7 +607,7 @@ public class TileManager {
MapTile tile = null;
if (cnt == maxTiles) {
Log.wtf(TAG, "reached maximum tiles " + maxTiles);
Log.d(TAG, "reached maximum tiles " + maxTiles);
break;
}
int xx = x;

View File

@ -17,15 +17,15 @@ package org.oscim.layers.tile;
import static org.oscim.layers.tile.MapTile.STATE_NEW_DATA;
import static org.oscim.layers.tile.MapTile.STATE_READY;
import org.oscim.view.MapView;
import org.oscim.core.MapPosition;
import org.oscim.renderer.BufferObject;
import org.oscim.renderer.GLRenderer;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.RenderLayer;
import org.oscim.utils.ScanBox;
import org.oscim.view.MapView;
import android.util.Log;
import org.oscim.backend.Log;
public class TileRenderLayer extends RenderLayer {
private final static String TAG = TileRenderLayer.class.getName();

View File

@ -0,0 +1,62 @@
/*
* 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.layers.tile.bitmap;
import java.net.MalformedURLException;
import java.net.URL;
import org.oscim.core.Tile;
//http://server.arcgisonline.com/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/5/14/14
//http://server.arcgisonline.com/ArcGIS/rest/services/World_Imagery/MapServer
public class ArcGISWorldShaded extends AbstractTileSource {
public static final ArcGISWorldShaded INSTANCE = new ArcGISWorldShaded("server.arcgisonline.com", 80);
private static final int PARALLEL_REQUESTS_LIMIT = 4;
private static final String PROTOCOL = "http";
private static final int ZOOM_LEVEL_MAX = 6;
private static final int ZOOM_LEVEL_MIN = 0;
public ArcGISWorldShaded(String hostName, int port) {
super(hostName, port);
}
@Override
public int getParallelRequestsLimit() {
return PARALLEL_REQUESTS_LIMIT;
}
@Override
public URL getTileUrl(Tile tile) throws MalformedURLException {
StringBuilder stringBuilder = new StringBuilder(32);
//stringBuilder.append("/ArcGIS/rest/services/World_Imagery/MapServer/tile/");
stringBuilder.append("/ArcGIS/rest/services/World_Shaded_Relief/MapServer/tile/");
stringBuilder.append(tile.zoomLevel);
stringBuilder.append('/');
stringBuilder.append(tile.tileY);
stringBuilder.append('/');
stringBuilder.append(tile.tileX);
return new URL(PROTOCOL, this.hostName, this.port, stringBuilder.toString());
}
@Override
public byte getZoomLevelMax() {
return ZOOM_LEVEL_MAX;
}
@Override
public byte getZoomLevelMin() {
return ZOOM_LEVEL_MIN;
}
}

View File

@ -20,6 +20,9 @@ import java.net.URL;
import java.net.URLConnection;
import java.util.zip.GZIPInputStream;
import org.oscim.view.MapView;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.core.Tile;
import org.oscim.layers.tile.MapTile;
import org.oscim.layers.tile.TileLayer;
@ -27,10 +30,7 @@ import org.oscim.layers.tile.TileLoader;
import org.oscim.layers.tile.TileManager;
import org.oscim.renderer.sublayers.BitmapLayer;
import org.oscim.renderer.sublayers.Layers;
import org.oscim.view.MapView;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
public class BitmapTileLayer extends TileLayer<TileLoader> {
private static final int TIMEOUT_CONNECT = 5000;
@ -54,7 +54,7 @@ public class BitmapTileLayer extends TileLayer<TileLoader> {
url = mTileSource.getTileUrl(tile);
URLConnection urlConnection = getURLConnection(url);
InputStream inputStream = getInputStream(urlConnection);
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
Bitmap bitmap = CanvasAdapter.g.decodeBitmap(inputStream);
tile.layers = new Layers();
BitmapLayer l = new BitmapLayer(false);

View File

@ -0,0 +1,45 @@
/*
* 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.layers.tile.geojson;
import org.oscim.view.MapView;
import org.oscim.layers.tile.MapTile;
import org.oscim.layers.tile.TileLayer;
import org.oscim.layers.tile.TileLoader;
import org.oscim.layers.tile.TileManager;
public class GeoJsonTileLayer extends TileLayer<TileLoader> {
public GeoJsonTileLayer(MapView mapView) {
super(mapView);
}
@Override
protected TileLoader createLoader(TileManager tm) {
return new TileLoader(tm) {
@Override
public void cleanup() {
}
@Override
protected boolean executeJob(MapTile tile) {
return false;
}
};
}
}

View File

@ -14,10 +14,11 @@
*/
package org.oscim.layers.tile.test;
import org.oscim.view.MapView;
import org.oscim.backend.canvas.Color;
import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.Tile;
import org.oscim.graphics.Color;
import org.oscim.graphics.Paint.Cap;
import org.oscim.layers.tile.MapTile;
import org.oscim.layers.tile.TileLayer;
import org.oscim.layers.tile.TileLoader;
@ -26,9 +27,8 @@ import org.oscim.layers.tile.test.TestTileLayer.TestTileLoader;
import org.oscim.renderer.sublayers.Layers;
import org.oscim.renderer.sublayers.LineLayer;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.view.MapView;
import android.util.Log;
import org.oscim.backend.Log;
public class TestTileLayer extends TileLayer<TestTileLoader> {
final static String TAG = TestTileLayer.class.getName();

View File

@ -20,6 +20,7 @@ import java.io.InputStream;
import javax.xml.parsers.ParserConfigurationException;
import org.oscim.view.MapView;
import org.oscim.core.GeoPoint;
import org.oscim.core.MapPosition;
import org.oscim.layers.tile.TileLayer;
@ -35,10 +36,9 @@ import org.oscim.tilesource.MapInfo;
import org.oscim.tilesource.TileSource;
import org.oscim.tilesource.TileSource.OpenResult;
import org.oscim.tilesource.oscimap.OSciMap1TileSource;
import org.oscim.view.MapView;
import org.xml.sax.SAXException;
import android.util.Log;
import org.oscim.backend.Log;
public class MapTileLayer extends TileLayer<MapTileLoader> {
private final static String TAG = MapTileLayer.class.getName();

View File

@ -48,7 +48,7 @@ import org.oscim.utils.LineClipper;
import org.oscim.utils.pool.Inlist;
import org.oscim.view.DebugSettings;
import android.util.Log;
import org.oscim.backend.Log;
/**
* @note

View File

@ -17,8 +17,9 @@ package org.oscim.renderer;
import java.nio.Buffer;
import org.oscim.backend.Log;
import android.opengl.GLES20;
import android.util.Log;
public final class BufferObject {
private final static String TAG = BufferObject.class.getName();

View File

@ -24,9 +24,7 @@ import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import java.util.concurrent.locks.ReentrantLock;
import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.opengles.GL10;
import org.oscim.backend.Log;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.layers.tile.MapTile;
@ -38,14 +36,10 @@ import org.oscim.view.MapView;
import org.oscim.view.MapViewPosition;
import android.opengl.GLES20;
import android.opengl.GLSurfaceView;
import android.os.SystemClock;
import android.util.Log;
/**
* @author Hannes Janetzek
*/
public class GLRenderer implements GLSurfaceView.Renderer {
//import android.os.SystemClock;
public class GLRenderer {
private static final String TAG = GLRenderer.class.getName();
@ -53,7 +47,6 @@ public class GLRenderer implements GLSurfaceView.Renderer {
private static final int SHORT_BYTES = 2;
private static final int CACHE_TILES_MAX = 250;
public static final float COORD_SCALE = 8.0f;
static int CACHE_TILES = CACHE_TILES_MAX;
@ -210,18 +203,17 @@ public class GLRenderer implements GLSurfaceView.Renderer {
return true;
}
private long lastDraw = 0;
//private long lastDraw = 0;
@Override
public void onDrawFrame(GL10 glUnused) {
long start = SystemClock.uptimeMillis();
long wait = 30 - (start - lastDraw);
if (wait > 5) {
//Log.d(TAG, "wait " + wait);
SystemClock.sleep(wait);
lastDraw = start + wait;
} else
lastDraw = start;
public void onDrawFrame() {
//long start = SystemClock.uptimeMillis();
//long wait = 30 - (start - lastDraw);
//if (wait > 5) {
// //Log.d(TAG, "wait " + wait);
// SystemClock.sleep(wait);
// lastDraw = start + wait;
//} else
// lastDraw = start;
// prevent main thread recreating all tiles (updateMap)
// while rendering is going on.
@ -234,10 +226,10 @@ public class GLRenderer implements GLSurfaceView.Renderer {
}
private static void draw() {
long start = 0;
//long start = 0;
if (MapView.debugFrameTime)
start = SystemClock.uptimeMillis();
//if (MapView.debugFrameTime)
// start = SystemClock.uptimeMillis();
if (mUpdateColor) {
float cc[] = mClearColor;
@ -292,10 +284,10 @@ public class GLRenderer implements GLSurfaceView.Renderer {
renderLayer.render(mMapPosition, mMatrices);
}
if (MapView.debugFrameTime) {
GLES20.glFinish();
Log.d(TAG, "draw took " + (SystemClock.uptimeMillis() - start));
}
//if (MapView.debugFrameTime) {
// GLES20.glFinish();
// Log.d(TAG, "draw took " + (SystemClock.uptimeMillis() - start));
//}
if (GlUtils.checkGlOutOfMemory("finish")) {
BufferObject.checkBufferUsage(true);
@ -307,8 +299,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
return ((t.tileX % 4) + (t.tileY % 4 * 4) + 1);
}
@Override
public void onSurfaceChanged(GL10 glUnused, int width, int height) {
public void onSurfaceChanged(int width, int height) {
Log.d(TAG, "SurfaceChanged:" + mNewSurface + " " + width + "x" + height);
if (width <= 0 || height <= 0)
@ -338,7 +329,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
//mBufferMemoryUsage = 0;
if (!mNewSurface) {
mMapView.redrawMap(false);
mMapView.updateMap(false);
return;
}
@ -377,11 +368,10 @@ public class GLRenderer implements GLSurfaceView.Renderer {
GLState.init();
mMapView.redrawMap(true);
mMapView.updateMap(true);
}
@Override
public void onSurfaceCreated(GL10 gl, EGLConfig config) {
public void onSurfaceCreated() {
// Log.d(TAG, GLES20.glGetString(GLES20.GL_EXTENSIONS));
// classes that require GL context for initialization
@ -397,7 +387,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
public static final boolean debugView = false;
void clearBuffer() {
mNewSurface = true;
}
// void clearBuffer() {
// mNewSurface = true;
// }
}

View File

@ -15,7 +15,7 @@
package org.oscim.renderer;
import android.opengl.GLES20;
import android.util.Log;
import org.oscim.backend.Log;
public class GLState {
private final static String TAG = GLState.class.getName();

View File

@ -14,10 +14,10 @@
*/
package org.oscim.renderer;
import org.oscim.view.MapView;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.view.MapView;
public abstract class RenderLayer {

View File

@ -14,11 +14,12 @@
*/
package org.oscim.renderer.atlas;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Canvas;
import org.oscim.renderer.atlas.TextureAtlas.Rect;
import org.oscim.renderer.sublayers.TextureItem;
import org.oscim.utils.pool.Inlist;
import android.graphics.Canvas;
@ -42,7 +43,7 @@ public abstract class SpriteManager<T> {
Sprite items;
protected final Canvas mCanvas = new Canvas();
protected final Canvas mCanvas = CanvasAdapter.g.getCanvas();
protected TextureItem mTexture;
public SpriteManager() {

View File

@ -61,11 +61,11 @@ package org.oscim.renderer.atlas;
import java.util.HashMap;
import org.oscim.backend.Log;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.renderer.sublayers.TextureItem;
import org.oscim.utils.pool.Inlist;
import android.graphics.Bitmap;
import android.util.Log;
public class TextureAtlas extends Inlist<TextureAtlas> {
private final static String TAG = TextureAtlas.class.getName();
@ -100,7 +100,7 @@ public class TextureAtlas extends Inlist<TextureAtlas> {
return texture;
}
Log.wtf(TAG, "Missing atlas texture");
Log.d(TAG, "Missing atlas texture");
return null;
}

View File

@ -14,6 +14,7 @@
*/
package org.oscim.renderer.layers;
import org.oscim.view.MapView;
import org.oscim.core.MapPosition;
import org.oscim.renderer.BufferObject;
import org.oscim.renderer.GLRenderer;
@ -28,7 +29,6 @@ import org.oscim.renderer.sublayers.LineTexRenderer;
import org.oscim.renderer.sublayers.PolygonRenderer;
import org.oscim.renderer.sublayers.TextureRenderer;
import org.oscim.utils.FastMath;
import org.oscim.view.MapView;
import android.opengl.GLES20;

View File

@ -14,13 +14,13 @@
*/
package org.oscim.renderer.layers;
import org.oscim.view.MapView;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.core.MapPosition;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.sublayers.BitmapLayer;
import org.oscim.renderer.sublayers.BitmapRenderer;
import org.oscim.view.MapView;
import android.graphics.Bitmap;
/**
* RenderLayer to draw a custom Bitmap.

View File

@ -18,12 +18,12 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import org.oscim.view.MapView;
import org.oscim.core.MapPosition;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.GLState;
import org.oscim.renderer.RenderLayer;
import org.oscim.utils.GlUtils;
import org.oscim.view.MapView;
import android.opengl.GLES20;

View File

@ -14,6 +14,7 @@
*/
package org.oscim.renderer.layers;
import org.oscim.view.MapView;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.layers.tile.MapTile;
@ -25,10 +26,9 @@ import org.oscim.renderer.GLState;
import org.oscim.renderer.RenderLayer;
import org.oscim.renderer.sublayers.ExtrusionLayer;
import org.oscim.utils.GlUtils;
import org.oscim.view.MapView;
import android.opengl.GLES20;
import android.util.Log;
import org.oscim.backend.Log;
public class ExtrusionRenderLayer extends RenderLayer {
private final static String TAG = ExtrusionRenderLayer.class.getName();

View File

@ -16,18 +16,18 @@ package org.oscim.renderer.layers;
import java.util.Locale;
import org.oscim.view.MapView;
import org.oscim.backend.canvas.Color;
import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.graphics.Color;
import org.oscim.graphics.Paint.Cap;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.sublayers.LineLayer;
import org.oscim.renderer.sublayers.TextItem;
import org.oscim.renderer.sublayers.TextLayer;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.theme.renderinstruction.Text;
import org.oscim.view.MapView;
public class GridRenderLayer extends BasicRenderLayer {
private final static String TILE_FORMAT = "%d/%d/%d";

View File

@ -28,9 +28,10 @@ package org.oscim.renderer.layers;
// 5 R-Tree might be handy
//
import org.oscim.view.MapView;
import org.oscim.backend.canvas.Color;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.graphics.Color;
import org.oscim.layers.tile.MapTile;
import org.oscim.layers.tile.TileRenderLayer;
import org.oscim.layers.tile.TileSet;
@ -49,11 +50,12 @@ import org.oscim.utils.FastMath;
import org.oscim.utils.OBB2D;
import org.oscim.utils.pool.LList;
import org.oscim.utils.pool.Pool;
import org.oscim.view.MapView;
import org.oscim.view.MapViewPosition;
import android.opengl.GLES20;
import android.os.AsyncTask;
import android.os.SystemClock;
import org.oscim.backend.Log;
import android.os.Handler;
import android.os.Looper;

View File

@ -2,9 +2,10 @@ package org.oscim.renderer.layers.test;
import java.util.Arrays;
import org.oscim.view.MapView;
import org.oscim.backend.canvas.Color;
import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.core.MapPosition;
import org.oscim.graphics.Color;
import org.oscim.graphics.Paint.Cap;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.atlas.TextureAtlas;
import org.oscim.renderer.atlas.TextureAtlas.Rect;
@ -15,9 +16,8 @@ import org.oscim.renderer.sublayers.TextItem;
import org.oscim.renderer.sublayers.TextLayer;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.theme.renderinstruction.Text;
import org.oscim.view.MapView;
import android.util.Log;
import org.oscim.backend.Log;
public class AtlasRenderLayer extends BasicRenderLayer {

View File

@ -19,10 +19,10 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import org.oscim.view.MapView;
import org.oscim.core.MapPosition;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.RenderLayer;
import org.oscim.view.MapView;
public class ModelRenderLayer extends RenderLayer{
public ModelRenderLayer(MapView mapView) {

View File

@ -16,12 +16,12 @@ package org.oscim.renderer.layers.test;
import java.io.IOException;
import org.oscim.backend.BitmapUtils;
import org.oscim.core.MapPosition;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.layers.BasicRenderLayer;
import org.oscim.renderer.sublayers.SymbolItem;
import org.oscim.renderer.sublayers.SymbolLayer;
import org.oscim.theme.renderinstruction.BitmapUtils;
import org.oscim.view.MapView;
public class SymbolRenderLayer extends BasicRenderLayer {

View File

@ -14,11 +14,11 @@
*/
package org.oscim.renderer.layers.test;
import org.oscim.view.MapView;
import org.oscim.core.MapPosition;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.layers.BasicRenderLayer;
import org.oscim.renderer.sublayers.TextItem;
import org.oscim.view.MapView;
public class TestRenderLayer extends BasicRenderLayer {

View File

@ -16,10 +16,9 @@ package org.oscim.renderer.sublayers;
import java.nio.ShortBuffer;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.renderer.GLRenderer;
import android.graphics.Bitmap;
/**
* Renderer for a single bitmap, width and height must be power of 2.
*/

View File

@ -18,16 +18,16 @@ import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.ShortBuffer;
import org.oscim.view.MapView;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapElement;
import org.oscim.core.Tile;
import org.oscim.renderer.BufferObject;
import org.oscim.renderer.GLRenderer;
import org.oscim.utils.LineClipper;
import org.oscim.view.MapView;
import android.opengl.GLES20;
import android.util.Log;
import org.oscim.backend.Log;
/**
* @author Hannes Janetzek

View File

@ -19,7 +19,7 @@ import java.nio.ShortBuffer;
import org.oscim.renderer.BufferObject;
import org.oscim.theme.renderinstruction.Line;
import android.util.Log;
import org.oscim.backend.Log;
public class Layers {
private final static String TAG = Layers.class.getName();

View File

@ -16,13 +16,13 @@ package org.oscim.renderer.sublayers;
import java.nio.ShortBuffer;
import org.oscim.view.MapView;
import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.core.GeometryBuffer;
import org.oscim.core.Tile;
import org.oscim.graphics.Paint.Cap;
import org.oscim.renderer.GLRenderer;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.utils.FastMath;
import org.oscim.view.MapView;
/**
*/

View File

@ -30,7 +30,7 @@ import org.oscim.theme.renderinstruction.Line;
import org.oscim.utils.GlUtils;
import android.opengl.GLES20;
import android.util.Log;
import org.oscim.backend.Log;
public final class LineRenderer {
private final static String TAG = LineRenderer.class.getName();

View File

@ -25,7 +25,7 @@ import org.oscim.theme.renderinstruction.Line;
import org.oscim.utils.GlUtils;
import android.opengl.GLES20;
import android.util.Log;
import org.oscim.backend.Log;
public class LineTexRenderer {
private final static String TAG = LineTexRenderer.class.getName();

View File

@ -31,7 +31,6 @@ import static android.opengl.GLES20.glStencilOp;
import static android.opengl.GLES20.glUniform4fv;
import static android.opengl.GLES20.glVertexAttribPointer;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
@ -41,14 +40,11 @@ import org.oscim.renderer.GLRenderer;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.GLState;
import org.oscim.theme.renderinstruction.Area;
import org.oscim.theme.renderinstruction.BitmapUtils;
import org.oscim.utils.FastMath;
import org.oscim.utils.GlUtils;
import org.oscim.utils.Matrix4;
import android.graphics.Bitmap;
import android.opengl.GLES20;
import android.opengl.GLUtils;
/**
* Special Renderer for drawing tile polygon layers
@ -110,33 +106,35 @@ public final class PolygonRenderer {
}
mFillPolys = new PolygonLayer[STENCIL_BITS];
if (enableTexture) {
mTexWood = loadSprite("jar:grass3.png");
mTexWater = loadSprite("jar:water2.png");
mTexGrass = loadSprite("jar:grass2.png");
}
// if (enableTexture) {
// mTexWood = loadSprite("jar:grass3.png");
// mTexWater = loadSprite("jar:water2.png");
// mTexGrass = loadSprite("jar:grass2.png");
// }
return true;
}
private static int loadSprite(String name) {
int[] textures = new int[1];
try {
Bitmap b = BitmapUtils.createBitmap(name);
GLES20.glGenTextures(1, textures, 0);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
GlUtils.setTextureParameter(GLES20.GL_LINEAR, GLES20.GL_LINEAR,
GLES20.GL_REPEAT, GLES20.GL_REPEAT);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, b, 0);
} catch (IOException e) {
e.printStackTrace();
}
return textures[0];
}
// private static int loadSprite(String name) {
// int[] textures = new int[1];
//
// try {
// Bitmap b = BitmapUtils.createBitmap(name);
// GLES20.glGenTextures(1, textures, 0);
//
// GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textures[0]);
//
// GlUtils.setTextureParameter(GLES20.GL_LINEAR, GLES20.GL_LINEAR,
// GLES20.GL_REPEAT, GLES20.GL_REPEAT);
//
// b.uploadToTexture(false);
//
// //GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, b, 0);
//
// } catch (IOException e) {
// e.printStackTrace();
// }
// return textures[0];
// }
private static void fillPolygons(Matrices m, int start, int end, int zoom, float scale,
float div) {

View File

@ -14,12 +14,12 @@
*/
package org.oscim.renderer.sublayers;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.core.PointF;
import org.oscim.renderer.atlas.TextureRegion;
import org.oscim.utils.pool.Inlist;
import org.oscim.utils.pool.SyncPool;
import android.graphics.Bitmap;
public class SymbolItem extends Inlist<SymbolItem> {

View File

@ -16,11 +16,11 @@ package org.oscim.renderer.sublayers;
import java.nio.ShortBuffer;
import org.oscim.backend.Log;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.renderer.atlas.TextureAtlas;
import org.oscim.utils.pool.Inlist;
import android.graphics.Bitmap;
import android.util.Log;
public final class SymbolLayer extends TextureLayer {
private final static String TAG = SymbolLayer.class.getSimpleName();
@ -114,7 +114,7 @@ public final class SymbolLayer extends TextureLayer {
}
if (to == null) {
Log.wtf(TAG, "Bad SymbolItem");
Log.d(TAG, "Bad SymbolItem");
continue;
}

View File

@ -17,7 +17,9 @@ package org.oscim.renderer.sublayers;
import static org.oscim.renderer.GLRenderer.COORD_SCALE;
import static org.oscim.renderer.sublayers.TextureItem.TEXTURE_HEIGHT;
import static org.oscim.renderer.sublayers.TextureItem.TEXTURE_WIDTH;
import android.graphics.Canvas;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Canvas;
public final class TextLayer extends TextureLayer {
@ -38,7 +40,7 @@ public final class TextLayer extends TextureLayer {
public TextLayer() {
type = Layer.SYMBOL;
//mCanvas = Graphics.res.getCanvas();
mCanvas = new Canvas();
mCanvas = CanvasAdapter.g.getCanvas();
fixed = true;
}

View File

@ -15,15 +15,15 @@
package org.oscim.renderer.sublayers;
import java.util.ArrayList;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Color;
import org.oscim.utils.GlUtils;
import org.oscim.utils.pool.Inlist;
import org.oscim.utils.pool.SyncPool;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import android.util.Log;
import org.oscim.backend.Log;
// FIXME
@ -75,16 +75,12 @@ public class TextureItem extends Inlist<TextureItem> {
}
/**
* Retrieve a TextureItem from pool.
*
* @param poolBitmap
* initialize with pooled Bitmap with dimension
* TextureRenderer.TEXTURE_WIDTH/HEIGHT.
* Retrieve a TextureItem from pool with default Bitmap
* with dimension TextureRenderer.TEXTURE_WIDTH/HEIGHT.
*/
public synchronized static TextureItem get(boolean poolBitmap) {
public synchronized static TextureItem get(boolean initBitmap) {
TextureItem ti = pool.get();
if (poolBitmap) {
if (initBitmap) {
ti.bitmap = getBitmap();
ti.bitmap.eraseColor(Color.TRANSPARENT);
ti.ownBitmap = false;
@ -212,13 +208,16 @@ public class TextureItem extends Inlist<TextureItem> {
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, to.id);
if (to.ownBitmap) {
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
bitmap.uploadToTexture(false);
//GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
} else if (to.width == w && to.height == h) {
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, bitmap, format, type);
bitmap.uploadToTexture(true);
//GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0, bitmap, format, type);
} else {
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format, bitmap, type, 0);
bitmap.uploadToTexture(false);
//GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format, bitmap, type, 0);
to.width = w;
to.height = h;
}
@ -247,14 +246,15 @@ public class TextureItem extends Inlist<TextureItem> {
mTextures.clear();
for (int i = 0; i < 4; i++) {
Bitmap bitmap = Bitmap.createBitmap(
TEXTURE_WIDTH, TEXTURE_HEIGHT,
Bitmap.Config.ARGB_8888);
Bitmap bitmap = CanvasAdapter.g.getBitmap(TEXTURE_WIDTH, TEXTURE_HEIGHT, 0);
//Bitmap bitmap = Bitmap.createBitmap(
// TEXTURE_WIDTH, TEXTURE_HEIGHT,
// Bitmap.Config.ARGB_8888);
mBitmaps.add(bitmap);
}
mBitmapFormat = GLUtils.getInternalFormat(mBitmaps.get(0));
mBitmapType = GLUtils.getType(mBitmaps.get(0));
//mBitmapFormat = GLUtils.getInternalFormat(mBitmaps.get(0));
//mBitmapType = GLUtils.getType(mBitmaps.get(0));
mTexCnt = num;
}
@ -264,15 +264,15 @@ public class TextureItem extends Inlist<TextureItem> {
int size = mBitmaps.size();
if (size == 0) {
Bitmap bitmap = Bitmap.createBitmap(
TEXTURE_WIDTH, TEXTURE_HEIGHT,
Bitmap.Config.ARGB_8888);
//Bitmap bitmap = Bitmap.createBitmap(
// TEXTURE_WIDTH, TEXTURE_HEIGHT,
// Bitmap.Config.ARGB_8888);
//
//if (TextureRenderer.debug)
// Log.d(TAG, "alloc bitmap: " +
// android.os.Debug.getNativeHeapAllocatedSize() / (1024 * 1024));
if (TextureRenderer.debug)
Log.d(TAG, "alloc bitmap: " +
android.os.Debug.getNativeHeapAllocatedSize() / (1024 * 1024));
return bitmap;
return CanvasAdapter.g.getBitmap(TEXTURE_WIDTH, TEXTURE_HEIGHT, 0);
}
return mBitmaps.remove(size - 1);
}

View File

@ -18,6 +18,8 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import org.oscim.backend.canvas.Color;
import org.oscim.core.GeometryBuffer.GeometryType;
import org.oscim.core.MapElement;
import org.oscim.theme.renderinstruction.RenderInstruction;
import org.oscim.theme.rule.Element;
@ -25,8 +27,7 @@ import org.oscim.theme.rule.Rule;
import org.oscim.utils.LRUCache;
import org.xml.sax.Attributes;
import android.graphics.Color;
import android.util.Log;
import org.oscim.backend.Log;
/**
* A RenderTheme defines how map elements are drawn.

View File

@ -24,11 +24,13 @@ import java.util.Stack;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
import org.oscim.backend.BitmapUtils;
import org.oscim.backend.Log;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.renderer.atlas.TextureAtlas;
import org.oscim.renderer.atlas.TextureAtlas.Rect;
import org.oscim.theme.renderinstruction.Area;
import org.oscim.theme.renderinstruction.AreaLevel;
import org.oscim.theme.renderinstruction.BitmapUtils;
import org.oscim.theme.renderinstruction.Circle;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.theme.renderinstruction.LineSymbol;
@ -43,8 +45,6 @@ import org.xml.sax.SAXParseException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.DefaultHandler;
import android.graphics.Bitmap;
import android.util.Log;
/**
* SAX2 handler to parse XML render theme files.

View File

@ -14,7 +14,7 @@
*/
package org.oscim.theme.renderinstruction;
import org.oscim.graphics.Color;
import org.oscim.backend.canvas.Color;
import org.oscim.theme.IRenderCallback;
import org.oscim.theme.RenderThemeHandler;
import org.xml.sax.Attributes;

View File

@ -14,7 +14,7 @@
*/
package org.oscim.theme.renderinstruction;
import org.oscim.graphics.Color;
import org.oscim.backend.canvas.Color;
import org.oscim.theme.IRenderCallback;
import org.oscim.theme.RenderThemeHandler;
import org.xml.sax.Attributes;

View File

@ -17,8 +17,8 @@ package org.oscim.theme.renderinstruction;
import java.util.Locale;
import java.util.regex.Pattern;
import org.oscim.graphics.Color;
import org.oscim.graphics.Paint.Cap;
import org.oscim.backend.canvas.Color;
import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.theme.IRenderCallback;
import org.oscim.theme.RenderThemeHandler;
import org.xml.sax.Attributes;

View File

@ -14,13 +14,10 @@
*/
package org.oscim.theme.renderinstruction;
import java.io.IOException;
import org.oscim.theme.IRenderCallback;
import org.oscim.theme.RenderThemeHandler;
import org.xml.sax.Attributes;
import android.graphics.Bitmap;
/**
* Represents an icon along a polyline on the map.
@ -32,11 +29,8 @@ public final class LineSymbol extends RenderInstruction {
* @param attributes
* the attributes of the XML element.
* @return a new LineSymbol with the given rendering attributes.
* @throws IOException
* if an I/O error occurs while reading a resource.
*/
public static LineSymbol create(String elementName, Attributes attributes)
throws IOException {
public static LineSymbol create(String elementName, Attributes attributes) {
String src = null;
boolean alignCenter = false;
boolean repeat = false;
@ -68,23 +62,19 @@ public final class LineSymbol extends RenderInstruction {
}
public final boolean alignCenter;
public final Bitmap bitmap;
//public final Bitmap bitmap;
public final boolean repeat;
public final String bitmap;
private LineSymbol(String src, boolean alignCenter, boolean repeat)
throws IOException {
private LineSymbol(String src, boolean alignCenter, boolean repeat) {
super();
this.bitmap = BitmapUtils.createBitmap(src);
this.bitmap = src;
//this.bitmap = BitmapUtils.createBitmap(src);
this.alignCenter = alignCenter;
this.repeat = repeat;
}
@Override
public void destroy() {
bitmap.recycle();
}
@Override
public void renderWay(IRenderCallback renderCallback) {
renderCallback.renderWaySymbol(this);

View File

@ -16,20 +16,18 @@ package org.oscim.theme.renderinstruction;
import java.util.Locale;
import org.oscim.graphics.Color;
import org.oscim.graphics.Paint.FontFamily;
import org.oscim.graphics.Paint.FontStyle;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Color;
import org.oscim.backend.canvas.Paint;
import org.oscim.backend.canvas.Paint.Align;
import org.oscim.backend.canvas.Paint.FontFamily;
import org.oscim.backend.canvas.Paint.FontStyle;
import org.oscim.backend.canvas.Paint.Style;
import org.oscim.renderer.atlas.TextureRegion;
import org.oscim.theme.IRenderCallback;
import org.oscim.theme.RenderThemeHandler;
import org.xml.sax.Attributes;
import android.graphics.Paint;
import android.graphics.Paint.Align;
import android.graphics.Paint.FontMetrics;
import android.graphics.Paint.Style;
import android.graphics.Typeface;
/**
* Represents a text along a polyline on the map.
*/
@ -132,43 +130,47 @@ public final class Text extends RenderInstruction {
Text t = new Text("", "", FontFamily.DEFAULT, FontStyle.NORMAL,
fontSize, fill, outline, strokeWidth, 0, billboard, null, Integer.MAX_VALUE);
FontMetrics fm = t.paint.getFontMetrics();
t.fontHeight = (float) Math.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
t.fontDescent = (float) Math.ceil(Math.abs(fm.bottom));
//FontMetrics fm = t.paint.getFontMetrics();
//t.fontHeight = (float) Math.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
//t.fontDescent = (float) Math.ceil(Math.abs(fm.bottom));
t.fontHeight = t.paint.getFontHeight();
t.fontDescent = t.paint.getFontDescent();
return t;
}
private static int getStyle(FontStyle fontStyle) {
switch (fontStyle) {
case BOLD:
return 1;
case BOLD_ITALIC:
return 3;
case ITALIC:
return 2;
case NORMAL:
return 0;
}
//private static int getStyle(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);
//}
throw new IllegalArgumentException("unknown font style: " + fontStyle);
}
private static Typeface getTypeface(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);
}
//private static Typeface getTypeface(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);
//}
private Text(String style, String textKey, FontFamily fontFamily, FontStyle fontStyle,
float fontSize, int fill, int outline, float strokeWidth, float dy, boolean caption,
@ -181,23 +183,21 @@ public final class Text extends RenderInstruction {
this.priority = priority;
this.symbol = symbol;
//paint = Graphics.res.getPaint();
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paint = CanvasAdapter.g.getPaint();
paint.setTextAlign(Align.CENTER);
Typeface typeFace = Typeface.create(Text.getTypeface(fontFamily), Text.getStyle(fontStyle));
//paint.setTypeface(fontFamily, fontStyle);
paint.setTypeface(typeFace);
//Typeface typeFace = Typeface.create(Text.getTypeface(fontFamily), Text.getStyle(fontStyle));
paint.setTypeface(fontFamily, fontStyle);
//paint.setTypeface(typeFace);
paint.setColor(fill);
paint.setTextSize(fontSize);
if (strokeWidth > 0) {
stroke = new Paint(Paint.ANTI_ALIAS_FLAG);
//stroke = Graphics.res.getPaint();
stroke = CanvasAdapter.g.getPaint();
stroke.setStyle(Style.STROKE);
stroke.setTextAlign(Align.CENTER);
//stroke.setTypeface(fontFamily, fontStyle);
stroke.setTypeface(typeFace);
stroke.setTypeface(fontFamily, fontStyle);
//stroke.setTypeface(typeFace);
stroke.setColor(outline);
stroke.setStrokeWidth(strokeWidth);
stroke.setTextSize(fontSize);
@ -227,11 +227,11 @@ public final class Text extends RenderInstruction {
if (stroke != null)
stroke.setTextSize(fontSize * scaleFactor);
FontMetrics fm = paint.getFontMetrics();
fontHeight = (float) Math.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
fontDescent = (float) Math.ceil(Math.abs(fm.bottom));
//FontMetrics fm = paint.getFontMetrics();
//fontHeight = (float) Math.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
//fontDescent = (float) Math.ceil(Math.abs(fm.bottom));
// fontHeight = paint.getFontHeight();
// fontDescent = paint.getFontDescent();
fontHeight = paint.getFontHeight();
fontDescent = paint.getFontDescent();
}
}

File diff suppressed because it is too large Load Diff

View File

@ -24,10 +24,10 @@ import java.net.SocketAddress;
import java.net.URL;
import java.util.zip.InflaterInputStream;
import org.oscim.backend.Log;
import org.oscim.core.Tile;
import android.os.SystemClock;
import android.util.Log;
public class LwHttp {
private static final String TAG = LwHttp.class.getName();
@ -199,7 +199,7 @@ public class LwHttp {
try {
mSocket.close();
} catch (IOException e) {
Log.wtf(TAG, e);
Log.d(TAG, e.getMessage());
}
// Log.d(TAG, "not alive - recreate connection " + mMaxReq);

View File

@ -21,7 +21,7 @@ import org.oscim.core.Tile;
import org.oscim.tilesource.ITileDataSink;
import org.oscim.utils.UTF8Decoder;
import android.util.Log;
import org.oscim.backend.Log;
public abstract class PbfDecoder {
private final static String TAG = PbfDecoder.class.getName();

View File

@ -23,7 +23,7 @@ import org.oscim.layers.tile.MapTile;
import org.oscim.tilesource.ITileDataSink;
import org.oscim.tilesource.ITileDataSource;
import android.util.Log;
import org.oscim.backend.Log;
/**
*

View File

@ -27,7 +27,7 @@ import org.oscim.tilesource.ITileDataSink;
import org.oscim.tilesource.ITileDataSource;
import org.oscim.tilesource.mapfile.header.SubFileParameter;
import android.util.Log;
import org.oscim.backend.Log;
/**
* A class for reading binary map files.

View File

@ -25,7 +25,7 @@ import org.oscim.tilesource.TileSource;
import org.oscim.tilesource.mapfile.header.MapFileHeader;
import org.oscim.tilesource.mapfile.header.MapFileInfo;
import android.util.Log;
import org.oscim.backend.Log;
public class MapFileTileSource extends TileSource {
private final static String TAG = MapFileTileSource.class.getName();

View File

@ -28,7 +28,7 @@ import org.oscim.tilesource.common.PbfDecoder;
import org.oscim.utils.pool.Inlist;
import org.oscim.utils.pool.Pool;
import android.util.Log;
import org.oscim.backend.Log;
public class TileDecoder extends PbfDecoder {
private final static String TAG = TileDecoder.class.getName();

View File

@ -27,7 +27,7 @@ import org.oscim.core.Tile;
import org.oscim.tilesource.ITileDataSink;
import org.oscim.tilesource.common.PbfDecoder;
import android.util.Log;
import org.oscim.backend.Log;
public class TileDecoder extends PbfDecoder {
private final static String TAG = TileDecoder.class.getName();

View File

@ -31,7 +31,7 @@ import org.oscim.tilesource.common.PbfDecoder;
import org.oscim.tilesource.common.PbfTileDataSource;
import org.oscim.tilesource.common.UrlTileSource;
import android.util.Log;
import org.oscim.backend.Log;
public class OSciMap2TileSource extends UrlTileSource {

View File

@ -26,7 +26,7 @@ import org.oscim.core.Tile;
import org.oscim.tilesource.ITileDataSink;
import org.oscim.tilesource.common.PbfDecoder;
import android.util.Log;
import org.oscim.backend.Log;
public class TileDecoder extends PbfDecoder {
private final static String TAG = TileDecoder.class.getName();

View File

@ -16,7 +16,6 @@ package org.oscim.utils;
import org.oscim.core.PointD;
import android.graphics.Point;
/**
* @author Hannes Janetzek
@ -166,10 +165,10 @@ public final class GeometryUtils {
}
// http://en.wikipedia.org/wiki/Distance_from_a_point_to_a_line
public static double pointToLineDistance(Point A, Point B, Point P) {
double normalLength = Math.hypot(B.x - A.x, B.y - A.y);
return Math.abs((P.x - A.x) * (B.y - A.y) - (P.y - A.y) * (B.x - A.x)) / normalLength;
}
// public static double pointToLineDistance(Point A, Point B, Point P) {
// double normalLength = Math.hypot(B.x - A.x, B.y - A.y);
// return Math.abs((P.x - A.x) * (B.y - A.y) - (P.y - A.y) * (B.x - A.x)) / normalLength;
// }
// from libosmscout-render
public static byte calcLinesIntersect(
@ -331,39 +330,39 @@ public final class GeometryUtils {
return inside;
}
public static float areaSigned(Point p1, Point p2, Point p3) {
return ((p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y)) * 0.5f;
}
public static float areaSigned(float ax, float ay, float bx, float by, float cx, float cy) {
return ((ax - cx) * (by - cy) - (bx - cx) * (ay - cy)) * 0.5f;
}
// public static float areaSigned(Point p1, Point p2, Point p3) {
// return ((p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y)) * 0.5f;
// }
//
// public static float areaSigned(float ax, float ay, float bx, float by, float cx, float cy) {
// return ((ax - cx) * (by - cy) - (bx - cx) * (ay - cy)) * 0.5f;
// }
//
public static float area(float ax, float ay, float bx, float by, float cx, float cy) {
float area = ((ax - cx) * (by - cy) - (bx - cx) * (ay - cy)) * 0.5f;
return area < 0 ? -area : area;
}
public static boolean pointInTri(Point pt, Point p1, Point p2, Point p3) {
boolean inside = false;
boolean p1s = p1.y > pt.y;
boolean p2s = p2.y > pt.y;
boolean p3s = p3.y > pt.y;
if ((p1s != p3s)
&& (pt.x < (p3.x - p1.x) * (pt.y - p1.y) / (p3.y - p1.y) + p1.x))
inside = !inside;
if ((p2s != p1s)
&& (pt.x < (p1.x - p2.x) * (pt.y - p2.y) / (p1.y - p2.y) + p2.x))
inside = !inside;
if ((p3s != p2s)
&& (pt.x < (p2.x - p3.x) * (pt.y - p3.y) / (p2.y - p3.y) + p3.x))
inside = !inside;
return inside;
}
//
// public static boolean pointInTri(Point pt, Point p1, Point p2, Point p3) {
// boolean inside = false;
// boolean p1s = p1.y > pt.y;
// boolean p2s = p2.y > pt.y;
// boolean p3s = p3.y > pt.y;
//
// if ((p1s != p3s)
// && (pt.x < (p3.x - p1.x) * (pt.y - p1.y) / (p3.y - p1.y) + p1.x))
// inside = !inside;
//
// if ((p2s != p1s)
// && (pt.x < (p1.x - p2.x) * (pt.y - p2.y) / (p1.y - p2.y) + p2.x))
// inside = !inside;
//
// if ((p3s != p2s)
// && (pt.x < (p2.x - p3.x) * (pt.y - p3.y) / (p2.y - p3.y) + p3.x))
// inside = !inside;
//
// return inside;
// }
// TODO compare with http://alienryderflex.com/polygon/
}

View File

@ -5,7 +5,7 @@ import javax.microedition.khronos.egl.EGLConfig;
import javax.microedition.khronos.egl.EGLDisplay;
import android.opengl.GLSurfaceView;
import android.util.Log;
import org.oscim.backend.Log;
/**
*

View File

@ -17,10 +17,8 @@ package org.oscim.utils;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import android.graphics.Bitmap;
import android.opengl.GLES20;
import android.opengl.GLUtils;
import android.util.Log;
import org.oscim.backend.Log;
/**
* Utility functions
@ -47,27 +45,27 @@ public class GlUtils {
wrap_t); // Set V Wrapping
}
/**
* @param bitmap
* ...
* @return textureId
*/
public static int loadTextures(Bitmap bitmap) {
int[] textures = new int[1];
GLES20.glGenTextures(1, textures, 0);
int textureID = textures[0];
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureID);
setTextureParameter(GLES20.GL_LINEAR, GLES20.GL_LINEAR,
GLES20.GL_CLAMP_TO_EDGE, GLES20.GL_CLAMP_TO_EDGE);
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
return textureID;
}
// /**
// * @param bitmap
// * ...
// * @return textureId
// */
// public static int loadTextures(Bitmap bitmap) {
//
// int[] textures = new int[1];
// GLES20.glGenTextures(1, textures, 0);
//
// int textureID = textures[0];
//
// GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, textureID);
//
// setTextureParameter(GLES20.GL_LINEAR, GLES20.GL_LINEAR,
// GLES20.GL_CLAMP_TO_EDGE, GLES20.GL_CLAMP_TO_EDGE);
//
// GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);
//
// return textureID;
// }
public static int loadTexture(byte[] pixel, int width, int height, int format,
int min_filter, int mag_filter, int wrap_s, int wrap_t) {

View File

@ -14,6 +14,12 @@
*/
package org.oscim.utils;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import android.opengl.GLES20;
public class Matrix4 {
static {
@ -55,18 +61,22 @@ public class Matrix4 {
private native static void setTransScale(long self, float tx, float ty, float scale);
private native static void setAsUniform(long self, int handle);
//private native static void setAsUniform(long self, int handle);
private native void setValueAt(long self, int pos, float value);
private native static void setValueAt(long self, int pos, float value);
private native void addDepthOffset(long self, int delta);
private native static void addDepthOffset(long self, int delta);
private native static ByteBuffer getBuffer(long self);
private final long pointer;
private final FloatBuffer buffer;
private final static String INVALID_INPUT = "Bad Array!";
public Matrix4() {
pointer = alloc();
buffer = (getBuffer(pointer)).order(ByteOrder.nativeOrder()).asFloatBuffer();
}
/**
@ -207,7 +217,8 @@ public class Matrix4 {
* @param location GL location id
*/
public void setAsUniform(int location) {
setAsUniform(pointer, location);
GLES20.glUniformMatrix4fv(location, 1, false, buffer);
//setAsUniform(pointer, location);
}
/**

View File

@ -19,6 +19,9 @@ package org.oscim.view;
import java.util.AbstractList;
import java.util.concurrent.CopyOnWriteArrayList;
import org.oscim.backend.Log;
import org.oscim.backend.input.KeyEvent;
import org.oscim.backend.input.MotionEvent;
import org.oscim.core.MapPosition;
import org.oscim.core.PointF;
import org.oscim.layers.InputLayer;
@ -26,27 +29,21 @@ import org.oscim.layers.Layer;
import org.oscim.layers.overlay.Overlay.Snappable;
import org.oscim.renderer.RenderLayer;
import android.content.Context;
import android.util.Log;
import android.view.GestureDetector;
import android.view.GestureDetector.OnDoubleTapListener;
import android.view.GestureDetector.OnGestureListener;
import android.view.KeyEvent;
import android.view.MotionEvent;
public class LayerManager extends AbstractList<Layer> implements OnGestureListener,
OnDoubleTapListener {
public class LayerManager extends AbstractList<Layer>
//implements OnGestureListener,
//OnDoubleTapListener
{
private final static String TAG = LayerManager.class.getName();
private final static boolean debugInput = false;
private final GestureDetector mGestureDetector;
//private final GestureDetector mGestureDetector;
private final CopyOnWriteArrayList<Layer> mLayerList;
LayerManager(Context context) {
LayerManager() {
mLayerList = new CopyOnWriteArrayList<Layer>();
mGestureDetector = new GestureDetector(context, this);
mGestureDetector.setOnDoubleTapListener(this);
//mGestureDetector = new GestureDetector(context, this);
//mGestureDetector.setOnDoubleTapListener(this);
}
@Override
@ -172,12 +169,13 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
action == MotionEvent.ACTION_UP);
}
if (handleGesture) {
if (mGestureDetector.onTouchEvent(e))
return true;
mCancelGesture = false;
}
// if (handleGesture) {
// if (mGestureDetector.onTouchEvent(e))
// return true;
//
// mCancelGesture = false;
// }
Log.d(TAG, "motionEvent");
if (onTouchEvent(e))
return true;
@ -256,7 +254,7 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
/* GestureDetector.OnDoubleTapListener */
@Override
//@Override
public boolean onDoubleTap(final MotionEvent e) {
if (mDirtyLayers)
@ -272,7 +270,7 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
return false;
}
@Override
//@Override
public boolean onDoubleTapEvent(final MotionEvent e) {
if (mDirtyLayers)
updateLayers();
@ -287,7 +285,7 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
return false;
}
@Override
//@Override
public boolean onSingleTapConfirmed(final MotionEvent e) {
if (mDirtyLayers)
updateLayers();
@ -304,7 +302,7 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
/* OnGestureListener */
@Override
//@Override
public boolean onDown(final MotionEvent pEvent) {
if (mDirtyLayers)
updateLayers();
@ -319,7 +317,7 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
return false;
}
@Override
//@Override
public boolean onFling(final MotionEvent pEvent1, final MotionEvent pEvent2,
final float pVelocityX, final float pVelocityY) {
if (mDirtyLayers)
@ -335,7 +333,7 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
return false;
}
@Override
//@Override
public void onLongPress(final MotionEvent pEvent) {
if (mCancelGesture)
return;
@ -348,7 +346,7 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
return;
}
@Override
//@Override
public boolean onScroll(final MotionEvent pEvent1, final MotionEvent pEvent2,
final float pDistanceX, final float pDistanceY) {
if (mDirtyLayers)
@ -364,7 +362,7 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
return false;
}
@Override
//@Override
public void onShowPress(final MotionEvent pEvent) {
if (mDirtyLayers)
updateLayers();
@ -374,7 +372,7 @@ public class LayerManager extends AbstractList<Layer> implements OnGestureListen
}
@Override
//@Override
public boolean onSingleTapUp(final MotionEvent pEvent) {
if (mDirtyLayers)
updateLayers();

View File

@ -0,0 +1,19 @@
/*
* 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.view;
public class MapAnimator {
}

View File

@ -0,0 +1,23 @@
/*
* 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.view;
public interface MapRenderCallback {
void updateMap(boolean forceRender);
void renderMap();
int getWidth();
int getHeight();
}

View File

@ -1,6 +1,5 @@
/*
* Copyright 2010, 2011, 2012 mapsforge.org
* Copyright 2012 Hannes Janetzek
* 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
@ -17,12 +16,9 @@ package org.oscim.view;
import java.util.List;
import org.oscim.android.Compass;
import org.oscim.android.MapActivity;
import org.oscim.core.BoundingBox;
import org.oscim.core.GeoPoint;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.layers.Layer;
import org.oscim.layers.MapEventLayer;
import org.oscim.layers.labeling.LabelLayer;
@ -31,115 +27,31 @@ import org.oscim.layers.overlay.Overlay;
import org.oscim.layers.tile.bitmap.BitmapTileLayer;
import org.oscim.layers.tile.vector.MapTileLayer;
import org.oscim.layers.tile.vector.MapTileLoader;
import org.oscim.renderer.GLView;
import org.oscim.tilesource.TileSource;
import android.content.Context;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.RelativeLayout;
/**
* 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 MapView extends RelativeLayout {
final static String TAG = MapView.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;
public class MapView {
public static int dpi;
public static boolean enableClosePolygons;
private final LayerManager mLayerManager;
private final MapViewPosition mMapViewPosition;
private final MapPosition mMapPosition;
private final Compass mCompass;
private DebugSettings mDebugSettings;
private final MapRenderCallback mMapRenderCallback;
private int mWidth;
private int mHeight;
private boolean mInitialized;
// FIXME: keep until old pbmap reader is removed
public static boolean enableClosePolygons = false;
public static float dpi;
/**
* @param context
* the enclosing MapActivity instance.
* @throws IllegalArgumentException
* if the context object is not an instance of
* {@link MapActivity} .
*/
public MapView(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 MapView(Context context, AttributeSet attributeSet) {
super(context, attributeSet);
if (!(context instanceof MapActivity)) {
throw new IllegalArgumentException(
"context is not an instance of MapActivity");
}
this.setWillNotDraw(true);
DisplayMetrics metrics = getResources().getDisplayMetrics();
dpi = Math.max(metrics.xdpi, metrics.ydpi);
// TODO make this dpi dependent
Tile.SIZE = 400;
MapActivity mapActivity = (MapActivity) context;
public MapView(MapRenderCallback mapRenderCallback) {
mMapRenderCallback = mapRenderCallback;
mMapViewPosition = new MapViewPosition(this);
mMapPosition = new MapPosition();
mLayerManager = new LayerManager(context);
mCompass = new Compass(mapActivity, this);
mGLView = new GLView(context, this);
mDebugSettings = new DebugSettings();
mLayerManager = new LayerManager();
// FIXME
mDebugSettings = new DebugSettings();
MapTileLoader.setDebugSettings(mDebugSettings);
mapActivity.registerMapView(this);
LayoutParams params = new LayoutParams(
android.view.ViewGroup.LayoutParams.MATCH_PARENT,
android.view.ViewGroup.LayoutParams.MATCH_PARENT);
addView(mGLView, params);
mLayerManager.add(0, new MapEventLayer(this));
clearMap();
redrawMap(false);
}
public MapTileLayer setBaseMap(TileSource tileSource) {
@ -147,14 +59,15 @@ public class MapView extends RelativeLayout {
baseLayer.setTileSource(tileSource);
//mLayerManager.add(0, new MapEventLayer(this));
mLayerManager.add(1, baseLayer);
mRotationEnabled = true;
//mRotationEnabled = true;
//mLayerManager.add(new GenericOverlay(this, new GridRenderLayer(this)));
mLayerManager.add(new BuildingOverlay(this, baseLayer.getTileLayer()));
LabelLayer ll = new LabelLayer(this, baseLayer.getTileLayer());
mLayerManager.add(ll);
mLayerManager.add(new LabelLayer(this, baseLayer.getTileLayer()));
return baseLayer;
}
@ -173,136 +86,53 @@ public class MapView extends RelativeLayout {
mLayerManager.destroy();
}
public void onStop() {
Log.d(TAG, "onStop");
//mLayerManager.destroy();
/**
* Request call to onUpdate for all layers. This function can
* be called from any thread. Request will be handled on main
* thread.
*
* @param forceRedraw pass true to render next frame
*/
public void updateMap(boolean forceRedraw) {
mMapRenderCallback.updateMap(forceRedraw);
}
private boolean mPausing = false;
public void onPause() {
mPausing = true;
if (this.mCompassEnabled)
mCompass.disable();
}
public void onResume() {
if (this.mCompassEnabled)
mCompass.enable();
mPausing = false;
}
@Override
public boolean onTouchEvent(MotionEvent motionEvent) {
if (!isClickable())
return false;
return mLayerManager.handleMotionEvent(motionEvent);
}
@Override
protected synchronized 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)
mMapViewPosition.setViewport(width, height);
}
/* private */boolean mWaitRedraw;
private final Runnable mRedrawRequest = new Runnable() {
@Override
public void run() {
mWaitRedraw = false;
redrawMapInternal(false);
}
};
boolean mClearMap;
/**
* 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
* Request to clear all layers before rendering next frame
*/
public void redrawMap(boolean requestRender) {
if (requestRender && !mClearMap && !mPausing && mInitialized)
mGLView.requestRender();
if (!mWaitRedraw) {
mWaitRedraw = true;
post(mRedrawRequest);
}
}
private boolean mClearMap;
public void clearMap(){
public void clearMap() {
mClearMap = true;
}
/**
* Request to render a frame. Use this for animations.
* Request to render a frame. Request will be handled on main
* thread.
*/
public void render() {
if (mClearMap)
redrawMap(false);
else
mGLView.requestRender();
mMapRenderCallback.renderMap();
}
/**
* Update all Layers on Main thread.
*
* @param forceRedraw also render frame
* FIXME (does nothing atm)
* Do not call directly. This function is run on main-loop
* before rendering a frame.
*/
void redrawMapInternal(boolean forceRedraw) {
boolean changed = forceRedraw;
if (mPausing || !mInitialized)
return;
if (forceRedraw && !mClearMap)
mGLView.requestRender();
public void updateLayers() {
boolean changed = false;
// get the current MapPosition
changed |= mMapViewPosition.getMapPosition(mMapPosition);
mLayerManager.onUpdate(mMapPosition, changed, mClearMap);
// delay redraw until all layers had the chance to clear
// their state.
if (mClearMap){
mGLView.requestRender();
mClearMap =false;
}
mClearMap = false;
}
/**
* @param debugSettings
* the new DebugSettings for this MapView.
*/
public void setDebugSettings(DebugSettings debugSettings) {
mDebugSettings = debugSettings;
MapTileLoader.setDebugSettings(debugSettings);
}
/**
* @return the debug settings which are used in this MapView.
*/
public DebugSettings getDebugSettings() {
return mDebugSettings;
}
@ -320,7 +150,7 @@ public class MapView extends RelativeLayout {
public void setCenter(GeoPoint geoPoint) {
mMapViewPosition.setMapCenter(geoPoint);
redrawMap(true);
updateMap(true);
}
/**
@ -352,35 +182,26 @@ public class MapView extends RelativeLayout {
return mMapViewPosition.getViewBox();
}
public void enableRotation(boolean enable) {
mRotationEnabled = enable;
public void onPause() {
// TODO Auto-generated method stub
if (enable) {
enableCompass(false);
}
}
public void enableCompass(boolean enable) {
if (enable == mCompassEnabled)
return;
public void onResume() {
// TODO Auto-generated method stub
mCompassEnabled = enable;
if (enable)
enableRotation(false);
if (enable)
mCompass.enable();
else
mCompass.disable();
}
public boolean getCompassEnabled() {
return mCompassEnabled;
public void onStop() {
// TODO Auto-generated method stub
}
public boolean getRotationEnabled() {
return mRotationEnabled;
public int getWidth() {
return mMapRenderCallback.getWidth();
}
public int getHeight() {
return mMapRenderCallback.getHeight();
}
}

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