refactor: theme...RenderInstruction -> theme.styles.RenderStyle
This commit is contained in:
parent
1e2837c33f
commit
833f49eb35
@ -31,14 +31,14 @@ import org.oscim.renderer.elements.PolygonLayer;
|
|||||||
import org.oscim.renderer.elements.SymbolItem;
|
import org.oscim.renderer.elements.SymbolItem;
|
||||||
import org.oscim.renderer.elements.TextItem;
|
import org.oscim.renderer.elements.TextItem;
|
||||||
import org.oscim.theme.IRenderTheme;
|
import org.oscim.theme.IRenderTheme;
|
||||||
import org.oscim.theme.renderinstruction.Area;
|
import org.oscim.theme.styles.Area;
|
||||||
import org.oscim.theme.renderinstruction.Circle;
|
import org.oscim.theme.styles.Circle;
|
||||||
import org.oscim.theme.renderinstruction.Extrusion;
|
import org.oscim.theme.styles.Extrusion;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
import org.oscim.theme.renderinstruction.LineSymbol;
|
import org.oscim.theme.styles.LineSymbol;
|
||||||
import org.oscim.theme.renderinstruction.RenderInstruction;
|
import org.oscim.theme.styles.RenderStyle;
|
||||||
import org.oscim.theme.renderinstruction.Symbol;
|
import org.oscim.theme.styles.Symbol;
|
||||||
import org.oscim.theme.renderinstruction.Text;
|
import org.oscim.theme.styles.Text;
|
||||||
import org.oscim.tiling.MapTile;
|
import org.oscim.tiling.MapTile;
|
||||||
import org.oscim.tiling.TileLoader;
|
import org.oscim.tiling.TileLoader;
|
||||||
import org.oscim.tiling.TileManager;
|
import org.oscim.tiling.TileManager;
|
||||||
@ -243,7 +243,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
// renderWay(ri);
|
// renderWay(ri);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
private void renderWay(RenderInstruction[] ri) {
|
private void renderWay(RenderStyle[] ri) {
|
||||||
if (ri == null)
|
if (ri == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -251,7 +251,7 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
ri[i].renderWay(this);
|
ri[i].renderWay(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderNode(RenderInstruction[] ri) {
|
private void renderNode(RenderStyle[] ri) {
|
||||||
if (ri == null)
|
if (ri == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import org.oscim.map.Map;
|
|||||||
import org.oscim.renderer.ElementRenderer;
|
import org.oscim.renderer.ElementRenderer;
|
||||||
import org.oscim.renderer.MapRenderer.Matrices;
|
import org.oscim.renderer.MapRenderer.Matrices;
|
||||||
import org.oscim.renderer.elements.LineLayer;
|
import org.oscim.renderer.elements.LineLayer;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
import org.oscim.utils.FastMath;
|
import org.oscim.utils.FastMath;
|
||||||
import org.oscim.utils.LineClipper;
|
import org.oscim.utils.LineClipper;
|
||||||
|
|
||||||
|
|||||||
@ -25,7 +25,7 @@ import org.oscim.layers.tile.example.TestTileLayer.TestTileLoader;
|
|||||||
import org.oscim.map.Map;
|
import org.oscim.map.Map;
|
||||||
import org.oscim.renderer.elements.ElementLayers;
|
import org.oscim.renderer.elements.ElementLayers;
|
||||||
import org.oscim.renderer.elements.LineLayer;
|
import org.oscim.renderer.elements.LineLayer;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
import org.oscim.tiling.MapTile;
|
import org.oscim.tiling.MapTile;
|
||||||
import org.oscim.tiling.TileLoader;
|
import org.oscim.tiling.TileLoader;
|
||||||
import org.oscim.tiling.TileManager;
|
import org.oscim.tiling.TileManager;
|
||||||
|
|||||||
@ -35,14 +35,14 @@ import org.oscim.renderer.elements.PolygonLayer;
|
|||||||
import org.oscim.renderer.elements.SymbolItem;
|
import org.oscim.renderer.elements.SymbolItem;
|
||||||
import org.oscim.renderer.elements.TextItem;
|
import org.oscim.renderer.elements.TextItem;
|
||||||
import org.oscim.theme.IRenderTheme;
|
import org.oscim.theme.IRenderTheme;
|
||||||
import org.oscim.theme.renderinstruction.Area;
|
import org.oscim.theme.styles.Area;
|
||||||
import org.oscim.theme.renderinstruction.Circle;
|
import org.oscim.theme.styles.Circle;
|
||||||
import org.oscim.theme.renderinstruction.Extrusion;
|
import org.oscim.theme.styles.Extrusion;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
import org.oscim.theme.renderinstruction.LineSymbol;
|
import org.oscim.theme.styles.LineSymbol;
|
||||||
import org.oscim.theme.renderinstruction.RenderInstruction;
|
import org.oscim.theme.styles.RenderStyle;
|
||||||
import org.oscim.theme.renderinstruction.Symbol;
|
import org.oscim.theme.styles.Symbol;
|
||||||
import org.oscim.theme.renderinstruction.Text;
|
import org.oscim.theme.styles.Text;
|
||||||
import org.oscim.tiling.MapTile;
|
import org.oscim.tiling.MapTile;
|
||||||
import org.oscim.tiling.TileLoader;
|
import org.oscim.tiling.TileLoader;
|
||||||
import org.oscim.tiling.TileManager;
|
import org.oscim.tiling.TileManager;
|
||||||
@ -253,20 +253,20 @@ public class VectorTileLoader extends TileLoader implements IRenderTheme.Callbac
|
|||||||
// renderWay(ri);
|
// renderWay(ri);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
private void renderWay(RenderInstruction[] ri) {
|
private void renderWay(RenderStyle[] style) {
|
||||||
if (ri == null)
|
if (style == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0, n = ri.length; i < n; i++)
|
for (int i = 0, n = style.length; i < n; i++)
|
||||||
ri[i].renderWay(this);
|
style[i].renderWay(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void renderNode(RenderInstruction[] ri) {
|
private void renderNode(RenderStyle[] style) {
|
||||||
if (ri == null)
|
if (style == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (int i = 0, n = ri.length; i < n; i++)
|
for (int i = 0, n = style.length; i < n; i++)
|
||||||
ri[i].renderNode(this);
|
style[i].renderNode(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearState() {
|
private void clearState() {
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import org.oscim.backend.canvas.Color;
|
|||||||
import org.oscim.renderer.elements.ElementLayers;
|
import org.oscim.renderer.elements.ElementLayers;
|
||||||
import org.oscim.renderer.elements.LineLayer;
|
import org.oscim.renderer.elements.LineLayer;
|
||||||
import org.oscim.renderer.elements.TextItem;
|
import org.oscim.renderer.elements.TextItem;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
|
|
||||||
class Debug {
|
class Debug {
|
||||||
|
|
||||||
|
|||||||
@ -19,7 +19,7 @@ package org.oscim.layers.tile.vector.labeling;
|
|||||||
|
|
||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.renderer.elements.TextItem;
|
import org.oscim.renderer.elements.TextItem;
|
||||||
import org.oscim.theme.renderinstruction.Text;
|
import org.oscim.theme.styles.Text;
|
||||||
import org.oscim.tiling.MapTile;
|
import org.oscim.tiling.MapTile;
|
||||||
import org.oscim.utils.GeometryUtils;
|
import org.oscim.utils.GeometryUtils;
|
||||||
import org.oscim.utils.LineClipper;
|
import org.oscim.utils.LineClipper;
|
||||||
|
|||||||
@ -25,8 +25,8 @@ import org.oscim.renderer.MapRenderer.Matrices;
|
|||||||
import org.oscim.renderer.elements.LineLayer;
|
import org.oscim.renderer.elements.LineLayer;
|
||||||
import org.oscim.renderer.elements.TextItem;
|
import org.oscim.renderer.elements.TextItem;
|
||||||
import org.oscim.renderer.elements.TextLayer;
|
import org.oscim.renderer.elements.TextLayer;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
import org.oscim.theme.renderinstruction.Text;
|
import org.oscim.theme.styles.Text;
|
||||||
|
|
||||||
public class GridRenderer extends ElementRenderer {
|
public class GridRenderer extends ElementRenderer {
|
||||||
// private final static String TILE_FORMAT = "%d/%d/%d";
|
// private final static String TILE_FORMAT = "%d/%d/%d";
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import java.nio.ShortBuffer;
|
|||||||
|
|
||||||
import org.oscim.backend.GL20;
|
import org.oscim.backend.GL20;
|
||||||
import org.oscim.renderer.BufferObject;
|
import org.oscim.renderer.BufferObject;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
import org.oscim.utils.pool.Inlist;
|
import org.oscim.utils.pool.Inlist;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|||||||
@ -28,7 +28,7 @@ import org.oscim.renderer.GLState;
|
|||||||
import org.oscim.renderer.GLUtils;
|
import org.oscim.renderer.GLUtils;
|
||||||
import org.oscim.renderer.MapRenderer;
|
import org.oscim.renderer.MapRenderer;
|
||||||
import org.oscim.renderer.MapRenderer.Matrices;
|
import org.oscim.renderer.MapRenderer.Matrices;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
import org.oscim.utils.FastMath;
|
import org.oscim.utils.FastMath;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import org.oscim.renderer.GLState;
|
|||||||
import org.oscim.renderer.GLUtils;
|
import org.oscim.renderer.GLUtils;
|
||||||
import org.oscim.renderer.MapRenderer;
|
import org.oscim.renderer.MapRenderer;
|
||||||
import org.oscim.renderer.MapRenderer.Matrices;
|
import org.oscim.renderer.MapRenderer.Matrices;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@ import org.oscim.renderer.GLState;
|
|||||||
import org.oscim.renderer.GLUtils;
|
import org.oscim.renderer.GLUtils;
|
||||||
import org.oscim.renderer.MapRenderer;
|
import org.oscim.renderer.MapRenderer;
|
||||||
import org.oscim.renderer.MapRenderer.Matrices;
|
import org.oscim.renderer.MapRenderer.Matrices;
|
||||||
import org.oscim.theme.renderinstruction.Area;
|
import org.oscim.theme.styles.Area;
|
||||||
import org.oscim.utils.FastMath;
|
import org.oscim.utils.FastMath;
|
||||||
import org.oscim.utils.Interpolation;
|
import org.oscim.utils.Interpolation;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|||||||
@ -16,7 +16,7 @@
|
|||||||
*/
|
*/
|
||||||
package org.oscim.renderer.elements;
|
package org.oscim.renderer.elements;
|
||||||
|
|
||||||
import org.oscim.theme.renderinstruction.Text;
|
import org.oscim.theme.styles.Text;
|
||||||
import org.oscim.utils.pool.Inlist;
|
import org.oscim.utils.pool.Inlist;
|
||||||
import org.oscim.utils.pool.SyncPool;
|
import org.oscim.utils.pool.SyncPool;
|
||||||
|
|
||||||
|
|||||||
@ -29,8 +29,8 @@ import org.oscim.renderer.atlas.TextureAtlas.Slot;
|
|||||||
import org.oscim.renderer.elements.LineLayer;
|
import org.oscim.renderer.elements.LineLayer;
|
||||||
import org.oscim.renderer.elements.TextItem;
|
import org.oscim.renderer.elements.TextItem;
|
||||||
import org.oscim.renderer.elements.TextLayer;
|
import org.oscim.renderer.elements.TextLayer;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
import org.oscim.theme.renderinstruction.Text;
|
import org.oscim.theme.styles.Text;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
|||||||
@ -2,12 +2,12 @@ package org.oscim.theme;
|
|||||||
|
|
||||||
import org.oscim.core.GeometryBuffer.GeometryType;
|
import org.oscim.core.GeometryBuffer.GeometryType;
|
||||||
import org.oscim.core.TagSet;
|
import org.oscim.core.TagSet;
|
||||||
import org.oscim.theme.renderinstruction.RenderInstruction;
|
import org.oscim.theme.styles.RenderStyle;
|
||||||
|
|
||||||
public class DebugTheme implements IRenderTheme {
|
public class DebugTheme implements IRenderTheme {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderInstruction[] matchElement(GeometryType type, TagSet tags, int zoomLevel) {
|
public RenderStyle[] matchElement(GeometryType type, TagSet tags, int zoomLevel) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -19,14 +19,14 @@ package org.oscim.theme;
|
|||||||
|
|
||||||
import org.oscim.core.GeometryBuffer.GeometryType;
|
import org.oscim.core.GeometryBuffer.GeometryType;
|
||||||
import org.oscim.core.TagSet;
|
import org.oscim.core.TagSet;
|
||||||
import org.oscim.theme.renderinstruction.Area;
|
import org.oscim.theme.styles.Area;
|
||||||
import org.oscim.theme.renderinstruction.Circle;
|
import org.oscim.theme.styles.Circle;
|
||||||
import org.oscim.theme.renderinstruction.Extrusion;
|
import org.oscim.theme.styles.Extrusion;
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
import org.oscim.theme.styles.Line;
|
||||||
import org.oscim.theme.renderinstruction.LineSymbol;
|
import org.oscim.theme.styles.LineSymbol;
|
||||||
import org.oscim.theme.renderinstruction.RenderInstruction;
|
import org.oscim.theme.styles.RenderStyle;
|
||||||
import org.oscim.theme.renderinstruction.Symbol;
|
import org.oscim.theme.styles.Symbol;
|
||||||
import org.oscim.theme.renderinstruction.Text;
|
import org.oscim.theme.styles.Text;
|
||||||
|
|
||||||
public interface IRenderTheme {
|
public interface IRenderTheme {
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public interface IRenderTheme {
|
|||||||
* the zoom level at which the way should be matched.
|
* the zoom level at which the way should be matched.
|
||||||
* @return matching render instructions
|
* @return matching render instructions
|
||||||
*/
|
*/
|
||||||
public abstract RenderInstruction[] matchElement(GeometryType type, TagSet tags, int zoomLevel);
|
public abstract RenderStyle[] matchElement(GeometryType type, TagSet tags, int zoomLevel);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Must be called when this RenderTheme gets destroyed to clean up and free
|
* Must be called when this RenderTheme gets destroyed to clean up and free
|
||||||
|
|||||||
@ -23,9 +23,9 @@ import java.util.List;
|
|||||||
|
|
||||||
import org.oscim.core.GeometryBuffer.GeometryType;
|
import org.oscim.core.GeometryBuffer.GeometryType;
|
||||||
import org.oscim.core.TagSet;
|
import org.oscim.core.TagSet;
|
||||||
import org.oscim.theme.renderinstruction.RenderInstruction;
|
|
||||||
import org.oscim.theme.rule.Element;
|
import org.oscim.theme.rule.Element;
|
||||||
import org.oscim.theme.rule.Rule;
|
import org.oscim.theme.rule.Rule;
|
||||||
|
import org.oscim.theme.styles.RenderStyle;
|
||||||
import org.oscim.utils.LRUCache;
|
import org.oscim.utils.LRUCache;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -44,52 +44,52 @@ public class RenderTheme implements IRenderTheme {
|
|||||||
private int mLevels;
|
private int mLevels;
|
||||||
private Rule[] mRules;
|
private Rule[] mRules;
|
||||||
|
|
||||||
class ElementCache {
|
class RenderStyleCache {
|
||||||
final int matchType;
|
final int matchType;
|
||||||
final LRUCache<MatchingCacheKey, RenderInstructionItem> cache;
|
final LRUCache<MatchingCacheKey, RenderStyleItem> cache;
|
||||||
final MatchingCacheKey cacheKey;
|
final MatchingCacheKey cacheKey;
|
||||||
|
|
||||||
/* temporary matching instructions list */
|
/* temporary matching instructions list */
|
||||||
final ArrayList<RenderInstruction> instructionList;
|
final ArrayList<RenderStyle> instructionList;
|
||||||
|
|
||||||
RenderInstructionItem prevItem;
|
RenderStyleItem prevItem;
|
||||||
|
|
||||||
public ElementCache(int type) {
|
public RenderStyleCache(int type) {
|
||||||
cache = new LRUCache<MatchingCacheKey, RenderInstructionItem>(MATCHING_CACHE_SIZE);
|
cache = new LRUCache<MatchingCacheKey, RenderStyleItem>(MATCHING_CACHE_SIZE);
|
||||||
instructionList = new ArrayList<RenderInstruction>(4);
|
instructionList = new ArrayList<RenderStyle>(4);
|
||||||
cacheKey = new MatchingCacheKey();
|
cacheKey = new MatchingCacheKey();
|
||||||
matchType = type;
|
matchType = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderInstructionItem getRenderInstructions() {
|
RenderStyleItem getRenderInstructions() {
|
||||||
return cache.get(cacheKey);
|
return cache.get(cacheKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class RenderInstructionItem {
|
class RenderStyleItem {
|
||||||
RenderInstructionItem next;
|
RenderStyleItem next;
|
||||||
int zoom;
|
int zoom;
|
||||||
RenderInstruction[] list;
|
RenderStyle[] list;
|
||||||
MatchingCacheKey key;
|
MatchingCacheKey key;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final ElementCache[] mElementCache;
|
private final RenderStyleCache[] mStyleCache;
|
||||||
|
|
||||||
public RenderTheme(int mapBackground, float baseStrokeWidth, float baseTextSize) {
|
public RenderTheme(int mapBackground, float baseStrokeWidth, float baseTextSize) {
|
||||||
mMapBackground = mapBackground;
|
mMapBackground = mapBackground;
|
||||||
mBaseTextSize = baseTextSize;
|
mBaseTextSize = baseTextSize;
|
||||||
|
|
||||||
mElementCache = new ElementCache[3];
|
mStyleCache = new RenderStyleCache[3];
|
||||||
mElementCache[0] = new ElementCache(Element.NODE);
|
mStyleCache[0] = new RenderStyleCache(Element.NODE);
|
||||||
mElementCache[1] = new ElementCache(Element.LINE);
|
mStyleCache[1] = new RenderStyleCache(Element.LINE);
|
||||||
mElementCache[2] = new ElementCache(Element.POLY);
|
mStyleCache[2] = new RenderStyleCache(Element.POLY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void destroy() {
|
public void destroy() {
|
||||||
|
|
||||||
for (int i = 0; i < 3; i++)
|
for (int i = 0; i < 3; i++)
|
||||||
mElementCache[i].cache.clear();
|
mStyleCache[i].cache.clear();
|
||||||
|
|
||||||
if (mRules != null) {
|
if (mRules != null) {
|
||||||
for (int i = 0, n = mRules.length; i < n; i++)
|
for (int i = 0, n = mRules.length; i < n; i++)
|
||||||
@ -108,13 +108,13 @@ public class RenderTheme implements IRenderTheme {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public RenderInstruction[] matchElement(GeometryType geometryType, TagSet tags, int zoomLevel) {
|
public RenderStyle[] matchElement(GeometryType geometryType, TagSet tags, int zoomLevel) {
|
||||||
|
|
||||||
// list of renderinsctruction items in cache
|
// list of renderinsctruction items in cache
|
||||||
RenderInstructionItem ris = null;
|
RenderStyleItem ris = null;
|
||||||
|
|
||||||
// the item matching tags and zoomlevel
|
// the item matching tags and zoomlevel
|
||||||
RenderInstructionItem ri = null;
|
RenderStyleItem ri = null;
|
||||||
|
|
||||||
int type = geometryType.nativeInt;
|
int type = geometryType.nativeInt;
|
||||||
if (type < 1 || type > 3) {
|
if (type < 1 || type > 3) {
|
||||||
@ -122,7 +122,7 @@ public class RenderTheme implements IRenderTheme {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
ElementCache cache = mElementCache[type - 1];
|
RenderStyleCache cache = mStyleCache[type - 1];
|
||||||
|
|
||||||
// NOTE: maximum zoom level supported is 32
|
// NOTE: maximum zoom level supported is 32
|
||||||
int zoomMask = 1 << zoomLevel;
|
int zoomMask = 1 << zoomLevel;
|
||||||
@ -154,7 +154,7 @@ public class RenderTheme implements IRenderTheme {
|
|||||||
// cache miss
|
// cache miss
|
||||||
//log.debug(missCnt++ + " / " + hitCnt + " Cache Miss");
|
//log.debug(missCnt++ + " / " + hitCnt + " Cache Miss");
|
||||||
|
|
||||||
List<RenderInstruction> matches = cache.instructionList;
|
List<RenderStyle> matches = cache.instructionList;
|
||||||
matches.clear();
|
matches.clear();
|
||||||
|
|
||||||
for (Rule rule : mRules)
|
for (Rule rule : mRules)
|
||||||
@ -163,7 +163,7 @@ public class RenderTheme implements IRenderTheme {
|
|||||||
int size = matches.size();
|
int size = matches.size();
|
||||||
if (size > 1) {
|
if (size > 1) {
|
||||||
for (int i = 0; i < size - 1; i++) {
|
for (int i = 0; i < size - 1; i++) {
|
||||||
RenderInstruction r = matches.get(i);
|
RenderStyle r = matches.get(i);
|
||||||
for (int j = i + 1; j < size; j++) {
|
for (int j = i + 1; j < size; j++) {
|
||||||
if (matches.get(j) == r) {
|
if (matches.get(j) == r) {
|
||||||
log.debug("fix duplicate instruction! "
|
log.debug("fix duplicate instruction! "
|
||||||
@ -193,8 +193,8 @@ public class RenderTheme implements IRenderTheme {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (RenderInstruction r : ri.list) {
|
for (RenderStyle style : ri.list) {
|
||||||
if (r != matches.get(i))
|
if (style != matches.get(i))
|
||||||
break;
|
break;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
@ -208,17 +208,17 @@ public class RenderTheme implements IRenderTheme {
|
|||||||
// this zoom level to the existing RenderInstructionItem.
|
// this zoom level to the existing RenderInstructionItem.
|
||||||
ri.zoom |= zoomMask;
|
ri.zoom |= zoomMask;
|
||||||
|
|
||||||
//log.debug( // zoomLevel + " same instructions " + size + " "
|
//log.debug(zoomLevel + " same instructions " + size + " "
|
||||||
// + Arrays.deepToString(tags));
|
// + Arrays.deepToString(tags));
|
||||||
} else {
|
} else {
|
||||||
//log.debug( // zoomLevel + " new instructions " + size + " "
|
//log.debug(zoomLevel + " new instructions " + size + " "
|
||||||
// + Arrays.deepToString(tags));
|
// + Arrays.deepToString(tags));
|
||||||
|
|
||||||
ri = new RenderInstructionItem();
|
ri = new RenderStyleItem();
|
||||||
ri.zoom = zoomMask;
|
ri.zoom = zoomMask;
|
||||||
|
|
||||||
if (size > 0) {
|
if (size > 0) {
|
||||||
ri.list = new RenderInstruction[size];
|
ri.list = new RenderStyle[size];
|
||||||
matches.toArray(ri.list);
|
matches.toArray(ri.list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -37,15 +37,15 @@ import org.oscim.renderer.atlas.TextureAtlas.Rect;
|
|||||||
import org.oscim.renderer.atlas.TextureRegion;
|
import org.oscim.renderer.atlas.TextureRegion;
|
||||||
import org.oscim.renderer.elements.TextureItem;
|
import org.oscim.renderer.elements.TextureItem;
|
||||||
import org.oscim.theme.IRenderTheme.ThemeException;
|
import org.oscim.theme.IRenderTheme.ThemeException;
|
||||||
import org.oscim.theme.renderinstruction.Area;
|
|
||||||
import org.oscim.theme.renderinstruction.Circle;
|
|
||||||
import org.oscim.theme.renderinstruction.Extrusion;
|
|
||||||
import org.oscim.theme.renderinstruction.Line;
|
|
||||||
import org.oscim.theme.renderinstruction.LineSymbol;
|
|
||||||
import org.oscim.theme.renderinstruction.RenderInstruction;
|
|
||||||
import org.oscim.theme.renderinstruction.Symbol;
|
|
||||||
import org.oscim.theme.renderinstruction.Text;
|
|
||||||
import org.oscim.theme.rule.Rule;
|
import org.oscim.theme.rule.Rule;
|
||||||
|
import org.oscim.theme.styles.Area;
|
||||||
|
import org.oscim.theme.styles.Circle;
|
||||||
|
import org.oscim.theme.styles.Extrusion;
|
||||||
|
import org.oscim.theme.styles.Line;
|
||||||
|
import org.oscim.theme.styles.LineSymbol;
|
||||||
|
import org.oscim.theme.styles.RenderStyle;
|
||||||
|
import org.oscim.theme.styles.Symbol;
|
||||||
|
import org.oscim.theme.styles.Text;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
@ -130,8 +130,8 @@ public class RenderThemeHandler extends DefaultHandler {
|
|||||||
|
|
||||||
private Stack<Element> mElementStack = new Stack<Element>();
|
private Stack<Element> mElementStack = new Stack<Element>();
|
||||||
private Stack<Rule> mRuleStack = new Stack<Rule>();
|
private Stack<Rule> mRuleStack = new Stack<Rule>();
|
||||||
private HashMap<String, RenderInstruction> mStyles =
|
private HashMap<String, RenderStyle> mStyles =
|
||||||
new HashMap<String, RenderInstruction>(10);
|
new HashMap<String, RenderStyle>(10);
|
||||||
|
|
||||||
private TextureAtlas mTextureAtlas;
|
private TextureAtlas mTextureAtlas;
|
||||||
|
|
||||||
|
|||||||
@ -27,7 +27,7 @@ import java.util.Stack;
|
|||||||
import org.oscim.core.Tag;
|
import org.oscim.core.Tag;
|
||||||
import org.oscim.theme.IRenderTheme.ThemeException;
|
import org.oscim.theme.IRenderTheme.ThemeException;
|
||||||
import org.oscim.theme.RenderThemeHandler;
|
import org.oscim.theme.RenderThemeHandler;
|
||||||
import org.oscim.theme.renderinstruction.RenderInstruction;
|
import org.oscim.theme.styles.RenderStyle;
|
||||||
import org.xml.sax.Attributes;
|
import org.xml.sax.Attributes;
|
||||||
|
|
||||||
public abstract class Rule {
|
public abstract class Rule {
|
||||||
@ -189,14 +189,14 @@ public abstract class Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Rule[] mSubRules;
|
private Rule[] mSubRules;
|
||||||
private RenderInstruction[] mRenderInstructions;
|
private RenderStyle[] mRenderInstructions;
|
||||||
|
|
||||||
final int mZoom;
|
final int mZoom;
|
||||||
final int mElement;
|
final int mElement;
|
||||||
final boolean mMatchFirst;
|
final boolean mMatchFirst;
|
||||||
|
|
||||||
static class Builder {
|
static class Builder {
|
||||||
ArrayList<RenderInstruction> renderInstructions = new ArrayList<RenderInstruction>(4);
|
ArrayList<RenderStyle> renderInstructions = new ArrayList<RenderStyle>(4);
|
||||||
ArrayList<Rule> subRules = new ArrayList<Rule>(4);
|
ArrayList<Rule> subRules = new ArrayList<Rule>(4);
|
||||||
|
|
||||||
public void clear() {
|
public void clear() {
|
||||||
@ -216,7 +216,7 @@ public abstract class Rule {
|
|||||||
mMatchFirst = matchFirst;
|
mMatchFirst = matchFirst;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addRenderingInstruction(RenderInstruction renderInstruction) {
|
public void addRenderingInstruction(RenderStyle renderInstruction) {
|
||||||
builder.renderInstructions.add(renderInstruction);
|
builder.renderInstructions.add(renderInstruction);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ public abstract class Rule {
|
|||||||
abstract boolean matchesTags(Tag[] tags);
|
abstract boolean matchesTags(Tag[] tags);
|
||||||
|
|
||||||
public boolean matchElement(int type, Tag[] tags, int zoomLevel,
|
public boolean matchElement(int type, Tag[] tags, int zoomLevel,
|
||||||
List<RenderInstruction> matchingList) {
|
List<RenderStyle> matchingList) {
|
||||||
|
|
||||||
if (((mElement & type) != 0) && ((mZoom & zoomLevel) != 0) && (matchesTags(tags))) {
|
if (((mElement & type) != 0) && ((mZoom & zoomLevel) != 0) && (matchesTags(tags))) {
|
||||||
|
|
||||||
@ -243,8 +243,8 @@ public abstract class Rule {
|
|||||||
|
|
||||||
if (!mMatchFirst || matched) {
|
if (!mMatchFirst || matched) {
|
||||||
// add instructions for this rule
|
// add instructions for this rule
|
||||||
for (RenderInstruction ri : mRenderInstructions)
|
for (RenderStyle style : mRenderInstructions)
|
||||||
matchingList.add(ri);
|
matchingList.add(style);
|
||||||
}
|
}
|
||||||
|
|
||||||
// this rule did match
|
// this rule did match
|
||||||
@ -259,7 +259,7 @@ public abstract class Rule {
|
|||||||
MATCHERS_CACHE_KEY.clear();
|
MATCHERS_CACHE_KEY.clear();
|
||||||
MATCHERS_CACHE_VALUE.clear();
|
MATCHERS_CACHE_VALUE.clear();
|
||||||
|
|
||||||
mRenderInstructions = new RenderInstruction[builder.renderInstructions.size()];
|
mRenderInstructions = new RenderStyle[builder.renderInstructions.size()];
|
||||||
builder.renderInstructions.toArray(mRenderInstructions);
|
builder.renderInstructions.toArray(mRenderInstructions);
|
||||||
|
|
||||||
mSubRules = new Rule[builder.subRules.size()];
|
mSubRules = new Rule[builder.subRules.size()];
|
||||||
@ -273,16 +273,16 @@ public abstract class Rule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
for (RenderInstruction ri : mRenderInstructions)
|
for (RenderStyle style : mRenderInstructions)
|
||||||
ri.destroy();
|
style.destroy();
|
||||||
|
|
||||||
for (Rule subRule : mSubRules)
|
for (Rule subRule : mSubRules)
|
||||||
subRule.onDestroy();
|
subRule.onDestroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void scaleTextSize(float scaleFactor) {
|
public void scaleTextSize(float scaleFactor) {
|
||||||
for (RenderInstruction ri : mRenderInstructions)
|
for (RenderStyle style : mRenderInstructions)
|
||||||
ri.scaleTextSize(scaleFactor);
|
style.scaleTextSize(scaleFactor);
|
||||||
for (Rule subRule : mSubRules)
|
for (Rule subRule : mSubRules)
|
||||||
subRule.scaleTextSize(scaleFactor);
|
subRule.scaleTextSize(scaleFactor);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.oscim.theme.renderinstruction;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
import org.oscim.backend.canvas.Color;
|
import org.oscim.backend.canvas.Color;
|
||||||
import org.oscim.renderer.elements.TextureItem;
|
import org.oscim.renderer.elements.TextureItem;
|
||||||
@ -24,7 +24,7 @@ import org.oscim.theme.IRenderTheme.Callback;
|
|||||||
/**
|
/**
|
||||||
* Represents a closed polygon on the map.
|
* Represents a closed polygon on the map.
|
||||||
*/
|
*/
|
||||||
public final class Area extends RenderInstruction {
|
public final class Area extends RenderStyle {
|
||||||
|
|
||||||
public Area(int fill) {
|
public Area(int fill) {
|
||||||
this(0, fill);
|
this(0, fill);
|
||||||
@ -14,11 +14,11 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.oscim.theme.renderinstruction;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
import org.oscim.theme.IRenderTheme.Callback;
|
import org.oscim.theme.IRenderTheme.Callback;
|
||||||
|
|
||||||
public class AreaLevel extends RenderInstruction {
|
public class AreaLevel extends RenderStyle {
|
||||||
private final Area area;
|
private final Area area;
|
||||||
private final int level;
|
private final int level;
|
||||||
|
|
||||||
@ -15,14 +15,14 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.oscim.theme.renderinstruction;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
import org.oscim.theme.IRenderTheme.Callback;
|
import org.oscim.theme.IRenderTheme.Callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a round area on the map.
|
* Represents a round area on the map.
|
||||||
*/
|
*/
|
||||||
public final class Circle extends RenderInstruction {
|
public final class Circle extends RenderStyle {
|
||||||
|
|
||||||
public final int level;
|
public final int level;
|
||||||
|
|
||||||
@ -14,12 +14,12 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.oscim.theme.renderinstruction;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
import org.oscim.backend.canvas.Color;
|
import org.oscim.backend.canvas.Color;
|
||||||
import org.oscim.theme.IRenderTheme.Callback;
|
import org.oscim.theme.IRenderTheme.Callback;
|
||||||
|
|
||||||
public class Extrusion extends RenderInstruction {
|
public class Extrusion extends RenderStyle {
|
||||||
|
|
||||||
public Extrusion(int level, int colorSides, int colorTop, int colorLine, int defaultHeight) {
|
public Extrusion(int level, int colorSides, int colorTop, int colorLine, int defaultHeight) {
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.oscim.theme.renderinstruction;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
import org.oscim.backend.canvas.Paint.Cap;
|
import org.oscim.backend.canvas.Paint.Cap;
|
||||||
import org.oscim.theme.IRenderTheme.Callback;
|
import org.oscim.theme.IRenderTheme.Callback;
|
||||||
@ -23,7 +23,7 @@ import org.oscim.theme.IRenderTheme.Callback;
|
|||||||
/**
|
/**
|
||||||
* Represents a polyline on the map.
|
* Represents a polyline on the map.
|
||||||
*/
|
*/
|
||||||
public final class Line extends RenderInstruction {
|
public final class Line extends RenderStyle {
|
||||||
|
|
||||||
// static float[] parseFloatArray(String dashString) {
|
// static float[] parseFloatArray(String dashString) {
|
||||||
// String[] dashEntries = SPLIT_PATTERN.split(dashString);
|
// String[] dashEntries = SPLIT_PATTERN.split(dashString);
|
||||||
@ -15,14 +15,14 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.oscim.theme.renderinstruction;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
import org.oscim.theme.IRenderTheme.Callback;
|
import org.oscim.theme.IRenderTheme.Callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents an icon along a polyline on the map.
|
* Represents an icon along a polyline on the map.
|
||||||
*/
|
*/
|
||||||
public final class LineSymbol extends RenderInstruction {
|
public final class LineSymbol extends RenderStyle {
|
||||||
|
|
||||||
public final boolean alignCenter;
|
public final boolean alignCenter;
|
||||||
// public final Bitmap bitmap;
|
// public final Bitmap bitmap;
|
||||||
@ -15,14 +15,14 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.oscim.theme.renderinstruction;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
import org.oscim.theme.IRenderTheme.Callback;
|
import org.oscim.theme.IRenderTheme.Callback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A RenderInstruction is a basic graphical primitive to draw a map.
|
* A RenderInstruction is a basic graphical primitive to draw a map.
|
||||||
*/
|
*/
|
||||||
public abstract class RenderInstruction {
|
public abstract class RenderStyle {
|
||||||
/**
|
/**
|
||||||
* Destroys this RenderInstruction and cleans up all its internal resources.
|
* Destroys this RenderInstruction and cleans up all its internal resources.
|
||||||
*/
|
*/
|
||||||
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.oscim.theme.renderinstruction;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
import org.oscim.renderer.atlas.TextureRegion;
|
import org.oscim.renderer.atlas.TextureRegion;
|
||||||
import org.oscim.theme.IRenderTheme.Callback;
|
import org.oscim.theme.IRenderTheme.Callback;
|
||||||
@ -23,7 +23,7 @@ import org.oscim.theme.IRenderTheme.Callback;
|
|||||||
/**
|
/**
|
||||||
* Represents an icon on the map.
|
* Represents an icon on the map.
|
||||||
*/
|
*/
|
||||||
public final class Symbol extends RenderInstruction {
|
public final class Symbol extends RenderStyle {
|
||||||
|
|
||||||
public final TextureRegion texture;
|
public final TextureRegion texture;
|
||||||
|
|
||||||
@ -15,7 +15,7 @@
|
|||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
* You should have received a copy of the GNU Lesser General Public License along with
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
* this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package org.oscim.theme.renderinstruction;
|
package org.oscim.theme.styles;
|
||||||
|
|
||||||
import org.oscim.backend.CanvasAdapter;
|
import org.oscim.backend.CanvasAdapter;
|
||||||
import org.oscim.backend.canvas.Paint;
|
import org.oscim.backend.canvas.Paint;
|
||||||
@ -28,7 +28,7 @@ import org.oscim.theme.IRenderTheme.Callback;
|
|||||||
/**
|
/**
|
||||||
* Represents a text along a polyline on the map.
|
* Represents a text along a polyline on the map.
|
||||||
*/
|
*/
|
||||||
public final class Text extends RenderInstruction {
|
public final class Text extends RenderStyle {
|
||||||
|
|
||||||
public final String style;
|
public final String style;
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user