diff --git a/src/org/oscim/theme/RenderTheme.java b/src/org/oscim/theme/RenderTheme.java index 32926771..aa31fa20 100644 --- a/src/org/oscim/theme/RenderTheme.java +++ b/src/org/oscim/theme/RenderTheme.java @@ -19,6 +19,8 @@ import java.util.List; import org.oscim.core.Tag; import org.oscim.theme.renderinstruction.RenderInstruction; +import org.oscim.theme.rule.Closed; +import org.oscim.theme.rule.Rule; import org.oscim.utils.LRUCache; import org.xml.sax.Attributes; @@ -88,13 +90,13 @@ public class RenderTheme { private final LRUCache mWayCache; private final LRUCache mAreaCache; - private final MatchingCacheKey mAreaCacheKey = new MatchingCacheKey(); - private final MatchingCacheKey mWayCacheKey = new MatchingCacheKey(); - private final MatchingCacheKey mNodeCacheKey = new MatchingCacheKey(); + private final MatchingCacheKey mAreaCacheKey; + private final MatchingCacheKey mWayCacheKey; + private final MatchingCacheKey mNodeCacheKey; - private final ArrayList mWayInstructionList = new ArrayList(4); - private final ArrayList mAreaInstructionList = new ArrayList(4); - private final ArrayList mNodeInstructionList = new ArrayList(4); + private final ArrayList mWayInstructionList; + private final ArrayList mAreaInstructionList; + private final ArrayList mNodeInstructionList; private RenderInstructionItem mPrevAreaItem; private RenderInstructionItem mPrevWayItem; @@ -113,12 +115,17 @@ public class RenderTheme { mBaseTextSize = baseTextSize; mRulesList = new ArrayList(); - mNodesCache = new LRUCache( - MATCHING_CACHE_SIZE); - mWayCache = new LRUCache( - MATCHING_CACHE_SIZE); - mAreaCache = new LRUCache( - MATCHING_CACHE_SIZE); + mNodesCache = new LRUCache(MATCHING_CACHE_SIZE); + mWayCache = new LRUCache(MATCHING_CACHE_SIZE); + mAreaCache = new LRUCache(MATCHING_CACHE_SIZE); + + mWayInstructionList = new ArrayList(4); + mAreaInstructionList = new ArrayList(4); + mNodeInstructionList = new ArrayList(4); + + mAreaCacheKey = new MatchingCacheKey(); + mWayCacheKey = new MatchingCacheKey(); + mNodeCacheKey = new MatchingCacheKey(); } /** @@ -152,7 +159,8 @@ public class RenderTheme { } /** - * ... + * ... + * * @param tags * ... * @param zoomLevel @@ -260,9 +268,6 @@ public class RenderTheme { } - //private int missCnt = 0; - //private int hitCnt = 0; - /** * Matches a way with the given parameters against this RenderTheme. * @@ -416,7 +421,10 @@ public class RenderTheme { for (int i = 0, n = mRulesList.size(); i < n; ++i) { mRulesList.get(i).onComplete(); } + } + void setLevels(int levels) { + mLevels = levels; } /** @@ -442,8 +450,4 @@ public class RenderTheme { mRulesList.get(i).scaleTextSize(scaleFactor * mBaseTextSize); } } - - void setLevels(int levels) { - mLevels = levels; - } } diff --git a/src/org/oscim/theme/RenderThemeHandler.java b/src/org/oscim/theme/RenderThemeHandler.java index 58fd156b..f71e9e6f 100644 --- a/src/org/oscim/theme/RenderThemeHandler.java +++ b/src/org/oscim/theme/RenderThemeHandler.java @@ -31,6 +31,7 @@ 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.xml.sax.Attributes; import org.xml.sax.InputSource; import org.xml.sax.SAXException; diff --git a/src/org/oscim/theme/AnyMatcher.java b/src/org/oscim/theme/rule/AnyMatcher.java similarity index 97% rename from src/org/oscim/theme/AnyMatcher.java rename to src/org/oscim/theme/rule/AnyMatcher.java index 41a4f595..8b0fd66c 100644 --- a/src/org/oscim/theme/AnyMatcher.java +++ b/src/org/oscim/theme/rule/AnyMatcher.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import org.oscim.core.Tag; diff --git a/src/org/oscim/theme/AttributeMatcher.java b/src/org/oscim/theme/rule/AttributeMatcher.java similarity index 96% rename from src/org/oscim/theme/AttributeMatcher.java rename to src/org/oscim/theme/rule/AttributeMatcher.java index 63cb3166..91e1d647 100644 --- a/src/org/oscim/theme/AttributeMatcher.java +++ b/src/org/oscim/theme/rule/AttributeMatcher.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import org.oscim.core.Tag; diff --git a/src/org/oscim/theme/Closed.java b/src/org/oscim/theme/rule/Closed.java similarity index 93% rename from src/org/oscim/theme/Closed.java rename to src/org/oscim/theme/rule/Closed.java index b98e1ecd..0aaa0014 100644 --- a/src/org/oscim/theme/Closed.java +++ b/src/org/oscim/theme/rule/Closed.java @@ -12,9 +12,9 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; -final class Closed { +public final class Closed { public static final int ANY = 0; public static final int NO = 1; public static final int YES = 2; diff --git a/src/org/oscim/theme/Element.java b/src/org/oscim/theme/rule/Element.java similarity index 96% rename from src/org/oscim/theme/Element.java rename to src/org/oscim/theme/rule/Element.java index c990a291..d3524866 100644 --- a/src/org/oscim/theme/Element.java +++ b/src/org/oscim/theme/rule/Element.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; final class Element { public static final int ANY = 0; diff --git a/src/org/oscim/theme/MultiKeyMatcher.java b/src/org/oscim/theme/rule/MultiKeyMatcher.java similarity index 98% rename from src/org/oscim/theme/MultiKeyMatcher.java rename to src/org/oscim/theme/rule/MultiKeyMatcher.java index 96b4082a..9c3ceef1 100644 --- a/src/org/oscim/theme/MultiKeyMatcher.java +++ b/src/org/oscim/theme/rule/MultiKeyMatcher.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import java.util.List; diff --git a/src/org/oscim/theme/MultiValueMatcher.java b/src/org/oscim/theme/rule/MultiValueMatcher.java similarity index 98% rename from src/org/oscim/theme/MultiValueMatcher.java rename to src/org/oscim/theme/rule/MultiValueMatcher.java index f4d0e982..9c69db52 100644 --- a/src/org/oscim/theme/MultiValueMatcher.java +++ b/src/org/oscim/theme/rule/MultiValueMatcher.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import java.util.List; diff --git a/src/org/oscim/theme/NegativeMatcher.java b/src/org/oscim/theme/rule/NegativeMatcher.java similarity index 98% rename from src/org/oscim/theme/NegativeMatcher.java rename to src/org/oscim/theme/rule/NegativeMatcher.java index ed80077f..11afdf4a 100644 --- a/src/org/oscim/theme/NegativeMatcher.java +++ b/src/org/oscim/theme/rule/NegativeMatcher.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import java.util.List; diff --git a/src/org/oscim/theme/NegativeRule.java b/src/org/oscim/theme/rule/NegativeRule.java similarity index 97% rename from src/org/oscim/theme/NegativeRule.java rename to src/org/oscim/theme/rule/NegativeRule.java index 8388397f..bac3241a 100644 --- a/src/org/oscim/theme/NegativeRule.java +++ b/src/org/oscim/theme/rule/NegativeRule.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import org.oscim.core.Tag; diff --git a/src/org/oscim/theme/PositiveRule.java b/src/org/oscim/theme/rule/PositiveRule.java similarity index 98% rename from src/org/oscim/theme/PositiveRule.java rename to src/org/oscim/theme/rule/PositiveRule.java index 8843e42f..05dd10d4 100644 --- a/src/org/oscim/theme/PositiveRule.java +++ b/src/org/oscim/theme/rule/PositiveRule.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import org.oscim.core.Tag; diff --git a/src/org/oscim/theme/Rule.java b/src/org/oscim/theme/rule/Rule.java similarity index 93% rename from src/org/oscim/theme/Rule.java rename to src/org/oscim/theme/rule/Rule.java index 9990c1b1..b252a2f7 100644 --- a/src/org/oscim/theme/Rule.java +++ b/src/org/oscim/theme/rule/Rule.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import java.util.ArrayList; import java.util.Arrays; @@ -24,10 +24,11 @@ import java.util.Stack; import java.util.regex.Pattern; import org.oscim.core.Tag; +import org.oscim.theme.RenderThemeHandler; import org.oscim.theme.renderinstruction.RenderInstruction; import org.xml.sax.Attributes; -abstract class Rule { +public abstract class Rule { private static final Map, AttributeMatcher> MATCHERS_CACHE_KEY = new HashMap, AttributeMatcher>(); private static final Map, AttributeMatcher> MATCHERS_CACHE_VALUE = new HashMap, AttributeMatcher>(); private static final Pattern SPLIT_PATTERN = Pattern.compile("\\|"); @@ -121,7 +122,7 @@ abstract class Rule { } } - static Rule create(String elementName, Attributes attributes, Stack ruleStack) { + public static Rule create(String elementName, Attributes attributes, Stack ruleStack) { int element = Element.ANY; String keys = null; String values = null; @@ -184,11 +185,11 @@ abstract class Rule { mSubRules = new ArrayList(4); } - void addRenderingInstruction(RenderInstruction renderInstruction) { + public void addRenderingInstruction(RenderInstruction renderInstruction) { mRenderInstructions.add(renderInstruction); } - void addSubRule(Rule rule) { + public void addSubRule(Rule rule) { mSubRules.add(rule); } @@ -196,7 +197,7 @@ abstract class Rule { abstract boolean matchesWay(Tag[] tags); - void matchNode(Tag[] tags, byte zoomLevel, + public void matchNode(Tag[] tags, byte zoomLevel, List matchingList) { if ((mElement != Element.WAY) && mZoomMin <= zoomLevel @@ -212,7 +213,7 @@ abstract class Rule { } } - void matchWay(Tag[] tags, byte zoomLevel, + public void matchWay(Tag[] tags, byte zoomLevel, int closed, List matchingList) { if ((mElement != Element.NODE) @@ -233,7 +234,7 @@ abstract class Rule { } } - void onComplete() { + public void onComplete() { MATCHERS_CACHE_KEY.clear(); MATCHERS_CACHE_VALUE.clear(); @@ -253,7 +254,7 @@ abstract class Rule { } - void onDestroy() { + public void onDestroy() { for (int i = 0, n = mRenderInstructionArray.length; i < n; i++) mRenderInstructionArray[i].destroy(); @@ -262,7 +263,7 @@ abstract class Rule { } - void scaleStrokeWidth(float scaleFactor) { + public void scaleStrokeWidth(float scaleFactor) { for (int i = 0, n = mRenderInstructionArray.length; i < n; i++) mRenderInstructionArray[i].scaleStrokeWidth(scaleFactor); @@ -271,7 +272,7 @@ abstract class Rule { } - void scaleTextSize(float scaleFactor) { + public void scaleTextSize(float scaleFactor) { for (int i = 0, n = mRenderInstructionArray.length; i < n; i++) mRenderInstructionArray[i].scaleTextSize(scaleFactor); diff --git a/src/org/oscim/theme/RuleOptimizer.java b/src/org/oscim/theme/rule/RuleOptimizer.java similarity index 99% rename from src/org/oscim/theme/RuleOptimizer.java rename to src/org/oscim/theme/rule/RuleOptimizer.java index 4b1bbde7..cae9e42d 100644 --- a/src/org/oscim/theme/RuleOptimizer.java +++ b/src/org/oscim/theme/rule/RuleOptimizer.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import java.util.Stack; diff --git a/src/org/oscim/theme/SingleKeyMatcher.java b/src/org/oscim/theme/rule/SingleKeyMatcher.java similarity index 97% rename from src/org/oscim/theme/SingleKeyMatcher.java rename to src/org/oscim/theme/rule/SingleKeyMatcher.java index ffd19cd0..497ad32d 100644 --- a/src/org/oscim/theme/SingleKeyMatcher.java +++ b/src/org/oscim/theme/rule/SingleKeyMatcher.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import org.oscim.core.Tag; diff --git a/src/org/oscim/theme/SingleValueMatcher.java b/src/org/oscim/theme/rule/SingleValueMatcher.java similarity index 97% rename from src/org/oscim/theme/SingleValueMatcher.java rename to src/org/oscim/theme/rule/SingleValueMatcher.java index 1cc8a532..0dc8de75 100644 --- a/src/org/oscim/theme/SingleValueMatcher.java +++ b/src/org/oscim/theme/rule/SingleValueMatcher.java @@ -12,7 +12,7 @@ * You should have received a copy of the GNU Lesser General Public License along with * this program. If not, see . */ -package org.oscim.theme; +package org.oscim.theme.rule; import org.oscim.core.Tag;