Render styles improvements
This commit is contained in:
parent
02db7ca08d
commit
1de6ca8fb7
@ -134,6 +134,11 @@ class AndroidPaint implements Paint {
|
||||
return Math.abs(fm.bottom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrokeWidth() {
|
||||
return mPaint.getStrokeWidth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTextHeight(String text) {
|
||||
mPaint.getTextBounds(text, 0, text.length(), rect);
|
||||
|
@ -212,6 +212,11 @@ public class AwtPaint implements Paint {
|
||||
stroke = new BasicStroke(strokeWidth, cap, join, join == BasicStroke.JOIN_MITER ? 1.0f : 0, null, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrokeWidth() {
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTextHeight(String text) {
|
||||
Graphics2D graphics2d = bufferedImage.createGraphics();
|
||||
|
@ -337,6 +337,11 @@ public class IosPaint implements Paint {
|
||||
return descent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrokeWidth() {
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTextHeight(String text) {
|
||||
return this.fontHeight;
|
||||
|
@ -124,6 +124,11 @@ public class GwtPaint implements Paint {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getStrokeWidth() {
|
||||
return strokeWidth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getTextHeight(String text) {
|
||||
// TODO
|
||||
|
@ -71,6 +71,8 @@ public interface Paint {
|
||||
|
||||
float getFontDescent();
|
||||
|
||||
float getStrokeWidth();
|
||||
|
||||
float getTextHeight(String text);
|
||||
|
||||
float getTextWidth(String text);
|
||||
|
@ -74,7 +74,7 @@ public class BuildingLayer extends Layer implements TileLoaderThemeHook {
|
||||
if (!(style instanceof ExtrusionStyle))
|
||||
return false;
|
||||
|
||||
ExtrusionStyle extrusion = (ExtrusionStyle) style;
|
||||
ExtrusionStyle extrusion = (ExtrusionStyle) style.current();
|
||||
|
||||
int height = 0;
|
||||
int minHeight = 0;
|
||||
|
@ -1,4 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 devemux86
|
||||
* Copyright 2016 Andrey Novikov
|
||||
*
|
||||
@ -56,7 +57,7 @@ public class LabelTileLoaderHook implements TileLoaderThemeHook {
|
||||
if (style instanceof TextStyle) {
|
||||
LabelTileData ld = get(tile);
|
||||
|
||||
TextStyle text = (TextStyle) style;
|
||||
TextStyle text = (TextStyle) style.current();
|
||||
if (element.type == LINE) {
|
||||
String value = element.tags.getValue(text.textKey);
|
||||
if (value == null || value.length() == 0)
|
||||
@ -104,7 +105,7 @@ public class LabelTileLoaderHook implements TileLoaderThemeHook {
|
||||
}
|
||||
}
|
||||
} else if (style instanceof SymbolStyle) {
|
||||
SymbolStyle symbol = (SymbolStyle) style;
|
||||
SymbolStyle symbol = (SymbolStyle) style.current();
|
||||
|
||||
if (symbol.bitmap == null && symbol.texture == null)
|
||||
return false;
|
||||
|
@ -251,6 +251,7 @@ public class AreaStyle extends RenderStyle<AreaStyle> {
|
||||
}
|
||||
|
||||
public T reset() {
|
||||
level = -1;
|
||||
fillColor = Color.WHITE;
|
||||
strokeColor = Color.BLACK;
|
||||
strokeWidth = 0;
|
||||
|
@ -94,6 +94,7 @@ public final class CircleStyle extends RenderStyle<CircleStyle> {
|
||||
}
|
||||
|
||||
public T reset() {
|
||||
level = -1;
|
||||
radius = 0;
|
||||
scaleRadius = false;
|
||||
fillColor = Color.TRANSPARENT;
|
||||
|
@ -173,25 +173,30 @@ public final class TextStyle extends RenderStyle<TextStyle> {
|
||||
return self();
|
||||
}
|
||||
|
||||
public TextBuilder<?> from(TextStyle style) {
|
||||
this.style = style.style;
|
||||
this.textKey = style.textKey;
|
||||
this.caption = style.caption;
|
||||
this.dy = style.dy;
|
||||
this.priority = style.priority;
|
||||
this.areaSize = style.areaSize;
|
||||
this.bitmap = style.bitmap;
|
||||
this.texture = style.texture;
|
||||
this.fillColor = style.paint.getColor();
|
||||
public TextBuilder<?> set(TextStyle text) {
|
||||
if (text == null)
|
||||
return reset();
|
||||
|
||||
this.style = text.style;
|
||||
this.textKey = text.textKey;
|
||||
this.caption = text.caption;
|
||||
this.dy = text.dy;
|
||||
this.priority = text.priority;
|
||||
this.areaSize = text.areaSize;
|
||||
this.bitmap = text.bitmap;
|
||||
this.texture = text.texture;
|
||||
this.fillColor = text.paint.getColor();
|
||||
this.fontFamily = FontFamily.DEFAULT;
|
||||
this.fontStyle = FontStyle.NORMAL;
|
||||
this.strokeColor = style.stroke.getColor();
|
||||
this.strokeWidth = 2;
|
||||
this.fontSize = style.fontSize;
|
||||
if (text.stroke != null) {
|
||||
this.strokeColor = text.stroke.getColor();
|
||||
this.strokeWidth = text.stroke.getStrokeWidth();
|
||||
}
|
||||
this.fontSize = text.fontSize;
|
||||
|
||||
this.symbolWidth = style.symbolWidth;
|
||||
this.symbolHeight = style.symbolHeight;
|
||||
this.symbolPercent = style.symbolPercent;
|
||||
this.symbolWidth = text.symbolWidth;
|
||||
this.symbolHeight = text.symbolHeight;
|
||||
this.symbolPercent = text.symbolPercent;
|
||||
|
||||
return self();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user