Graphics API: enable paint text alignment, closes #320
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, 2011, 2012 mapsforge.org
|
* Copyright 2010, 2011, 2012 mapsforge.org
|
||||||
* Copyright 2016 devemux86
|
* Copyright 2016-2017 devemux86
|
||||||
* Copyright 2017 nebular
|
* Copyright 2017 nebular
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
@@ -101,8 +101,7 @@ class AndroidPaint implements Paint {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTextAlign(Align align) {
|
public void setTextAlign(Align align) {
|
||||||
// Align text in text layer
|
mPaint.setTextAlign(android.graphics.Paint.Align.valueOf(align.name()));
|
||||||
//mPaint.setTextAlign(android.graphics.Paint.Align.valueOf(align.name()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
* Copyright 2010, 2011, 2012, 2013 mapsforge.org
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016 devemux86
|
* Copyright 2016-2017 devemux86
|
||||||
* Copyright 2017 nebular
|
* Copyright 2017 nebular
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
@@ -101,6 +101,7 @@ public class AwtPaint implements Paint {
|
|||||||
DEFAULT_FONT = new Font("Arial", Font.PLAIN, 14).deriveFont(TEXT_ATTRIBUTES);
|
DEFAULT_FONT = new Font("Arial", Font.PLAIN, 14).deriveFont(TEXT_ATTRIBUTES);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Align align;
|
||||||
Color color = new Color(0.1f, 0.1f, 0.1f, 1);
|
Color color = new Color(0.1f, 0.1f, 0.1f, 1);
|
||||||
FontMetrics fm;
|
FontMetrics fm;
|
||||||
Font font = DEFAULT_FONT; // new Font("Default", Font.PLAIN, 13);
|
Font font = DEFAULT_FONT; // new Font("Default", Font.PLAIN, 13);
|
||||||
@@ -156,8 +157,8 @@ public class AwtPaint implements Paint {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTextAlign(Align align) {
|
public void setTextAlign(Align align) {
|
||||||
// Align text in text layer
|
// TODO never read
|
||||||
//this.align = align;
|
this.align = align;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2016 Longri
|
* Copyright 2016 Longri
|
||||||
* Copyright 2016 devemux86
|
* Copyright 2016-2017 devemux86
|
||||||
* Copyright 2017 nebular
|
* Copyright 2017 nebular
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
* This program is free software: you can redistribute it and/or modify it under the
|
||||||
@@ -65,6 +65,7 @@ public class IosPaint implements Paint {
|
|||||||
private static final String DEFAULT_FONT_NAME_BOLD = UIFont.getSystemFont(1, UIFontWeight.Bold).getFontDescriptor().getPostscriptName();
|
private static final String DEFAULT_FONT_NAME_BOLD = UIFont.getSystemFont(1, UIFontWeight.Bold).getFontDescriptor().getPostscriptName();
|
||||||
private static final String DEFAULT_FONT_NAME_ITALIC = UIFont.getItalicSystemFont(1).getFontDescriptor().getPostscriptName();
|
private static final String DEFAULT_FONT_NAME_ITALIC = UIFont.getItalicSystemFont(1).getFontDescriptor().getPostscriptName();
|
||||||
|
|
||||||
|
private Align align;
|
||||||
private final NSAttributedStringAttributes attribs = new NSAttributedStringAttributes();
|
private final NSAttributedStringAttributes attribs = new NSAttributedStringAttributes();
|
||||||
private CGLineCap cap = CGLineCap.Butt;
|
private CGLineCap cap = CGLineCap.Butt;
|
||||||
private CGLineJoin join = CGLineJoin.Miter;
|
private CGLineJoin join = CGLineJoin.Miter;
|
||||||
@@ -147,8 +148,8 @@ public class IosPaint implements Paint {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTextAlign(Align align) {
|
public void setTextAlign(Align align) {
|
||||||
// Align text in text layer
|
// TODO never read
|
||||||
//this.align = align;
|
this.align = align;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016 devemux86
|
* Copyright 2016-2017 devemux86
|
||||||
* Copyright 2017 nebular
|
* Copyright 2017 nebular
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
@@ -24,6 +24,7 @@ import org.oscim.backend.canvas.Paint;
|
|||||||
|
|
||||||
public class GwtPaint implements Paint {
|
public class GwtPaint implements Paint {
|
||||||
|
|
||||||
|
private Align align;
|
||||||
String color;
|
String color;
|
||||||
boolean stroke;
|
boolean stroke;
|
||||||
|
|
||||||
@@ -77,8 +78,8 @@ public class GwtPaint implements Paint {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setTextAlign(Align align) {
|
public void setTextAlign(Align align) {
|
||||||
// Align text in text layer
|
// TODO never read
|
||||||
//this.align = align;
|
this.align = align;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2013 Hannes Janetzek
|
* Copyright 2013 Hannes Janetzek
|
||||||
* Copyright 2016 devemux86
|
* Copyright 2016-2017 devemux86
|
||||||
* Copyright 2016 Andrey Novikov
|
* Copyright 2016 Andrey Novikov
|
||||||
*
|
*
|
||||||
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
* This file is part of the OpenScienceMap project (http://www.opensciencemap.org).
|
||||||
@@ -22,7 +22,6 @@ import org.oscim.backend.CanvasAdapter;
|
|||||||
import org.oscim.backend.canvas.Bitmap;
|
import org.oscim.backend.canvas.Bitmap;
|
||||||
import org.oscim.backend.canvas.Color;
|
import org.oscim.backend.canvas.Color;
|
||||||
import org.oscim.backend.canvas.Paint;
|
import org.oscim.backend.canvas.Paint;
|
||||||
import org.oscim.backend.canvas.Paint.Align;
|
|
||||||
import org.oscim.backend.canvas.Paint.FontFamily;
|
import org.oscim.backend.canvas.Paint.FontFamily;
|
||||||
import org.oscim.backend.canvas.Paint.FontStyle;
|
import org.oscim.backend.canvas.Paint.FontStyle;
|
||||||
import org.oscim.renderer.atlas.TextureRegion;
|
import org.oscim.renderer.atlas.TextureRegion;
|
||||||
@@ -213,7 +212,7 @@ public final class TextStyle extends RenderStyle<TextStyle> {
|
|||||||
this.texture = b.texture;
|
this.texture = b.texture;
|
||||||
|
|
||||||
paint = CanvasAdapter.newPaint();
|
paint = CanvasAdapter.newPaint();
|
||||||
paint.setTextAlign(Align.CENTER);
|
//paint.setTextAlign(Align.CENTER);
|
||||||
paint.setTypeface(b.fontFamily, b.fontStyle);
|
paint.setTypeface(b.fontFamily, b.fontStyle);
|
||||||
|
|
||||||
paint.setColor(b.themeCallback != null ? b.themeCallback.getColor(b.fillColor) : b.fillColor);
|
paint.setColor(b.themeCallback != null ? b.themeCallback.getColor(b.fillColor) : b.fillColor);
|
||||||
@@ -222,7 +221,7 @@ public final class TextStyle extends RenderStyle<TextStyle> {
|
|||||||
if (b.strokeWidth > 0) {
|
if (b.strokeWidth > 0) {
|
||||||
stroke = CanvasAdapter.newPaint();
|
stroke = CanvasAdapter.newPaint();
|
||||||
stroke.setStyle(Paint.Style.STROKE);
|
stroke.setStyle(Paint.Style.STROKE);
|
||||||
stroke.setTextAlign(Align.CENTER);
|
//stroke.setTextAlign(Align.CENTER);
|
||||||
stroke.setTypeface(b.fontFamily, b.fontStyle);
|
stroke.setTypeface(b.fontFamily, b.fontStyle);
|
||||||
stroke.setColor(b.themeCallback != null ? b.themeCallback.getColor(b.strokeColor) : b.strokeColor);
|
stroke.setColor(b.themeCallback != null ? b.themeCallback.getColor(b.strokeColor) : b.strokeColor);
|
||||||
stroke.setStrokeWidth(b.strokeWidth);
|
stroke.setStrokeWidth(b.strokeWidth);
|
||||||
|
|||||||
Reference in New Issue
Block a user