Java Code Examples for android.graphics.PointF#set()

The following examples show how to use android.graphics.PointF#set() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SpiderWebChart.java    From bither-android with Apache License 2.0 6 votes vote down vote up
protected List<PointF> getDataPoints(List<TitleValueEntity> data) {
	List<PointF> points = new ArrayList<PointF>();
	for (int i = 0; i < longitudeNum; i++) {
		PointF pt = new PointF();
		float offsetX = (float) (position.x - data.get(i).getValue() / 10f
				* longitudeLength
				* Math.sin(i * 2 * Math.PI / longitudeNum));
		float offsetY = (float) (position.y - data.get(i).getValue() / 10f
				* longitudeLength
				* Math.cos(i * 2 * Math.PI / longitudeNum));
		pt.set(offsetX, offsetY);

		points.add(pt);
	}
	return points;
}
 
Example 2
Source File: ChipDrawable.java    From material-components-android with Apache License 2.0 6 votes vote down vote up
/** Calculates the chip text's origin and alignment based on the ChipDrawable-absolute bounds. */
@NonNull
Align calculateTextOriginAndAlignment(@NonNull Rect bounds, @NonNull PointF pointF) {
  pointF.set(0, 0);
  Align align = Align.LEFT;

  if (text != null) {
    float offsetFromStart = chipStartPadding + calculateChipIconWidth() + textStartPadding;

    if (DrawableCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) {
      pointF.x = bounds.left + offsetFromStart;
      align = Align.LEFT;
    } else {
      pointF.x = bounds.right - offsetFromStart;
      align = Align.RIGHT;
    }

    pointF.y = bounds.centerY() - calculateTextCenterFromBaseline();
  }

  return align;
}
 
Example 3
Source File: OC_AddSubCountersPt1.java    From GLEXP-Team-onebillion with Apache License 2.0 6 votes vote down vote up
public void slideOnBottomLabels() throws Exception
{
    playSfxAudio("slide",false);
    List anims = new ArrayList<>();
    lockScreen();
    for(OBLabel lab : bottomLabels)
    {
        PointF pos = new PointF();
        pos.set(lab.position());
        lab.setPosition(new PointF(pos.x + bounds() .width(), pos.y));
        anims.add(OBAnim.moveAnim(pos,lab));
        lab.show();
    }
    unlockScreen();
    OBAnimationGroup.runAnims(anims,0.4,true,OBAnim.ANIM_EASE_IN_EASE_OUT,null);
}
 
Example 4
Source File: OC_ScoreHammer.java    From GLEXP-Team-onebillion with Apache License 2.0 6 votes vote down vote up
public void animateHammerStrike() throws Exception
{
    OBControl hammer = objectDict.get("hammer");
    OBControl hammer2 = objectDict.get("hammer2");
    float angle1 = hammer.rotation();
    float angle2 = hammer2.rotation();
    PointF pos1 = new PointF();
    pos1.set(hammer.position());
    PointF pos2 = new PointF();
    pos2.set(hammer2.position());
    moveObjects(Arrays.asList(hammer),pos2,-1,OBAnim.ANIM_EASE_IN_EASE_OUT);
    OBAnim rotAnim = OBAnim.rotationAnim(angle2,hammer);
    OBAnimationGroup.runAnims(Arrays.asList(rotAnim),0.1,true,OBAnim.ANIM_EASE_IN,null);
    playSfxAudio("hit",false);
    waitForSecs(0.02f);
    rotAnim = OBAnim.rotationAnim(angle1,hammer);
    OBAnimationGroup.runAnims(Arrays.asList(rotAnim),0.1,true,OBAnim.ANIM_EASE_OUT,null);
    moveObjects(Arrays.asList(hammer),pos1,-1,OBAnim.ANIM_EASE_IN_EASE_OUT);
}
 
Example 5
Source File: OC_CapitalTrace.java    From GLEXP-Team-onebillion with Apache License 2.0 6 votes vote down vote up
public void doStrokeDemo() throws Exception
{
    float rt = hotPath.right() + paths.get(0).lineWidth();
    PointF destpt = OB_Maths.locationForRect(0, 0.6f, bounds());
    destpt.set(rt, destpt.y);
    PointF startpt = pointForDestPoint(destpt,35);
    loadPointerStartPoint(startpt,destpt);
    movePointerToPoint(destpt,-1,true);
    waitForSecs(0.3f);

    playAudioQueuedScene("DEMO",true);
    waitForSecs(0.3f);
    thePointer.hide();
    waitForSecs(0.3f);
    demoStroke();
    waitForSecs(0.3f);
    nextScene();
}
 
Example 6
Source File: OC_CapitalTrace.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public void demog() throws Exception
{
    showLetter();
    waitAudio();
    waitForSecs(0.5f);
    PointF destpt = paths.get(0).sAlongPath(0,null);
    destpt = convertPointFromControl(destpt,paths.get(0));
    PointF startpt = pointForDestPoint(destpt,25);
    loadPointerStartPoint(startpt,destpt);

    float rt = hotPath.right() + paths.get(0).lineWidth();
    PointF dpt = OB_Maths.locationForRect(0, 0.6f, bounds());
    dpt.set(rt, dpt.y);

    movePointerToPoint(dpt,-1,true);
    waitForSecs(0.3f);
    playAudioQueuedSceneIndex(currentEvent(),"DEMO",0,true);
    waitForSecs(0.3f);
    preTrace(0);
    waitForSecs(0.3f);
    movePointerToPoint(OB_Maths.tPointAlongLine(0.8f, startpt, destpt),-1,true);
    waitForSecs(0.3f);
    playAudioQueuedSceneIndex(currentEvent(),"DEMO",1,true);
    waitForSecs(0.3f);
    thePointer.hide();
    nextScene();
}
 
Example 7
Source File: OC_ListeningComprehension.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public void demoa() throws Exception
{
    presenter.walk((PointF)presenter.control.settings.get("restpos"));
    presenter.faceFront();
    waitForSecs(0.2f);
    List aud = currentAudio("DEMO");
    presenter.speak(Arrays.asList(aud.get(0)),this);
    presenter.moveHandToEarController(this);
    waitForSecs(1.3f);
    presenter.moveHandFromEarController(this);
    presenter.speak(Arrays.asList(aud.get(1)),this);
    waitForSecs(0.5f);

    OBControl head = presenter.control.objectDict.get("head");
    PointF right = convertPointFromControl(new PointF(head.width(), 0),head);
    PointF currPos = new PointF();
    currPos.set(presenter.control.position());
    float margin = right.x - currPos.x + applyGraphicScale(20);
    PointF edgepos = new PointF(bounds() .width() - margin, currPos.y);
    presenter.walk(edgepos);
    presenter.faceFront();
    waitForSecs(0.2f);
    presenter.speak(Arrays.asList(aud.get(2)),this);
    waitForSecs(0.5f);
    OBControl faceright = presenter.control.objectDict.get("faceright");
    PointF lp = presenter.control.convertPointFromControl(new PointF(0, 0),faceright);
    PointF destpos = new PointF(bounds() .width() + lp.x + 1, currPos.y);
    presenter.walk(destpos);
    detachControl(presenter.control);
    presenter = null;

    PointF destpoint = OB_Maths.locationForRect(new PointF(0.8f,0.85f) ,bounds());
    PointF startpt = pointForDestPoint(destpoint,2);
    loadPointerStartPoint(startpt,destpoint);
    movePointerToPoint(destpoint,-1,true);

    nextScene();

}
 
Example 8
Source File: InDoorView.java    From InDoorSurfaceView with Apache License 2.0 5 votes vote down vote up
/**
 * 手势(拖动)事件
 */
private void drawMap(MotionEvent event) {
    synchronized (InDoorView.class) {
        PointF currentPoint = new PointF();
        currentPoint.set(event.getX(), event.getY());
        int offsetX = (int) (currentPoint.x - mStartPoint.x);
        int offsetY = (int) (currentPoint.y - mStartPoint.y);
        mStartPoint = currentPoint;
        bx += offsetX;
        by += offsetY;
    }
}
 
Example 9
Source File: SubsamplingScaleImageView.java    From subsampling-scale-image-view with Apache License 2.0 5 votes vote down vote up
/**
 * Convert screen coordinate to source coordinate.
 * @param vx view X coordinate.
 * @param vy view Y coordinate.
 * @param sTarget target object for result. The same instance is also returned.
 * @return source coordinates. This is the same instance passed to the sTarget param.
 */
@Nullable
public final PointF viewToSourceCoord(float vx, float vy, @NonNull PointF sTarget) {
    if (vTranslate == null) {
        return null;
    }
    sTarget.set(viewToSourceX(vx), viewToSourceY(vy));
    return sTarget;
}
 
Example 10
Source File: SubsamplingScaleImageView.java    From EasyPhotos with Apache License 2.0 5 votes vote down vote up
/**
 * Convert source coordinate to view coordinate.
 *
 * @param sx      source X coordinate.
 * @param sy      source Y coordinate.
 * @param vTarget target object for result. The same instance is also returned.
 * @return view coordinates. This is the same instance passed to the vTarget param.
 */
@Nullable
public final PointF sourceToViewCoord(float sx, float sy, @NonNull PointF vTarget) {
    if (vTranslate == null) {
        return null;
    }
    vTarget.set(sourceToViewX(sx), sourceToViewY(sy));
    return vTarget;
}
 
Example 11
Source File: SubsamplingScaleImageView.java    From EasyPhotos with Apache License 2.0 5 votes vote down vote up
/**
 * Convert screen coordinate to source coordinate.
 *
 * @param vx      view X coordinate.
 * @param vy      view Y coordinate.
 * @param sTarget target object for result. The same instance is also returned.
 * @return source coordinates. This is the same instance passed to the sTarget param.
 */
@Nullable
public final PointF viewToSourceCoord(float vx, float vy, @NonNull PointF sTarget) {
    if (vTranslate == null) {
        return null;
    }
    sTarget.set(viewToSourceX(vx), viewToSourceY(vy));
    return sTarget;
}
 
Example 12
Source File: SubsamplingScaleImageView.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Convert source coordinate to screen coordinate.
 */
public final PointF sourceToViewCoord(float sx, float sy, PointF vTarget) {
    if (vTranslate == null) {
        return null;
    }
    vTarget.set(sourceToViewX(sx), sourceToViewY(sy));
    return vTarget;
}
 
Example 13
Source File: SubsamplingScaleImageViewDragClose.java    From imsdk-android with MIT License 5 votes vote down vote up
/**
 * Convert source coordinate to view coordinate.
 *
 * @param sx source X coordinate.
 * @param sy source Y coordinate.
 * @param vTarget target object for result. The same instance is also returned.
 * @return view coordinates. This is the same instance passed to the vTarget param.
 */
@Nullable
public final PointF sourceToViewCoord(float sx, float sy, @NonNull PointF vTarget) {
    if (vTranslate == null) {
        return null;
    }
    vTarget.set(sourceToViewX(sx), sourceToViewY(sy));
    return vTarget;
}
 
Example 14
Source File: OC_PhraseRead.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public void setScenea()
{
    setSceneXX(currentEvent());
    presenter = OBPresenter.characterWithGroup((OBGroup)objectDict.get("presenter"));
    presenter.control.setZPosition(200);
    PointF rp = new PointF();
    rp.set(presenter.control.position());
    presenter.control.setProperty("restpos",rp);
    presenter.control.setRight(0);
    presenter.control.show();
}
 
Example 15
Source File: OC_AddSubCountersPt2.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public void setScenek()
{
    loadEvent("anna");
    presenter = OBPresenter.characterWithGroup((OBGroup) objectDict.get("anna"));
    presenter.control.setZPosition(200);
    PointF pt = new PointF();
    pt.set(presenter.control.position());
    presenter.control.setProperty("restpos",pt);
    presenter.control.setRight(0);
    presenter.control.show();
    setButtonActive(false);
}
 
Example 16
Source File: OC_SectionController.java    From GLEXP-Team-onebillion with Apache License 2.0 5 votes vote down vote up
public OBPath StarWithScale(float scale,boolean shadow)
{
    Path starpath = new Path();
    boolean outer = true;
    PointF pt = new PointF();
    for (double ang = -(Math.PI);ang < Math.PI;ang += (2.0 * Math.PI / 10.0))
    {
        double cosang = Math.cos(ang);
        double sinang = Math.sin(ang);
        if (outer)
            pt.set((float) cosang, (float) sinang);
        else
            pt.set((float)cosang*0.5f, (float)sinang*0.5f);
        pt.x += 1.0;
        pt.y += 1.0;
        pt.x *= scale;
        pt.y *= scale;
        outer = !outer;
        if (starpath.isEmpty())
            starpath.moveTo(pt.x,pt.y);
        else
            starpath.lineTo(pt.x,pt.y);
    }
    starpath.close();
    Matrix m = new Matrix();
    m.postRotate(28.87f);
    starpath.transform(m);
    OBPath p = new OBPath(starpath);
    p.sizeToBoundingBoxIncludingStroke();
    float r = 1.0f,g = 216.0f/255.0f,b = 0.0f;
    p.setFillColor(Color.argb(255, (int) (r * 255), (int) (g * 255), (int) (b * 255)));
    p.setStrokeColor(Color.argb((int)(0.7*255),(int)(r*0.7*255),(int)(g*0.7*255),(int)(b*0.7*255)));
    p.setZPosition(200);
    return p;
}
 
Example 17
Source File: c.java    From letv with Apache License 2.0 5 votes vote down vote up
private void a(PointF pointF) {
    float f = 1.0f;
    if (this.h != null) {
        float[] fArr = new float[9];
        this.c.getValues(fArr);
        float f2 = fArr[2];
        float f3 = fArr[5];
        float f4 = fArr[0];
        float width = ((float) this.h.getWidth()) * f4;
        float height = ((float) this.h.getHeight()) * f4;
        f4 = ((float) this.p.left) - f2;
        if (f4 <= 1.0f) {
            f4 = 1.0f;
        }
        f2 = (f2 + width) - ((float) this.p.right);
        if (f2 <= 1.0f) {
            f2 = 1.0f;
        }
        width = ((f4 * ((float) this.p.width())) / (f2 + f4)) + ((float) this.p.left);
        f2 = ((float) this.p.top) - f3;
        f4 = (f3 + height) - ((float) this.p.bottom);
        if (f2 <= 1.0f) {
            f2 = 1.0f;
        }
        if (f4 > 1.0f) {
            f = f4;
        }
        pointF.set(width, ((((float) this.p.height()) * f2) / (f2 + f)) + ((float) this.p.top));
    }
}
 
Example 18
Source File: ImageDisplay.java    From DroidDLNA with GNU General Public License v3.0 4 votes vote down vote up
private void midPoint(PointF point, MotionEvent event) {
	float x = event.getX(0) + event.getX(1);
	float y = event.getY(0) + event.getY(1);
	point.set(x / 2, y / 2);
}
 
Example 19
Source File: ImageClipActivity.java    From imsdk-android with MIT License 2 votes vote down vote up
/**
 * 多点触控时,计算最先放下的两指中心坐标
 *
 * @param point
 * @param event
 */
private void midPoint(PointF point, MotionEvent event) {
    float x = event.getX(0) + event.getX(1);
    float y = event.getY(0) + event.getY(1);
    point.set(x / 2, y / 2);
}
 
Example 20
Source File: WXComponent.java    From weex with Apache License 2.0 2 votes vote down vote up
/**
 * This method computes user visible left-top point in view's coordinate.
 * The default implementation uses the scrollX and scrollY of the view as the result,
 * and put the value in the parameter pointer.
 * Components with different computation algorithm
 * (e.g. {@link WXListComponent#computeVisiblePointInViewCoordinate(PointF)} )
 * <strong> should override </strong> this method.
 *
 * @param pointF the user visible left-top point in view's coordinate.
 */
public void computeVisiblePointInViewCoordinate(PointF pointF) {
  View view = getRealView();
  pointF.set(view.getScrollX(), view.getScrollY());
}