當前位置: 首頁>>代碼示例>>Java>>正文


Java FontStyle類代碼示例

本文整理匯總了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);
	}
}
 
開發者ID:monossido,項目名稱:CoopTDMOrienteering,代碼行數:26,代碼來源:MyLocationOverlay.java

示例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);
    }
}
 
開發者ID:OsmHackTW,項目名稱:Geomancer,代碼行數:68,代碼來源:Pin.java


注:本文中的org.mapsforge.core.graphics.FontStyle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。