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


Java Paint类代码示例

本文整理汇总了Java中org.mapsforge.core.graphics.Paint的典型用法代码示例。如果您正苦于以下问题:Java Paint类的具体用法?Java Paint怎么用?Java Paint使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Paint类属于org.mapsforge.core.graphics包,在下文中一共展示了Paint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createPolyline

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
/**
 * draws a connected series of line segments specified by a list of LatLongs.
 *
 * @param pointList
 * @param color:       the color of the polyline
 * @param strokeWidth: the stroke width of the polyline
 * @return Polyline
 */
public Polyline createPolyline(PointList pointList, int color, int strokeWidth) {
    Paint paintStroke = AndroidGraphicFactory.INSTANCE.createPaint();

    paintStroke.setStyle(Style.STROKE);
    paintStroke.setStrokeJoin(Join.ROUND);
    paintStroke.setStrokeCap(Cap.ROUND);
    paintStroke.setColor(color);
    //        paintStroke.setDashPathEffect(new float[]{25, 25});
    paintStroke.setStrokeWidth(strokeWidth);

    // TODO: new mapsforge version wants an mapsforge-paint, not an android paint.
    // This doesn't seem to support transparceny
    //paintStroke.setAlpha(128);
    Polyline line = new Polyline((Paint) paintStroke, AndroidGraphicFactory.INSTANCE);
    List<LatLong> geoPoints = line.getLatLongs();
    PointList tmp = pointList;
    for (int i = 0; i < pointList.getSize(); i++) {
        geoPoints.add(new LatLong(tmp.getLatitude(i), tmp.getLongitude(i)));
    }
    return line;
}
 
开发者ID:junjunguo,项目名称:PocketMaps,代码行数:30,代码来源:MapHandler.java

示例2: draw

import org.mapsforge.core.graphics.Paint; //导入依赖的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.Paint; //导入依赖的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: ThreeStateLocationOverlay

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
/**
 * Constructs a new {@code ThreeStateLocationOverlay} with the given circle paints.
 *
 * @param context
 *            a reference to the application context.
 * @param mapViewPosition
 *            the {@code MapViewPosition} whose location will be updated.
 * @param circleFill
 *            the {@code Paint} used to fill the circle that represents the accuracy of the current location (might be null).
 * @param circleStroke
 *            the {@code Paint} used to stroke the circle that represents the accuracy of the current location (might be null).
 */
public ThreeStateLocationOverlay(Context context, MapViewPosition mapViewPosition, Paint circleFill,
						Paint circleStroke) {
	super();
	this.mapViewPosition = mapViewPosition;
	locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
	map_needle_pinned = new Marker(null, AndroidGraphicFactory.convertToBitmap(
		context.getResources().getDrawable(R.drawable.map_needle_pinned)), 0, 0);
	map_needle = new RotatingMarker(null, AndroidGraphicFactory.convertToBitmap(
		context.getResources().getDrawable(R.drawable.map_needle)), 0, 0);
	map_needle_off = new Marker(null, AndroidGraphicFactory.convertToBitmap(
		context.getResources().getDrawable(R.drawable.map_needle_off)), 0, 0);
	marker = map_needle_off;
	showAccuracy = true;
	circle = new Circle(null, 0, circleFill, circleStroke);
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:28,代码来源:ThreeStateLocationOverlay.java

示例5: draw

import org.mapsforge.core.graphics.Paint; //导入依赖的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: createPolyline

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
/**
   * Draws a polyline on the map view.
   * @param coordinates
   * @param color
   * @param strokeWidth
   * @return identifier for the object.
   */
  public int createPolyline(List<LatLong> coordinates, Color color, float strokeWidth) {
Paint paintStroke = mGraphicFactory.createPaint();
paintStroke.setStyle(Style.STROKE);
paintStroke.setColor(color);
paintStroke.setStrokeWidth(strokeWidth);

Polyline pl = new Polyline(paintStroke,mGraphicFactory);
pl.getLatLongs().addAll(coordinates);
MapView mapView = (MapView) getNativeView();
mapView.getLayerManager().getLayers().add(pl);
mLayers.put(Integer.toString(pl.hashCode()), pl);
mapView.getLayerManager().redrawLayers();

return pl.hashCode();
  }
 
开发者ID:snowciety,项目名称:sc.mapsforge,代码行数:23,代码来源:MapsforgeView.java

示例7: createPolygon

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
/**
   * Draws a polygon on the map view.
   * @param coordinates
   * @param fillColor
   * @param strokeColor
   * @param strokeWidth
   * @return identifier for the object.
   */
  public int createPolygon(List<LatLong> coordinates, Color fillColor, Color strokeColor, float strokeWidth) {
  	Paint paintFill = mGraphicFactory.createPaint();
  	paintFill.setStyle(Style.FILL);
  	paintFill.setColor(fillColor);
  	
  	Paint paintStroke = mGraphicFactory.createPaint();
  	paintStroke.setStyle(Style.STROKE);
  	paintStroke.setColor(strokeColor);
  	paintStroke.setStrokeWidth(strokeWidth);
  	
  	Polygon pg = new Polygon(paintFill, paintStroke, mGraphicFactory);
  	pg.getLatLongs().addAll(coordinates);
MapView mapView = (MapView) getNativeView();
  	mapView.getLayerManager().getLayers().add(pg);
  	mLayers.put(Integer.toString(pg.hashCode()), pg);
mapView.getLayerManager().redrawLayers();

  	return pg.hashCode();
  }
 
开发者ID:snowciety,项目名称:sc.mapsforge,代码行数:28,代码来源:MapsforgeView.java

示例8: createCircle

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
/**
   * Draws a circle on the map view.
   * @param latLong
   * @param radius	Note: The radius is in meters!
   * @param fillColor
   * @param strokeColor
   * @param strokeWidth
   * @return identifier for the object.
   */
  public int createCircle(LatLong latLong, float radius, Color fillColor, Color strokeColor, float strokeWidth) {
  	Paint paintFill = mGraphicFactory.createPaint();
  	paintFill.setColor(fillColor);
  	paintFill.setStyle(Style.FILL);
  	
  	Paint paintStroke = mGraphicFactory.createPaint();
  	paintStroke.setColor(strokeColor);
  	paintStroke.setStrokeWidth(strokeWidth);
  	paintStroke.setStyle(Style.STROKE);
  	
  	Circle c = new Circle(latLong, radius, paintFill, paintStroke);
MapView mapView = (MapView) getNativeView();
  	mapView.getLayerManager().getLayers().add(c);
  	mLayers.put(Integer.toString(c.hashCode()), c);
mapView.getLayerManager().redrawLayers();

  	return c.hashCode();
  }
 
开发者ID:snowciety,项目名称:sc.mapsforge,代码行数:28,代码来源:MapsforgeView.java

示例9: createPaint

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
public static Paint createPaint(final int color, final int strokeWidth, final Style style) {
	final Paint paint = AndroidGraphicFactory.INSTANCE.createPaint();
	paint.setColor(color);
	paint.setStrokeWidth(strokeWidth);
	paint.setStyle(style);
	return paint;
}
 
开发者ID:saintbyte,项目名称:openbmap,代码行数:8,代码来源:MapUtils.java

示例10: getPaint

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
protected static Paint getPaint(int color, int strokeWidth, Style style) {
	Paint paint = GRAPHIC_FACTORY.createPaint();
	paint.setColor(color);
	paint.setStrokeWidth(strokeWidth);
	paint.setStyle(style);
	return paint;
}
 
开发者ID:emdete,项目名称:tabulae,代码行数:8,代码来源:ThreeStateLocationOverlay.java

示例11: getDefaultCircleFill

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
private static Paint getDefaultCircleFill() {
    return getPaint(GRAPHIC_FACTORY.createColor(48, 0, 0, 255), 0, Style.FILL);
}
 
开发者ID:marunjar,项目名称:anewjkuapp,代码行数:4,代码来源:MyLocationOverlay.java

示例12: getPaint

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
private static Paint getPaint(int color, int strokeWidth, Style style) {
    Paint paint = GRAPHIC_FACTORY.createPaint();
    paint.setColor(color);
    paint.setStrokeWidth(strokeWidth);
    paint.setStyle(style);
    return paint;
}
 
开发者ID:marunjar,项目名称:anewjkuapp,代码行数:8,代码来源:MyLocationOverlay.java

示例13: MyLocationOverlay

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
/**
 * Constructs a new {@code MyLocationOverlay} with the given circle paints.
 *
 * @param activity        a reference to the activity.
 * @param mapViewPosition the {@code MapViewPosition} whose location will be updated.
 * @param bitmap          a bitmap to display at the current location (might be null).
 * @param circleFill      the {@code Paint} used to fill the circle that represents the accuracy of the current location (might be null).
 * @param circleStroke    the {@code Paint} used to stroke the circle that represents the accuracy of the current location (might be null).
 */
public MyLocationOverlay(Activity activity, MapViewPosition mapViewPosition, Bitmap bitmap, Paint circleFill,
                         Paint circleStroke) {
    super();
    this.activity = activity;
    this.mapViewPosition = mapViewPosition;
    this.locationManager = (LocationManager) activity.getSystemService(Context.LOCATION_SERVICE);
    this.marker = new Marker(null, bitmap, 0, 0);
    this.circle = new Circle(null, 0, circleFill, circleStroke);
}
 
开发者ID:marunjar,项目名称:anewjkuapp,代码行数:19,代码来源:MyLocationOverlay.java

示例14: LocationOverlay

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
public LocationOverlay(Activity activity, MapViewPosition mapViewPosition,
                       Bitmap bitmap, Paint circleFill, Paint circleStroke) {
    super(activity, mapViewPosition, bitmap, circleFill, circleStroke);
    this.mContext = activity;
}
 
开发者ID:marunjar,项目名称:anewjkuapp,代码行数:6,代码来源:LocationOverlay.java

示例15: getPaintStroke

import org.mapsforge.core.graphics.Paint; //导入依赖的package包/类
public synchronized Paint getPaintStroke(LatLong from, LatLong to) {
	Paint paint = AndroidGraphicFactory.INSTANCE.createPaint();
	paint.setStrokeWidth(16);
	paint.setStyle(Style.STROKE);
	int alt = to == null? 0: ((TrackGpxParser.TrackPoint)to).getAltitude();
	switch (alt % 3) {
		case 0: paint.setColor(AndroidGraphicFactory.INSTANCE.createColor(Color.GREEN)); break;
		case 1: paint.setColor(AndroidGraphicFactory.INSTANCE.createColor(Color.RED)); break;
		default: paint.setColor(AndroidGraphicFactory.INSTANCE.createColor(Color.BLUE)); break;
	}
	return paint;
}
 
开发者ID:emdete,项目名称:Simplicissimus,代码行数:13,代码来源:AlternatingLine.java


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