labeling testing
This commit is contained in:
@@ -290,7 +290,7 @@ public class ExtrusionLayer extends Layer {
|
||||
}
|
||||
|
||||
/* check if face is within tile */
|
||||
if (!mClipper.clipNext((int) nx, (int) ny)) {
|
||||
if (mClipper.clipNext((int) nx, (int) ny) == 0) {
|
||||
even = (even == 0 ? 1 : 0);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
package org.oscim.renderer.layer;
|
||||
|
||||
import org.oscim.theme.renderinstruction.Text;
|
||||
import org.oscim.utils.OBB2D;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
@@ -40,7 +39,33 @@ public class TextItem {
|
||||
pool = pool.next;
|
||||
|
||||
ti.next = null;
|
||||
ti.active = 0;
|
||||
//ti.active = 0;
|
||||
return ti;
|
||||
}
|
||||
}
|
||||
|
||||
public static TextItem copy(TextItem orig) {
|
||||
synchronized (lock) {
|
||||
TextItem ti = pool;
|
||||
|
||||
if (ti == null) {
|
||||
count++;
|
||||
ti = new TextItem();
|
||||
} else {
|
||||
inPool--;
|
||||
pool = pool.next;
|
||||
}
|
||||
|
||||
ti.next = null;
|
||||
|
||||
ti.x = orig.x;
|
||||
ti.y = orig.y;
|
||||
|
||||
ti.x1 = orig.x1;
|
||||
ti.y1 = orig.y1;
|
||||
ti.x2 = orig.x2;
|
||||
ti.y2 = orig.y2;
|
||||
|
||||
return ti;
|
||||
}
|
||||
}
|
||||
@@ -115,28 +140,24 @@ public class TextItem {
|
||||
public TextItem move(TextItem ti, float dx, float dy) {
|
||||
this.x = dx + ti.x;
|
||||
this.y = dy + ti.y;
|
||||
this.string = ti.string;
|
||||
this.text = ti.text;
|
||||
this.width = ti.width;
|
||||
this.length = ti.length;
|
||||
return this;
|
||||
|
||||
}
|
||||
|
||||
/* copy properties from 'ti' and add offset
|
||||
*
|
||||
* */
|
||||
public TextItem move(TextItem ti, float dx, float dy, float scale) {
|
||||
this.x = dx + (ti.x * scale);
|
||||
this.y = dy + (ti.y * scale);
|
||||
this.x = (dx + ti.x) * scale;
|
||||
this.y = (dy + ti.y) * scale;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void clone(TextItem ti){
|
||||
this.string = ti.string;
|
||||
this.text = ti.text;
|
||||
this.width = ti.width;
|
||||
this.length = ti.length;
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setAxisAlignedBBox(){
|
||||
public void setAxisAlignedBBox() {
|
||||
this.x1 = x - width / 2;
|
||||
this.y1 = y - text.fontHeight / 2;
|
||||
this.x2 = x + width / 2;
|
||||
@@ -197,8 +218,10 @@ public class TextItem {
|
||||
public TextItem n1;
|
||||
public TextItem n2;
|
||||
|
||||
public byte origin;
|
||||
public byte edges;
|
||||
|
||||
public int active;
|
||||
public OBB2D bbox;
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + " " + y + " " + string;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,7 +34,6 @@ public final class TextLayer extends TextureLayer {
|
||||
|
||||
public TextItem labels;
|
||||
private final Canvas mCanvas;
|
||||
private float mScale;
|
||||
|
||||
public TextItem getLabels() {
|
||||
return labels;
|
||||
@@ -44,11 +43,6 @@ public final class TextLayer extends TextureLayer {
|
||||
type = Layer.SYMBOL;
|
||||
mCanvas = new Canvas();
|
||||
fixed = true;
|
||||
mScale = 1;
|
||||
}
|
||||
|
||||
public void setScale(float scale) {
|
||||
mScale = scale;
|
||||
}
|
||||
|
||||
public boolean removeText(TextItem item) {
|
||||
@@ -132,7 +126,7 @@ public final class TextLayer extends TextureLayer {
|
||||
for (TextItem it = labels; it != null;) {
|
||||
|
||||
float width = it.width + 2 * mFontPadX;
|
||||
float height = (int) (it.text.fontHeight) + 2 * mFontPadY + 0.5f;
|
||||
float height = (int) (it.text.fontHeight) + 0.5f;
|
||||
|
||||
if (height > advanceY)
|
||||
advanceY = (int) height;
|
||||
@@ -158,7 +152,8 @@ public final class TextLayer extends TextureLayer {
|
||||
}
|
||||
}
|
||||
|
||||
yy = y + (height - 1) - it.text.fontDescent - mFontPadY;
|
||||
//yy = y + (height - 1) - it.text.fontDescent - mFontPadY;
|
||||
yy = y + height - it.text.fontDescent; // - mFontPadY;
|
||||
|
||||
if (it.text.stroke != null)
|
||||
mCanvas.drawText(it.string, x + it.width / 2, yy, it.text.stroke);
|
||||
@@ -174,11 +169,10 @@ public final class TextLayer extends TextureLayer {
|
||||
|
||||
float hh2 = 0;
|
||||
if (!it.text.caption) {
|
||||
hw /= mScale;
|
||||
hh2 = hh + it.text.fontDescent / 2;
|
||||
hh -= it.text.fontDescent / 2;
|
||||
hh /= mScale;
|
||||
hh2 /= mScale;
|
||||
// displace by baseline
|
||||
float desc = it.text.fontDescent / 2;
|
||||
hh2 = hh + desc;
|
||||
hh = hh - desc;
|
||||
}
|
||||
|
||||
// texture coordinates
|
||||
@@ -192,17 +186,17 @@ public final class TextLayer extends TextureLayer {
|
||||
short x1, x2, x3, x4, y1, y3, y2, y4;
|
||||
|
||||
if (it.text.caption) {
|
||||
if (it.origin == 0) {
|
||||
x1 = x3 = (short) (SCALE * -hw);
|
||||
x2 = x4 = (short) (SCALE * hw);
|
||||
y1 = y2 = (short) (SCALE * hh);
|
||||
y3 = y4 = (short) (SCALE * -hh);
|
||||
} else {
|
||||
x1 = x3 = (short) (SCALE * 0);
|
||||
x2 = x4 = (short) (SCALE * width);
|
||||
y1 = y2 = (short) (SCALE * 0);
|
||||
y3 = y4 = (short) (SCALE * -height);
|
||||
}
|
||||
//if (it.origin == 0) {
|
||||
x1 = x3 = (short) (SCALE * -hw);
|
||||
x2 = x4 = (short) (SCALE * hw);
|
||||
y1 = y2 = (short) (SCALE * hh);
|
||||
y3 = y4 = (short) (SCALE * -hh);
|
||||
//} else {
|
||||
// x1 = x3 = (short) (SCALE * 0);
|
||||
// x2 = x4 = (short) (SCALE * width);
|
||||
// y1 = y2 = (short) (SCALE * 0);
|
||||
// y3 = y4 = (short) (SCALE * -height);
|
||||
//}
|
||||
} else {
|
||||
float vx = it.x1 - it.x2;
|
||||
float vy = it.y1 - it.y2;
|
||||
@@ -219,12 +213,16 @@ public final class TextLayer extends TextureLayer {
|
||||
vx *= hw;
|
||||
vy *= hw;
|
||||
|
||||
// top-left
|
||||
x1 = (short) (SCALE * (vx - ux));
|
||||
y1 = (short) (SCALE * (vy - uy));
|
||||
// top-right
|
||||
x2 = (short) (SCALE * (-vx - ux));
|
||||
y2 = (short) (SCALE * (-vy - uy));
|
||||
// bot-right
|
||||
x4 = (short) (SCALE * (-vx + ux2));
|
||||
y4 = (short) (SCALE * (-vy + uy2));
|
||||
// bot-left
|
||||
x3 = (short) (SCALE * (vx + ux2));
|
||||
y3 = (short) (SCALE * (vy + uy2));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2012 Hannes Janetzek
|
||||
* Copyright 2012, 2013 OpenScienceMap
|
||||
*
|
||||
* 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
|
||||
@@ -17,12 +17,15 @@ package org.oscim.renderer.layer;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
import org.oscim.renderer.TextureObject;
|
||||
import org.oscim.renderer.TextureRenderer;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
/**
|
||||
* @author Hannes Janetzek
|
||||
*/
|
||||
public abstract class TextureLayer extends Layer {
|
||||
// holds textures and offset in vbo
|
||||
public TextureObject textures;
|
||||
|
||||
// scale mode
|
||||
public boolean fixed;
|
||||
|
||||
/**
|
||||
@@ -30,12 +33,11 @@ public abstract class TextureLayer extends Layer {
|
||||
* buffer to add vertices
|
||||
*/
|
||||
void compile(ShortBuffer sbuf) {
|
||||
if (TextureRenderer.debug)
|
||||
Log.d("...", "compile");
|
||||
|
||||
for (TextureObject to = textures; to != null; to = to.next)
|
||||
TextureObject.uploadTexture(to);
|
||||
|
||||
// add vertices to vbo
|
||||
Layers.addPoolItems(this, sbuf);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user