- more work on generic pools

- generic inlist
This commit is contained in:
Hannes Janetzek
2013-04-10 01:56:38 +02:00
parent ab56cc4b18
commit 129a780c41
7 changed files with 151 additions and 125 deletions

View File

@@ -16,10 +16,11 @@ package org.oscim.renderer.layer;
import java.nio.ShortBuffer;
import org.oscim.utils.pool.Inlist;
/**
* @authorHannes Janetzek
*/
public abstract class Layer {
public abstract class Layer extends Inlist<Layer>{
public final static byte LINE = 0;
public final static byte POLYGON = 1;
public final static byte TEXLINE = 2;
@@ -31,8 +32,6 @@ public abstract class Layer {
public byte type = -1;
public Layer next;
// drawing order from bottom to top
int level;

View File

@@ -43,8 +43,6 @@ public class TextItem extends Inlist<TextItem> {
TextItem ti = pool.get();
ti.next = null;
ti.x = orig.x;
ti.y = orig.y;
@@ -56,6 +54,22 @@ public class TextItem extends Inlist<TextItem> {
return ti;
}
public static boolean shareText(TextItem ti1, TextItem ti2){
if (ti1.text != ti2.text)
return false;
if (ti1.string == ti2.string)
return true;
if (ti1.string.equals(ti2.string)){
// make strings unique, should be done only once..
ti1.string = ti2.string;
return true;
}
return false;
}
public TextItem set(float x, float y, String string, Text text) {
this.x = x;
this.y = y;