Improve code / xml formatting, closes #54
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.oscim.gdx"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
android:versionName="1.0">
|
||||
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
@@ -13,15 +13,15 @@
|
||||
android:targetSdkVersion="22" />
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:allowBackup="true" >
|
||||
android:label="@string/app_name">
|
||||
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait"
|
||||
android:configChanges="keyboard|keyboardHidden|orientation|screenSize">
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
@@ -29,4 +29,4 @@
|
||||
</activity>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
||||
@@ -3,9 +3,12 @@
|
||||
#
|
||||
# This file must be checked in Version Control Systems.
|
||||
#
|
||||
# To customize properties used by the Ant build system use,
|
||||
# To customize properties used by the Ant build system edit
|
||||
# "ant.properties", and override values to adapt the script to your
|
||||
# project structure.
|
||||
#
|
||||
# To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home):
|
||||
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
|
||||
|
||||
# Project target.
|
||||
target=android-21
|
||||
target=android-23
|
||||
|
||||
@@ -2,6 +2,6 @@
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
android:orientation="vertical">
|
||||
|
||||
</LinearLayout>
|
||||
@@ -16,88 +16,88 @@
|
||||
*/
|
||||
package org.oscim.android.canvas;
|
||||
|
||||
import static android.graphics.Bitmap.Config.ARGB_8888;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.opengl.GLES20;
|
||||
import android.opengl.GLUtils;
|
||||
|
||||
import java.io.InputStream;
|
||||
|
||||
import static android.graphics.Bitmap.Config.ARGB_8888;
|
||||
|
||||
public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap {
|
||||
final Bitmap mBitmap;
|
||||
final Bitmap mBitmap;
|
||||
|
||||
public AndroidBitmap(InputStream inputStream) {
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
||||
try {
|
||||
GLUtils.getType(bitmap);
|
||||
} catch (IllegalArgumentException e) {
|
||||
bitmap = bitmap.copy(ARGB_8888, false);
|
||||
}
|
||||
mBitmap = bitmap;
|
||||
}
|
||||
public AndroidBitmap(InputStream inputStream) {
|
||||
Bitmap bitmap = BitmapFactory.decodeStream(inputStream);
|
||||
try {
|
||||
GLUtils.getType(bitmap);
|
||||
} catch (IllegalArgumentException e) {
|
||||
bitmap = bitmap.copy(ARGB_8888, false);
|
||||
}
|
||||
mBitmap = bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return mBitmap != null;
|
||||
}
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return mBitmap != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param format ignored always ARGB8888
|
||||
*/
|
||||
public AndroidBitmap(int width, int height, int format) {
|
||||
mBitmap = android.graphics.Bitmap
|
||||
.createBitmap(width, height, ARGB_8888);
|
||||
}
|
||||
/**
|
||||
* @param format ignored always ARGB8888
|
||||
*/
|
||||
public AndroidBitmap(int width, int height, int format) {
|
||||
mBitmap = android.graphics.Bitmap
|
||||
.createBitmap(width, height, ARGB_8888);
|
||||
}
|
||||
|
||||
public AndroidBitmap(android.graphics.Bitmap bitmap) {
|
||||
mBitmap = bitmap;
|
||||
}
|
||||
public AndroidBitmap(android.graphics.Bitmap bitmap) {
|
||||
mBitmap = bitmap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return mBitmap.getWidth();
|
||||
}
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return mBitmap.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return mBitmap.getHeight();
|
||||
}
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return mBitmap.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getPixels() {
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
int[] colors = new int[width * height];
|
||||
mBitmap.getPixels(colors, 0, width, 0, 0, width, height);
|
||||
return colors;
|
||||
}
|
||||
@Override
|
||||
public int[] getPixels() {
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
int[] colors = new int[width * height];
|
||||
mBitmap.getPixels(colors, 0, width, 0, 0, width, height);
|
||||
return colors;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseColor(int color) {
|
||||
//int a = android.graphics.Color.TRANSPARENT;
|
||||
mBitmap.eraseColor(color);
|
||||
}
|
||||
@Override
|
||||
public void eraseColor(int color) {
|
||||
//int a = android.graphics.Color.TRANSPARENT;
|
||||
mBitmap.eraseColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadToTexture(boolean replace) {
|
||||
int format = GLUtils.getInternalFormat(mBitmap);
|
||||
int type = GLUtils.getType(mBitmap);
|
||||
@Override
|
||||
public void uploadToTexture(boolean replace) {
|
||||
int format = GLUtils.getInternalFormat(mBitmap);
|
||||
int type = GLUtils.getType(mBitmap);
|
||||
|
||||
if (replace)
|
||||
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0,
|
||||
mBitmap, format, type);
|
||||
else
|
||||
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format,
|
||||
mBitmap, type, 0);
|
||||
}
|
||||
if (replace)
|
||||
GLUtils.texSubImage2D(GLES20.GL_TEXTURE_2D, 0, 0, 0,
|
||||
mBitmap, format, type);
|
||||
else
|
||||
GLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, format,
|
||||
mBitmap, type, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
if (mBitmap == null)
|
||||
return;
|
||||
@Override
|
||||
public void recycle() {
|
||||
if (mBitmap == null)
|
||||
return;
|
||||
|
||||
mBitmap.recycle();
|
||||
}
|
||||
mBitmap.recycle();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,31 +21,31 @@ import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
public class AndroidCanvas implements Canvas {
|
||||
final android.graphics.Canvas canvas;
|
||||
final android.graphics.Canvas canvas;
|
||||
|
||||
public AndroidCanvas() {
|
||||
canvas = new android.graphics.Canvas();
|
||||
}
|
||||
public AndroidCanvas() {
|
||||
canvas = new android.graphics.Canvas();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
canvas.setBitmap(((AndroidBitmap) bitmap).mBitmap);
|
||||
}
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
canvas.setBitmap(((AndroidBitmap) bitmap).mBitmap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawText(String string, float x, float y, Paint fill, Paint stroke) {
|
||||
if (string != null) {
|
||||
if (stroke != null)
|
||||
canvas.drawText(string, x, y, ((AndroidPaint) stroke).mPaint);
|
||||
@Override
|
||||
public void drawText(String string, float x, float y, Paint fill, Paint stroke) {
|
||||
if (string != null) {
|
||||
if (stroke != null)
|
||||
canvas.drawText(string, x, y, ((AndroidPaint) stroke).mPaint);
|
||||
|
||||
canvas.drawText(string, x, y, ((AndroidPaint) fill).mPaint);
|
||||
}
|
||||
}
|
||||
canvas.drawText(string, x, y, ((AndroidPaint) fill).mPaint);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, float x, float y) {
|
||||
canvas.drawBitmap(((AndroidBitmap) bitmap).mBitmap, x, y, null);
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, float x, float y) {
|
||||
canvas.drawBitmap(((AndroidBitmap) bitmap).mBitmap, x, y, null);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,10 @@
|
||||
*/
|
||||
package org.oscim.android.canvas;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
@@ -27,99 +29,97 @@ import org.oscim.backend.canvas.Paint;
|
||||
import org.oscim.layers.marker.MarkerItem.HotspotPlace;
|
||||
import org.oscim.layers.marker.MarkerSymbol;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public final class AndroidGraphics extends CanvasAdapter {
|
||||
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new AndroidGraphics());
|
||||
}
|
||||
public static void init() {
|
||||
CanvasAdapter.init(new AndroidGraphics());
|
||||
}
|
||||
|
||||
public static android.graphics.Paint getAndroidPaint(Paint paint) {
|
||||
return ((AndroidPaint) paint).mPaint;
|
||||
}
|
||||
public static android.graphics.Paint getAndroidPaint(Paint paint) {
|
||||
return ((AndroidPaint) paint).mPaint;
|
||||
}
|
||||
|
||||
public static android.graphics.Bitmap getBitmap(Bitmap bitmap) {
|
||||
return ((AndroidBitmap) bitmap).mBitmap;
|
||||
}
|
||||
public static android.graphics.Bitmap getBitmap(Bitmap bitmap) {
|
||||
return ((AndroidBitmap) bitmap).mBitmap;
|
||||
}
|
||||
|
||||
private AndroidGraphics() {
|
||||
// do nothing
|
||||
}
|
||||
private AndroidGraphics() {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap decodeBitmapImpl(InputStream inputStream) {
|
||||
return new AndroidBitmap(inputStream);
|
||||
}
|
||||
@Override
|
||||
public Bitmap decodeBitmapImpl(InputStream inputStream) {
|
||||
return new AndroidBitmap(inputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap loadBitmapAssetImpl(String fileName) {
|
||||
try {
|
||||
return createBitmap(fileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@Override
|
||||
public Bitmap loadBitmapAssetImpl(String fileName) {
|
||||
try {
|
||||
return createBitmap(fileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paint newPaintImpl() {
|
||||
return new AndroidPaint();
|
||||
}
|
||||
@Override
|
||||
public Paint newPaintImpl() {
|
||||
return new AndroidPaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap newBitmapImpl(int width, int height, int format) {
|
||||
return new AndroidBitmap(width, height, format);
|
||||
}
|
||||
@Override
|
||||
public Bitmap newBitmapImpl(int width, int height, int format) {
|
||||
return new AndroidBitmap(width, height, format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Canvas newCanvasImpl() {
|
||||
return new AndroidCanvas();
|
||||
}
|
||||
@Override
|
||||
public Canvas newCanvasImpl() {
|
||||
return new AndroidCanvas();
|
||||
}
|
||||
|
||||
//-------------------------------------
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
|
||||
}
|
||||
//-------------------------------------
|
||||
public static Bitmap drawableToBitmap(Drawable drawable) {
|
||||
if (drawable instanceof BitmapDrawable) {
|
||||
return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap());
|
||||
}
|
||||
|
||||
android.graphics.Bitmap bitmap = android.graphics.Bitmap
|
||||
.createBitmap(drawable.getIntrinsicWidth(),
|
||||
drawable.getIntrinsicHeight(),
|
||||
Config.ARGB_8888);
|
||||
android.graphics.Bitmap bitmap = android.graphics.Bitmap
|
||||
.createBitmap(drawable.getIntrinsicWidth(),
|
||||
drawable.getIntrinsicHeight(),
|
||||
Config.ARGB_8888);
|
||||
|
||||
android.graphics.Canvas canvas = new android.graphics.Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
android.graphics.Canvas canvas = new android.graphics.Canvas(bitmap);
|
||||
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
|
||||
drawable.draw(canvas);
|
||||
|
||||
return new AndroidBitmap(bitmap);
|
||||
}
|
||||
return new AndroidBitmap(bitmap);
|
||||
}
|
||||
|
||||
public static Bitmap drawableToBitmap(Resources res, int resId) {
|
||||
return new AndroidBitmap(res.openRawResource(resId));
|
||||
}
|
||||
public static Bitmap drawableToBitmap(Resources res, int resId) {
|
||||
return new AndroidBitmap(res.openRawResource(resId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static MarkerSymbol makeMarker(Drawable drawable, HotspotPlace place) {
|
||||
if (place == null)
|
||||
place = HotspotPlace.CENTER;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static MarkerSymbol makeMarker(Drawable drawable, HotspotPlace place) {
|
||||
if (place == null)
|
||||
place = HotspotPlace.CENTER;
|
||||
|
||||
return new MarkerSymbol(drawableToBitmap(drawable), place);
|
||||
}
|
||||
return new MarkerSymbol(drawableToBitmap(drawable), place);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static MarkerSymbol makeMarker(Resources res, int resId, HotspotPlace place) {
|
||||
if (place == null)
|
||||
place = HotspotPlace.CENTER;
|
||||
/**
|
||||
* @deprecated
|
||||
*/
|
||||
public static MarkerSymbol makeMarker(Resources res, int resId, HotspotPlace place) {
|
||||
if (place == null)
|
||||
place = HotspotPlace.CENTER;
|
||||
|
||||
InputStream in = res.openRawResource(resId);
|
||||
return new MarkerSymbol(new AndroidBitmap(in), place);
|
||||
}
|
||||
InputStream in = res.openRawResource(resId);
|
||||
return new MarkerSymbol(new AndroidBitmap(in), place);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,110 +16,110 @@
|
||||
*/
|
||||
package org.oscim.android.canvas;
|
||||
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
import android.graphics.Paint.FontMetrics;
|
||||
import android.graphics.Typeface;
|
||||
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
class AndroidPaint implements Paint {
|
||||
private static int getStyle(org.oscim.backend.canvas.Paint.FontStyle fontStyle) {
|
||||
switch (fontStyle) {
|
||||
case BOLD:
|
||||
return 1;
|
||||
case BOLD_ITALIC:
|
||||
return 3;
|
||||
case ITALIC:
|
||||
return 2;
|
||||
case NORMAL:
|
||||
return 0;
|
||||
}
|
||||
private static int getStyle(org.oscim.backend.canvas.Paint.FontStyle fontStyle) {
|
||||
switch (fontStyle) {
|
||||
case BOLD:
|
||||
return 1;
|
||||
case BOLD_ITALIC:
|
||||
return 3;
|
||||
case ITALIC:
|
||||
return 2;
|
||||
case NORMAL:
|
||||
return 0;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("unknown font style: " + fontStyle);
|
||||
}
|
||||
throw new IllegalArgumentException("unknown font style: " + fontStyle);
|
||||
}
|
||||
|
||||
private static Typeface getTypeface(org.oscim.backend.canvas.Paint.FontFamily fontFamily) {
|
||||
switch (fontFamily) {
|
||||
case DEFAULT:
|
||||
return Typeface.DEFAULT;
|
||||
case DEFAULT_BOLD:
|
||||
return Typeface.DEFAULT_BOLD;
|
||||
case MONOSPACE:
|
||||
return Typeface.MONOSPACE;
|
||||
case SANS_SERIF:
|
||||
return Typeface.SANS_SERIF;
|
||||
case SERIF:
|
||||
return Typeface.SERIF;
|
||||
}
|
||||
private static Typeface getTypeface(org.oscim.backend.canvas.Paint.FontFamily fontFamily) {
|
||||
switch (fontFamily) {
|
||||
case DEFAULT:
|
||||
return Typeface.DEFAULT;
|
||||
case DEFAULT_BOLD:
|
||||
return Typeface.DEFAULT_BOLD;
|
||||
case MONOSPACE:
|
||||
return Typeface.MONOSPACE;
|
||||
case SANS_SERIF:
|
||||
return Typeface.SANS_SERIF;
|
||||
case SERIF:
|
||||
return Typeface.SERIF;
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException("unknown font family: " + fontFamily);
|
||||
}
|
||||
throw new IllegalArgumentException("unknown font family: " + fontFamily);
|
||||
}
|
||||
|
||||
final android.graphics.Paint mPaint;
|
||||
final android.graphics.Paint mPaint;
|
||||
|
||||
AndroidPaint() {
|
||||
mPaint = new android.graphics.Paint(
|
||||
android.graphics.Paint.ANTI_ALIAS_FLAG);
|
||||
}
|
||||
AndroidPaint() {
|
||||
mPaint = new android.graphics.Paint(
|
||||
android.graphics.Paint.ANTI_ALIAS_FLAG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return mPaint.getColor();
|
||||
}
|
||||
@Override
|
||||
public int getColor() {
|
||||
return mPaint.getColor();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(int color) {
|
||||
mPaint.setColor(color);
|
||||
}
|
||||
@Override
|
||||
public void setColor(int color) {
|
||||
mPaint.setColor(color);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrokeCap(Cap cap) {
|
||||
android.graphics.Paint.Cap androidCap = android.graphics.Paint.Cap
|
||||
.valueOf(cap.name());
|
||||
mPaint.setStrokeCap(androidCap);
|
||||
}
|
||||
@Override
|
||||
public void setStrokeCap(Cap cap) {
|
||||
android.graphics.Paint.Cap androidCap = android.graphics.Paint.Cap
|
||||
.valueOf(cap.name());
|
||||
mPaint.setStrokeCap(androidCap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrokeWidth(float width) {
|
||||
mPaint.setStrokeWidth(width);
|
||||
}
|
||||
@Override
|
||||
public void setStrokeWidth(float width) {
|
||||
mPaint.setStrokeWidth(width);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStyle(Style style) {
|
||||
mPaint.setStyle(android.graphics.Paint.Style.valueOf(style.name()));
|
||||
}
|
||||
@Override
|
||||
public void setStyle(Style style) {
|
||||
mPaint.setStyle(android.graphics.Paint.Style.valueOf(style.name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextAlign(Align align) {
|
||||
//mPaint.setTextAlign(android.graphics.Paint.Align.valueOf(align.name()));
|
||||
}
|
||||
@Override
|
||||
public void setTextAlign(Align align) {
|
||||
//mPaint.setTextAlign(android.graphics.Paint.Align.valueOf(align.name()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextSize(float textSize) {
|
||||
mPaint.setTextSize(textSize);
|
||||
}
|
||||
@Override
|
||||
public void setTextSize(float textSize) {
|
||||
mPaint.setTextSize(textSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
|
||||
Typeface typeface = Typeface.create(getTypeface(fontFamily),
|
||||
getStyle(fontStyle));
|
||||
mPaint.setTypeface(typeface);
|
||||
}
|
||||
@Override
|
||||
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
|
||||
Typeface typeface = Typeface.create(getTypeface(fontFamily),
|
||||
getStyle(fontStyle));
|
||||
mPaint.setTypeface(typeface);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float measureText(String text) {
|
||||
return mPaint.measureText(text);
|
||||
}
|
||||
@Override
|
||||
public float measureText(String text) {
|
||||
return mPaint.measureText(text);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFontHeight() {
|
||||
FontMetrics fm = mPaint.getFontMetrics();
|
||||
return (float) Math.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
|
||||
}
|
||||
@Override
|
||||
public float getFontHeight() {
|
||||
FontMetrics fm = mPaint.getFontMetrics();
|
||||
return (float) Math.ceil(Math.abs(fm.bottom) + Math.abs(fm.top));
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFontDescent() {
|
||||
FontMetrics fm = mPaint.getFontMetrics();
|
||||
// //fontDescent = (float) Math.ceil(Math.abs(fm.descent));
|
||||
return Math.abs(fm.bottom);
|
||||
}
|
||||
@Override
|
||||
public float getFontDescent() {
|
||||
FontMetrics fm = mPaint.getFontMetrics();
|
||||
// //fontDescent = (float) Math.ceil(Math.abs(fm.descent));
|
||||
return Math.abs(fm.bottom);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,42 +17,42 @@
|
||||
*/
|
||||
package org.oscim.gdx;
|
||||
|
||||
import org.oscim.android.canvas.AndroidGraphics;
|
||||
import org.oscim.backend.GLAdapter;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.badlogic.gdx.backends.android.AndroidApplication;
|
||||
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
|
||||
import com.badlogic.gdx.utils.SharedLibraryLoader;
|
||||
|
||||
import org.oscim.android.canvas.AndroidGraphics;
|
||||
import org.oscim.backend.GLAdapter;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
|
||||
public class MainActivity extends AndroidApplication {
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AndroidGraphics.init();
|
||||
GdxAssets.init("");
|
||||
GLAdapter.init(new AndroidGL());
|
||||
Tile.SIZE = 400;
|
||||
AndroidGraphics.init();
|
||||
GdxAssets.init("");
|
||||
GLAdapter.init(new AndroidGL());
|
||||
Tile.SIZE = 400;
|
||||
|
||||
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
|
||||
cfg.stencil = 8;
|
||||
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
|
||||
cfg.stencil = 8;
|
||||
|
||||
new SharedLibraryLoader().load("vtm-jni");
|
||||
new SharedLibraryLoader().load("vtm-jni");
|
||||
|
||||
initialize(new GdxMapAndroid(), cfg);
|
||||
}
|
||||
initialize(new GdxMapAndroid(), cfg);
|
||||
}
|
||||
|
||||
class GdxMapAndroid extends GdxMap {
|
||||
@Override
|
||||
public void createLayers() {
|
||||
TileSource ts = new OSciMap4TileSource();
|
||||
initDefaultLayers(ts, true, true, true);
|
||||
}
|
||||
}
|
||||
class GdxMapAndroid extends GdxMap {
|
||||
@Override
|
||||
public void createLayers() {
|
||||
TileSource ts = new OSciMap4TileSource();
|
||||
initDefaultLayers(ts, true, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user