Add name rendering
This commit is contained in:
parent
54deb45b8b
commit
9812332322
2 changed files with 24 additions and 3 deletions
|
@ -18,6 +18,7 @@ public class RenderingRuleStorageProperties {
|
|||
|
||||
public static final String TEXT_LENGTH = "textLength";
|
||||
public static final String NAME_TAG = "nameTag";
|
||||
public static final String NAME_TAG2 = "nameTag2";
|
||||
public static final String TEXT_SHIELD = "textShield";
|
||||
public static final String SHADOW_RADIUS = "shadowRadius";
|
||||
public static final String SHADOW_COLOR = "shadowColor";
|
||||
|
@ -76,6 +77,7 @@ public class RenderingRuleStorageProperties {
|
|||
public RenderingRuleProperty R_ATTR_STRING_VALUE;
|
||||
public RenderingRuleProperty R_TEXT_LENGTH;
|
||||
public RenderingRuleProperty R_NAME_TAG;
|
||||
public RenderingRuleProperty R_NAME_TAG2;
|
||||
public RenderingRuleProperty R_TEXT_SHIELD;
|
||||
public RenderingRuleProperty R_SHADOW_RADIUS;
|
||||
public RenderingRuleProperty R_SHADOW_COLOR;
|
||||
|
@ -159,6 +161,7 @@ public class RenderingRuleStorageProperties {
|
|||
|
||||
R_TEXT_LENGTH = registerRuleInternal(RenderingRuleProperty.createInputIntProperty(TEXT_LENGTH));
|
||||
R_NAME_TAG = registerRuleInternal(RenderingRuleProperty.createInputStringProperty(NAME_TAG));
|
||||
R_NAME_TAG2 = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty(NAME_TAG2));
|
||||
|
||||
R_DISABLE = registerRuleInternal(RenderingRuleProperty.createOutputBooleanProperty(DISABLE));
|
||||
R_ATTR_INT_VALUE = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ATTR_INT_VALUE));
|
||||
|
|
|
@ -15,6 +15,7 @@ import net.osmand.data.QuadTree;
|
|||
import net.osmand.plus.render.OsmandRenderer.RenderingContext;
|
||||
import net.osmand.render.RenderingRuleSearchRequest;
|
||||
import net.osmand.render.RenderingRulesStorage;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.sf.junidecode.Junidecode;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
|
@ -303,15 +304,32 @@ public class TextRenderer {
|
|||
}
|
||||
}
|
||||
|
||||
private void createTextDrawInfo(BinaryMapDataObject o, RenderingRuleSearchRequest render, RenderingContext rc, TagValuePair pair, float xMid, float yMid,
|
||||
Path path, PointF[] points, String name, String tagName) {
|
||||
private void createTextDrawInfo(final BinaryMapDataObject o, RenderingRuleSearchRequest render, RenderingContext rc, TagValuePair pair, final float xMid, float yMid,
|
||||
Path path, final PointF[] points, String name, String tagName) {
|
||||
render.setInitialTagValueZoom(pair.tag, pair.value, rc.zoom, o);
|
||||
render.setIntFilter(render.ALL.R_TEXT_LENGTH, name.length());
|
||||
render.setStringFilter(render.ALL.R_NAME_TAG, tagName);
|
||||
if(render.search(RenderingRulesStorage.TEXT_RULES)){
|
||||
if(render.getIntPropertyValue(render.ALL.R_TEXT_SIZE) > 0){
|
||||
TextDrawInfo text = new TextDrawInfo(name);
|
||||
final TextDrawInfo text = new TextDrawInfo(name);
|
||||
text.fillProperties(render, xMid, yMid);
|
||||
final String tagName2 = render.getStringPropertyValue(render.ALL.R_NAME_TAG2);
|
||||
if (!Algorithms.isEmpty(tagName2)) {
|
||||
o.getObjectNames().forEachEntry(new TIntObjectProcedure<String>() {
|
||||
@Override
|
||||
public boolean execute(int tagid, String nname) {
|
||||
String tagNameN2 = o.getMapIndex().decodeType(tagid).tag;
|
||||
if (tagName2.equals(tagNameN2)) {
|
||||
if (nname != null && nname.trim().length() > 0) {
|
||||
text.text += " " + nname;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
paintText.setTextSize(rc.getDensityValue(text.textSize));
|
||||
Rect bs = new Rect();
|
||||
paintText.getTextBounds(name, 0, name.length(), bs);
|
||||
|
|
Loading…
Reference in a new issue