consistent formatting

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,19 +10,21 @@ public class AndroidCanvas implements Canvas {
public AndroidCanvas() {
this.canvas = new android.graphics.Canvas();
}
@Override
public void setBitmap(Bitmap bitmap) {
this.canvas.setBitmap(((AndroidBitmap)bitmap).mBitmap);
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);
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);
this.canvas.drawBitmap(((AndroidBitmap) bitmap).mBitmap, x, y, null);
}

View File

@ -100,10 +100,10 @@ public final class AndroidGraphics extends CanvasAdapter {
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
}
android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap(
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
Config.ARGB_8888);
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());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,19 +10,21 @@ public class AndroidCanvas implements Canvas {
public AndroidCanvas() {
this.canvas = new android.graphics.Canvas();
}
@Override
public void setBitmap(Bitmap bitmap) {
this.canvas.setBitmap(((AndroidBitmap)bitmap).mBitmap);
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);
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);
this.canvas.drawBitmap(((AndroidBitmap) bitmap).mBitmap, x, y, null);
}

View File

@ -94,10 +94,10 @@ public final class AndroidGraphics extends CanvasAdapter {
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
}
android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap(
drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(),
Config.ARGB_8888);
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());

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -20,8 +20,10 @@ 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);
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;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -128,6 +128,7 @@ public abstract class Map implements EventDispatcher {
* 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 abstract void updateMap(boolean forceRedraw);
@ -192,6 +193,7 @@ public abstract class Map implements EventDispatcher {
/**
* Get current {@link MapPosition}.
*
* @param mapPosition
*/
public boolean getMapPosition(MapPosition mapPosition) {

View File

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

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