本文整理汇总了Java中org.mapsforge.core.graphics.Canvas类的典型用法代码示例。如果您正苦于以下问题:Java Canvas类的具体用法?Java Canvas怎么用?Java Canvas使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Canvas类属于org.mapsforge.core.graphics包,在下文中一共展示了Canvas类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的package包/类
@Override
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
if (getLatLong() == null || getBitmap() == null) {
return;
}
long mapSize = MercatorProjection.getMapSize(zoomLevel, displayModel.getTileSize());
double pixelX = MercatorProjection.longitudeToPixelX(getLatLong().longitude, mapSize);
double pixelY = MercatorProjection.latitudeToPixelY(getLatLong().latitude, mapSize);
int halfBitmapWidth = getBitmap().getWidth() / 2;
int halfBitmapHeight = getBitmap().getHeight() / 2;
int left = (int) (pixelX - topLeftPoint.x - halfBitmapWidth + getHorizontalOffset());
int top = (int) (pixelY - topLeftPoint.y - halfBitmapHeight + getVerticalOffset());
int right = left + getBitmap().getWidth();
int bottom = top + getBitmap().getHeight();
Rectangle bitmapRectangle = new Rectangle(left, top, right, bottom);
Rectangle canvasRectangle = new Rectangle(0, 0, canvas.getWidth(), canvas.getHeight());
if (!canvasRectangle.intersects(bitmapRectangle)) {
return;
}
android.graphics.Canvas androidCanvas = AndroidGraphicFactory.getCanvas(canvas);
androidCanvas.save();
androidCanvas.rotate(degree, (float) (pixelX - topLeftPoint.x), (float) (pixelY - topLeftPoint.y));
canvas.drawBitmap(getBitmap(), left, top);
androidCanvas.restore();
}
开发者ID:emdete,项目名称:tabulae,代码行数:26,代码来源:RotatingMarker.java
示例2: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的package包/类
@Override
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
if (!getLatLongs().isEmpty()) {
int bl = getLatLongs().size() / 3 * 2;
int index = 0;
Iterator<LatLong> iterator = getLatLongs().iterator();
if (iterator.hasNext()) {
long mapSize = MercatorProjection.getMapSize(zoomLevel, displayModel.getTileSize());
LatLong from = iterator.next();
while (iterator.hasNext()) {
LatLong to = iterator.next();
if (boundingBox.contains(to) || boundingBox.contains(from)) {
Paint paint = getPaintStroke(from, to, index<bl?2:1);
int x1 = (int) (MercatorProjection.longitudeToPixelX(from.longitude, mapSize) - topLeftPoint.x);
int y1 = (int) (MercatorProjection.latitudeToPixelY(from.latitude, mapSize) - topLeftPoint.y);
int x2 = (int) (MercatorProjection.longitudeToPixelX(to.longitude, mapSize) - topLeftPoint.x);
int y2 = (int) (MercatorProjection.latitudeToPixelY(to.latitude, mapSize) - topLeftPoint.y);
canvas.drawLine(x1, y1, x2, y2, paint);
index++;
}
from = to;
}
}
}
//if (DEBUG) Log.d(TAG, "AlternatingLine.draw count=" + count);
}
开发者ID:emdete,项目名称:tabulae,代码行数:27,代码来源:AlternatingLine.java
示例3: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的package包/类
@Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
if (DEBUG) { Log.d(TAG, "AlternatingLine.draw"); }
if (getLatLongs().isEmpty()) {
return;
}
Iterator<LatLong> iterator = getLatLongs().iterator();
if (!iterator.hasNext()) {
return;
}
long mapSize = MercatorProjection.getMapSize(zoomLevel, displayModel.getTileSize());
LatLong from = iterator.next();
while (iterator.hasNext()) {
LatLong to = iterator.next();
if (boundingBox.contains(to) || boundingBox.contains(from)) {
Paint paint = getPaintStroke(from, to);
int x1 = (int) (MercatorProjection.longitudeToPixelX(from.longitude, mapSize) - topLeftPoint.x);
int y1 = (int) (MercatorProjection.latitudeToPixelY(from.latitude, mapSize) - topLeftPoint.y);
int x2 = (int) (MercatorProjection.longitudeToPixelX(to.longitude, mapSize) - topLeftPoint.x);
int y2 = (int) (MercatorProjection.latitudeToPixelY(to.latitude, mapSize) - topLeftPoint.y);
canvas.drawLine(x1, y1, x2, y2, paint);
}
from = to;
}
}
开发者ID:emdete,项目名称:Simplicissimus,代码行数:25,代码来源:AlternatingLine.java
示例4: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的package包/类
@Override public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
if (getLatLong() == null || getBitmap() == null) {
return;
}
long mapSize = MercatorProjection.getMapSize(zoomLevel, displayModel.getTileSize());
double pixelX = MercatorProjection.longitudeToPixelX(getLatLong().longitude, mapSize);
double pixelY = MercatorProjection.latitudeToPixelY(getLatLong().latitude, mapSize);
int halfBitmapWidth = getBitmap().getWidth() / 2;
int halfBitmapHeight = getBitmap().getHeight() / 2;
int left = (int) (pixelX - topLeftPoint.x - halfBitmapWidth + getHorizontalOffset());
int top = (int) (pixelY - topLeftPoint.y - halfBitmapHeight + getVerticalOffset());
int right = left + getBitmap().getWidth();
int bottom = top + getBitmap().getHeight();
Rectangle bitmapRectangle = new Rectangle(left, top, right, bottom);
Rectangle canvasRectangle = new Rectangle(0, 0, canvas.getWidth(), canvas.getHeight());
if (!canvasRectangle.intersects(bitmapRectangle)) {
return;
}
android.graphics.Canvas androidCanvas = AndroidGraphicFactory.getCanvas(canvas);
androidCanvas.save();
androidCanvas.rotate(degree, (float) (pixelX - topLeftPoint.x), (float) (pixelY - topLeftPoint.y));
canvas.drawBitmap(getBitmap(), left, top);
androidCanvas.restore();
}
开发者ID:emdete,项目名称:Simplicissimus,代码行数:25,代码来源:RotatingMarker.java
示例5: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的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
示例6: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的package包/类
@Override
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
// draw bottom first
for (int i = pinPool.size() - 1; i >= 0; i--) {
Pin p = pinPool.get(i);
p.setDisplayModel(getDisplayModel());
p.draw(boundingBox, zoomLevel, canvas, topLeftPoint);
}
}
开发者ID:OsmHackTW,项目名称:Geomancer,代码行数:10,代码来源:PinGroup.java
示例7: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的package包/类
@Override
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
if (showAccuracy) {
circle.draw(boundingBox, zoomLevel, canvas, topLeftPoint);
}
marker.draw(boundingBox, zoomLevel, canvas, topLeftPoint);
}
开发者ID:emdete,项目名称:tabulae,代码行数:8,代码来源:ThreeStateLocationOverlay.java
示例8: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的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);
}
开发者ID:marunjar,项目名称:anewjkuapp,代码行数:10,代码来源:MyLocationOverlay.java
示例9: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的package包/类
@Override
public synchronized void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint) {
if (!myLocationEnabled) {
return;
}
if (showAccuracy) {
circle.draw(boundingBox, zoomLevel, canvas, topLeftPoint);
}
marker.draw(boundingBox, zoomLevel, canvas, topLeftPoint);
}
开发者ID:emdete,项目名称:Simplicissimus,代码行数:11,代码来源:ThreeStateLocationOverlay.java
示例10: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的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
示例11: call
import org.mapsforge.core.graphics.Canvas; //导入依赖的package包/类
@Override
public BufferedImage call() {
// get mapsforge zoom from jxmapviewer2 zoom (they use different conventions)
byte mapsforgeZoom = zoomLevelConverter.getMapsforge(tile.getZoom());
// load the render them
RenderThemeFuture rtf = new RenderThemeFuture(AwtGraphicFactory.INSTANCE, renderTheme, model);
rtf.run();
// render the mapsforge tile
org.mapsforge.core.model.Tile mtile = new org.mapsforge.core.model.Tile(tile.getX(), tile.getY(), mapsforgeZoom, TILE_SIZE);
RendererJob job = new RendererJob(mtile, mapDatabase, rtf, model, TEXT_SCALE, true, false);
TileBitmap bitmap = databaseRenderer.executeJob(job);
// copy it over onto an image (CompressedImage needs TYPE_INT_ARGB and anyway we can't access the buffered image internal to the tile)
BufferedImage image = new BufferedImage(TILE_SIZE, TILE_SIZE, BufferedImage.TYPE_INT_ARGB);
Graphics2D g = (Graphics2D)image.getGraphics();
g.setClip(0, 0, TILE_SIZE, TILE_SIZE);
g.setColor(Color.WHITE);
g.fillRect(0, 0, TILE_SIZE, TILE_SIZE);
Canvas canvas = (Canvas) AwtGraphicFactory.createGraphicContext(g);
canvas.drawBitmap(bitmap, 0, 0);
if(fadeColour!=null){
BackgroundMapUtils.renderFade(g,fadeColour.getColour());
}
g.dispose();
if(fadeColour!=null){
image = BackgroundMapUtils.greyscale(image, fadeColour.getGreyscale());
}
// TEST save to file
// ImageUtils.toPNGFile(image, new File("C:\\temp\\MapsforgeOutput\\" + System.currentTimeMillis() + ".png"));
// add to cache
CompressedImage compressed = new CompressedImage(image, CompressedType.LZ4);
cacheImage(tile.getX(), tile.getY(), tile.getZoom(), compressed);
// remove from pending after adding from cache (so can't be added twice)
removeTile(tile);
return image;
}
开发者ID:PGWelch,项目名称:com.opendoorlogistics,代码行数:44,代码来源:MapsforgeTileFactory.java
示例12: draw
import org.mapsforge.core.graphics.Canvas; //导入依赖的package包/类
@Override
public void draw(BoundingBox boundingBox, byte zoomLevel, Canvas canvas, Point topLeftPoint)
{
}
开发者ID:andreynovikov,项目名称:Androzic,代码行数:5,代码来源:ForgeLayer.java
注:本文中的org.mapsforge.core.graphics.Canvas类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论