diff --git a/vtm-android-example/res/drawable-hdpi/ic_launcher.png b/vtm-android-example/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 6a0db8b6..00000000 Binary files a/vtm-android-example/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/vtm-android-example/res/drawable-ldpi/ic_launcher.png b/vtm-android-example/res/drawable-ldpi/ic_launcher.png deleted file mode 100644 index 80ebd903..00000000 Binary files a/vtm-android-example/res/drawable-ldpi/ic_launcher.png and /dev/null differ diff --git a/vtm-android-example/res/drawable-mdpi/ic_launcher.png b/vtm-android-example/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index 4337a920..00000000 Binary files a/vtm-android-example/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/vtm-android-example/res/drawable-xhdpi/ic_launcher.png b/vtm-android-example/res/drawable-xhdpi/ic_launcher.png deleted file mode 100644 index 436ec1cc..00000000 Binary files a/vtm-android-example/res/drawable-xhdpi/ic_launcher.png and /dev/null differ diff --git a/vtm-android-example/ic_launcher-web.png b/vtm-android-example/res/drawable/ic_launcher.png similarity index 100% rename from vtm-android-example/ic_launcher-web.png rename to vtm-android-example/res/drawable/ic_launcher.png diff --git a/vtm-android-gdx/build.gradle b/vtm-android-gdx/build.gradle index 8faed494..14f8666a 100644 --- a/vtm-android-gdx/build.gradle +++ b/vtm-android-gdx/build.gradle @@ -2,9 +2,9 @@ apply plugin: 'com.android.application' apply plugin: 'com.github.dcendents.android-maven' dependencies { + compile project(':vtm-android') compile project(':vtm-gdx') compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" - compile 'com.caverock:androidsvg:1.2.2-beta-1' compile 'com.noveogroup.android:android-logger:1.3.6' } diff --git a/vtm-android-gdx/res/drawable-hdpi/ic_launcher.png b/vtm-android-gdx/res/drawable-hdpi/ic_launcher.png deleted file mode 100644 index 8074c4c5..00000000 Binary files a/vtm-android-gdx/res/drawable-hdpi/ic_launcher.png and /dev/null differ diff --git a/vtm-android-gdx/res/drawable-ldpi/ic_launcher.png b/vtm-android-gdx/res/drawable-ldpi/ic_launcher.png deleted file mode 100644 index 1095584e..00000000 Binary files a/vtm-android-gdx/res/drawable-ldpi/ic_launcher.png and /dev/null differ diff --git a/vtm-android-gdx/res/drawable-mdpi/ic_launcher.png b/vtm-android-gdx/res/drawable-mdpi/ic_launcher.png deleted file mode 100644 index a07c69fa..00000000 Binary files a/vtm-android-gdx/res/drawable-mdpi/ic_launcher.png and /dev/null differ diff --git a/vtm-android-gdx/res/drawable/ic_launcher.png b/vtm-android-gdx/res/drawable/ic_launcher.png new file mode 100644 index 00000000..6496c5ad Binary files /dev/null and b/vtm-android-gdx/res/drawable/ic_launcher.png differ diff --git a/vtm-android-gdx/res/values/strings.xml b/vtm-android-gdx/res/values/strings.xml index 5622347c..7eca5512 100644 --- a/vtm-android-gdx/res/values/strings.xml +++ b/vtm-android-gdx/res/values/strings.xml @@ -1,4 +1,4 @@ - VtmGdx - \ No newline at end of file + VTM GDX + diff --git a/vtm-android-gdx/src/org/oscim/android/canvas/AndroidBitmap.java b/vtm-android-gdx/src/org/oscim/android/canvas/AndroidBitmap.java deleted file mode 100644 index 6b7b9b48..00000000 --- a/vtm-android-gdx/src/org/oscim/android/canvas/AndroidBitmap.java +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright 2013 Hannes Janetzek - * Copyright 2016 Longri - * Copyright 2016 devemux86 - * - * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ -package org.oscim.android.canvas; - -import android.graphics.Bitmap; -import android.graphics.BitmapFactory; -import android.opengl.GLES20; -import android.opengl.GLUtils; - -import org.oscim.utils.IOUtils; - -import java.io.ByteArrayOutputStream; -import java.io.InputStream; - -import static android.graphics.Bitmap.Config.ARGB_8888; - -public class AndroidBitmap implements org.oscim.backend.canvas.Bitmap { - 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; - } - - @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); - } - - public AndroidBitmap(android.graphics.Bitmap bitmap) { - mBitmap = bitmap; - } - - @Override - public int getWidth() { - return mBitmap.getWidth(); - } - - @Override - public int getHeight() { - return mBitmap.getHeight(); - } - - @Override - public int[] getPixels() { - int width = getWidth(); - int height = getHeight(); - int[] colors = new int[width * height]; - mBitmap.getPixels(colors, 0, width, 0, 0, width, height); - return colors; - } - - @Override - public void eraseColor(int color) { - //int a = android.graphics.Color.TRANSPARENT; - mBitmap.eraseColor(color); - } - - @Override - public 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); - } - - @Override - public void recycle() { - if (mBitmap == null) - return; - - mBitmap.recycle(); - } - - @Override - public byte[] getPngEncodedData() { - ByteArrayOutputStream outputStream = null; - try { - outputStream = new ByteArrayOutputStream(); - mBitmap.compress(Bitmap.CompressFormat.PNG, 100, outputStream); - return outputStream.toByteArray(); - } finally { - IOUtils.closeQuietly(outputStream); - } - } -} diff --git a/vtm-android-gdx/src/org/oscim/android/canvas/AndroidCanvas.java b/vtm-android-gdx/src/org/oscim/android/canvas/AndroidCanvas.java deleted file mode 100644 index 2ae0e4c2..00000000 --- a/vtm-android-gdx/src/org/oscim/android/canvas/AndroidCanvas.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2013 Hannes Janetzek - * - * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ -package org.oscim.android.canvas; - -import org.oscim.backend.canvas.Bitmap; -import org.oscim.backend.canvas.Canvas; -import org.oscim.backend.canvas.Paint; - -public class AndroidCanvas implements Canvas { - final android.graphics.Canvas canvas; - - public AndroidCanvas() { - canvas = new android.graphics.Canvas(); - } - - @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); - - 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); - - } - -} diff --git a/vtm-android-gdx/src/org/oscim/android/canvas/AndroidGraphics.java b/vtm-android-gdx/src/org/oscim/android/canvas/AndroidGraphics.java deleted file mode 100644 index 5165e7a8..00000000 --- a/vtm-android-gdx/src/org/oscim/android/canvas/AndroidGraphics.java +++ /dev/null @@ -1,135 +0,0 @@ -/* - * Copyright 2010, 2011, 2012 mapsforge.org - * Copyright 2016 devemux86 - * - * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ -package org.oscim.android.canvas; - -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; -import org.oscim.backend.canvas.Canvas; -import org.oscim.backend.canvas.Paint; -import org.oscim.layers.marker.MarkerItem.HotspotPlace; -import org.oscim.layers.marker.MarkerSymbol; - -import java.io.IOException; -import java.io.InputStream; - -public final class AndroidGraphics extends CanvasAdapter { - - public static void init() { - CanvasAdapter.init(new AndroidGraphics()); - } - - public static android.graphics.Paint getAndroidPaint(Paint paint) { - return ((AndroidPaint) paint).mPaint; - } - - public static android.graphics.Bitmap getBitmap(Bitmap bitmap) { - return ((AndroidBitmap) bitmap).mBitmap; - } - - private AndroidGraphics() { - // do nothing - } - - @Override - public Bitmap decodeBitmapImpl(InputStream inputStream) { - return new AndroidBitmap(inputStream); - } - - @Override - public Bitmap decodeSvgBitmapImpl(InputStream inputStream) { - try { - return new AndroidSvgBitmap(inputStream); - } catch (IOException e) { - e.printStackTrace(); - return null; - } - } - - @Override - public Bitmap loadBitmapAssetImpl(String relativePathPrefix, String src) { - try { - return createBitmap(relativePathPrefix, src); - } catch (IOException e) { - e.printStackTrace(); - } - return null; - } - - @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 Canvas newCanvasImpl() { - return new AndroidCanvas(); - } - - //------------------------------------- - public static Bitmap drawableToBitmap(Drawable drawable) { - if (drawable instanceof BitmapDrawable) { - return new AndroidBitmap(((BitmapDrawable) drawable).getBitmap()); - } - - android.graphics.Bitmap bitmap = android.graphics.Bitmap - .createBitmap(drawable.getIntrinsicWidth(), - drawable.getIntrinsicHeight(), - Config.ARGB_8888); - - android.graphics.Canvas canvas = new android.graphics.Canvas(bitmap); - drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight()); - drawable.draw(canvas); - - return new AndroidBitmap(bitmap); - } - - public static 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; - - return new MarkerSymbol(drawableToBitmap(drawable), place); - } - - /** - * @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); - } -} diff --git a/vtm-android-gdx/src/org/oscim/android/canvas/AndroidPaint.java b/vtm-android-gdx/src/org/oscim/android/canvas/AndroidPaint.java deleted file mode 100644 index e574328e..00000000 --- a/vtm-android-gdx/src/org/oscim/android/canvas/AndroidPaint.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * Copyright 2010, 2011, 2012 mapsforge.org - * - * This file is part of the OpenScienceMap project (http://www.opensciencemap.org). - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ -package org.oscim.android.canvas; - -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; - } - - throw new IllegalArgumentException("unknown font style: " + fontStyle); - } - - private static Typeface getTypeface(org.oscim.backend.canvas.Paint.FontFamily fontFamily) { - switch (fontFamily) { - case DEFAULT: - return Typeface.DEFAULT; - case DEFAULT_BOLD: - return Typeface.DEFAULT_BOLD; - case MONOSPACE: - return Typeface.MONOSPACE; - case SANS_SERIF: - return Typeface.SANS_SERIF; - case SERIF: - return Typeface.SERIF; - } - - throw new IllegalArgumentException("unknown font family: " + fontFamily); - } - - final android.graphics.Paint mPaint; - - AndroidPaint() { - mPaint = new android.graphics.Paint( - android.graphics.Paint.ANTI_ALIAS_FLAG); - } - - @Override - public int getColor() { - return mPaint.getColor(); - } - - @Override - public 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 setStrokeWidth(float width) { - mPaint.setStrokeWidth(width); - } - - @Override - public void setStyle(Style style) { - mPaint.setStyle(android.graphics.Paint.Style.valueOf(style.name())); - } - - @Override - public void setTextAlign(Align align) { - //mPaint.setTextAlign(android.graphics.Paint.Align.valueOf(align.name())); - } - - @Override - public void setTextSize(float textSize) { - mPaint.setTextSize(textSize); - } - - @Override - public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) { - Typeface typeface = Typeface.create(getTypeface(fontFamily), - getStyle(fontStyle)); - mPaint.setTypeface(typeface); - } - - @Override - public float measureText(String text) { - return mPaint.measureText(text); - } - - @Override - public float getFontHeight() { - FontMetrics fm = mPaint.getFontMetrics(); - return (float) Math.ceil(Math.abs(fm.bottom) + Math.abs(fm.top)); - } - - @Override - public float getFontDescent() { - FontMetrics fm = mPaint.getFontMetrics(); - // //fontDescent = (float) Math.ceil(Math.abs(fm.descent)); - return Math.abs(fm.bottom); - } -} diff --git a/vtm-android-gdx/src/org/oscim/android/canvas/AndroidSvgBitmap.java b/vtm-android-gdx/src/org/oscim/android/canvas/AndroidSvgBitmap.java deleted file mode 100644 index ac4c3777..00000000 --- a/vtm-android-gdx/src/org/oscim/android/canvas/AndroidSvgBitmap.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2016 devemux86 - * - * This program is free software: you can redistribute it and/or modify it under the - * terms of the GNU Lesser General Public License as published by the Free Software - * Foundation, either version 3 of the License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY - * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License along with - * this program. If not, see . - */ -package org.oscim.android.canvas; - -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Picture; -import android.graphics.RectF; - -import com.caverock.androidsvg.SVG; - -import org.oscim.backend.CanvasAdapter; - -import java.io.IOException; -import java.io.InputStream; - -public class AndroidSvgBitmap extends AndroidBitmap { - /** - * Default size is 20x20px (400px) at baseline mdpi (160dpi). - */ - public static float DEFAULT_SIZE = 400f; - - public static android.graphics.Bitmap getResourceBitmap(InputStream inputStream, float scaleFactor, float defaultSize, int width, int height, int percent) throws IOException { - try { - SVG svg = SVG.getFromInputStream(inputStream); - Picture picture = svg.renderToPicture(); - - double scale = scaleFactor / Math.sqrt((picture.getHeight() * picture.getWidth()) / defaultSize); - - float bitmapWidth = (float) (picture.getWidth() * scale); - float bitmapHeight = (float) (picture.getHeight() * scale); - - float aspectRatio = (1f * picture.getWidth()) / picture.getHeight(); - - if (width != 0 && height != 0) { - // both width and height set, override any other setting - bitmapWidth = width; - bitmapHeight = height; - } else if (width == 0 && height != 0) { - // only width set, calculate from aspect ratio - bitmapWidth = height * aspectRatio; - bitmapHeight = height; - } else if (width != 0 && height == 0) { - // only height set, calculate from aspect ratio - bitmapHeight = width / aspectRatio; - bitmapWidth = width; - } - - if (percent != 100) { - bitmapWidth *= percent / 100f; - bitmapHeight *= percent / 100f; - } - - android.graphics.Bitmap bitmap = android.graphics.Bitmap.createBitmap((int) Math.ceil(bitmapWidth), - (int) Math.ceil(bitmapHeight), Bitmap.Config.ARGB_8888); - Canvas canvas = new Canvas(bitmap); - canvas.drawPicture(picture, new RectF(0, 0, bitmapWidth, bitmapHeight)); - - return bitmap; - } catch (Exception e) { - throw new IOException(e); - } - } - - private static android.graphics.Bitmap getResourceBitmapImpl(InputStream inputStream) throws IOException { - synchronized (SVG.getVersion()) { - return getResourceBitmap(inputStream, CanvasAdapter.dpi / 160, DEFAULT_SIZE, 0, 0, 100); - } - } - - public AndroidSvgBitmap(InputStream inputStream) throws IOException { - super(getResourceBitmapImpl(inputStream)); - } -}