move RenderTheme internals to theme.rules.*
This commit is contained in:
parent
d74e5a7d00
commit
b9c3c3fad8
@ -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<MatchingCacheKey, RenderInstructionItem> mWayCache;
|
||||
private final LRUCache<MatchingCacheKey, RenderInstructionItem> 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<RenderInstruction> mWayInstructionList = new ArrayList<RenderInstruction>(4);
|
||||
private final ArrayList<RenderInstruction> mAreaInstructionList = new ArrayList<RenderInstruction>(4);
|
||||
private final ArrayList<RenderInstruction> mNodeInstructionList = new ArrayList<RenderInstruction>(4);
|
||||
private final ArrayList<RenderInstruction> mWayInstructionList;
|
||||
private final ArrayList<RenderInstruction> mAreaInstructionList;
|
||||
private final ArrayList<RenderInstruction> mNodeInstructionList;
|
||||
|
||||
private RenderInstructionItem mPrevAreaItem;
|
||||
private RenderInstructionItem mPrevWayItem;
|
||||
@ -113,12 +115,17 @@ public class RenderTheme {
|
||||
mBaseTextSize = baseTextSize;
|
||||
mRulesList = new ArrayList<Rule>();
|
||||
|
||||
mNodesCache = new LRUCache<MatchingCacheKey, RenderInstructionItem>(
|
||||
MATCHING_CACHE_SIZE);
|
||||
mWayCache = new LRUCache<MatchingCacheKey, RenderInstructionItem>(
|
||||
MATCHING_CACHE_SIZE);
|
||||
mAreaCache = new LRUCache<MatchingCacheKey, RenderInstructionItem>(
|
||||
MATCHING_CACHE_SIZE);
|
||||
mNodesCache = new LRUCache<MatchingCacheKey, RenderInstructionItem>(MATCHING_CACHE_SIZE);
|
||||
mWayCache = new LRUCache<MatchingCacheKey, RenderInstructionItem>(MATCHING_CACHE_SIZE);
|
||||
mAreaCache = new LRUCache<MatchingCacheKey, RenderInstructionItem>(MATCHING_CACHE_SIZE);
|
||||
|
||||
mWayInstructionList = new ArrayList<RenderInstruction>(4);
|
||||
mAreaInstructionList = new ArrayList<RenderInstruction>(4);
|
||||
mNodeInstructionList = new ArrayList<RenderInstruction>(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;
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
@ -12,9 +12,9 @@
|
||||
* 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/>.
|
||||
*/
|
||||
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;
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
final class Element {
|
||||
public static final int ANY = 0;
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
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<List<String>, AttributeMatcher> MATCHERS_CACHE_KEY = new HashMap<List<String>, AttributeMatcher>();
|
||||
private static final Map<List<String>, AttributeMatcher> MATCHERS_CACHE_VALUE = new HashMap<List<String>, AttributeMatcher>();
|
||||
private static final Pattern SPLIT_PATTERN = Pattern.compile("\\|");
|
||||
@ -121,7 +122,7 @@ abstract class Rule {
|
||||
}
|
||||
}
|
||||
|
||||
static Rule create(String elementName, Attributes attributes, Stack<Rule> ruleStack) {
|
||||
public static Rule create(String elementName, Attributes attributes, Stack<Rule> ruleStack) {
|
||||
int element = Element.ANY;
|
||||
String keys = null;
|
||||
String values = null;
|
||||
@ -184,11 +185,11 @@ abstract class Rule {
|
||||
mSubRules = new ArrayList<Rule>(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<RenderInstruction> 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<RenderInstruction> 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);
|
||||
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
import java.util.Stack;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
@ -12,7 +12,7 @@
|
||||
* 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/>.
|
||||
*/
|
||||
package org.oscim.theme;
|
||||
package org.oscim.theme.rule;
|
||||
|
||||
import org.oscim.core.Tag;
|
||||
|
Loading…
x
Reference in New Issue
Block a user