当前位置: 首页>>代码示例>>Java>>正文


Java Canvas.drawLine方法代码示例

本文整理汇总了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);
}
 
开发者ID:emdete,项目名称:tabulae,代码行数:27,代码来源:AlternatingLine.java

示例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;
	}
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:25,代码来源:AlternatingLine.java


注:本文中的org.mapsforge.core.graphics.Canvas.drawLine方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。