本文整理汇总了Java中org.mapsforge.core.graphics.Canvas.drawLine方法的典型用法代码示例。如果您正苦于以下问题:Java Canvas.drawLine方法的具体用法?Java Canvas.drawLine怎么用?Java Canvas.drawLine使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.mapsforge.core.graphics.Canvas
的用法示例。
在下文中一共展示了Canvas.drawLine方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
}