本文整理汇总了Java中org.mapsforge.core.graphics.FontStyle类的典型用法代码示例。如果您正苦于以下问题:Java FontStyle类的具体用法?Java FontStyle怎么用?Java FontStyle使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FontStyle类属于org.mapsforge.core.graphics包,在下文中一共展示了FontStyle类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: draw
import org.mapsforge.core.graphics.FontStyle; //导入依赖的package包/类
@Override
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
if (!this.myLocationEnabled) {
return;
}
this.circle.draw(boundingBox, zoomLevel, canvas, topLeftPoint);
this.marker.draw(boundingBox, zoomLevel, canvas, topLeftPoint);
if (lastLocation != null) {
int tileSize = displayModel.getTileSize();
int pixelX = (int) (MercatorProjection.longitudeToPixelXWithScaleFactor(lastLocation.getLongitude(), zoomLevel, tileSize) - topLeftPoint.x);
int pixelY = (int) (MercatorProjection.longitudeToPixelXWithScaleFactor(lastLocation.getLatitude(), zoomLevel, tileSize) - topLeftPoint.y);
Paint paint = GRAPHIC_FACTORY.createPaint();
paint.setColor(Color.BLACK);
Resources r = context.getResources();
float px = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 25, r.getDisplayMetrics());
paint.setTextSize(px);
paint.setTextAlign(Align.CENTER);
paint.setTypeface(FontFamily.DEFAULT, FontStyle.BOLD);
float pxY = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 45, r.getDisplayMetrics());
canvas.drawText(userText, pixelX, pixelY - (int) pxY, paint);
}
}
示例2: draw
import org.mapsforge.core.graphics.FontStyle; //导入依赖的package包/类
@Override
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
long mapSize = MercatorProjection.getMapSize(zoomLevel, displayModel.getTileSize());
int tx = (int)(MercatorProjection.longitudeToPixelX(latLong.longitude, mapSize) - topLeftPoint.x);
int ty = (int)(MercatorProjection.latitudeToPixelY(latLong.latitude, mapSize) - topLeftPoint.y);
Paint paint = gf.createPaint();
if (selected) {
paint.setColor(brightColor);
} else {
paint.setColor(darkColor);
}
Bitmap tempBitmap = gf.createBitmap(PIN_WIDTH, PIN_HEIGHT);
Canvas tempCanvas = gf.createCanvas();
tempCanvas.setBitmap(tempBitmap);
// Draw triangle
Path path = gf.createPath();
path.moveTo(PIN_WIDTH/2, PIN_HEIGHT-1);
path.lineTo((int)(PIN_WIDTH*0.2), PIN_WIDTH/2);
path.lineTo((int)(PIN_WIDTH*0.8), PIN_WIDTH/2);
path.close();
tempCanvas.drawPath(path, paint);
// Draw circle
tempCanvas.drawCircle(PIN_WIDTH/2, PIN_WIDTH/2, PIN_WIDTH/2, paint);
// Draw category
paint.setColor(0xffffffff);
paint.setTextSize(PIN_WIDTH * 0.55f);
paint.setTypeface(FontFamily.SANS_SERIF, FontStyle.BOLD);
int cx = (PIN_WIDTH - paint.getTextWidth(category))/2;
int cy = (int)(PIN_WIDTH/2 + paint.getTextHeight(category)*0.35);
tempCanvas.drawText(category, cx, cy, paint);
// Paste pin
Matrix matrix = gf.createMatrix();
matrix.translate(tx, ty);
matrix.scale(scale, scale);
matrix.rotate((float)Math.toRadians(angle));
matrix.translate(-PIN_WIDTH/2, -PIN_HEIGHT);
canvas.drawBitmap(tempBitmap, matrix);
// Draw label
if (selected) {
paint.setColor(0xff000000);
paint.setTextSize(PIN_WIDTH * 0.4f);
int margin = 10;
int lw = paint.getTextWidth(label);
int lh = paint.getTextHeight(label);
int fw = lw + margin * 2;
int fh = lh + margin * 2;
tempBitmap = gf.createBitmap(fw, fh);
tempCanvas.setBitmap(tempBitmap);
tempCanvas.fillColor(0xe0ffd070);
tempCanvas.drawText(label, margin, lh + margin - 3, paint);
matrix.reset();
matrix.translate(tx, ty);
matrix.scale(scale, scale);
matrix.rotate((float)Math.toRadians(angle));
matrix.translate(-fw/2, margin);
canvas.drawBitmap(tempBitmap, matrix);
}
}