Example usage for android.graphics Point Point

List of usage examples for android.graphics Point Point

Introduction

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

Prototype

public Point(int x, int y) 

Source Link

Usage

From source file:Main.java

public static Point getScreenPoint(Context ctx) {
    DisplayMetrics dm = ctx.getResources().getDisplayMetrics();
    Point point = new Point(dm.widthPixels, dm.heightPixels);
    return point;
}

From source file:Main.java

static Point getDisplaySizeLT11(Display d) {
    try {/*from w w  w  . j a  va  2  s .c o m*/
        Method getWidth = Display.class.getMethod("getWidth", new Class[] {});
        Method getHeight = Display.class.getMethod("getHeight", new Class[] {});
        return new Point(((Integer) getWidth.invoke(d, (Object[]) null)).intValue(),
                ((Integer) getHeight.invoke(d, (Object[]) null)).intValue());
    } catch (Exception ex) { // None of these exceptions should ever occur.
        return new Point(-1, -1);
    }
}

From source file:Main.java

public static List<Point> midPoints(List<Point> points) {
    List<Point> midPoints = new ArrayList<>();
    for (int i = 0; i < points.size() - 1; i++) {
        Point p = points.get(i);/*from ww  w.  jav  a 2  s.  com*/
        Point next = points.get(i + 1);
        midPoints.add(new Point((p.x + next.x) / 2, (p.y + next.y) / 2));
    }
    return midPoints;
}

From source file:Main.java

public static Point getScreenMetrics(Context context) {
    DisplayMetrics dm = context.getResources().getDisplayMetrics();
    int w_screen = dm.widthPixels;
    int h_screen = dm.heightPixels;
    return new Point(w_screen, h_screen);

}

From source file:Main.java

public static Point getScreenMetrics(Context context) {
    DisplayMetrics dm = context.getResources().getDisplayMetrics();
    int screenWidth = dm.widthPixels;
    int screenHeight = dm.heightPixels;
    return new Point(screenWidth, screenHeight);

}

From source file:Main.java

public static Point measure(View view) {
    int w = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    int h = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    view.measure(w, h);//w  w  w  .  ja va 2s  .  com
    int height = view.getMeasuredHeight();
    int width = view.getMeasuredWidth();
    return new Point(width, height);
}

From source file:Main.java

public static Point getLocationInView(View src, View target) {
    final int[] l0 = new int[2];
    src.getLocationOnScreen(l0);//from   ww  w  .  j a va  2  s.c  o  m

    final int[] l1 = new int[2];
    target.getLocationOnScreen(l1);

    l1[0] = l1[0] - l0[0] + target.getWidth() / 2;
    l1[1] = l1[1] - l0[1] + target.getHeight() / 2;

    return new Point(l1[0], l1[1]);
}

From source file:Main.java

public static Point getSuitableSize(int w, int h, int containerW, int containerH) {
    int resultW = 0, resultH = 0;
    if ((float) w / h >= (float) containerW / containerH) {
        resultW = containerW;/*from   w  w w  .ja  v  a2s.c  om*/
        resultH = h * resultW / w;
    } else {
        resultH = containerH;
        resultW = w * resultH / h;
    }
    return new Point(resultW, resultH);
}

From source file:Main.java

public static Point getPointOnView(View root, View target) {
    final int[] l0 = new int[2];
    root.getLocationOnScreen(l0);/*  w w w . j  a  v a2s .c  o m*/

    final int[] l1 = new int[2];
    target.getLocationOnScreen(l1);

    l1[0] = l1[0] - l0[0] + target.getWidth() / 2;
    l1[1] = l1[1] - l0[1] + target.getHeight() / 2;

    return new Point(l1[0], l1[1]);
}

From source file:Main.java

public static Point getScreenResolution(Context context) {
    WindowManager manager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
    Display display = manager.getDefaultDisplay();
    Point wh = new Point(display.getWidth(), display.getHeight());
    if (wh.x == 0 || wh.y == 0) {
        Log.e("AndroidUtils", "Screen resolution " + wh + " for " + context);
    }//from   w  w  w.  j a  va2  s  .  c  o m
    return wh;
}