rename vtm-gdx-*
This commit is contained in:
59
vtm-ios/src/org/oscim/ios/RobovmLauncher.java
Normal file
59
vtm-ios/src/org/oscim/ios/RobovmLauncher.java
Normal file
@@ -0,0 +1,59 @@
|
||||
package org.oscim.ios;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.GLAdapter;
|
||||
import org.oscim.gdx.GdxMap;
|
||||
import org.oscim.ios.backend.IosGLAdapter;
|
||||
import org.oscim.ios.backend.IosGraphics;
|
||||
import org.oscim.layers.tile.vector.BuildingLayer;
|
||||
import org.oscim.layers.tile.vector.VectorTileLayer;
|
||||
import org.oscim.layers.tile.vector.labeling.LabelLayer;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.tiling.TileSource;
|
||||
import org.oscim.tiling.source.oscimap4.OSciMap4TileSource;
|
||||
import org.robovm.cocoatouch.foundation.NSAutoreleasePool;
|
||||
import org.robovm.cocoatouch.glkit.GLKViewDrawableStencilFormat;
|
||||
import org.robovm.cocoatouch.uikit.UIApplication;
|
||||
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSApplication;
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSApplicationConfiguration;
|
||||
|
||||
public class RobovmLauncher extends IOSApplication.Delegate {
|
||||
@Override
|
||||
protected IOSApplication createApplication() {
|
||||
IOSApplicationConfiguration config = new IOSApplicationConfiguration();
|
||||
config.orientationLandscape = true;
|
||||
config.orientationPortrait = true;
|
||||
config.stencilFormat = GLKViewDrawableStencilFormat.Format8;
|
||||
|
||||
return new IOSApplication(new GdxMap() {
|
||||
@Override
|
||||
public void createLayers() {
|
||||
TileSource tileSource = new OSciMap4TileSource();
|
||||
|
||||
//initDefaultLayers(tileSource, false,true, false);
|
||||
VectorTileLayer l = mMap.setBaseMap(tileSource);
|
||||
mMap.setTheme(VtmThemes.NEWTRON);
|
||||
mMap.layers().add(new BuildingLayer(mMap, l));
|
||||
mMap.layers().add(new LabelLayer(mMap, l));
|
||||
|
||||
// mMap.getLayers().add(new GenericLayer(mMap, new
|
||||
// GridRenderer(1,new Line(Color.LTGRAY, 1.2f),null)));
|
||||
|
||||
mMap.setMapPosition(53.1, 8.8, 1 << 14);
|
||||
}
|
||||
|
||||
}, config);
|
||||
}
|
||||
|
||||
public static void main(String[] argv) {
|
||||
|
||||
NSAutoreleasePool pool = new NSAutoreleasePool();
|
||||
System.setProperty(org.slf4j.impl.SimpleLogger.DEFAULT_LOG_LEVEL_KEY, "TRACE");
|
||||
CanvasAdapter.g = IosGraphics.get();
|
||||
GLAdapter.g = new IosGLAdapter();
|
||||
|
||||
UIApplication.main(argv, null, RobovmLauncher.class);
|
||||
pool.drain();
|
||||
}
|
||||
}
|
||||
77
vtm-ios/src/org/oscim/ios/backend/IosBitmap.java
Normal file
77
vtm-ios/src/org/oscim/ios/backend/IosBitmap.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package org.oscim.ios.backend;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.oscim.backend.GL20;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.g2d.Gdx2DPixmap;
|
||||
|
||||
public class IosBitmap implements Bitmap {
|
||||
|
||||
Pixmap pixmap;
|
||||
boolean disposable;
|
||||
|
||||
/** always argb8888 */
|
||||
public IosBitmap(int width, int height, int format) {
|
||||
pixmap = new Pixmap(width, height, Pixmap.Format.RGBA8888);
|
||||
}
|
||||
|
||||
public IosBitmap(String fileName) {
|
||||
FileHandle handle = Gdx.files.internal(fileName);
|
||||
pixmap = new Pixmap(handle);
|
||||
disposable = true;
|
||||
}
|
||||
|
||||
public IosBitmap(InputStream inputStream) throws IOException {
|
||||
pixmap = new Pixmap(new Gdx2DPixmap(inputStream, Gdx2DPixmap.GDX2D_FORMAT_RGBA8888));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWidth() {
|
||||
return pixmap.getWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHeight() {
|
||||
return pixmap.getHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void recycle() {
|
||||
// FIXME this should be called at some point in time
|
||||
pixmap.dispose();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getPixels() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eraseColor(int color) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void uploadToTexture(boolean replace) {
|
||||
|
||||
Gdx.gl.glTexImage2D(GL20.GL_TEXTURE_2D, 0, pixmap.getGLInternalFormat(),
|
||||
pixmap.getWidth(), pixmap.getHeight(), 0,
|
||||
pixmap.getGLFormat(), pixmap.getGLType(),
|
||||
pixmap.getPixels());
|
||||
|
||||
if (disposable) {
|
||||
pixmap.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
78
vtm-ios/src/org/oscim/ios/backend/IosCanvas.java
Normal file
78
vtm-ios/src/org/oscim/ios/backend/IosCanvas.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package org.oscim.ios.backend;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.TextureData;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont;
|
||||
import com.badlogic.gdx.graphics.g2d.BitmapFont.Glyph;
|
||||
|
||||
public class IosCanvas implements Canvas {
|
||||
|
||||
IosBitmap bitmap;
|
||||
static BitmapFont font = new BitmapFont();
|
||||
|
||||
public IosCanvas() {
|
||||
// canvas comes with gdx pixmap
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmap(Bitmap bitmap) {
|
||||
this.bitmap = (IosBitmap) bitmap;
|
||||
this.bitmap.pixmap.setColor(0);
|
||||
this.bitmap.pixmap.fill();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawText(String string, float x, float y, Paint paint) {
|
||||
if (bitmap == null) {
|
||||
// log.debug("no bitmap set");
|
||||
return;
|
||||
}
|
||||
|
||||
// IosPaint p = (IosPaint) paint;
|
||||
|
||||
Pixmap pixmap = bitmap.pixmap;
|
||||
|
||||
TextureData td = font.getRegion().getTexture().getTextureData();
|
||||
if (!td.isPrepared())
|
||||
td.prepare();
|
||||
|
||||
Pixmap f = td.consumePixmap();
|
||||
|
||||
int adv = (int) x;
|
||||
Glyph last = null;
|
||||
|
||||
int ch = (int) font.getCapHeight();
|
||||
int h = (int) font.getLineHeight();
|
||||
int yy = (int) (y - font.getLineHeight());
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
|
||||
// pixmap.setColor(0xff0000ff);
|
||||
// int w = (int) font.getBounds(string).width;
|
||||
// pixmap.drawRectangle((int) x - 4, (int) y - 4, w + 8, h + 8);
|
||||
|
||||
for (int i = 0; i < string.length(); i++) {
|
||||
char c = string.charAt(i);
|
||||
Glyph g = font.getData().getGlyph(c);
|
||||
if (g == null)
|
||||
g = font.getData().getGlyph(' ');
|
||||
|
||||
if (i > 0)
|
||||
adv += last.getKerning(c);
|
||||
pixmap.drawPixmap(f, adv, //- g.xoffset,
|
||||
yy - (g.height + g.yoffset) - (h - ch),
|
||||
g.srcX, g.srcY,
|
||||
g.width, g.height);
|
||||
adv += g.width;
|
||||
last = g;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBitmap(Bitmap bitmap, float x, float y) {
|
||||
}
|
||||
}
|
||||
9
vtm-ios/src/org/oscim/ios/backend/IosGLAdapter.java
Normal file
9
vtm-ios/src/org/oscim/ios/backend/IosGLAdapter.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package org.oscim.ios.backend;
|
||||
|
||||
import org.oscim.backend.GL20;
|
||||
|
||||
import com.badlogic.gdx.backends.iosrobovm.IOSGLES20;
|
||||
|
||||
public class IosGLAdapter extends IOSGLES20 implements GL20 {
|
||||
|
||||
}
|
||||
56
vtm-ios/src/org/oscim/ios/backend/IosGraphics.java
Normal file
56
vtm-ios/src/org/oscim/ios/backend/IosGraphics.java
Normal file
@@ -0,0 +1,56 @@
|
||||
package org.oscim.ios.backend;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
import org.oscim.backend.CanvasAdapter;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Canvas;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
public class IosGraphics extends CanvasAdapter {
|
||||
|
||||
private static final IosGraphics INSTANCE = new IosGraphics();
|
||||
|
||||
public static CanvasAdapter get() {
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Canvas getCanvas() {
|
||||
return new IosCanvas();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Paint getPaint() {
|
||||
return new IosPaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap getBitmap(int width, int height, int format) {
|
||||
return new IosBitmap(width, height, format);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap decodeBitmap(InputStream inputStream) {
|
||||
try {
|
||||
return new IosBitmap(inputStream);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Bitmap loadBitmapAsset(String fileName) {
|
||||
return new IosBitmap(fileName);
|
||||
|
||||
// try {
|
||||
// return createBitmap(fileName);
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
// return null;
|
||||
}
|
||||
|
||||
}
|
||||
74
vtm-ios/src/org/oscim/ios/backend/IosPaint.java
Normal file
74
vtm-ios/src/org/oscim/ios/backend/IosPaint.java
Normal file
@@ -0,0 +1,74 @@
|
||||
package org.oscim.ios.backend;
|
||||
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.backend.canvas.Paint;
|
||||
|
||||
public class IosPaint implements Paint {
|
||||
|
||||
@Override
|
||||
public int getColor() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextHeight(String text) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTextWidth(String text) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBitmapShader(Bitmap bitmap) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColor(int color) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDashPathEffect(float[] strokeDasharray) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrokeCap(Cap cap) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStrokeWidth(float width) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStyle(Style style) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextAlign(Align align) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTextSize(float textSize) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public float measureText(String text) {
|
||||
return IosCanvas.font.getBounds(text).width;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFontHeight() {
|
||||
return IosCanvas.font.getLineHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getFontDescent() {
|
||||
return IosCanvas.font.getDescent();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user