Improve code / xml formatting, closes #54

This commit is contained in:
Emux
2016-07-09 19:45:22 +03:00
parent 7919d0ab9c
commit e793e8851b
458 changed files with 58405 additions and 63062 deletions

View File

@@ -14,7 +14,6 @@ dependencies {
sourceSets {
main {
java.srcDirs = ['src']
output.resourcesDir = 'assets'
}
}

View File

@@ -17,6 +17,13 @@
*/
package org.oscim.awt;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.BufferUtils;
import org.oscim.backend.GL;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.renderer.bucket.TextureBucket;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
@@ -25,130 +32,123 @@ import java.nio.IntBuffer;
import javax.imageio.ImageIO;
import org.oscim.backend.GL;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.renderer.bucket.TextureBucket;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.BufferUtils;
public class AwtBitmap implements Bitmap {
BufferedImage bitmap;
int width;
int height;
BufferedImage bitmap;
int width;
int height;
boolean internal;
boolean internal;
public AwtBitmap(int width, int height, int format) {
bitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
this.width = width;
this.height = height;
public AwtBitmap(int width, int height, int format) {
bitmap = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
this.width = width;
this.height = height;
internal = true;
// if (!this.bitmap.isAlphaPremultiplied())
// this.bitmap.coerceData(true);
}
internal = true;
// if (!this.bitmap.isAlphaPremultiplied())
// this.bitmap.coerceData(true);
}
AwtBitmap(InputStream inputStream) throws IOException {
AwtBitmap(InputStream inputStream) throws IOException {
this.bitmap = ImageIO.read(inputStream);
this.width = this.bitmap.getWidth();
this.height = this.bitmap.getHeight();
if (!this.bitmap.isAlphaPremultiplied()
&& this.bitmap.getType() == BufferedImage.TYPE_INT_ARGB)
this.bitmap.coerceData(true);
}
this.bitmap = ImageIO.read(inputStream);
this.width = this.bitmap.getWidth();
this.height = this.bitmap.getHeight();
if (!this.bitmap.isAlphaPremultiplied()
&& this.bitmap.getType() == BufferedImage.TYPE_INT_ARGB)
this.bitmap.coerceData(true);
}
public AwtBitmap(BufferedImage bitmap) {
this.bitmap = bitmap;
this.width = this.bitmap.getWidth();
this.height = this.bitmap.getHeight();
if (!this.bitmap.isAlphaPremultiplied()
&& this.bitmap.getType() == BufferedImage.TYPE_INT_ARGB)
this.bitmap.coerceData(true);
}
public AwtBitmap(BufferedImage bitmap) {
this.bitmap = bitmap;
this.width = this.bitmap.getWidth();
this.height = this.bitmap.getHeight();
if (!this.bitmap.isAlphaPremultiplied()
&& this.bitmap.getType() == BufferedImage.TYPE_INT_ARGB)
this.bitmap.coerceData(true);
}
@Override
public int getWidth() {
return width;
}
@Override
public int getWidth() {
return width;
}
@Override
public int getHeight() {
return height;
}
@Override
public int getHeight() {
return height;
}
@Override
public int[] getPixels() {
return null;
}
@Override
public int[] getPixels() {
return null;
}
@Override
public void eraseColor(int transparent) {
}
@Override
public void eraseColor(int transparent) {
}
private final static IntBuffer tmpBuffer = BufferUtils
.newIntBuffer(TextureBucket.TEXTURE_HEIGHT
* TextureBucket.TEXTURE_WIDTH);
private final static int[] tmpPixel = new int[TextureBucket.TEXTURE_HEIGHT
* TextureBucket.TEXTURE_WIDTH];
private final static IntBuffer tmpBuffer = BufferUtils
.newIntBuffer(TextureBucket.TEXTURE_HEIGHT
* TextureBucket.TEXTURE_WIDTH);
private final static int[] tmpPixel = new int[TextureBucket.TEXTURE_HEIGHT
* TextureBucket.TEXTURE_WIDTH];
private final static boolean WRITE_TEX = false;
private int dbgCnt;
private final static boolean WRITE_TEX = false;
private int dbgCnt;
@Override
public void uploadToTexture(boolean replace) {
int[] pixels;
IntBuffer buffer;
@Override
public void uploadToTexture(boolean replace) {
int[] pixels;
IntBuffer buffer;
if (width * height < TextureBucket.TEXTURE_HEIGHT * TextureBucket.TEXTURE_WIDTH) {
pixels = tmpPixel;
buffer = tmpBuffer;
buffer.clear();
} else {
pixels = new int[width * height];
buffer = BufferUtils.newIntBuffer(width * height);
}
if (width * height < TextureBucket.TEXTURE_HEIGHT * TextureBucket.TEXTURE_WIDTH) {
pixels = tmpPixel;
buffer = tmpBuffer;
buffer.clear();
} else {
pixels = new int[width * height];
buffer = BufferUtils.newIntBuffer(width * height);
}
// FIXME dont convert to argb when there data is greyscale
bitmap.getRGB(0, 0, width, height, pixels, 0, width);
// FIXME dont convert to argb when there data is greyscale
bitmap.getRGB(0, 0, width, height, pixels, 0, width);
if (WRITE_TEX) {
try {
boolean ok = ImageIO.write(bitmap, "png", new File("texture_" + dbgCnt + ".png"));
System.out.println("write tex " + ok + " " + dbgCnt);
dbgCnt++;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (WRITE_TEX) {
try {
boolean ok = ImageIO.write(bitmap, "png", new File("texture_" + dbgCnt + ".png"));
System.out.println("write tex " + ok + " " + dbgCnt);
dbgCnt++;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
for (int i = 0, n = width * height; i < n; i++) {
int c = pixels[i];
if (c == 0)
continue;
for (int i = 0, n = width * height; i < n; i++) {
int c = pixels[i];
if (c == 0)
continue;
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;
}
buffer.put(pixels, 0, width * height);
buffer.flip();
buffer.put(pixels, 0, width * height);
buffer.flip();
Gdx.gl20.glTexImage2D(GL.TEXTURE_2D, 0, GL.RGBA, width,
height, 0, GL.RGBA, GL.UNSIGNED_BYTE, buffer);
}
Gdx.gl20.glTexImage2D(GL.TEXTURE_2D, 0, GL.RGBA, width,
height, 0, GL.RGBA, GL.UNSIGNED_BYTE, buffer);
}
@Override
public void recycle() {
}
@Override
public void recycle() {
}
@Override
public boolean isValid() {
return true;
}
@Override
public boolean isValid() {
return true;
}
}

View File

@@ -17,6 +17,10 @@
*/
package org.oscim.awt;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint;
import java.awt.AlphaComposite;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
@@ -24,73 +28,69 @@ import java.awt.Shape;
import java.awt.font.TextLayout;
import java.awt.geom.AffineTransform;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint;
public class AwtCanvas implements Canvas {
Graphics2D canvas;
Graphics2D canvas;
public AwtCanvas() {
public AwtCanvas() {
}
}
@Override
public void setBitmap(Bitmap bitmap) {
if (canvas != null)
canvas.dispose();
@Override
public void setBitmap(Bitmap bitmap) {
if (canvas != null)
canvas.dispose();
AwtBitmap awtBitamp = (AwtBitmap) bitmap;
AwtBitmap awtBitamp = (AwtBitmap) bitmap;
canvas = awtBitamp.bitmap.createGraphics();
canvas = awtBitamp.bitmap.createGraphics();
canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0));
canvas.fillRect(0, 0, bitmap.getWidth(), bitmap.getHeight());
canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.CLEAR, 0));
canvas.fillRect(0, 0, bitmap.getWidth(), bitmap.getHeight());
canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
canvas.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 1.0f));
//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);
//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);
}
}
private final AffineTransform tx = new AffineTransform();
private final AffineTransform tx = new AffineTransform();
@Override
public void drawText(String text, float x, float y, Paint fill, Paint stroke) {
@Override
public void drawText(String text, float x, float y, Paint fill, Paint stroke) {
AwtPaint fillPaint = (AwtPaint) fill;
AwtPaint fillPaint = (AwtPaint) fill;
if (stroke == null) {
canvas.setColor(fillPaint.color);
canvas.setFont(fillPaint.font);
canvas.drawString(text, x + AwtPaint.TEXT_OFFSET, y);
} else {
AwtPaint strokePaint = (AwtPaint) stroke;
if (stroke == null) {
canvas.setColor(fillPaint.color);
canvas.setFont(fillPaint.font);
canvas.drawString(text, x + AwtPaint.TEXT_OFFSET, y);
} else {
AwtPaint strokePaint = (AwtPaint) stroke;
canvas.setColor(strokePaint.color);
canvas.setStroke(strokePaint.stroke);
canvas.setColor(strokePaint.color);
canvas.setStroke(strokePaint.stroke);
TextLayout tl = new TextLayout(text, fillPaint.font,
canvas.getFontRenderContext());
tx.setToIdentity();
tx.translate(x, y);
TextLayout tl = new TextLayout(text, fillPaint.font,
canvas.getFontRenderContext());
tx.setToIdentity();
tx.translate(x, y);
Shape s = tl.getOutline(tx);
Shape s = tl.getOutline(tx);
canvas.draw(s);
canvas.setColor(fillPaint.color);
canvas.fill(s);
}
}
canvas.draw(s);
canvas.setColor(fillPaint.color);
canvas.fill(s);
}
}
@Override
public void drawBitmap(Bitmap bitmap, float x, float y) {
throw new UnknownError("not implemented");
}
@Override
public void drawBitmap(Bitmap bitmap, float x, float y) {
throw new UnknownError("not implemented");
}
}

View File

@@ -17,6 +17,11 @@
*/
package org.oscim.awt;
import org.oscim.backend.CanvasAdapter;
import org.oscim.backend.canvas.Bitmap;
import org.oscim.backend.canvas.Canvas;
import org.oscim.backend.canvas.Paint;
import java.awt.Font;
import java.awt.FontMetrics;
import java.awt.Graphics2D;
@@ -25,88 +30,83 @@ import java.awt.image.BufferedImage;
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 AwtGraphics extends CanvasAdapter {
public static void init() {
CanvasAdapter.init(new AwtGraphics());
}
public static void init() {
CanvasAdapter.init(new AwtGraphics());
}
public static BufferedImage getBitmap(Bitmap bitmap) {
return ((AwtBitmap) bitmap).bitmap;
}
public static BufferedImage getBitmap(Bitmap bitmap) {
return ((AwtBitmap) bitmap).bitmap;
}
private AwtGraphics() {
// do nothing
}
private AwtGraphics() {
// do nothing
}
@Override
public Paint newPaintImpl() {
return new AwtPaint();
}
@Override
public Paint newPaintImpl() {
return new AwtPaint();
}
@Override
public Bitmap newBitmapImpl(int width, int height, int format) {
return new AwtBitmap(width, height, format);
}
@Override
public Bitmap newBitmapImpl(int width, int height, int format) {
return new AwtBitmap(width, height, format);
}
@Override
public Canvas newCanvasImpl() {
return new AwtCanvas();
}
@Override
public Canvas newCanvasImpl() {
return new AwtCanvas();
}
static final BufferedImage image;
static final BufferedImage image;
static final Graphics2D canvas;
static final Graphics2D canvas;
static {
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_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_ON);
//canvas.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
}
static {
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_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
FontMetrics fm = canvas.getFontMetrics();
// int ascent = fm.getMaxAscent();
// int descent = fm.getMaxDescent();
// int advance = fm.charWidth('W'); // width of widest char, more
// reliable than getMaxAdvance();
// int leading = fm.getLeading();
//
return fm;
}
static synchronized FontMetrics getFontMetrics(Font font) {
canvas.setFont(font);
// get character measurements
FontMetrics fm = canvas.getFontMetrics();
// int ascent = fm.getMaxAscent();
// int descent = fm.getMaxDescent();
// int advance = fm.charWidth('W'); // width of widest char, more
// reliable than getMaxAdvance();
// int leading = fm.getLeading();
//
return fm;
}
static synchronized float getTextWidth(FontMetrics fm, String text) {
//return (float)fm.getStringBounds(text, canvas).getWidth();
return fm.stringWidth(text);
}
static synchronized float getTextWidth(FontMetrics fm, String text) {
//return (float)fm.getStringBounds(text, canvas).getWidth();
return fm.stringWidth(text);
}
@Override
public Bitmap decodeBitmapImpl(InputStream inputStream) {
try {
return new AwtBitmap(inputStream);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
@Override
public Bitmap decodeBitmapImpl(InputStream inputStream) {
try {
return new AwtBitmap(inputStream);
} 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 Bitmap loadBitmapAssetImpl(String fileName) {
try {
return createBitmap(fileName);
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}

View File

@@ -17,6 +17,8 @@
*/
package org.oscim.awt;
import org.oscim.backend.canvas.Paint;
import java.awt.BasicStroke;
import java.awt.Color;
import java.awt.Font;
@@ -27,136 +29,135 @@ import java.text.AttributedCharacterIterator.Attribute;
import java.util.HashMap;
import java.util.Map;
import org.oscim.backend.canvas.Paint;
public class AwtPaint implements Paint {
final static float TEXT_OFFSET = 2;
final static float TEXT_OFFSET = 2;
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;
}
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;
}
throw new IllegalArgumentException("unknown cap: " + cap);
}
throw new IllegalArgumentException("unknown cap: " + cap);
}
static final Font defaultFont;
static {
Map<Attribute, Object> textAttributes = new HashMap<Attribute, Object>();
textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
textAttributes.put(TextAttribute.FAMILY, "Arial");
textAttributes.put(TextAttribute.SIZE, 14);
static final Font defaultFont;
defaultFont = Font.getFont(textAttributes);
}
static {
Map<Attribute, Object> textAttributes = new HashMap<Attribute, Object>();
textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON);
textAttributes.put(TextAttribute.FAMILY, "Arial");
textAttributes.put(TextAttribute.SIZE, 14);
Font font = defaultFont; // new Font("Default", Font.PLAIN, 13);
Stroke stroke;
FontMetrics fm;
Color color = new Color(0.1f, 0.1f, 0.1f, 1);
defaultFont = Font.getFont(textAttributes);
}
private int cap;
private float strokeWidth;
Font font = defaultFont; // new Font("Default", Font.PLAIN, 13);
Stroke stroke;
FontMetrics fm;
Color color = new Color(0.1f, 0.1f, 0.1f, 1);
//private Align mAlign;
private int cap;
private float strokeWidth;
@Override
public int getColor() {
return 0;
}
//private Align mAlign;
@Override
public void setColor(int c) {
color = new Color(((c >> 16) & 0xff) / 255f,
((c >> 8) & 0xff) / 255f,
((c >> 0) & 0xff) / 255f,
((c >> 24) & 0xff) / 255f);
}
@Override
public int getColor() {
return 0;
}
@Override
public void setStrokeCap(Cap cap) {
this.cap = getCap(cap);
createStroke();
}
@Override
public void setColor(int c) {
color = new Color(((c >> 16) & 0xff) / 255f,
((c >> 8) & 0xff) / 255f,
((c >> 0) & 0xff) / 255f,
((c >> 24) & 0xff) / 255f);
}
@Override
public void setStrokeWidth(float width) {
strokeWidth = width + 1;
createStroke();
@Override
public void setStrokeCap(Cap cap) {
this.cap = getCap(cap);
createStroke();
}
// int size = font.getSize();
// font = font.deriveFont(size + width * 4);
@Override
public void setStrokeWidth(float width) {
strokeWidth = width + 1;
createStroke();
// TODO Auto-generated method stub
// int size = font.getSize();
// font = font.deriveFont(size + width * 4);
}
// TODO Auto-generated method stub
@Override
public void setStyle(Style style) {
// TODO Auto-generated method stub
}
}
@Override
public void setStyle(Style style) {
// TODO Auto-generated method stub
@Override
public void setTextAlign(Align align) {
//mAlign = align;
}
}
@Override
public void setTextSize(float textSize) {
font = font.deriveFont(textSize);
@Override
public void setTextAlign(Align align) {
//mAlign = align;
}
}
@Override
public void setTextSize(float textSize) {
font = font.deriveFont(textSize);
@Override
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
// TODO Auto-generated method stub
}
}
@Override
public void setTypeface(FontFamily fontFamily, FontStyle fontStyle) {
// TODO Auto-generated method stub
@Override
public float measureText(String text) {
if (fm == null)
fm = AwtGraphics.getFontMetrics(this.font);
}
float w = AwtGraphics.getTextWidth(fm, text);
//Gdx.app.log("text width:", text + " " + w);
return w + 4;
// return fm.getStringBounds(text, A).getWidth();
// return AwtGraphics.getTextWidth(fm, text);
// return fm.stringWidth(text);
}
@Override
public float measureText(String text) {
if (fm == null)
fm = AwtGraphics.getFontMetrics(this.font);
@Override
public float getFontHeight() {
if (fm == null)
fm = AwtGraphics.getFontMetrics(this.font);
float w = AwtGraphics.getTextWidth(fm, text);
//Gdx.app.log("text width:", text + " " + w);
return w + 4;
// return fm.getStringBounds(text, A).getWidth();
// return AwtGraphics.getTextWidth(fm, text);
// return fm.stringWidth(text);
}
float height = fm.getHeight();
@Override
public float getFontHeight() {
if (fm == null)
fm = AwtGraphics.getFontMetrics(this.font);
return height;
}
float height = fm.getHeight();
@Override
public float getFontDescent() {
if (fm == null)
fm = AwtGraphics.getFontMetrics(this.font);
return height;
}
float desc = fm.getDescent();
@Override
public float getFontDescent() {
if (fm == null)
fm = AwtGraphics.getFontMetrics(this.font);
return desc;
}
float desc = fm.getDescent();
private void createStroke() {
if (strokeWidth <= 0) {
return;
}
stroke = new BasicStroke(strokeWidth, cap, BasicStroke.JOIN_MITER, 1, null, 0);
}
return desc;
}
private void createStroke() {
if (strokeWidth <= 0) {
return;
}
stroke = new BasicStroke(strokeWidth, cap, BasicStroke.JOIN_MITER, 1, null, 0);
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -17,6 +17,10 @@
*/
package org.oscim.gdx;
import com.badlogic.gdx.backends.jglfw.JglfwApplication;
import com.badlogic.gdx.backends.jglfw.JglfwApplicationConfiguration;
import com.badlogic.gdx.utils.SharedLibraryLoader;
import org.oscim.awt.AwtGraphics;
import org.oscim.backend.GLAdapter;
import org.oscim.core.Tile;
@@ -26,65 +30,61 @@ import org.oscim.utils.FastMath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.badlogic.gdx.backends.jglfw.JglfwApplication;
import com.badlogic.gdx.backends.jglfw.JglfwApplicationConfiguration;
import com.badlogic.gdx.utils.SharedLibraryLoader;
public class GdxMapApp extends GdxMap {
public static final Logger log = LoggerFactory.getLogger(GdxMapApp.class);
public static final Logger log = LoggerFactory.getLogger(GdxMapApp.class);
public static void init() {
// load native library
new SharedLibraryLoader().load("vtm-jni");
// init globals
AwtGraphics.init();
GdxAssets.init("assets/");
GLAdapter.init(new GdxGL());
GLAdapter.GDX_DESKTOP_QUIRKS = true;
}
public static void init() {
// load native library
new SharedLibraryLoader().load("vtm-jni");
// init globals
AwtGraphics.init();
GdxAssets.init("assets/");
GLAdapter.init(new GdxGL());
GLAdapter.GDX_DESKTOP_QUIRKS = true;
}
public static void main(String[] args) {
Tile.SIZE = 360;
init();
new JglfwApplication(new GdxMapApp(), getConfig());
}
public static void main(String[] args) {
Tile.SIZE = 360;
init();
new JglfwApplication(new GdxMapApp(), getConfig());
}
public static void run(GdxMap map, JglfwApplicationConfiguration config, int tileSize) {
Tile.SIZE = FastMath.clamp(tileSize, 128, 512);
public static void run(GdxMap map, JglfwApplicationConfiguration config, int tileSize) {
Tile.SIZE = FastMath.clamp(tileSize, 128, 512);
new JglfwApplication(map, (config == null ? getConfig() : config));
}
new JglfwApplication(map, (config == null ? getConfig() : config));
}
public static void run(JglfwApplicationConfiguration config, int tileSize, GdxMap map) {
run(map, config, tileSize);
}
public static void run(JglfwApplicationConfiguration config, int tileSize, GdxMap map) {
run(map, config, tileSize);
}
static protected JglfwApplicationConfiguration getConfig() {
JglfwApplicationConfiguration cfg = new JglfwApplicationConfiguration();
cfg.title = "vtm-gdx";
cfg.width = 800;
cfg.height = 600;
cfg.stencil = 8;
//cfg.samples = 2;
cfg.foregroundFPS = 30;
cfg.backgroundFPS = 10;
return cfg;
}
static protected JglfwApplicationConfiguration getConfig() {
JglfwApplicationConfiguration cfg = new JglfwApplicationConfiguration();
cfg.title = "vtm-gdx";
cfg.width = 800;
cfg.height = 600;
cfg.stencil = 8;
//cfg.samples = 2;
cfg.foregroundFPS = 30;
cfg.backgroundFPS = 10;
return cfg;
}
@Override
public void createLayers() {
TileSource tileSource = new OSciMap4TileSource();
@Override
public void createLayers() {
TileSource tileSource = new OSciMap4TileSource();
// TileSource tileSource = new MapFileTileSource();
// tileSource.setOption("file", "/home/jeff/germany.map");
// TileSource tileSource = new MapFileTileSource();
// tileSource.setOption("file", "/home/jeff/germany.map");
initDefaultLayers(tileSource, false, true, true);
initDefaultLayers(tileSource, false, true, true);
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ImagicoLandcover(), 20));
//mMap.getLayers().add(new BitmapTileLayer(mMap, new OSMTileSource(), 20));
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ArcGISWorldShaded(), 20));
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ImagicoLandcover(), 20));
//mMap.getLayers().add(new BitmapTileLayer(mMap, new OSMTileSource(), 20));
//mMap.getLayers().add(new BitmapTileLayer(mMap, new ArcGISWorldShaded(), 20));
mMap.setMapPosition(0, 0, 1 << 2);
}
mMap.setMapPosition(0, 0, 1 << 2);
}
}