Add support for icon visible size (special case 0)
This commit is contained in:
parent
d0df0bad67
commit
5331180650
2 changed files with 35 additions and 17 deletions
|
@ -46,6 +46,7 @@ public class RenderingRuleStorageProperties {
|
|||
public static final String TEXT_BOLD = "textBold";
|
||||
public static final String TEXT_ORDER = "textOrder";
|
||||
public static final String ICON_ORDER = "iconOrder";
|
||||
public static final String ICON_VISIBLE_SIZE = "iconVisibleSize";
|
||||
public static final String TEXT_MIN_DISTANCE = "textMinDistance";
|
||||
public static final String TEXT_ON_PATH = "textOnPath";
|
||||
public static final String ICON = "icon";
|
||||
|
@ -109,6 +110,7 @@ public class RenderingRuleStorageProperties {
|
|||
public RenderingRuleProperty R_TEXT_MIN_DISTANCE;
|
||||
public RenderingRuleProperty R_TEXT_ON_PATH;
|
||||
public RenderingRuleProperty R_ICON;
|
||||
public RenderingRuleProperty R_ICON_VISIBLE_SIZE;
|
||||
public RenderingRuleProperty R_LAYER;
|
||||
public RenderingRuleProperty R_ORDER;
|
||||
public RenderingRuleProperty R_POINT;
|
||||
|
@ -134,6 +136,7 @@ public class RenderingRuleStorageProperties {
|
|||
final List<RenderingRuleProperty> rules ;
|
||||
final List<RenderingRuleProperty> customRules ;
|
||||
|
||||
|
||||
public RenderingRuleStorageProperties() {
|
||||
properties = new LinkedHashMap<String, RenderingRuleProperty>();
|
||||
rules = new ArrayList<RenderingRuleProperty>();
|
||||
|
@ -184,6 +187,7 @@ public class RenderingRuleStorageProperties {
|
|||
R_TEXT_SIZE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(TEXT_SIZE));
|
||||
R_TEXT_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(TEXT_ORDER));
|
||||
R_ICON_ORDER = registerRuleInternal(RenderingRuleProperty.createOutputIntProperty(ICON_ORDER));
|
||||
R_ICON_VISIBLE_SIZE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(ICON_VISIBLE_SIZE));
|
||||
R_TEXT_MIN_DISTANCE = registerRuleInternal(RenderingRuleProperty.createOutputFloatProperty(TEXT_MIN_DISTANCE));
|
||||
R_TEXT_SHIELD = registerRuleInternal(RenderingRuleProperty.createOutputStringProperty(TEXT_SHIELD));
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@ import gnu.trove.list.array.TIntArrayList;
|
|||
import gnu.trove.map.hash.TIntObjectHashMap;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -86,6 +85,7 @@ public class OsmandRenderer {
|
|||
float y = 0;
|
||||
String resId;
|
||||
int iconOrder;
|
||||
float iconSize;
|
||||
}
|
||||
|
||||
|
||||
|
@ -315,29 +315,32 @@ public class OsmandRenderer {
|
|||
Bitmap ico = RenderingIcons.getIcon(context, icon.resId);
|
||||
if (ico != null) {
|
||||
if (icon.y >= 0 && icon.y < rc.height && icon.x >= 0 && icon.x < rc.width) {
|
||||
float left = icon.x - ico.getWidth() / 2 * rc.screenDensityRatio;
|
||||
float top = icon.y - ico.getHeight() / 2 * rc.screenDensityRatio;
|
||||
float right = left + ico.getWidth() * rc.screenDensityRatio;
|
||||
float bottom = top + ico.getHeight() * rc.screenDensityRatio;
|
||||
RectF rf = new RectF(left, top, right , bottom);
|
||||
boundIntersections.queryInBox(new QuadRect(left, top, right, bottom), result);
|
||||
int visbleWidth = icon.iconSize >= 0 ? (int) icon.iconSize : ico.getWidth();
|
||||
int visbleHeight = icon.iconSize >= 0 ? (int) icon.iconSize : ico.getHeight();
|
||||
boolean intersects = false;
|
||||
for(RectF r : result) {
|
||||
if(r.intersect(rf)) {
|
||||
intersects = true;
|
||||
break;
|
||||
RectF rf = calculateRect(rc, icon, ico.getWidth(), ico.getHeight());
|
||||
if (visbleHeight > 0 && visbleWidth > 0) {
|
||||
RectF visibleRect = calculateRect(rc, icon, visbleWidth, visbleHeight);
|
||||
boundIntersections.queryInBox(new QuadRect(visibleRect.left, visibleRect.top, visibleRect.right, visibleRect.bottom), result);
|
||||
for (RectF r : result) {
|
||||
if (r.intersect(visibleRect)) {
|
||||
intersects = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!intersects) {
|
||||
if(rc.screenDensityRatio != 1f){
|
||||
Rect src = new Rect(0, 0, ico.getWidth(), ico
|
||||
.getHeight());
|
||||
if (rc.screenDensityRatio != 1f) {
|
||||
Rect src = new Rect(0, 0, ico.getWidth(), ico.getHeight());
|
||||
cv.drawBitmap(ico, src, rf, paintIcon);
|
||||
} else {
|
||||
cv.drawBitmap(ico, left, top, paintIcon);
|
||||
cv.drawBitmap(ico, rf.left, rf.top, paintIcon);
|
||||
}
|
||||
if(rf != null) {
|
||||
rf.inset(-rf.width() / 4, -rf.height() / 4);
|
||||
boundIntersections.insert(rf, new QuadRect(rf.left, rf.top, rf.right, rf.bottom));
|
||||
}
|
||||
rf.inset(-rf.width()/4, -rf.height()/4);
|
||||
boundIntersections.insert(rf, new QuadRect(rf.left, rf.top, rf.right, rf.bottom));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -347,6 +350,16 @@ public class OsmandRenderer {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
private RectF calculateRect(RenderingContext rc, IconDrawInfo icon, int visbleWidth, int visbleHeight) {
|
||||
RectF rf;
|
||||
float left = icon.x - visbleWidth / 2 * rc.screenDensityRatio;
|
||||
float top = icon.y - visbleHeight / 2 * rc.screenDensityRatio;
|
||||
float right = left + visbleWidth * rc.screenDensityRatio;
|
||||
float bottom = top + visbleHeight * rc.screenDensityRatio;
|
||||
rf = new RectF(left, top, right, bottom);
|
||||
return rf;
|
||||
}
|
||||
|
||||
Comparator<MapDataObjectPrimitive> sortByOrder() {
|
||||
return new Comparator<MapDataObjectPrimitive>() {
|
||||
|
@ -742,6 +755,7 @@ public class OsmandRenderer {
|
|||
ico.x = ps.x;
|
||||
ico.y = ps.y;
|
||||
ico.iconOrder = render.getIntPropertyValue(render.ALL.R_ICON_ORDER, 100);
|
||||
ico.iconSize = rc.getComplexValue(render, render.ALL.R_ICON_VISIBLE_SIZE, -1);
|
||||
ico.resId = resId;
|
||||
rc.iconsToDraw.add(ico);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue