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() 

Source Link

Usage

From source file:de.ribeiro.android.gso.core.UntisProvider.java

/**
 * @param weekData WeekData, das bereinigt werden soll
 * @return WeekData, das bereinigt wurde
 * @author Tobias Janssen Entfernt doppelte Reihen und Spalten
 *//*from w  w  w  . j  av  a  2s . co m*/
private static WeekData removeDubColsnRows(WeekData weekData) {

    Xml[][] tempTimeTable = new Xml[0][0];

    Boolean dub = false;

    // zuerst alle Zeilen prfen, ob diese gleich der nchsten ist
    for (int y = 0; y + 1 < weekData.timetable.length; y++) {
        dub = true;
        for (int x = 0; x < weekData.timetable.length && dub; x++) {
            if (!weekData.timetable[y + 1][x].equals(weekData.timetable[y][x]) && dub) {
                dub = false;
            }
        }
        if (!dub) {
            // alle nicht Dublicate werden dem neuen array hinzugefgt
            tempTimeTable = (Xml[][]) ArrayOperations.AppendToArray(tempTimeTable, weekData.timetable[y]);
        }
    }
    tempTimeTable = (Xml[][]) ArrayOperations.AppendToArray(tempTimeTable,
            weekData.timetable[weekData.timetable.length - 1]);

    // fingerprints(strings aus 0 und 1) fr jede zeile erstellen. 1 zeigt,
    // dass dieses feld mit dem vorgnger gleich ist
    String[] print = new String[weekData.timetable.length];
    for (int y = 0; y < weekData.timetable.length; y++) {
        print[y] = fingerprintOfDubs(weekData.timetable[y]);
    }

    // nun mssen die fingerprints aller Array zeilen zusammengefgt werden
    int sum = 0;
    String printRes = "";
    for (int y = 0; y < print.length; y++) {
        sum = 0;
        for (int x = 0; x < print[y].length(); x++) {
            sum += Integer.decode(String.valueOf(print[y].charAt(x)));
        }
        if (sum != 0) {
            printRes += "1";
        } else {
            printRes += "0";
        }
    }
    // es ist eine fingerabdruck fr ein zweidimensinales array entstanden,
    // an hand diesem kann nun ein neues array erstellt werden, dass keine
    // dublicate hat

    int count = -1;
    // zhlen der 0en fr die lnge einer zeile, denn diese sind kein
    // dublicat.
    for (int y = 0; y < printRes.length() && count == -1; y++) {
        if (String.valueOf(printRes.charAt(y)).equalsIgnoreCase("0")) {
            count = print[y].length();
        }

    }
    // das neue array fr das ergebnis erstellen
    weekData.timetable = new Xml[tempTimeTable.length][count];
    Point point = new Point();
    // das vorherige ergenis nutzen wir nun um mit hilfe des fingerprints
    // das neue array zu fllen
    for (int y = 0; y < tempTimeTable.length; y++) {
        for (int x = 0; x < tempTimeTable[y].length; x++) {
            // nur 0en, also nicht dublicate hinzufgen
            if (String.valueOf(printRes.charAt(x)).equalsIgnoreCase("0")) {
                // das feld hinzufgen
                point = getLastFreePosition(weekData);
                System.arraycopy(tempTimeTable[y], x, weekData.timetable[point.y], point.x, 1);
            }
        }

    }

    return weekData;
}

From source file:com.klinker.android.sliding.MultiShrinkScroller.java

public void runExpansionAnimation() {

    final Interpolator interpolator;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        interpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.linear_out_slow_in);
    } else {/*from   www .  j  a v  a  2 s  .  co  m*/
        interpolator = new DecelerateInterpolator();
    }

    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int screenHeight = size.y;
    int screenWidth = size.x;

    final ValueAnimator heightExpansion = ValueAnimator.ofInt(expansionViewHeight, getHeight());
    heightExpansion.setInterpolator(interpolator);
    heightExpansion.setDuration(ANIMATION_DURATION);
    heightExpansion.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int val = (int) animation.getAnimatedValue();

            ViewGroup.LayoutParams params = getLayoutParams();
            params.height = val;
            setLayoutParams(params);
        }
    });
    heightExpansion.start();

    final ValueAnimator widthExpansion = ValueAnimator.ofInt(expansionViewWidth, getWidth());
    widthExpansion.setInterpolator(interpolator);
    widthExpansion.setDuration(ANIMATION_DURATION);
    widthExpansion.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int val = (int) animation.getAnimatedValue();

            ViewGroup.LayoutParams params = getLayoutParams();
            params.width = val;
            setLayoutParams(params);
        }
    });
    widthExpansion.start();

    ObjectAnimator translationX = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, expansionLeftOffset, 0f);
    translationX.setInterpolator(interpolator);
    translationX.setDuration(ANIMATION_DURATION);
    translationX.start();

    ObjectAnimator translationY = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, expansionTopOffset, 0f);
    translationY.setInterpolator(interpolator);
    translationY.setDuration(ANIMATION_DURATION);
    translationY.start();
}

From source file:at.ac.tuwien.caa.docscan.ui.CameraActivity.java

public static Point getPreviewDimension() {

    //        Taken from: http://stackoverflow.com/questions/1016896/get-screen-dimensions-in-pixels
    View v = ((Activity) mContext).findViewById(R.id.camera_controls_layout);

    WindowManager wm = (WindowManager) mContext.getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);//from   w  w  w. ja v a 2 s .com

    Point dim = null;

    if (v != null) {
        if (getOrientation() == Surface.ROTATION_0 || getOrientation() == Surface.ROTATION_180)
            dim = new Point(size.x, size.y - v.getHeight());
        //                return size.y - v.getHeight();
        else if (getOrientation() == Surface.ROTATION_90 || getOrientation() == Surface.ROTATION_270)
            dim = new Point(size.x - v.getWidth(), size.y);
        //                return size.x - v.getWidth();
    }

    return dim;

}

From source file:es.upv.riromu.arbre.main.MainActivity.java

private void setPic() {
    // Get the dimensions of the View
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);/*from  w ww  .j av a2s.c o m*/
    // Get the dimensions of the bitmap
    ImageView imv = (ImageView) findViewById(R.id.image_intro);
    int targetW = imv.getMaxWidth();
    int targetH = imv.getMaxHeight();
    BitmapFactory.Options bmOptions = new BitmapFactory.Options();
    bmOptions.inJustDecodeBounds = true;
    Bitmap bitmap = loadBitmap(image_uri.getPath());
    int photoW = bitmap.getWidth();
    int photoH = bitmap.getHeight();
    imv.setImageBitmap(bitmap);
    galleryAddPic();
}

From source file:androidx.media.widget.VideoView2.java

@Override
public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);

    if (mIsMusicMediaType) {
        if (mPrevWidth != getMeasuredWidth() || mPrevHeight != getMeasuredHeight()) {
            int currWidth = getMeasuredWidth();
            int currHeight = getMeasuredHeight();
            Point screenSize = new Point();
            mManager.getDefaultDisplay().getSize(screenSize);
            int screenWidth = screenSize.x;
            int screenHeight = screenSize.y;

            if (currWidth == screenWidth && currHeight == screenHeight) {
                int orientation = retrieveOrientation();
                if (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                    inflateMusicView(R.layout.full_landscape_music);
                } else {
                    inflateMusicView(R.layout.full_portrait_music);
                }/*from   w  ww .java  2s  . co  m*/

                if (mSizeType != SIZE_TYPE_FULL) {
                    mSizeType = SIZE_TYPE_FULL;
                    // Remove existing mFadeOut callback
                    mMediaControlView.removeCallbacks(mFadeOut);
                    mMediaControlView.setVisibility(View.VISIBLE);
                }
            } else {
                if (mSizeType != SIZE_TYPE_EMBEDDED) {
                    mSizeType = SIZE_TYPE_EMBEDDED;
                    inflateMusicView(R.layout.embedded_music);
                    // Add new mFadeOut callback
                    mMediaControlView.postDelayed(mFadeOut, mShowControllerIntervalMs);
                }
            }
            mPrevWidth = currWidth;
            mPrevHeight = currHeight;
        }
    }
}

From source file:com.klinker.android.sliding.MultiShrinkScroller.java

public void reverseExpansionAnimation() {

    final Interpolator interpolator;

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        interpolator = AnimationUtils.loadInterpolator(getContext(), android.R.interpolator.linear_out_slow_in);
    } else {//from   ww  w.  j  av a 2s  . co  m
        interpolator = new DecelerateInterpolator();
    }

    WindowManager wm = (WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int screenHeight = size.y;
    int screenWidth = size.x;

    final ValueAnimator heightExpansion = ValueAnimator.ofInt(screenHeight, expansionViewHeight);
    heightExpansion.setInterpolator(interpolator);
    heightExpansion.setDuration(ANIMATION_DURATION);
    heightExpansion.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int val = (int) animation.getAnimatedValue();

            ViewGroup.LayoutParams params = getLayoutParams();
            params.height = val;
            setLayoutParams(params);
        }
    });
    heightExpansion.start();

    final ValueAnimator widthExpansion = ValueAnimator.ofInt(getWidth(), expansionViewWidth);
    widthExpansion.setInterpolator(interpolator);
    widthExpansion.setDuration(ANIMATION_DURATION);
    widthExpansion.addUpdateListener(new AnimatorUpdateListener() {
        @Override
        public void onAnimationUpdate(ValueAnimator animation) {
            int val = (int) animation.getAnimatedValue();

            ViewGroup.LayoutParams params = getLayoutParams();
            params.width = val;
            setLayoutParams(params);
        }
    });
    widthExpansion.start();

    ObjectAnimator translationX = ObjectAnimator.ofFloat(this, View.TRANSLATION_X, 0f, expansionLeftOffset);
    translationX.setInterpolator(interpolator);
    translationX.setDuration(ANIMATION_DURATION);
    translationX.start();

    ObjectAnimator translationY = ObjectAnimator.ofFloat(this, View.TRANSLATION_Y, 0f, expansionTopOffset);
    translationY.setInterpolator(interpolator);
    translationY.setDuration(ANIMATION_DURATION);
    translationY.addListener(exitAnimationListner);
    translationY.start();
}

From source file:com.example.SmartBoard.DrawingView.java

public void onTouchLineMode(MotionEvent event) {
    int eventaction = event.getAction();

    int X = (int) event.getX();
    int Y = (int) event.getY();

    switch (eventaction) {

    case MotionEvent.ACTION_DOWN: // touch down so check if the finger is on
        // a ball

        points = new Point[2];
        startX = X;//from  w  ww  . j  av a  2s  .c  o  m
        startY = Y;
        linePath.from(X, Y);
        linePath.to(X, Y);

        finished = false;
        if (points[0] == null) {
            //initialize rectangle.
            points[0] = new Point();
            points[0].x = X;
            points[0].y = Y;

            points[1] = new Point();
            points[1].x = X;
            points[1].y = Y + 30;

            for (Point pt : points) {
                colorballs.add(new ColorBall(getContext(), R.drawable.dot_drag_handle, pt));
            }

            invalidate();
        }
        break;
    case MotionEvent.ACTION_MOVE: // touch drag with the ball
        linePath.to(X, Y);
        colorballs.get(1).setX(X);
        colorballs.get(1).setY(Y);
        invalidate();
        break;

    case MotionEvent.ACTION_UP:
        // touch drop - just do things here after dropping
        linePath.to(X, Y);
        colorballs.get(1).setX(X);
        colorballs.get(1).setY(Y);
        finished = true;

        break;
    }
    // redraw the canvas
    invalidate();
    return;

}

From source file:com.android.launcher2.Workspace.java

protected void setWallpaperDimension() {
    Point minDims = new Point();
    Point maxDims = new Point();
    DisplayCompt.getCurrentSizeRange(mLauncher.getWindowManager().getDefaultDisplay(), minDims, maxDims);

    final int maxDim = Math.max(maxDims.x, maxDims.y);
    final int minDim = Math.min(minDims.x, minDims.y);

    // We need to ensure that there is enough extra space in the wallpaper for the intended
    // parallax effects
    if (LauncherApplication.isScreenLarge()) {
        mWallpaperWidth = (int) (maxDim * wallpaperTravelToScreenWidthRatio(maxDim, minDim));
        mWallpaperHeight = maxDim;/*from  w  ww.j a v  a2 s.c o  m*/
    } else {
        mWallpaperWidth = Math.max((int) (minDim * WALLPAPER_SCREENS_SPAN), maxDim);
        mWallpaperHeight = maxDim;
    }
    new Thread("setWallpaperDimension") {
        public void run() {
            mWallpaperManager.suggestDesiredDimensions(mWallpaperWidth, mWallpaperHeight);
        }
    }.start();
}

From source file:com.ferdi2005.secondgram.AndroidUtilities.java

public static Point getRealScreenSize() {
    Point size = new Point();
    try {//from  w ww .ja va 2 s .  com
        WindowManager windowManager = (WindowManager) ApplicationLoader.applicationContext
                .getSystemService(Context.WINDOW_SERVICE);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
            windowManager.getDefaultDisplay().getRealSize(size);
        } else {
            try {
                Method mGetRawW = Display.class.getMethod("getRawWidth");
                Method mGetRawH = Display.class.getMethod("getRawHeight");
                size.set((Integer) mGetRawW.invoke(windowManager.getDefaultDisplay()),
                        (Integer) mGetRawH.invoke(windowManager.getDefaultDisplay()));
            } catch (Exception e) {
                size.set(windowManager.getDefaultDisplay().getWidth(),
                        windowManager.getDefaultDisplay().getHeight());
                FileLog.e(e);
            }
        }
    } catch (Exception e) {
        FileLog.e(e);
    }
    return size;
}

From source file:com.danilov.supermanga.core.view.SlidingLayer.java

@SuppressWarnings("deprecation")
private int getScreenSideAuto(int newLeft, int newRight) {

    int newScreenSide;

    if (mScreenSide == STICK_TO_AUTO) {
        int screenWidth;
        Display display = ((WindowManager) getContext().getSystemService(Context.WINDOW_SERVICE))
                .getDefaultDisplay();//from   www  .ja  v  a  2  s  .  c  o m
        try {
            Class<?> cls = Display.class;
            Class<?>[] parameterTypes = { Point.class };
            Point parameter = new Point();
            Method method = cls.getMethod("getSize", parameterTypes);
            method.invoke(display, parameter);
            screenWidth = parameter.x;
        } catch (Exception e) {
            screenWidth = display.getWidth();
        }

        boolean boundToLeftBorder = newLeft == 0;
        boolean boundToRightBorder = newRight == screenWidth;

        if (boundToLeftBorder == boundToRightBorder
                && getLayoutParams().width == android.view.ViewGroup.LayoutParams.MATCH_PARENT) {
            newScreenSide = STICK_TO_MIDDLE;
        } else if (boundToLeftBorder) {
            newScreenSide = STICK_TO_LEFT;
        } else {
            newScreenSide = STICK_TO_RIGHT;
        }
    } else {
        newScreenSide = mScreenSide;
    }

    return newScreenSide;
}