Fix transparent image and dependencies between packages
This commit is contained in:
parent
a0d2b7909f
commit
347245c8f2
7 changed files with 110 additions and 65 deletions
|
@ -85,6 +85,17 @@ public class RenderingRuleSearchRequest {
|
|||
return searchResult;
|
||||
}
|
||||
|
||||
public boolean searchRenderingAttribute(String attribute) {
|
||||
searchResult = false;
|
||||
RenderingRule rule = storage.getRenderingAttributeRule(attribute);
|
||||
if(rule == null){
|
||||
return false;
|
||||
}
|
||||
searchResult = visitRule(rule, true);
|
||||
return searchResult;
|
||||
}
|
||||
|
||||
|
||||
public boolean search(int state) {
|
||||
return search(state, true);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,13 @@ import java.util.Map;
|
|||
|
||||
public class RenderingRuleStorageProperties {
|
||||
|
||||
public static final String A_DEFAULT_COLOR = "defaultColor";
|
||||
public static final String A_SHADOW_RENDERING = "shadowRendering";
|
||||
public static final String ATTR_INT_VALUE = "attrIntValue";
|
||||
public static final String ATTR_BOOL_VALUE = "attrBoolValue";
|
||||
public static final String ATTR_COLOR_VALUE = "attrColorValue";
|
||||
public static final String ATTR_STRING_VALUE = "attrStringValue";
|
||||
|
||||
public static final String TEXT_LENGTH = "textLength";
|
||||
public static final String REF = "ref";
|
||||
public static final String TEXT_SHIELD = "textShield";
|
||||
|
@ -45,6 +52,11 @@ public class RenderingRuleStorageProperties {
|
|||
public static final String TEXT_WRAP_WIDTH = "textWrapWidth";
|
||||
public static final String SHADOW_LEVEL = "shadowLevel";
|
||||
|
||||
|
||||
public RenderingRuleProperty R_ATTR_INT_VALUE;
|
||||
public RenderingRuleProperty R_ATTR_BOOL_VALUE;
|
||||
public RenderingRuleProperty R_ATTR_COLOR_VALUE;
|
||||
public RenderingRuleProperty R_ATTR_STRING_VALUE;
|
||||
public RenderingRuleProperty R_TEXT_LENGTH;
|
||||
public RenderingRuleProperty R_REF;
|
||||
public RenderingRuleProperty R_TEXT_SHIELD;
|
||||
|
@ -113,6 +125,12 @@ public class RenderingRuleStorageProperties {
|
|||
R_TEXT_LENGTH = registerRuleInternal(RenderingRuleProperty.createInputIntProperty(TEXT_LENGTH));
|
||||
R_REF = registerRuleInternal(RenderingRuleProperty.createInputBooleanProperty(REF));
|
||||
|
||||
|
||||
R_ATTR_INT_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ATTR_INT_VALUE));
|
||||
R_ATTR_BOOL_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputBooleanProperty(ATTR_BOOL_VALUE));
|
||||
R_ATTR_COLOR_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputColorProperty(ATTR_COLOR_VALUE));
|
||||
R_ATTR_STRING_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty(ATTR_STRING_VALUE));
|
||||
|
||||
// order - no sense to make it float
|
||||
R_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ORDER));
|
||||
R_SHADOW_LEVEL = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(SHADOW_LEVEL));
|
||||
|
|
|
@ -6,10 +6,13 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.PrintStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Stack;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
|
@ -37,6 +40,7 @@ public class RenderingRulesStorage {
|
|||
private final static int LENGTH_RULES = 6;
|
||||
|
||||
private final static int SHIFT_TAG_VAL = 16;
|
||||
|
||||
// C++
|
||||
List<String> dictionary = new ArrayList<String>();
|
||||
Map<String, Integer> dictionaryMap = new LinkedHashMap<String, Integer>();
|
||||
|
@ -46,8 +50,8 @@ public class RenderingRulesStorage {
|
|||
@SuppressWarnings("unchecked")
|
||||
protected TIntObjectHashMap<RenderingRule>[] tagValueGlobalRules = new TIntObjectHashMap[LENGTH_RULES];
|
||||
|
||||
private int bgColor = 0;
|
||||
private int bgNightColor = 0;
|
||||
protected Map<String, RenderingRule> renderingAttributes = new LinkedHashMap<String, RenderingRule>();
|
||||
|
||||
private String renderingName;
|
||||
|
||||
|
||||
|
@ -83,18 +87,6 @@ public class RenderingRulesStorage {
|
|||
return renderingName;
|
||||
}
|
||||
|
||||
public int getBgColor() {
|
||||
return bgColor;
|
||||
}
|
||||
|
||||
public int getBgNightColor() {
|
||||
return bgNightColor;
|
||||
}
|
||||
|
||||
public int getBgColor(boolean nightMode){
|
||||
return nightMode ? bgNightColor : bgColor;
|
||||
}
|
||||
|
||||
|
||||
public void parseRulesFromXmlInputStream(InputStream is, RenderingRulesStorageResolver resolver) throws SAXException, IOException {
|
||||
try {
|
||||
|
@ -104,7 +96,20 @@ public class RenderingRulesStorage {
|
|||
RenderingRulesStorage depends = handler.getDependsStorage();
|
||||
if (depends != null) {
|
||||
// merge results
|
||||
// dictionary,bgNightColor and props are already merged
|
||||
// dictionary and props are already merged
|
||||
Iterator<Entry<String, RenderingRule>> it = depends.renderingAttributes.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Entry<String, RenderingRule> e = it.next();
|
||||
if (renderingAttributes.containsKey(e.getKey())) {
|
||||
RenderingRule root = renderingAttributes.get(e.getKey());
|
||||
List<RenderingRule> list = e.getValue().getIfElseChildren();
|
||||
for (RenderingRule every : list) {
|
||||
root.addIfElseChildren(every);
|
||||
}
|
||||
} else {
|
||||
renderingAttributes.put(e.getKey(), e.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i<LENGTH_RULES; i++) {
|
||||
if(depends.tagValueGlobalRules[i] == null || depends.tagValueGlobalRules[i].isEmpty()){
|
||||
|
@ -117,7 +122,7 @@ public class RenderingRulesStorage {
|
|||
RenderingRule dependsRule = depends.tagValueGlobalRules[i].get(keys[j]);
|
||||
if (dependsRule != null) {
|
||||
if (rule != null) {
|
||||
RenderingRule toInsert = createRootWrapperRule(keys[j], rule);
|
||||
RenderingRule toInsert = createTagValueRootWrapperRule(keys[j], rule);
|
||||
toInsert.addIfElseChildren(dependsRule);
|
||||
} else {
|
||||
tagValueGlobalRules[i].put(keys[j], dependsRule);
|
||||
|
@ -157,15 +162,14 @@ public class RenderingRulesStorage {
|
|||
RenderingRule previous = tagValueGlobalRules[state].get(key);
|
||||
if(previous != null){
|
||||
// all root rules should have at least tag/value
|
||||
toInsert = createRootWrapperRule(key, previous);
|
||||
toInsert = createTagValueRootWrapperRule(key, previous);
|
||||
toInsert.addIfElseChildren(rr);
|
||||
}
|
||||
tagValueGlobalRules[state].put(key, toInsert);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private RenderingRule createRootWrapperRule(int tagValueKey, RenderingRule previous) {
|
||||
private RenderingRule createTagValueRootWrapperRule(int tagValueKey, RenderingRule previous) {
|
||||
if (previous.getProperties().length > 2) {
|
||||
Map<String, String> m = new HashMap<String, String>();
|
||||
m.put("tag", getTagString(tagValueKey));
|
||||
|
@ -283,6 +287,12 @@ public class RenderingRulesStorage {
|
|||
} else if("polygon".equals(name)){ //$NON-NLS-1$
|
||||
state = POLYGON_RULES;
|
||||
stateChanged = true;
|
||||
} else if("renderingAttribute".equals(name)){ //$NON-NLS-1$
|
||||
String attr = attributes.getValue("name");
|
||||
@SuppressWarnings("unchecked")
|
||||
RenderingRule root = new RenderingRule(Collections.EMPTY_MAP, RenderingRulesStorage.this);
|
||||
renderingAttributes.put(attr, root);
|
||||
stack.push(root);
|
||||
} else if("renderingProperty".equals(name)){ //$NON-NLS-1$
|
||||
String attr = attributes.getValue("attr");
|
||||
RenderingRuleProperty prop;
|
||||
|
@ -306,24 +316,12 @@ public class RenderingRulesStorage {
|
|||
this.dependsStorage = resolver.resolve(depends, resolver);
|
||||
}
|
||||
if(dependsStorage != null){
|
||||
bgColor = dependsStorage.bgColor;
|
||||
bgNightColor = dependsStorage.bgNightColor;
|
||||
// copy dictionary
|
||||
dictionary = new ArrayList<String>(dependsStorage.dictionary);
|
||||
dictionaryMap = new LinkedHashMap<String, Integer>(dependsStorage.dictionaryMap);
|
||||
PROPS = new RenderingRuleStorageProperties(dependsStorage.PROPS);
|
||||
|
||||
}
|
||||
String dc = attributes.getValue("defaultColor");
|
||||
int defaultColor = 0;
|
||||
if(dc != null && dc.length() > 0){
|
||||
bgColor = RenderingRuleProperty.parseColor(dc);
|
||||
}
|
||||
String dnc = attributes.getValue("defaultNightColor");
|
||||
bgNightColor = defaultColor;
|
||||
if(dnc != null && dnc.length() > 0){
|
||||
bgNightColor = RenderingRuleProperty.parseColor(dnc);
|
||||
}
|
||||
renderingName = attributes.getValue("name");
|
||||
|
||||
} else if("renderer".equals(name)){ //$NON-NLS-1$
|
||||
|
@ -359,6 +357,8 @@ public class RenderingRulesStorage {
|
|||
}
|
||||
} else if("groupFilter".equals(name)){ //$NON-NLS-1$
|
||||
stack.pop();
|
||||
} else if("renderingAttribute".equals(name)){ //$NON-NLS-1$
|
||||
stack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -385,6 +385,10 @@ public class RenderingRulesStorage {
|
|||
return null;
|
||||
}
|
||||
|
||||
protected RenderingRule getRenderingAttributeRule(String attribute){
|
||||
return renderingAttributes.get(attribute);
|
||||
}
|
||||
|
||||
public RenderingRule[] getRules(int state){
|
||||
if(state >= tagValueGlobalRules.length || tagValueGlobalRules[state] == null) {
|
||||
return new RenderingRule[0];
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<renderingStyle name="default" depends="" defaultColor="#f1eee8" defaultNightColor="#003333" version="1">
|
||||
<renderingStyle name="default" depends="" defaultColor="#f1eee8" version="1">
|
||||
|
||||
<!-- Simple rule definition :
|
||||
- "filter" is analogue of If(...) Else. So if one "filter" passes other neighbors will not be checked.
|
||||
|
@ -6,7 +6,30 @@
|
|||
- inner "filter" is kind of inner If(..) { If(...) Else ... } Else...
|
||||
- ! All top level filters should have "tag" and "value" attributes to proper indexing them
|
||||
-->
|
||||
|
||||
|
||||
<!-- types : string, int, boolean; possibleValues comma separated possible values for int/string -->
|
||||
<renderingProperty attr="hmRendered" name="Show more map detail" description="Default renderer: Increase amount of map detail shown"
|
||||
type="boolean" possibleValues=""/>
|
||||
<renderingProperty attr="appMode" name="Rendering mode" description="Default renderer: Adjust rendering for specific purpose"
|
||||
type="string" possibleValues="default,car,bicycle,pedestrian"/>
|
||||
<renderingProperty attr="noPolygons" name="No polygons" description="Default renderer: Switch off fullfillment of area objects"
|
||||
type="boolean" possibleValues=""/>
|
||||
<!-- <renderingProperty attr="shadowRenderingMode" name="Shadow rendering" description="Default renderer: change way of displaying road edges."
|
||||
type="string" possibleValues="no shadow,one step,blur shadow,solid shadow"/>
|
||||
-->
|
||||
|
||||
<!-- 0 - no shadow, 1 - one step, 2 - blur shadow, 3 - solid shadow -->
|
||||
<renderingAttribute name="shadowRendering">
|
||||
<filter minzoom="14" attrIntValue="3" />
|
||||
<filter minzoom="10" maxzoom="14" attrIntValue="1" />
|
||||
<filter attrIntValue="0" />
|
||||
</renderingAttribute>
|
||||
|
||||
<renderingAttribute name="defaultColor">
|
||||
<filter noPolygons="true" attrColorValue="#00ffffff" />
|
||||
<filter nightMode="true" attrColorValue="#003333" />
|
||||
<filter attrColorValue="#f1eee8" />
|
||||
</renderingAttribute>
|
||||
<!--
|
||||
Based on All-Purpose Renderer (by Hardy Mueller), v023:
|
||||
- with ShowMoreMapDetails some roads already rendered at lower zooms than old default
|
||||
|
@ -50,13 +73,6 @@
|
|||
laundry, copyshop
|
||||
-->
|
||||
|
||||
<!-- types : string, int, boolean; possibleValues comma separated possible values for int/string -->
|
||||
<renderingProperty attr="hmRendered" name="Show more map detail" description="Default renderer: Increase amount of map detail shown"
|
||||
type="boolean" possibleValues=""/>
|
||||
<renderingProperty attr="appMode" name="Rendering mode" description="Default renderer: Adjust rendering for specific purpose"
|
||||
type="string" possibleValues="default,car,bicycle,pedestrian"/>
|
||||
<renderingProperty attr="shadowRenderingMode" name="Shadow rendering" description="Default renderer: change way of displaying road edges."
|
||||
type="string" possibleValues="no shadow,one step,blur shadow,solid shadow"/>
|
||||
|
||||
|
||||
<!-- input exact layer, orderType check tag, value -->
|
||||
|
|
|
@ -42,12 +42,14 @@ import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
|||
import net.osmand.plus.render.OsmandRenderer.ShadowRenderingMode;
|
||||
import net.osmand.render.RenderingRuleProperty;
|
||||
import net.osmand.render.RenderingRuleSearchRequest;
|
||||
import net.osmand.render.RenderingRuleStorageProperties;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.RectF;
|
||||
import android.graphics.Bitmap.Config;
|
||||
import android.os.Handler;
|
||||
|
@ -485,16 +487,16 @@ public class MapRenderRepositories {
|
|||
final long searchTime = System.currentTimeMillis() - now;
|
||||
|
||||
currentRenderingContext = new OsmandRenderer.RenderingContext(context);
|
||||
RenderingRuleProperty rr = storage.PROPS.get("shadowRenderingMode");
|
||||
if(rr != null){
|
||||
CommonPreference<String> settings = app.getSettings().getCustomRenderProperty(rr.getAttrName());
|
||||
if(settings.get().length() > 0 ) {
|
||||
try {
|
||||
ShadowRenderingMode m = ShadowRenderingMode.valueOf(settings.get().replace(' ', '_').toUpperCase());
|
||||
currentRenderingContext.shadowRenderingMode = m.value;
|
||||
} catch(IllegalArgumentException e){
|
||||
}
|
||||
}
|
||||
int fillColor = 0xf1eee8;
|
||||
renderingReq.clearState();
|
||||
renderingReq.setIntFilter(renderingReq.ALL.R_MINZOOM, requestedBox.getZoom());
|
||||
if(renderingReq.searchRenderingAttribute(RenderingRuleStorageProperties.A_DEFAULT_COLOR)) {
|
||||
fillColor = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_COLOR_VALUE);
|
||||
}
|
||||
renderingReq.clearState();
|
||||
renderingReq.setIntFilter(renderingReq.ALL.R_MINZOOM, requestedBox.getZoom());
|
||||
if(renderingReq.searchRenderingAttribute(RenderingRuleStorageProperties.A_SHADOW_RENDERING)) {
|
||||
currentRenderingContext.shadowRenderingMode = renderingReq.getIntPropertyValue(renderingReq.ALL.R_ATTR_INT_VALUE);
|
||||
}
|
||||
currentRenderingContext.leftX = (float) requestedBox.getLeftTileX();
|
||||
currentRenderingContext.topY = (float) requestedBox.getTopTileY();
|
||||
|
@ -511,7 +513,9 @@ public class MapRenderRepositories {
|
|||
|
||||
now = System.currentTimeMillis();
|
||||
|
||||
Bitmap bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, Config.RGB_565);
|
||||
// Bitmap bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, Config.RGB_565);
|
||||
Bitmap bmp = Bitmap.createBitmap(currentRenderingContext.width, currentRenderingContext.height, Config.ARGB_8888);
|
||||
bmp.eraseColor(Color.TRANSPARENT);
|
||||
|
||||
// 1. generate image step by step
|
||||
this.prevBmp = this.bmp;
|
||||
|
@ -519,12 +523,13 @@ public class MapRenderRepositories {
|
|||
this.bmp = bmp;
|
||||
this.bmpLocation = tileRect;
|
||||
|
||||
|
||||
if(app.getSettings().NATIVE_RENDERING.get()) {
|
||||
renderer.generateNewBitmapNative(currentRenderingContext, cNativeObjects, bmp, prefs.USE_ENGLISH_NAMES.get(), renderingReq,
|
||||
notifyList, storage.getBgColor(nightMode));
|
||||
notifyList, fillColor);
|
||||
} else {
|
||||
renderer.generateNewBitmap(currentRenderingContext, cObjects, bmp, prefs.USE_ENGLISH_NAMES.get(), renderingReq,
|
||||
notifyList, storage.getBgColor(nightMode));
|
||||
notifyList, fillColor);
|
||||
}
|
||||
String renderingDebugInfo = currentRenderingContext.renderingDebugInfo;
|
||||
currentRenderingContext.ended = true;
|
||||
|
|
|
@ -28,7 +28,6 @@ import android.content.Context;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapShader;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.DashPathEffect;
|
||||
import android.graphics.Paint;
|
||||
|
@ -50,12 +49,8 @@ import android.view.WindowManager;
|
|||
public class OsmandRenderer {
|
||||
private static final Log log = LogUtil.getLog(OsmandRenderer.class);
|
||||
|
||||
private final int clFillScreen = Color.rgb(241, 238, 232);
|
||||
|
||||
|
||||
private Paint paint;
|
||||
|
||||
private Paint paintFillEmpty;
|
||||
private Paint paintIcon;
|
||||
|
||||
public static final int TILE_SIZE = 256;
|
||||
|
@ -160,9 +155,6 @@ public class OsmandRenderer {
|
|||
paint = new Paint();
|
||||
paint.setAntiAlias(true);
|
||||
|
||||
paintFillEmpty = new Paint();
|
||||
paintFillEmpty.setStyle(Style.FILL);
|
||||
paintFillEmpty.setColor(clFillScreen);
|
||||
dm = new DisplayMetrics();
|
||||
WindowManager wmgr = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
|
||||
wmgr.getDefaultDisplay().getMetrics(dm);
|
||||
|
@ -246,9 +238,8 @@ public class OsmandRenderer {
|
|||
// fill area
|
||||
Canvas cv = new Canvas(bmp);
|
||||
if (defaultColor != 0) {
|
||||
paintFillEmpty.setColor(defaultColor);
|
||||
cv.drawColor(defaultColor);
|
||||
}
|
||||
cv.drawRect(0, 0, bmp.getWidth(), bmp.getHeight(), paintFillEmpty);
|
||||
// put in order map
|
||||
TIntObjectHashMap<TIntArrayList> orderMap = sortObjectsByProperOrder(rc, objects, render);
|
||||
|
||||
|
|
|
@ -93,7 +93,7 @@ public class RendererRegistry {
|
|||
if (dep == null) {
|
||||
log.warn("Dependent renderer not found : " + name); //$NON-NLS-1$
|
||||
}
|
||||
return null;
|
||||
return dep;
|
||||
}
|
||||
});
|
||||
renderers.put(name, main);
|
||||
|
|
Loading…
Reference in a new issue