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


Java Paint.setColor方法代码示例

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


在下文中一共展示了Paint.setColor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 (!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

示例3: 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

示例4: 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

示例5: 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

示例6: 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

示例7: 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

示例8: 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

示例9: 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

示例10: createPaint

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

示例11: 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:monossido,项目名称:CoopTDMOrienteering,代码行数:8,代码来源:MyLocationOverlay.java

示例12: draw

import org.mapsforge.core.graphics.Paint; //导入方法依赖的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.Paint.setColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。