• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Projection类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



Projection类属于org.osmdroid.views包,在下文中一共展示了Projection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: onSnapToItem

import org.osmdroid.views.Projection; //导入依赖的package包/类
@Override
    public boolean onSnapToItem(final int x, final int y, final Point snapPoint,
                                final IMapView mapView) {
        if (this.mLocation != null) {
            Projection pj = mMapView.getProjection();
            pj.toPixelsFromProjected(mMapCoordsProjected, mMapCoordsTranslated);
            snapPoint.x = mMapCoordsTranslated.x;
            snapPoint.y = mMapCoordsTranslated.y;
            final double xDiff = x - mMapCoordsTranslated.x;
            final double yDiff = y - mMapCoordsTranslated.y;
            boolean snap = xDiff * xDiff + yDiff * yDiff < 64;
//            if (DEBUGMODE) {
//                logger.debug("snap=" + snap);
//            }
            return snap;
        } else {
            return false;
        }
    }
 
开发者ID:Arman92,项目名称:Mapsforge-OsmDroid-GraphHopper,代码行数:20,代码来源:MyLocationNewOverlay.java


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


示例4: draw

import org.osmdroid.views.Projection; //导入依赖的package包/类
@Override protected void draw(Canvas canvas, MapView mapView, boolean shadow) {

		if (shadow) {
			return;
		}

		final Projection pj = mapView.getProjection();
		mPath.rewind();
		
		mOutline.buildPathPortion(pj);
		
		for (LinearRing hole:mHoles){
			hole.buildPathPortion(pj);
		}
		
		canvas.drawPath(mPath, mFillPaint);
		canvas.drawPath(mPath, mOutlinePaint);
	}
 
开发者ID:jeffallen,项目名称:MarshrutMe,代码行数:19,代码来源:Polygon.java


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


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


示例7: zoom

import org.osmdroid.views.Projection; //导入依赖的package包/类
private void zoom(MapView mapView, boolean ddragMode) {
    if (isDebugEnabled())  debug("zoom",this);
    // mapView.setC .zoomToBoundingBox(rect);

    final Projection projection = mapView.getProjection();
    IMapController controller = mapView.getController();
    if (ddragMode) {
        IGeoPoint start = projection.fromPixels(this.mStart.x, this.mStart.y);
        IGeoPoint end = projection.fromPixels(this.mEnd.x, this.mEnd.y);
        ZoomUtil.zoomTo(mapView, ZoomUtil.NO_ZOOM, start, end);
        if (isDebugEnabled()) debug("zoom(ddrag mode)", start, "..", end,
                "=>", mapView.getMapCenter(), "z=", mapView.getZoomLevel());
    } else {
        IGeoPoint center = projection.fromPixels(this.mStart.x, this.mStart.y);
        controller.setCenter(center);
        controller.zoomIn();
        if (isDebugEnabled()) debug("zoom(to center of)", center,
                "=>", mapView.getMapCenter(), "z=", mapView.getZoomLevel());
    }
}
 
开发者ID:k3b,项目名称:LocationMapViewer,代码行数:21,代码来源:GuestureOverlay.java


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


示例9: onSingleTapConfirmed

import org.osmdroid.views.Projection; //导入依赖的package包/类
@Override
public boolean onSingleTapConfirmed(final MotionEvent event, final MapView mapView) {
    final Projection pj = mapView.getProjection();
    GeoPoint eventPos = (GeoPoint) pj.fromPixels((int) event.getX(), (int) event.getY());
    double tolerance = mPaint.getStrokeWidth() * density;
    boolean touched = isCloseTo(eventPos, tolerance, mapView);
    if (touched) {
        //eventPos = this.getInfoWindowAnchorPoint(eventPos);
        if (mOnClickListener == null) {
            return onClickDefault(this, mapView, eventPos);
        } else {
            return mOnClickListener.onClick(this, mapView, eventPos);
        }
    } else
        return touched;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:17,代码来源:Polyline.java


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


示例11: onSnapToItem

import org.osmdroid.views.Projection; //导入依赖的package包/类
@Override
public boolean onSnapToItem(final int x, final int y, final Point snapPoint,
		final IMapView mapView) {
	if (this.mLocation != null) {
		Projection pj = mMapView.getProjection();
		final double powerDifference = pj.getProjectedPowerDifference();
		pj.getPixelsFromProjected(mMapCoordsProjected, powerDifference, mMapCoordsTranslated);
		snapPoint.x = mMapCoordsTranslated.x;
		snapPoint.y = mMapCoordsTranslated.y;
		final double xDiff = x - mMapCoordsTranslated.x;
		final double yDiff = y - mMapCoordsTranslated.y;
		boolean snap = xDiff * xDiff + yDiff * yDiff < 64;
		if (Configuration.getInstance().isDebugMode()) {
                   Log.d(IMapView.LOGTAG, "snap=" + snap);
		}
		return snap;
	} else {
		return false;
	}
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:21,代码来源:MyLocationNewOverlay.java


示例12: draw

import org.osmdroid.views.Projection; //导入依赖的package包/类
@Override
   public void draw(Canvas canvas, MapView mapView, boolean shadow)
   {
	if(null == mImage || shadow) {
		return;
	}

       final Projection pj = mapView.getProjection();

       long x0 = pj.getLongPixelXFromLongitude(mLonL),
            y0 = pj.getLongPixelYFromLatitude(mLatU),
            x1 = pj.getLongPixelXFromLongitude(mLonR),
            y1 = pj.getLongPixelYFromLatitude(mLatD);

       float widthOnTheMap = x1 - x0,
             heightOnTheMap = y1 - y0;

	float scaleX = widthOnTheMap / mImage.getWidth(),
	      scaleY = heightOnTheMap / mImage.getHeight();

       setupScalingThenTranslatingMatrix(scaleX, scaleY, x0, y0);

       Paint paint = new Paint();
       paint.setAlpha(255-(int)(mTransparency * 255));
	canvas.drawBitmap(mImage, mStretchToFitTransformationMatrix, paint);
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:27,代码来源:GroundOverlay2.java


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


示例14: buildPathPortion

import org.osmdroid.views.Projection; //导入依赖的package包/类
/**
 * Feed the path with the segments corresponding to the GeoPoint pairs
 * projected using pProjection and clipped into a "reasonable" clip area
 * In most cases (Polygon without holes, Polyline) the offset parameter will be null.
 * In the case of a Polygon with holes, the first path will use a null offset.
 * Then this method will return the pixel offset computed for this path so that
 * the path is in the best possible place on the map:
 * the center of all pixels is as close to the screen center as possible
 * Then, this computed offset must be injected into the buildPathPortion for each hole,
 * in order to have the main polygon and its holes at the same place on the map.
 * @return the initial offset if not null, or the computed offset
 */
PointL buildPathPortion(final Projection pProjection,
						final PointL pOffset,
						final boolean pStorePoints){
	final int size = mOriginalPoints.size();
	if (size < 2) { // nothing to paint
		return pOffset;
	}
	if (!mPrecomputed){
		computeProjectedAndDistances(pProjection);
		mPrecomputed = true;
	}
	final PointL offset;
	if (pOffset != null) {
		offset = pOffset;
	} else {
		offset = new PointL();
		getBestOffset(pProjection, offset);
	}
	mSegmentClipper.init();
	clipAndStore(pProjection, offset, true, pStorePoints, mSegmentClipper);
	mSegmentClipper.end();
	mPath.close();
	return offset;
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:37,代码来源:LinearRing.java


示例15: buildLinePortion

import org.osmdroid.views.Projection; //导入依赖的package包/类
/**
 * Dedicated to Polyline, as they can run much faster with drawLine than through a Path
 * @since 6.0.0
 */
void buildLinePortion(final Projection pProjection,
					  final boolean pStorePoints){
	final int size = mOriginalPoints.size();
	if (size < 2) { // nothing to paint
		return;
	}
	if (!mPrecomputed){
		computeProjectedAndDistances(pProjection);
		mPrecomputed = true;
	}
	final PointL offset = new PointL();
	getBestOffset(pProjection, offset);
	mSegmentClipper.init();
	clipAndStore(pProjection, offset, false, pStorePoints, mSegmentClipper);
	mSegmentClipper.end();
}
 
开发者ID:osmdroid,项目名称:osmdroid,代码行数:21,代码来源:LinearRing.java


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


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


示例18: hitTest

import org.osmdroid.views.Projection; //导入依赖的package包/类
public boolean hitTest(final MotionEvent event, final MapView mapView){
        final Projection pj = mapView.getProjection();
        pj.toPixelsFromProjected(mMapCoordsProjected, 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;
//        return true;
    }
 
开发者ID:Arman92,项目名称:Mapsforge-OsmDroid-GraphHopper,代码行数:12,代码来源:MyLocationNewOverlay.java


示例19: getMyLocationDrawingBounds

import org.osmdroid.views.Projection; //导入依赖的package包/类
protected Rect getMyLocationDrawingBounds(int zoomLevel, Location lastFix, Rect reuse) {
    if (reuse == null)
        reuse = new Rect();

    final Projection pj = mMapView.getProjection();
    pj.toPixelsFromProjected(mMapCoordsProjected, mMapCoordsTranslated);

    // Start with the bitmap bounds
    if (lastFix.hasBearing()) {
        // Get a square bounding box around the object, and expand by the length of the diagonal
        // so as to allow for extra space for rotating
        int widestEdge = (int) Math.ceil(Math.max(mDirectionArrowBitmap.getWidth(),
                mDirectionArrowBitmap.getHeight()) * Math.sqrt(2));
        reuse.set(mMapCoordsTranslated.x, mMapCoordsTranslated.y, mMapCoordsTranslated.x
                + widestEdge, mMapCoordsTranslated.y + widestEdge);
        reuse.offset(-widestEdge / 2, -widestEdge / 2);
    } else {
        reuse.set(mMapCoordsTranslated.x, mMapCoordsTranslated.y, mMapCoordsTranslated.x
                + mIconBitmap.getWidth(), mMapCoordsTranslated.y + mIconBitmap.getHeight());
        reuse.offset((int) (-mPersonHotspot.x + 0.5f), (int) (-mPersonHotspot.y + 0.5f));
    }

    // Add in the accuracy circle if enabled
    if (mDrawAccuracyEnabled) {
        final int radius = (int) java.lang.Math.ceil(lastFix.getAccuracy()
                / (float) TileSystem.GroundResolution(lastFix.getLatitude(), zoomLevel));
        reuse.union(mMapCoordsTranslated.x - radius, mMapCoordsTranslated.y - radius,
                mMapCoordsTranslated.x + radius, mMapCoordsTranslated.y + radius);
        final int strokeWidth = (int) java.lang.Math.ceil(mCirclePaint.getStrokeWidth() == 0 ? 1
                : mCirclePaint.getStrokeWidth());
        reuse.inset(-strokeWidth, -strokeWidth);
    }

    return reuse;
}
 
开发者ID:Arman92,项目名称:Mapsforge-OsmDroid-GraphHopper,代码行数:36,代码来源:MyLocationNewOverlay.java


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



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SupportSQLiteStatement类代码示例发布时间:2022-05-23
下一篇:
Java DContainerPattern类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap