static float getPivotX(View view) { return view.getPivotX(); }
@TargetApi(HONEYCOMB) public S hasPivotX(float pivotX) { isNotNull(); float actualPivotX = actual.getPivotX(); assertThat(actualPivotX) // .overridingErrorMessage("Expected x pivot <%s> but was <%s>", pivotX, actualPivotX) // .isEqualTo(pivotX); return myself; }
@Test public void pivotX() { view.setPivotX(10f); assertThat(view.getPivotX()).isEqualTo(10f); }
static float getPivotX(View view) { return view.getPivotX(); }
@Override public final void setPivot(@NonNull final Axis axis, @NonNull final AbstractItem item, final float pivot) { Condition.INSTANCE.ensureNotNull(axis, "The axis may not be null"); Condition.INSTANCE.ensureNotNull(item, "The item may not be null"); View view = item.getView(); FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) view.getLayoutParams(); if (getOrientationInvariantAxis(axis) == Axis.DRAGGING_AXIS) { float newPivot = pivot - layoutParams.topMargin - tabTitleContainerHeight; view.setTranslationY(view.getTranslationY() + (view.getPivotY() - newPivot) * (1 - view.getScaleY())); view.setPivotY(newPivot); } else { float newPivot = pivot - layoutParams.leftMargin; view.setTranslationX(view.getTranslationX() + (view.getPivotX() - newPivot) * (1 - view.getScaleX())); view.setPivotX(newPivot); } }
private static void computeRenderOffset(View view, float pivotX, float pivotY) { if (view.getPivotX() == pivotX && view.getPivotY() == pivotY) { return; } float[] prevPoint = {0.0f, 0.0f}; view.getMatrix().mapPoints(prevPoint); view.setPivotX(pivotX); view.setPivotY(pivotY); float[] currPoint = {0.0f, 0.0f}; view.getMatrix().mapPoints(currPoint); float offsetX = currPoint[0] - prevPoint[0]; float offsetY = currPoint[1] - prevPoint[1]; view.setTranslationX(view.getTranslationX() - offsetX); view.setTranslationY(view.getTranslationY() - offsetY); }
static float getPivotX(View view) { return view.getPivotX(); }
static float getPivotX(View view) { return view.getPivotX(); }
@Override public float getPivotX(View view) { return view.getPivotX(); }
public static float getPivotX(View view) { return view.getPivotX(); }
@TargetApi(HONEYCOMB) public S hasPivotX(float pivotX) { isNotNull(); float actualPivotX = actual.getPivotX(); assertThat(actualPivotX) // .overridingErrorMessage("Expected x pivot <%s> but was <%s>", pivotX, actualPivotX) // .isEqualTo(pivotX); return myself; }
private void ensureCenterPoint(ViewGroup sceneRoot, View view) { if (center != null) { return; } if (centerOn != null || centerOnId != View.NO_ID) { View source; if (centerOn != null) { source = centerOn; } else { source = sceneRoot.findViewById(centerOnId); } if (source != null) { // use window location to allow views in diff hierarchies int[] loc = new int[2]; source.getLocationInWindow(loc); int srcX = loc[0] + (source.getWidth() / 2); int srcY = loc[1] + (source.getHeight() / 2); view.getLocationInWindow(loc); center = new Point(srcX - loc[0], srcY - loc[1]); } } // else use the pivot point if (center == null) { center = new Point(Math.round(view.getPivotX()), Math.round(view.getPivotY())); } }
@Override public RectF getFrame() { if (mFrame == null) { mFrame = new RectF(0, 0, mView.getWidth(), mView.getHeight()); float pivotX = mView.getX() + mView.getPivotX(); float pivotY = mView.getY() + mView.getPivotY(); Matrix matrix = new Matrix(); matrix.setTranslate(mView.getX(), mView.getY()); matrix.postScale(mView.getScaleX(), mView.getScaleY(), pivotX, pivotY); matrix.mapRect(mFrame); } return mFrame; }
public static Rect getViewRect(View view) { Rect outRect = new Rect(); if(Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB_MR2){ outRect.right = (int)(view.getWidth() * getScalelX(view)); outRect.bottom = (int)(view.getHeight() * getScalelY(view)); int[] location = new int[2]; view.getLocationOnScreen(location); outRect.offset(location[0], location[1]); } else { outRect.right = view.getWidth(); outRect.bottom = view.getHeight(); int[] location = new int[2]; view.getLocationOnScreen(location); outRect.offset(location[0], location[1]); View parent = view; while(parent != null){ parent.getLocationOnScreen(location); scaleRect(outRect, parent.getScaleX(), parent.getScaleY(), parent.getPivotX() + location[0], parent.getPivotY() + location[1]); parent = getParent(parent); } } return outRect; }
private Rotatable(Builder builder) { this.rootView = builder.root; this.defaultPivotX = rootView.getPivotX(); this.defaultPivotY = rootView.getPivotY(); this.rotationListener = builder.listener; if (builder.pivotX != NULL_INT) { this.rootView.setPivotX(builder.pivotX); } if (builder.pivotY != NULL_INT) { this.rootView.setPivotY(builder.pivotY); } if (builder.frontId != NULL_INT) { this.frontView = rootView.findViewById(builder.frontId); } if (builder.backId != NULL_INT) { this.backView = rootView.findViewById(builder.backId); } this.rotation = builder.rotation; this.rotationCount = builder.rotationCount; this.rotationDistance = builder.rotationDistance; this.shouldSwapViews = frontView != null && backView != null; rootView.setOnTouchListener(this); }
private static void computeRenderOffset(View view, float pivotX, float pivotY) { if (view.getPivotX() == pivotX && view.getPivotY() == pivotY) { return; } float[] prevPoint = {0.0f, 0.0f}; view.getMatrix().mapPoints(prevPoint); view.setPivotX(pivotX); view.setPivotY(pivotY); float[] currPoint = {0.0f, 0.0f}; view.getMatrix().mapPoints(currPoint); float offsetX = currPoint[0] - prevPoint[0]; float offsetY = currPoint[1] - prevPoint[1]; view.setTranslationX(view.getTranslationX() - offsetX); view.setTranslationY(view.getTranslationY() - offsetY); }
private static void computeRenderOffset(View view, float pivotX, float pivotY) { if (view.getPivotX() == pivotX && view.getPivotY() == pivotY) { return; } float[] prevPoint = {0.0f, 0.0f}; view.getMatrix().mapPoints(prevPoint); view.setPivotX(pivotX); view.setPivotY(pivotY); float[] currPoint = {0.0f, 0.0f}; view.getMatrix().mapPoints(currPoint); float offsetX = currPoint[0] - prevPoint[0]; float offsetY = currPoint[1] - prevPoint[1]; view.setTranslationX(view.getTranslationX() - offsetX); view.setTranslationY(view.getTranslationY() - offsetY); }
data.put("RotationX", v.getRotationX()); data.put("RotationY", v.getRotationY()); data.put("PivotX", v.getPivotX()); data.put("PivotY", v.getPivotY()); data.put("TranslationX", v.getTranslationX());