Example usage for android.graphics PointF PointF

List of usage examples for android.graphics PointF PointF

Introduction

In this page you can find the example usage for android.graphics PointF PointF.

Prototype

public PointF(float x, float y) 

Source Link

Usage

From source file:Main.java

public static PointF[] getIntersectionPoints(PointF pMiddle, float radius, Double lineK) {
    PointF[] points = new PointF[2];

    float radian, xOffset = 0, yOffset = 0;
    if (lineK != null) {
        radian = (float) Math.atan(lineK);
        xOffset = (float) (Math.sin(radian) * radius);
        yOffset = (float) (Math.cos(radian) * radius);
    } else {//from   w w w .j a v  a2  s. co m
        xOffset = radius;
        yOffset = 0;
    }
    points[0] = new PointF(pMiddle.x + xOffset, pMiddle.y - yOffset);
    points[1] = new PointF(pMiddle.x - xOffset, pMiddle.y + yOffset);

    return points;
}

From source file:Main.java

/**
 *
 * Cross of line from (x1, y1) to (x2, y2) by line from (m1, n1) to (m2, n2)
 *
 * @param x1//from   w  w w . ja v  a2s  . c o m
 * @param y1
 * @param x2
 * @param y2
 * @param m1
 * @param n1
 * @param m2
 * @param n2
 *
 * @return cross point in PointF
 */
public static PointF crossPointOfTwoLines(float x1, float y1, float x2, float y2, float m1, float n1, float m2,
        float n2) {
    float a1 = 0, b1 = 0, a2 = 0, b2 = 0;
    float x0 = 0, y0 = 0;

    if (m1 == x1) {
        x0 = x1;
    } else {
        a1 = (n1 - y1) / (m1 - x1);
        b1 = n1 - a1 * m1;
    }

    if (m2 == x2) {
        x0 = x2;
    } else {
        a2 = (n2 - y2) / (m2 - x2);
        b2 = n2 - a2 * m2;
    }

    if (a1 != a2 && m1 != x1 && m2 != x2) {
        x0 = (b1 - b2) / (a2 - a1);
    }

    if (a1 == 0) {
        y0 = a2 * x0 + b2;
    } else {
        y0 = a1 * x0 + b1;
    }

    return new PointF(x0, y0);
}

From source file:Main.java

private static void init2DPoint() {

    XHead_2D = new PointF(+XAxisPosLen_2D, 0);
    XTail_2D = new PointF(-XAxisNegLen_2D, 0);
    XCap1_2D = new PointF(XAxisPosLen_2D - Cap_Head_Distance, +Cap_Axis_Distance);
    XCap2_2D = new PointF(XAxisPosLen_2D - Cap_Head_Distance, -Cap_Axis_Distance);

    YHead_2D = new PointF(0, +YAxisPosLen_2D);
    YTail_2D = new PointF(0, -YAxisNegLen_2D);
    YCap1_2D = new PointF(+Cap_Axis_Distance, YAxisPosLen_2D - Cap_Head_Distance);
    YCap2_2D = new PointF(-Cap_Axis_Distance, YAxisPosLen_2D - Cap_Head_Distance);
}

From source file:Main.java

private static void init3DPoint() {

    XHead_3D = new PointF(+XAxisPosLen_3D, 0);
    XTail_3D = new PointF(-XAxisNegLen_3D, 0);
    XCap1_3D = new PointF(XAxisPosLen_3D - Cap_Head_Distance, +Cap_Axis_Distance);
    XCap2_3D = new PointF(XAxisPosLen_3D - Cap_Head_Distance, -Cap_Axis_Distance);

    YHead_3D = new PointF(0, -YAxisPosLen_3D);
    YTail_3D = new PointF(0, +YAxisNegLen_3D);
    YCap1_3D = new PointF(+Cap_Axis_Distance, -YAxisPosLen_3D + Cap_Head_Distance);
    YCap2_3D = new PointF(-Cap_Axis_Distance, -YAxisPosLen_3D + Cap_Head_Distance);

    float zl = convert_3D_to_2D(ZAxisPosLen_3D);
    float nzl = convert_3D_to_2D(ZAxisNegLen_3D);
    float CAD = convert_3D_to_2D(Cap_Axis_Distance);
    float CHD = convert_3D_to_2D(Cap_Head_Distance);
    ZHead_3D = new PointF(zl, -zl);
    ZTail_3D = new PointF(-nzl, nzl);
    ZCap1_3D = new PointF(ZHead_3D.x - CHD - CAD, ZHead_3D.y + CHD - CAD);
    ZCap2_3D = new PointF(ZHead_3D.x - CHD + CAD, ZHead_3D.y + CHD + CAD);
}

From source file:net.evendanan.pushingpixels.PassengerFragmentSupport.java

public static void setItemExpandExtraData(@NonNull Fragment passengerFragment, float originateViewCenterX,
        float originateViewCenterY, float originateViewWidthScale, float originateViewHeightScale) {
    Bundle bundle = passengerFragment.getArguments();
    if (bundle == null)
        bundle = new Bundle();
    bundle.putParcelable(EXTRA_ORIGINATE_VIEW_CENTER,
            new PointFCompat(new PointF(originateViewCenterX, originateViewCenterY)));
    bundle.putParcelable(EXTRA_ORIGINATE_VIEW_SCALE,
            new PointFCompat(new PointF(originateViewWidthScale, originateViewHeightScale)));

    passengerFragment.setArguments(bundle);
}

From source file:org.mozilla.gecko.gfx.PointUtils.java

public static PointF add(PointF one, PointF two) {
    return new PointF(one.x + two.x, one.y + two.y);
}

From source file:org.mozilla.gecko.gfx.PointUtils.java

public static PointF subtract(PointF one, PointF two) {
    return new PointF(one.x - two.x, one.y - two.y);
}

From source file:org.mozilla.gecko.gfx.PointUtils.java

public static PointF scale(PointF point, float factor) {
    return new PointF(point.x * factor, point.y * factor);
}

From source file:com.barswipe.imagescale.extension.ExtensionPinFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(R.layout.extension_pin_fragment, container, false);
    rootView.findViewById(id.next).setOnClickListener(new OnClickListener() {
        @Override/* w  w  w. ja  v  a2  s  .c  o m*/
        public void onClick(View view) {
            ((ExtensionActivity) getActivity()).next();
        }
    });
    PinView imageView = (PinView) rootView.findViewById(id.imageView);
    imageView.setImage(ImageSource.asset("squirrel.jpg"));
    imageView.setPin(new PointF(1718f, 581f));
    return rootView;
}

From source file:com.davemorrissey.labs.subscaleview.sample.extension.ExtensionPinFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(layout.extension_pin_fragment, container, false);
    rootView.findViewById(id.next).setOnClickListener(new OnClickListener() {
        @Override// ww w. j  a  v a  2 s  . c  om
        public void onClick(View view) {
            ((ExtensionActivity) getActivity()).next();
        }
    });
    PinView imageView = (PinView) rootView.findViewById(id.imageView);
    imageView.setImage(ImageSource.asset("squirrel.jpg"));
    imageView.setPin(new PointF(1718f, 581f));
    return rootView;
}