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


Java Projection.toPixels方法代码示例

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


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

示例1: draw

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    if(!shadow) {
        if(this.mIcon != null) {
            Projection pj = mapView.getProjection();
            pj.toPixels(this.mPosition, this.mPositionPixels);
            int width = this.mIcon.getIntrinsicWidth();
            int height = this.mIcon.getIntrinsicHeight();
            Rect rect = new Rect(0, 0, width, height);
            rect.offset(-((int)(this.mAnchorU * (float)width)), -((int)(this.mAnchorV * (float)height)));
            this.mIcon.setBounds(rect);
            this.mIcon.setAlpha((int)(this.mAlpha * 255.0F));
            float rotationOnScreen = this.mFlat?-this.mBearing:mapView.getMapOrientation() - this.mBearing;
            drawAt(canvas, this.mIcon, this.mPositionPixels.x, this.mPositionPixels.y, false, rotationOnScreen);
        }
    }
}
 
开发者ID:Arman92,项目名称:Mapsforge-OsmDroid-GraphHopper,代码行数:17,代码来源:MyMarker.java

示例2: draw

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
@Override public void draw(Canvas canvas, MapView mapView, boolean shadow) {
	if (shadow)
		return;
	if (mIcon == null)
		return;
	
	final Projection pj = mapView.getProjection();
	
	pj.toPixels(mPosition, mPositionPixels);
	int width = mIcon.getIntrinsicWidth();
	int height = mIcon.getIntrinsicHeight();
	Rect rect = new Rect(0, 0, width, height);
	rect.offset(-(int)(mAnchorU*width), -(int)(mAnchorV*height));
	mIcon.setBounds(rect);
	
	mIcon.setAlpha((int)(mAlpha*255));
	
	float rotationOnScreen = (mFlat ? -mBearing : mapView.getMapOrientation()-mBearing);
	drawAt(canvas, mIcon, mPositionPixels.x, mPositionPixels.y, false, rotationOnScreen);
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:21,代码来源:Marker.java

示例3: isCloseTo

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
/** Detection is done is screen coordinates. 
 * @param point
 * @param tolerance in pixels
 * @return true if the Polyline is close enough to the point. 
 */
public boolean isCloseTo(GeoPoint point, double tolerance, MapView mapView) {
	final Projection pj = mapView.getProjection();
	precomputePoints(pj);
	Point p = pj.toPixels(point, null);
	int i = 0;
	boolean found = false;
	while (i < mPointsPrecomputed - 1 && !found) {
		Point projectedPoint1 = mPoints.get(i);
		if (i == 0){
			pj.toPixelsFromProjected(projectedPoint1, mTempPoint1);
		} else {
			//reuse last b:
			mTempPoint1.set(mTempPoint2.x, mTempPoint2.y);
		}
		Point projectedPoint2 = mPoints.get(i+1);
		pj.toPixelsFromProjected(projectedPoint2, mTempPoint2);
		found = (linePointDist(mTempPoint1, mTempPoint2, p, true) <= tolerance);
		//TODO: if found, compute and return the point ON the line. 
		i++;
	}
	return found;
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:28,代码来源:Polyline.java

示例4: draw

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
@Override protected void draw(Canvas canvas, MapView mapView, boolean shadow) {
	if (shadow)
		return;
	if (mImage == null)
		return;
	
	if (mHeight == NO_DIMENSION){
		mHeight = mWidth * mImage.getIntrinsicHeight() / mImage.getIntrinsicWidth();
	}
	
	final Projection pj = mapView.getProjection();
	
	pj.toPixels(mPosition, mPositionPixels);
	GeoPoint pEast = mPosition.destinationPoint(mWidth, 90.0f);
	GeoPoint pSouthEast = pEast.destinationPoint(mHeight, -180.0f);
	pj.toPixels(pSouthEast, mSouthEastPixels);
	int width = mSouthEastPixels.x-mPositionPixels.x;
	int height = mSouthEastPixels.y-mPositionPixels.y;
	mImage.setBounds(-width/2, -height/2, width/2, height/2);
	
	mImage.setAlpha(255-(int)(mTransparency*255));

	drawAt(canvas, mImage, mPositionPixels.x, mPositionPixels.y, false, -mBearing);
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:25,代码来源:GroundOverlay.java

示例5: draw

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
@Override public void draw(Canvas canvas, MapView mapView, boolean shadow) {
	if (shadow)
		return;
	if (mIcon == null)
		return;
	
	final Projection pj = mapView.getProjection();
	
	pj.toPixels(mPosition, mPositionPixels);
	int width = mIcon.getIntrinsicWidth();
	int height = mIcon.getIntrinsicHeight();
	Rect rect = new Rect(0, 0, width, height);
	rect.offset(-(int)(mAnchorU*width), -(int)(mAnchorV*height));
	mIcon.setBounds(rect);

	mIcon.setAlpha((int)(mAlpha*255));
	
	float rotationOnScreen = (mFlat ? -mBearing : mapView.getMapOrientation()-mBearing);
	drawAt(canvas, mIcon, mPositionPixels.x, mPositionPixels.y, false, rotationOnScreen);
	if (isInfoWindowShown()) {
		showInfoWindow();
	}
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:24,代码来源:Marker.java

示例6: activateSelectedItems

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
/**
 * When a content sensitive action is performed the content item needs to be identified. This
 * method does that and then performs the assigned task on that item.
 *
 * @param event
 * @param mapView
 * @param task
 * @return true if event is handled false otherwise
 */
private boolean activateSelectedItems(final MotionEvent event, final MapView mapView,
		final ActiveItem task) {
	final Projection pj = mapView.getProjection();
	final int eventX = (int) event.getX();
	final int eventY = (int) event.getY();

	for (int i = 0; i < this.mItemList.size(); ++i) {
		final Item item = getItem(i);
		if (item == null) {
			continue;
		}

		final Drawable marker = (item.getMarker(0) == null) ?
				this.mDefaultMarker : item.getMarker(0);

		pj.toPixels(item.getPoint(), mItemPoint);

		if (hitTest(item, marker, eventX - mItemPoint.x, eventY - mItemPoint.y)) {
			if (task.run(i)) {
				return true;
			}
		}
	}
	return false;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:35,代码来源:ItemizedIconOverlay.java

示例7: draw

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
/**
 * Draw the icon.
 */
@Override
public void draw(Canvas canvas, MapView mapView, boolean shadow) {
    if (shadow)
        return;
    if (mIcon == null)
        return;
    if (mPosition == null)
        return;

    final Projection pj = mapView.getProjection();

    pj.toPixels(mPosition, mPositionPixels);
    int width = mIcon.getIntrinsicWidth();
    int height = mIcon.getIntrinsicHeight();
    Rect rect = new Rect(0, 0, width, height);
    rect.offset(-(int)(mAnchorU*width), -(int)(mAnchorV*height));
    mIcon.setBounds(rect);

    mIcon.setAlpha((int) (mAlpha * 255));

    float rotationOnScreen = (mFlat ? -mBearing : mapView.getMapOrientation()-mBearing);
    drawAt(canvas, mIcon, mPositionPixels.x, mPositionPixels.y, false, rotationOnScreen);
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:27,代码来源:IconOverlay.java

示例8: testOffspringSameCenter

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
/**
 * "The geo center of an offspring matches the geo center of the parent"
 */
@Test
public void testOffspringSameCenter() {
    final GeoPoint center = new GeoPoint(0., 0);
    final Point pixel = new Point();
    final int centerX = (mScreenRect.right + mScreenRect.left) / 2;
    final int centerY = (mScreenRect.bottom + mScreenRect.top) / 2;
    final int miniCenterX = (mMiniMapScreenRect.right + mMiniMapScreenRect.left) / 2;
    final int miniCenterY = (mMiniMapScreenRect.bottom + mMiniMapScreenRect.top) / 2;
    for (int zoomLevel = mMinZoomLevel + mMinimapZoomLevelDifference; zoomLevel <= mMaxZoomLevel; zoomLevel ++) {
        for (int i = 0; i < mNbIterations; i ++) {
            final Projection projection = getRandomProjection(zoomLevel);
            final Projection miniMapProjection = projection.getOffspring(zoomLevel - mMinimapZoomLevelDifference, mMiniMapScreenRect);

            projection.fromPixels(centerX, centerY, center);
            miniMapProjection.toPixels(center, pixel);
            Assert.assertEquals(miniCenterX, pixel.x, mDeltaPixel);
            Assert.assertEquals(miniCenterY, pixel.y, mDeltaPixel);
        }
    }
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:24,代码来源:ProjectionTest.java

示例9: hitTest

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
public boolean hitTest(MotionEvent event, MapView mapView) {
    Projection pj = mapView.getProjection();
    pj.toPixels(this.mPosition, this.mPositionPixels);
    Rect screenRect = pj.getIntrinsicScreenRect();
    int x = -this.mPositionPixels.x + screenRect.left + (int)event.getX();
    int y = -this.mPositionPixels.y + screenRect.top + (int)event.getY();
    boolean hit = this.mIcon.getBounds().contains(x, y);
    return hit;
}
 
开发者ID:Arman92,项目名称:Mapsforge-OsmDroid-GraphHopper,代码行数:10,代码来源:MyMarker.java

示例10: hitTest

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
public boolean hitTest(final MotionEvent event, final MapView mapView){
	final Projection pj = mapView.getProjection();
	pj.toPixels(mPosition, mPositionPixels);
	final Rect screenRect = pj.getIntrinsicScreenRect();
	int x = -mPositionPixels.x + screenRect.left + (int) event.getX();
	int y = -mPositionPixels.y + screenRect.top + (int) event.getY();
	boolean hit = mIcon.getBounds().contains(x, y);
	return hit;
}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:10,代码来源:Marker.java

示例11: draw

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
@Override public void draw(Canvas canvas, MapView mapView, boolean shadow) {
	if (shadow)
		return;
	if (mImage == null)
		return;
	
	if (mHeight == NO_DIMENSION){
		mHeight = mWidth * mImage.getIntrinsicHeight() / mImage.getIntrinsicWidth();
	}
	
	final Projection pj = mapView.getProjection();
	
	pj.toPixels(mPosition, mPositionPixels);
	/*
	GeoPoint pEast = mPosition.destinationPoint(mWidth, 90.0f);
	GeoPoint pSouthEast = pEast.destinationPoint(mHeight, -180.0f);
	pj.toPixels(pSouthEast, mSouthEastPixels);
	int width = mSouthEastPixels.x-mPositionPixels.x;
	int height = mSouthEastPixels.y-mPositionPixels.y;
	mImage.setBounds(-width/2, -height/2, width/2, height/2);
	*/
	GeoPoint pEast = mPosition.destinationPoint(mWidth/2, 90.0f);
	GeoPoint pSouthEast = pEast.destinationPoint(mHeight/2, -180.0f);
	pj.toPixels(pSouthEast, mSouthEastPixels);
	int hWidth = mSouthEastPixels.x-mPositionPixels.x;
	int hHeight = mSouthEastPixels.y-mPositionPixels.y;
	mImage.setBounds(-hWidth, -hHeight, hWidth, hHeight);

	mImage.setAlpha(255-(int)(mTransparency*255));

	drawAt(canvas, mImage, mPositionPixels.x, mPositionPixels.y, false, -mBearing);
}
 
开发者ID:MKergall,项目名称:osmbonuspack,代码行数:33,代码来源:GroundOverlay.java

示例12: isHit

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
public boolean isHit(MotionEvent event, MapView mapView) {
    Projection pj = mapView.getProjection();

    Point PositionPixels = new Point();
    pj.toPixels(this.Position, PositionPixels);
    Rect screenRect = pj.getIntrinsicScreenRect();
    int x = -PositionPixels.x + screenRect.left + (int) event.getX();
    int y = -PositionPixels.y + screenRect.top + (int) event.getY();
    boolean hit = this.Icon.getBounds().contains(x, y);
    return hit;
}
 
开发者ID:gabm,项目名称:FancyPlaces,代码行数:12,代码来源:OsmMarker.java

示例13: draw

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
@Override
protected void draw(Canvas canvas, MapView mapView, boolean shadow) {
    if (this.Icon != null) {
        Projection pj = mapView.getProjection();
        Point PositionPixels = new Point();
        pj.toPixels(this.Position, PositionPixels);
        int width = this.Icon.getIntrinsicWidth();
        int height = this.Icon.getIntrinsicHeight();
        Rect rect = new Rect(0, 0, width, height);
        rect.offset(-((int) (this.AnchorU * (float) width)), -((int) (this.AnchorV * (float) height)));
        this.Icon.setBounds(rect);
        this.Icon.setAlpha((int) (this.Alpha * 255.0F));
        drawAt(canvas, this.Icon, PositionPixels.x, PositionPixels.y, false, 0);
    }
}
 
开发者ID:gabm,项目名称:FancyPlaces,代码行数:16,代码来源:OsmMarker.java

示例14: hitTest

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
public boolean hitTest(final MotionEvent event, final MapView mapView){
	final Projection pj = mapView.getProjection();
	pj.toPixels(mPosition, mPositionPixels);
	final Rect screenRect = mapView.getIntrinsicScreenRect(null);
	int x = -mPositionPixels.x + screenRect.left + (int) event.getX();
	int y = -mPositionPixels.y + screenRect.top + (int) event.getY();
	boolean hit = mIcon.getBounds().contains(x, y);
	return hit;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:10,代码来源:Marker.java

示例15: hitTest

import org.osmdroid.views.Projection; //导入方法依赖的package包/类
/**
 * From {@link Marker#hitTest(MotionEvent, MapView)}
 * @return true, if this marker was taped.
 */
protected boolean hitTest(final MotionEvent event, final MapView mapView){
    final Projection pj = mapView.getProjection();

    // sometime at higher zoomlevels pj is null
    if ((mPosition == null) || (mPositionPixels == null) || (pj == null)) return false;

    pj.toPixels(mPosition, mPositionPixels);
    final Rect screenRect = pj.getIntrinsicScreenRect();
    int x = -mPositionPixels.x + screenRect.left + (int) event.getX();
    int y = -mPositionPixels.y + screenRect.top + (int) event.getY();
    boolean hit = mIcon.getBounds().contains(x, y);
    return hit;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:18,代码来源:ClickableIconOverlay.java


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