android.graphics.Point#offset ( )源码实例Demo

下面列出了android.graphics.Point#offset ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

@Override
public void putHierarchy(LayoutHierarchyDumper dumper, JSONObject root, Object obj, Point offset)
    throws JSONException {
  if (!accept(obj)) {
    return;
  }

  if (obj instanceof LithoView) {
    LithoView lithoView = (LithoView) obj;
    DebugComponent debugComponent = DebugComponent.getRootInstance(lithoView);
    if (debugComponent == null) {
      return;
    }
    final int offsetLeft = LayoutHierarchyDumper.getViewLeft(lithoView);
    final int offsetTop = LayoutHierarchyDumper.getViewTop(lithoView);
    offset.offset(offsetLeft, offsetTop);
    dumpHierarchy(dumper, root, debugComponent, offset);
    offset.offset(-offsetLeft, -offsetTop);
  } else {
    dumpHierarchy(dumper, root, (DebugComponent) obj, offset);
  }
}
 
@Override
public void putHierarchy(LayoutHierarchyDumper dumper, JSONObject root, Object view, Point offset)
    throws JSONException {
  if (!(view instanceof ViewGroup)) {
    return;
  }

  ViewGroup group = (ViewGroup) view;
  final int offsetLeft = LayoutHierarchyDumper.getViewLeft(group);
  final int offsetTop = LayoutHierarchyDumper.getViewTop(group);
  offset.offset(offsetLeft, offsetTop);

  JSONArray children = new JSONArray();
  for (int i = 0, size = group.getChildCount(); i < size; ++i) {
    View child = group.getChildAt(i);
    children.put(dumper.dumpHierarchy(child, offset));
  }

  root.put(KEY_CHILDREN, children);
  offset.offset(-offsetLeft, -offsetTop);
}
 
源代码3 项目: Mupdf   文件: DocView.java
public Point getSelectedNoteLocation()
{
	int numPages = getPageCount();
	for (int i = 0; i < numPages; i++)
	{
		DocPageView cv = (DocPageView) getOrCreateChild(i);
		if (cv.hasNoteAnnotationSelected())
		{
			Point p = cv.getSelectedNoteLocation();
			if (p != null)
			{
				//  offset to 0,0
				p.offset(cv.getLeft(), cv.getTop());

				//  offset to position in the scrolling view (this)
				p.offset(-getScrollX(), -getScrollY());

				return p;
			}
		}
	}

	return null;
}
 
源代码4 项目: Mupdf   文件: DocView.java
protected void positionHandle(DragHandle handle, DocPageView dpv, int pageX, int pageY)
{
	if (handle != null)
	{
		//  convert to DocPageView-based coords
		Point p = dpv.pageToView(pageX, pageY);

		//  offset to 0,0
		p.offset(dpv.getLeft(), dpv.getTop());

		//  offset to position in the scrolling view (this)
		p.offset(-getScrollX(), -getScrollY());

		//  offset based on handle size and padding
		p.offset(-selectionHandlePadPx - selectionHandleSizePx / 2, -selectionHandlePadPx - selectionHandleSizePx / 2);

		//  move it
		handle.moveTo(p.x, p.y);
	}
}
 
源代码5 项目: android_9.0.0_r45   文件: WindowContainer.java
void getRelativePosition(Point outPos) {
    final Rect bounds = getBounds();
    outPos.set(bounds.left, bounds.top);
    final WindowContainer parent = getParent();
    if (parent != null) {
        final Rect parentBounds = parent.getBounds();
        outPos.offset(-parentBounds.left, -parentBounds.top);
    }
}
 
源代码6 项目: TraceByAmap   文件: MarkerClickActivity.java
/**
 * marker点击时跳动一下
 */
public void jumpPoint(final Marker marker) {
	final Handler handler = new Handler();
       final long start = SystemClock.uptimeMillis();
       Projection proj = aMap.getProjection();
       final LatLng markerLatlng = marker.getPosition();
       Point markerPoint = proj.toScreenLocation(markerLatlng);
       markerPoint.offset(0, -100);
       final LatLng startLatLng = proj.fromScreenLocation(markerPoint);
       final long duration = 1500;

       final Interpolator interpolator = new BounceInterpolator();
       handler.post(new Runnable() {
           @Override
           public void run() {
               long elapsed = SystemClock.uptimeMillis() - start;
               float t = interpolator.getInterpolation((float) elapsed
                       / duration);
               double lng = t * markerLatlng.longitude + (1 - t)
                       * startLatLng.longitude;
               double lat = t * markerLatlng.latitude + (1 - t)
                       * startLatLng.latitude;
               marker.setPosition(new LatLng(lat, lng));
               if (t < 1.0) {
                   handler.postDelayed(this, 16);
               }
           }
       });
}
 
源代码7 项目: TraceByAmap   文件: CustomMarkerActivity.java
/**
 * marker点击时跳动一下
 */
public void jumpPoint(final Marker marker) {
	final Handler handler = new Handler();
	final long start = SystemClock.uptimeMillis();
	Projection proj = aMap.getProjection();
	Point startPoint = proj.toScreenLocation(Constants.XIAN);
	startPoint.offset(0, -100);
	final LatLng startLatLng = proj.fromScreenLocation(startPoint);
	final long duration = 1500;

	final Interpolator interpolator = new BounceInterpolator();
	handler.post(new Runnable() {
		@Override
		public void run() {
			long elapsed = SystemClock.uptimeMillis() - start;
			float t = interpolator.getInterpolation((float) elapsed
					/ duration);
			double lng = t * Constants.XIAN.longitude + (1 - t)
					* startLatLng.longitude;
			double lat = t * Constants.XIAN.latitude + (1 - t)
					* startLatLng.latitude;
			marker.setPosition(new LatLng(lat, lng));
			if (t < 1.0) {
				handler.postDelayed(this, 16);
			}
		}
	});
}
 
源代码8 项目: UltimateAndroid   文件: ZoomPanLayout.java
/**
 * Scrolls and centers the ZoomPanLayout to the x and y values specified by {@param point} Point
 * @param point (Point) Point instance containing the destination x and y values
 */
public void scrollToAndCenter( Point point ) { // TODO:
	int x = (int) -( getWidth() * 0.5 );
	int y = (int) -( getHeight() * 0.5 );
	point.offset( x, y );
	scrollToPoint( point );
}
 
源代码9 项目: UltimateAndroid   文件: ZoomPanLayout.java
/**
 * Scrolls and centers the ZoomPanLayout to the x and y values specified by {@param point} Point using scrolling animation
 * @param point (Point) Point instance containing the destination x and y values
 */
public void slideToAndCenter( Point point ) { // TODO:
	int x = (int) -( getWidth() * 0.5 );
	int y = (int) -( getHeight() * 0.5 );
	point.offset( x, y );
	slideToPoint( point );
}
 
源代码10 项目: UltimateAndroid   文件: ZoomPanLayout.java
private void performDrag() {
	Point delta = new Point();
	if ( secondFingerIsDown && !firstFingerIsDown ) {
		delta.set( lastSecondFinger.x, lastSecondFinger.y );
		delta.offset( -secondFinger.x, -secondFinger.y );
	} else {
		delta.set( lastFirstFinger.x, lastFirstFinger.y );
		delta.offset( -firstFinger.x, -firstFinger.y );
	}
	scrollPosition.offset( delta.x, delta.y );
	scrollToPoint( scrollPosition );
}
 
源代码11 项目: OpenMapKitAndroid   文件: Projection.java
/**
 * Converts from map pixels to a Point value. Optionally reuses an existing Point.
 */
public Point fromMapPixels(final int x, final int y, final Point reuse) {
    final Point out = GeometryMath.reusable(reuse);
    out.set(x - viewWidth2, y - viewHeight2);
    out.offset(centerX, centerY);
    return out;
}
 
源代码12 项目: OpenMapKitAndroid   文件: Marker.java
/**
 * Populates this tooltip with all item info:
 * <ul>title and description in any case, </ul>
 * <ul>image and sub-description if any.</ul>
 * and centers the map view on the item if panIntoView is true. <br>
 */
public void showBubble(InfoWindow tooltip, MapView aMapView, boolean panIntoView) {
    //offset the tooltip to be top-centered on the marker:
    Point markerH = getAnchor();
    Point tooltipH = getAnchor(HotspotPlace.TOP_CENTER);
    markerH.offset(-tooltipH.x, tooltipH.y);
    tooltip.open(this, this.getPoint(), markerH.x, markerH.y);
    if (panIntoView) {
        aMapView.getController().animateTo(getPoint());
    }

    bubbleShowing = true;
    tooltip.setBoundMarker(this);
}
 
源代码13 项目: Mupdf   文件: DocView.java
private Point viewToScreen(Point p)
{
	Point newPoint = new Point(p);

	Rect r = new Rect();
	this.getGlobalVisibleRect(r);

	newPoint.offset(r.left, r.top);

	return newPoint;
}
 
源代码14 项目: Mupdf   文件: DocViewBase.java
private Point viewToScreen(Point p)
{
	Point newPoint = new Point(p);

	Rect r = new Rect();
	this.getGlobalVisibleRect(r);

	newPoint.offset(r.left, r.top);

	return newPoint;
}
 
源代码15 项目: za-Farmer   文件: PointerGesture.java
@Override
public Point interpolate(float fraction) {
    Point ret = new Point(start);
    ret.offset((int)(fraction * (end.x - start.x)), (int)(fraction * (end.y - start.y)));
    return ret;
}
 
源代码16 项目: imsdk-android   文件: ShareLocationActivity.java
private synchronized void addOverLay(final String id, final LatLng point, float rotate) {
        if (overlayMap.get(id) != null) {
            overlayMap.get(id).remove();
        }
        if (headMap.get(id) != null) {
            headMap.get(id).remove();
        }

        //添加头像Overlay
        LatLng latLng = new LatLng(point.latitude,point.longitude);
        if (projection != null) {
            Point screenPoint = projection.toScreenLocation(point);
            screenPoint.offset(0, -30);
            latLng = projection.fromScreenLocation(screenPoint);
        }
        Bitmap bmp = getBitmapWithId(id);
        if (bmp != null) {
            OverlayOptions head = new MarkerOptions().draggable(false)
                    .position(latLng)
                    .icon(BitmapDescriptorFactory.fromBitmap(bmp));
            Overlay headOverlay = baiduMap.addOverlay(head);
            Bundle extra = new Bundle();
            extra.putDouble(EXTRA_LATITUDE, point.latitude);
            extra.putDouble(EXTRA_LONGITUDE, point.longitude);
            extra.putParcelable(EXTRA_BITMAP, bmp);
            headOverlay.setExtraInfo(extra);
            headMap.put(id, headOverlay);
        }
        //添加图标Overlay
        OverlayOptions options = new MarkerOptions().draggable(false)
                .position(point)
                .rotate(rotate)
                .icon(BitmapDescriptorFactory.fromResource(R.drawable.atom_ui_loc));
        Overlay overlay = baiduMap.addOverlay(options);
        overlayMap.put(id, overlay);
//
//        ProfileUtils.loadNickName(id, false, new ProfileUtils.LoadNickNameCallback() {
//            @Override
//            public void finish(String name) {
//                OverlayOptions head = new TextOptions()
//                        .position(point)
//                        .text(name)
//                        .fontSize(50);
//                Overlay headOverlay = baiduMap.addOverlay(head);
//                headMap.put(id, headOverlay);
//            }
//        });
    }
 
源代码17 项目: JsDroidCmd   文件: PointerGesture.java
@Override
public Point interpolate(float fraction) {
    Point ret = new Point(start);
    ret.offset((int)(fraction * (end.x - start.x)), (int)(fraction * (end.y - start.y)));
    return ret;
}
 
源代码18 项目: mil-sym-android   文件: ImageInfo.java
public ImageInfo getSquareImageInfo()
{
	ImageInfo ii = null;
       int iwidth, iheight, x, y;
       int width = this._imageBounds.width();
       int height = this._imageBounds.height();
       
       if(this._imageBounds.width() > this._imageBounds.height())
       {
           iwidth = this._imageBounds.width();
           iheight = this._imageBounds.width();
           x=0;
           y=(iheight - height)/2;
       }
       else if(this._imageBounds.width() < this._imageBounds.height())
       {
           iwidth = this._imageBounds.height();
           iheight = this._imageBounds.height();
           x = (iwidth - width)/2;
           y = 0;
       }
       else
       {
           iwidth = this._imageBounds.width();
           iheight = this._imageBounds.height();
           x=0;
           y=0;
       }

     //Draw glyphs to bitmap
	Bitmap bmp = Bitmap.createBitmap(iwidth, iheight, Config.ARGB_8888);
	Canvas ctx = new Canvas(bmp);

       
       ctx.drawBitmap(_image,x,y,null);
       
       //create new ImageInfo
       Point center = new Point(_centerPoint);
       center.offset(x,y);
       Rect symbolBounds = new Rect(_symbolBounds);
       symbolBounds.offset(x,y);

       ii = new ImageInfo(bmp,center, symbolBounds);
       
       
       return ii;
}
 
源代码19 项目: Mupdf   文件: DocView.java
@Override
public void onDrag(DragHandle handle)
{
	if (handle == mSelectionHandleTopLeft)
	{
		Point p1 = mSelectionHandleTopLeft.getPosition();
		p1.offset(selectionHandlePadPx + selectionHandleSizePx / 2, selectionHandlePadPx + selectionHandleSizePx / 2);
		p1 = viewToScreen(p1);
		DocPageView pageView1 = findPageViewContainingPoint(p1.x, p1.y, false);
		if (pageView1 != null)
		{
			selectionStartPage = pageView1;
			p1 = pageView1.screenToPage(p1);
			selectionStartLoc.set(p1.x, p1.y);
			onChangeSelection();
		}
	}

	if (handle == mSelectionHandleBottomRight)
	{
		Point p2 = mSelectionHandleBottomRight.getPosition();
		p2.offset(selectionHandlePadPx + selectionHandleSizePx / 2, selectionHandlePadPx + selectionHandleSizePx / 2);
		p2 = viewToScreen(p2);
		DocPageView pageView2 = findPageViewContainingPoint(p2.x, p2.y, false);
		if (pageView2 != null)
		{
			selectionEndPage = pageView2;
			p2 = pageView2.screenToPage(p2);
			selectionEndLoc.set(p2.x, p2.y);
			onChangeSelection();
		}
	}

	//  TODO: for now, we're dealing with one page at a time
	int numPages = getPageCount();
	for (int i = 0; i < numPages; i++)
	{
		DocPageView cv = (DocPageView) getOrCreateChild(i);
		if (cv.isReallyVisible() && cv == selectionStartPage && cv == selectionEndPage)
		{
			cv.setSelection(selectionStartLoc, selectionEndLoc);
		}
		else
		{
			cv.removeSelection();
		}
		cv.invalidate();
	}
}
 
 方法所在类
 同类方法