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:com.example.android.wearable.gridviewpager.SampleGridPagerAdapter.java

@Override
public Drawable getBackgroundForPage(final int row, final int column) {
    return mPageBackgrounds.get(new Point(column, row));
}

From source file:com.nononsenseapps.feeder.model.ImageTextLoader.java

/**
 * Keeps aspect ratio.//from  ww w. j  a  v  a2 s.  c  o m
 *
 * @param w current width of image
 * @param h current height of image
 * @return scaled (width, height) of image to fit the intended maxSize
 */
Point scaleImage(int w, int h) {
    // Which is out of scale the most?
    float ratio = ((float) w) / ((float) maxSize.x);
    // Calculate new size. Maintains aspect ratio.
    int newWidth = (int) ((float) w / ratio);
    int newHeight = (int) ((float) h / ratio);

    return new Point(newWidth, newHeight);
}

From source file:com.amitupadhyay.aboutexample.util.CollapsingTextHelper.java

public Point getTextTopLeft() {
    return new Point((int) mCurrentBounds.left, (int) (mCurrentBounds.bottom + mTextPaint.ascent()));
}

From source file:com.github.mobile.util.HttpImageGetter.java

@SuppressWarnings("deprecation")
private Point fetchDisplaySizePreHoneycomb(WindowManager wm) {
    Display display = wm.getDefaultDisplay();
    return new Point(display.getWidth(), display.getHeight());
}

From source file:com.google.samples.apps.ourstreets.view.ViewUtils.java

/**
 * Get the center of a given view./*from   w  w  w  . ja v a 2s .com*/
 *
 * @param view The view to get coordinates from.
 * @return The center of the given view.
 */
public static Point getCenterForView(@NonNull View view) {
    final int centerX = (view.getLeft() + view.getRight()) / 2;
    final int centerY = (view.getTop() + view.getBottom()) / 2;
    return new Point(centerX, centerY);
}

From source file:com.explovia.mapdemo.CircleDemoActivity.java

@Override
public void onMapLongClick(LatLng point) {
    // We know the center, let's place the outline at a point 3/4 along the view.
    View view = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getView();
    LatLng radiusLatLng = mMap.getProjection()
            .fromScreenLocation(new Point(view.getHeight() * 3 / 4, view.getWidth() * 3 / 4));

    // ok create it
    DraggableCircle circle = new DraggableCircle(point, radiusLatLng);
    mCircles.add(circle);/* w ww.j a va  2  s . c om*/
}

From source file:com.cyrilmottier.android.polaris2demo.CircleDemoActivity.java

@Override
public void onMapLongClick(LatLng point) {
    // We know the center, let's place the outline at a point 3/4 along the view.
    View view = ((SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map)).getView();
    LatLng radiusLatLng = mMap.getProjection()
            .fromScreenLocation(new Point(view.getHeight() * 3 / 4, view.getWidth() * 3 / 4));

    // ok create it
    DraggableCircle circle = new DraggableCircle(point, radiusLatLng);
    mCircles.add(circle);/*from w w  w . j  av  a 2 s .  com*/
}

From source file:com.kaltura.playersdk.PlayerViewController.java

@SuppressLint("NewApi")
private Point getRealScreenSize() {
    Display display = mActivity.getWindowManager().getDefaultDisplay();
    int realWidth = 0;
    int realHeight = 0;

    if (Build.VERSION.SDK_INT >= 17) {
        //new pleasant way to get real metrics
        DisplayMetrics realMetrics = new DisplayMetrics();
        display.getRealMetrics(realMetrics);
        realWidth = realMetrics.widthPixels;
        realHeight = realMetrics.heightPixels;

    } else {//  w w  w. ja v a  2  s  .co m
        try {
            Method mGetRawH = Display.class.getMethod("getRawHeight");
            Method mGetRawW = Display.class.getMethod("getRawWidth");
            realWidth = (Integer) mGetRawW.invoke(display);
            realHeight = (Integer) mGetRawH.invoke(display);
        } catch (Exception e) {
            realWidth = display.getWidth();
            realHeight = display.getHeight();
            Log.e("Display Info", "Couldn't use reflection to get the real display metrics.");
        }

    }
    return new Point(realWidth, realHeight);
}

From source file:com.example.pyo.edit.MapsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_maps);
    // Obtain the SupportMapFragment and get notified when the map is ready to be used.
    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    mDeviceListView = (ListView) findViewById(R.id.deviceListView);
    mDeviceList = new ArrayList<String>();
    mDeviceList.add("Device1 10m");
    mDeviceList.add("Device2 15m");
    mDeviceList.add("Device3 20m");
    mDeviceList.add("Device4 25m");
    ArrayAdapter adapter = new ArrayAdapter(this, android.R.layout.simple_list_item_1, mDeviceList);
    mDeviceListView.setAdapter(adapter);
    mDeviceListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override/*from  ww  w  . ja  va2  s .c  om*/
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            mDeviceRange = 10 + 5 * position;
            mDeviceListView.setVisibility(View.INVISIBLE);
        }
    });
    mDeviceListView.setVisibility(View.INVISIBLE);

    // REGISTER DRAW MAP TOUCH LISENTER
    mDrawMap = (FrameLayout) findViewById(R.id.draw_map);
    IS_MAP_MOVEABLE = false;
    mDrawPoints = new Vector<Vector<Point>>();
    mDrawMap.setOnTouchListener(new View.OnTouchListener() {
        @Override
        public boolean onTouch(View v, MotionEvent event) {
            Point point = new Point(Math.round(event.getX()), Math.round(event.getY()));
            if (IS_MAP_MOVEABLE) {
                switch (event.getAction()) {
                case MotionEvent.ACTION_DOWN:
                    mDrawPoints.add(new Vector<Point>());
                    mDrawPoints.lastElement().add(point);
                    break;
                case MotionEvent.ACTION_MOVE:
                    mDrawPoints.lastElement().add(point);
                    break;
                case MotionEvent.ACTION_UP:
                    //mDrawPoints.clear();
                    break;
                }
            }

            System.out.println("[!] drag event : " + point.toString());

            return IS_MAP_MOVEABLE;
        }
    });
    mDrawCanvas = new DrawCanvas(this);
    mDrawMap.addView(mDrawCanvas);
}

From source file:com.gm.goldencity.fragment.search.SearchFragment.java

private void setupTransitions() {
    // grab the position that the search icon transitions in *from*
    // & use it to configure the return transition
    setEnterSharedElementCallback(new android.support.v4.app.SharedElementCallback() {
        @Override//w  ww  . jav a 2 s. c  om
        public void onSharedElementStart(List<String> sharedElementNames, List<View> sharedElements,
                List<View> sharedElementSnapshots) {
            if (sharedElements != null && !sharedElements.isEmpty()) {
                View searchIcon = sharedElements.get(0);
                if (searchIcon.getId() != R.id.searchback)
                    return;
                int centerX = (searchIcon.getLeft() + searchIcon.getRight()) / 2;
                CircularReveal hideResults = (CircularReveal) TransitionUtils.findTransition(
                        (TransitionSet) getActivity().getWindow().getReturnTransition(), CircularReveal.class,
                        R.id.results_container);
                if (hideResults != null) {
                    hideResults.setCenter(new Point(centerX, 0));
                }
            }
        }
    });
}