Example usage for android.graphics RectF RectF

List of usage examples for android.graphics RectF RectF

Introduction

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

Prototype

public RectF(float left, float top, float right, float bottom) 

Source Link

Document

Create a new rectangle with the specified coordinates.

Usage

From source file:devlight.io.library.ArcProgressStackView.java

@Override
protected void onDraw(final Canvas canvas) {
    super.onDraw(canvas);

    // Save and rotate to start angle
    canvas.save();/*  w  ww  .  j a  v  a2  s.  c  o  m*/
    final float radius = mSize * 0.5F;
    canvas.rotate(mStartAngle, radius, radius);

    // Draw all of progress
    for (int i = 0; i < mModels.size(); i++) {
        final Model model = mModels.get(i);
        // Get progress for current model
        float progressFraction = mIsAnimated && !isInEditMode()
                ? (model.mLastProgress + (mAnimatedFraction * (model.getProgress() - model.mLastProgress)))
                        / MAX_PROGRESS
                : model.getProgress() / MAX_PROGRESS;
        if (i != mActionMoveModelIndex && mActionMoveModelIndex != ANIMATE_ALL_INDEX)
            progressFraction = model.getProgress() / MAX_PROGRESS;
        final float progress = progressFraction * mSweepAngle;

        // Check if model have gradient
        final boolean isGradient = model.getColors() != null;
        // Set width of progress
        mProgressPaint.setStrokeWidth(mProgressModelSize);

        // Set model arc progress
        model.mPath.reset();
        model.mPath.addArc(model.mBounds, 0.0F, progress);

        // Draw gradient progress or solid
        resetShadowLayer();
        mProgressPaint.setShader(null);
        mProgressPaint.setStyle(Paint.Style.STROKE);

        if (mIsModelBgEnabled) {
            //noinspection ResourceAsColor
            mProgressPaint.setColor(isInEditMode() ? mPreviewModelBgColor : model.getBgColor());
            canvas.drawArc(model.mBounds, 0.0F, mSweepAngle, false, mProgressPaint);
            if (!isInEditMode())
                mProgressPaint.clearShadowLayer();
        }

        // Check if gradient for draw shadow at first and then gradient progress
        if (isGradient) {
            if (!mIsModelBgEnabled) {
                canvas.drawPath(model.mPath, mProgressPaint);

                if (!isInEditMode())
                    mProgressPaint.clearShadowLayer();
            }

            mProgressPaint.setShader(model.mSweepGradient);
        } else
            mProgressPaint.setColor(model.getColor());

        // Here we draw main progress
        mProgressPaint.setAlpha(255);
        canvas.drawPath(model.mPath, mProgressPaint);

        // Preview mode
        if (isInEditMode())
            continue;

        // Get model title bounds
        mTextPaint.setTextSize(mProgressModelSize * 0.5F);
        mTextPaint.getTextBounds(model.getTitle(), 0, model.getTitle().length(), model.mTextBounds);

        // Draw title at start with offset
        final float titleHorizontalOffset = model.mTextBounds.height() * 0.5F;
        final float progressLength = (float) (Math.PI / 180.0F) * progress * model.mBounds.width() * 0.5F;
        final String title = (String) TextUtils.ellipsize(model.getTitle(), mTextPaint,
                progressLength - titleHorizontalOffset * 2, TextUtils.TruncateAt.END);
        canvas.drawTextOnPath(title, model.mPath, mIsRounded ? 0.0F : titleHorizontalOffset,
                titleHorizontalOffset, mTextPaint);

        // Get pos and tan at final path point
        model.mPathMeasure.setPath(model.mPath, false);
        model.mPathMeasure.getPosTan(model.mPathMeasure.getLength(), model.mPos, model.mTan);

        // Get title width
        final float titleWidth = model.mTextBounds.width();

        // Create model progress like : 23%
        final String percentProgress = String.format("%d%%", (int) model.getProgress());
        // Get progress text bounds
        mTextPaint.setTextSize(mProgressModelSize * 0.35f);
        mTextPaint.getTextBounds(percentProgress, 0, percentProgress.length(), model.mTextBounds);

        // Get pos tan with end point offset and check whether the rounded corners for offset
        final float progressHorizontalOffset = mIndicatorOrientation == IndicatorOrientation.VERTICAL
                ? model.mTextBounds.height() * 0.5F
                : model.mTextBounds.width() * 0.5F;
        final float indicatorProgressOffset = (mIsRounded ? progressFraction : 1.0F)
                * (-progressHorizontalOffset - titleHorizontalOffset
                        - (mIsRounded ? model.mTextBounds.height() * 2.0F : 0.0F));
        model.mPathMeasure.getPosTan(model.mPathMeasure.getLength() + indicatorProgressOffset, model.mPos,
                mIndicatorOrientation == IndicatorOrientation.VERTICAL && !mIsRounded ? new float[2]
                        : model.mTan);

        // Check if there available place for indicator
        if ((titleWidth + model.mTextBounds.height() + titleHorizontalOffset * 2.0F)
                - indicatorProgressOffset < progressLength) {
            // Get rotate indicator progress angle for progress value
            float indicatorProgressAngle = (float) (Math.atan2(model.mTan[1], model.mTan[0])
                    * (180.0F / Math.PI));
            // Get arc angle of progress indicator
            final float indicatorLengthProgressAngle = ((progressLength + indicatorProgressOffset)
                    / (model.mBounds.width() * 0.5F)) * (float) (180.0F / Math.PI);

            // Detect progress indicator position : left or right and then rotate
            if (mIndicatorOrientation == IndicatorOrientation.VERTICAL) {
                // Get X point of arc angle progress indicator
                final float x = (float) (model.mBounds.width() * 0.5F
                        * (Math.cos((indicatorLengthProgressAngle + mStartAngle) * Math.PI / 180.0F)))
                        + model.mBounds.centerX();
                indicatorProgressAngle += (x > radius) ? -90.0F : 90.0F;
            } else {
                // Get Y point of arc angle progress indicator
                final float y = (float) (model.mBounds.height() * 0.5F
                        * (Math.sin((indicatorLengthProgressAngle + mStartAngle) * Math.PI / 180.0F)))
                        + model.mBounds.centerY();
                indicatorProgressAngle += (y > radius) ? 180.0F : 0.0F;
            }

            // Draw progress value
            canvas.save();
            canvas.rotate(indicatorProgressAngle, model.mPos[0], model.mPos[1]);
            canvas.drawText(percentProgress, model.mPos[0] - model.mTextBounds.exactCenterX(),
                    model.mPos[1] - model.mTextBounds.exactCenterY(), mTextPaint);
            canvas.restore();
        }

        // Check if gradient and have rounded corners, because we must to create elevation effect
        // for start progress corner
        if ((isGradient || mIsLeveled) && mIsRounded && progress != 0) {
            model.mPathMeasure.getPosTan(0.0F, model.mPos, model.mTan);

            // Set paint for overlay rounded gradient with shadow
            setLevelShadowLayer();
            //noinspection ResourceAsColor
            mLevelPaint.setColor(isGradient ? model.getColors()[0] : model.getColor());

            // Get bounds of start pump
            final float halfSize = mProgressModelSize * 0.5F;
            final RectF arcRect = new RectF(model.mPos[0] - halfSize, model.mPos[1] - halfSize,
                    model.mPos[0] + halfSize, model.mPos[1] + halfSize + 2.0F);
            canvas.drawArc(arcRect, 0.0F, -180.0F, true, mLevelPaint);
        }
    }

    // Restore after drawing
    canvas.restore();
}

From source file:xiaofan.llongimageview.view.SubsamplingScaleImageView.java

/**
 * Loads the optimum tiles for display at the current scale and translate, so the screen can be filled with tiles
 * that are at least as high resolution as the screen. Frees up bitmaps that are now off the screen.
 * @param load Whether to load the new tiles needed. Use false while scrolling/panning for performance.
 */// www .  j ava  2 s  . c o  m
private void refreshRequiredTiles(boolean load) {
    int sampleSize = Math.min(fullImageSampleSize, calculateInSampleSize());
    RectF vVisRect = new RectF(0, 0, getWidth(), getHeight());
    RectF sVisRect = viewToSourceRect(vVisRect);

    // Load tiles of the correct sample size that are on screen. Discard tiles off screen, and those that are higher
    // resolution than required, or lower res than required but not the base layer, so the base layer is always present.
    for (Map.Entry<Integer, List<Tile>> tileMapEntry : tileMap.entrySet()) {
        for (Tile tile : tileMapEntry.getValue()) {
            if (tile.sampleSize < sampleSize
                    || (tile.sampleSize > sampleSize && tile.sampleSize != fullImageSampleSize)) {
                tile.visible = false;
                if (tile.bitmap != null) {
                    tile.bitmap.recycle();
                    tile.bitmap = null;
                }
            }
            if (tile.sampleSize == sampleSize) {
                if (RectF.intersects(sVisRect, convertRect(tile.sRect))) {
                    tile.visible = true;
                    if (!tile.loading && tile.bitmap == null && load) {
                        BitmapTileTask task = new BitmapTileTask(this, decoder, decoderLock, tile);
                        task.execute();
                    }
                } else if (tile.sampleSize != fullImageSampleSize) {
                    tile.visible = false;
                    if (tile.bitmap != null) {
                        tile.bitmap.recycle();
                        tile.bitmap = null;
                    }
                }
            } else if (tile.sampleSize == fullImageSampleSize) {
                tile.visible = true;
            }
        }
    }

}

From source file:com.bizcom.vc.widget.cus.SubsamplingScaleImageView.java

/**
 * Loads the optimum tiles for display at the current scale and translate,
 * so the screen can be filled with tiles that are at least as high
 * resolution as the screen. Frees up bitmaps that are now off the screen.
 * /*www  .j  av  a 2 s. c  o  m*/
 * @param load
 *            Whether to load the new tiles needed. Use false while
 *            scrolling/panning for performance.
 */
private void refreshRequiredTiles(boolean load) {
    int sampleSize = Math.min(fullImageSampleSize, calculateInSampleSize());
    RectF vVisRect = new RectF(0, 0, getWidth(), getHeight());
    RectF sVisRect = viewToSourceRect(vVisRect);

    // Load tiles of the correct sample size that are on screen. Discard
    // tiles off screen, and those that are higher
    // resolution than required, or lower res than required but not the base
    // layer, so the base layer is always present.
    for (Map.Entry<Integer, List<Tile>> tileMapEntry : tileMap.entrySet()) {
        for (Tile tile : tileMapEntry.getValue()) {
            if (tile.sampleSize < sampleSize
                    || (tile.sampleSize > sampleSize && tile.sampleSize != fullImageSampleSize)) {
                tile.visible = false;
                if (tile.bitmap != null) {
                    tile.bitmap.recycle();
                    tile.bitmap = null;
                }
            }
            if (tile.sampleSize == sampleSize) {
                if (RectF.intersects(sVisRect, convertRect(tile.sRect))) {
                    tile.visible = true;
                    if (!tile.loading && tile.bitmap == null && load) {
                        BitmapTileTask task = new BitmapTileTask(this, decoder, decoderLock, tile);
                        task.execute();
                    }
                } else if (tile.sampleSize != fullImageSampleSize) {
                    tile.visible = false;
                    if (tile.bitmap != null) {
                        tile.bitmap.recycle();
                        tile.bitmap = null;
                    }
                }
            } else if (tile.sampleSize == fullImageSampleSize) {
                tile.visible = true;
            }
        }
    }

}

From source file:com.nextgis.maplibui.overlay.EditLayerOverlay.java

protected Bitmap getMarker() {
    float scaledDensity = mContext.getResources().getDisplayMetrics().scaledDensity;
    int size = (int) (12 * scaledDensity);
    Bitmap marker = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888);
    Canvas c = new Canvas(marker);
    Paint p = new Paint(Paint.ANTI_ALIAS_FLAG);
    //noinspection deprecation
    p.setColor(mContext.getResources().getColor(R.color.accent));
    p.setAlpha(128);/* w  w  w .  j av a 2 s. c  om*/
    c.drawOval(new RectF(0, 0, size * 3 / 4, size * 3 / 4), p);
    return marker;
}

From source file:com.pdftron.pdf.tools.Tool.java

protected RectF getAnnotRect() {
    if (mAnnot != null) {
        double[] pts1 = mPDFView.convPagePtToScreenPt(mAnnotBBox.left, mAnnotBBox.bottom, mAnnotPageNum);
        double[] pts2 = mPDFView.convPagePtToScreenPt(mAnnotBBox.right, mAnnotBBox.top, mAnnotPageNum);
        return new RectF((float) pts1[0], (float) pts1[1], (float) pts2[0], (float) pts2[1]);
    } else {//from  w  w w  .j a v  a  2  s  .c om
        return null;
    }
}

From source file:com.pdftron.pdf.tools.Tool.java

public boolean showMenu(List<MenuEntry> menu_titles, RectF anchor_rect, List<MenuEntry> overflow_menu_titles) {
    if (anchor_rect == null) {
        return false;
    }// w ww . j ava  2 s.co m

    int menu_sz = menu_titles.size();
    if (menu_sz > 0) {
        if (mQuickMenu != null) {
            closeMenu();
            mQuickMenu = null;
        }

        RectF client_r = new RectF(0, 0, mPDFView.getWidth(), mPDFView.getHeight());
        if (!client_r.intersect(anchor_rect)) {
            return false;
        }

        View anchor = new View(mPDFView.getContext());
        anchor.setVisibility(View.INVISIBLE);

        RectF anchorRect = calculateQMAnchor(anchor_rect);
        int atop = (int) anchorRect.top;
        int abottom = (int) anchorRect.bottom;
        int aright = (int) anchorRect.right;
        int aleft = (int) anchorRect.left;

        anchor.layout(aleft, atop, aright, abottom);

        ToolManager toolManager = (ToolManager) mPDFView.getToolManager();

        toolManager.setQuickMenuJustClosed(false);

        mQuickMenu = new QuickMenu(anchor, atop, aleft, abottom, aright, menu_titles, overflow_menu_titles,
                toolManager, new PopupWindow.OnDismissListener() {
                    public void onDismiss() {
                        if (mPDFView.getToolManager() instanceof ToolManager) {
                            ((ToolManager) mPDFView.getToolManager()).setQuickMenuJustClosed(true);
                        }
                        // When dismissed, trigger the menu-clicked call-back function.
                        mMenuShown = false;
                        if (mQuickMenu != null) {
                            int selected = mQuickMenu.getSelectedId();
                            if (selected >= 0) {
                                com.pdftron.pdf.utils.AnalyticsHandlerAdapter.getInstance().sendEvent(
                                        AnalyticsHandlerAdapter.CATEGORY_QUICKTOOL,
                                        mQuickMenu.getSelectedType() + " selected");

                                onQuickMenuClicked(selected, mQuickMenu.getSelectedType());
                            }
                        }
                    }
                }, mPDFView.isHardwareAccelerated());
        //adriaan
        if (!ToolManager.isPenMarkActive && !ToolManager.isRedHighlight && !ToolManager.isGreenHighlight) {
            mQuickMenu.show();
            mMenuShown = true;
            return true;
        } else {
            ToolManager.isRedHighlight = false;
            ToolManager.isGreenHighlight = false;
            return false;
        }
    }
    return false;
}

From source file:com.ape.camera2raw.Camera2RawFragment.java

/**
 * Configure the necessary {@link Matrix} transformation to `mTextureView`,
 * and start/restart the preview capture session if necessary.
 * <p/>// ww w  .  j av a 2  s.  c  o  m
 * This method should be called after the camera state has been initialized in
 * setUpCameraOutputs.
 *
 * @param viewWidth  The width of `mTextureView`
 * @param viewHeight The height of `mTextureView`
 */
private void configureTransform(int viewWidth, int viewHeight) {
    Activity activity = getActivity();
    synchronized (mCameraStateLock) {
        if (null == mTextureView || null == activity) {
            return;
        }

        StreamConfigurationMap map = mCharacteristics
                .get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);

        // For still image captures, we always use the largest available size.
        Size largestJpeg = Collections.max(Arrays.asList(map.getOutputSizes(ImageFormat.JPEG)),
                new CompareSizesByArea());

        // Find the rotation of the device relative to the native device orientation.
        int deviceRotation = activity.getWindowManager().getDefaultDisplay().getRotation();
        Point displaySize = new Point();
        activity.getWindowManager().getDefaultDisplay().getSize(displaySize);

        // Find the rotation of the device relative to the camera sensor's orientation.
        int totalRotation = sensorToDeviceRotation(mCharacteristics, deviceRotation);

        // Swap the view dimensions for calculation as needed if they are rotated relative to
        // the sensor.
        boolean swappedDimensions = totalRotation == 90 || totalRotation == 270;
        int rotatedViewWidth = viewWidth;
        int rotatedViewHeight = viewHeight;
        int maxPreviewWidth = displaySize.x;
        int maxPreviewHeight = displaySize.y;

        if (swappedDimensions) {
            rotatedViewWidth = viewHeight;
            rotatedViewHeight = viewWidth;
            maxPreviewWidth = displaySize.y;
            maxPreviewHeight = displaySize.x;
        }

        // Preview should not be larger than display size and 1080p.
        if (maxPreviewWidth > MAX_PREVIEW_WIDTH) {
            maxPreviewWidth = MAX_PREVIEW_WIDTH;
        }

        if (maxPreviewHeight > MAX_PREVIEW_HEIGHT) {
            maxPreviewHeight = MAX_PREVIEW_HEIGHT;
        }

        // Find the best preview size for these view dimensions and configured JPEG size.
        Size previewSize = chooseOptimalSize(map.getOutputSizes(SurfaceTexture.class), rotatedViewWidth,
                rotatedViewHeight, maxPreviewWidth, maxPreviewHeight, largestJpeg);

        if (swappedDimensions) {
            mTextureView.setAspectRatio(previewSize.getHeight(), previewSize.getWidth());
        } else {
            mTextureView.setAspectRatio(previewSize.getWidth(), previewSize.getHeight());
        }

        // Find rotation of device in degrees (reverse device orientation for front-facing
        // cameras).
        int rotation = (mCharacteristics
                .get(CameraCharacteristics.LENS_FACING) == CameraCharacteristics.LENS_FACING_FRONT)
                        ? (360 + ORIENTATIONS.get(deviceRotation)) % 360
                        : (360 - ORIENTATIONS.get(deviceRotation)) % 360;

        Matrix matrix = new Matrix();
        RectF viewRect = new RectF(0, 0, viewWidth, viewHeight);
        RectF bufferRect = new RectF(0, 0, previewSize.getHeight(), previewSize.getWidth());
        float centerX = viewRect.centerX();
        float centerY = viewRect.centerY();

        // Initially, output stream images from the Camera2 API will be rotated to the native
        // device orientation from the sensor's orientation, and the TextureView will default to
        // scaling these buffers to fill it's view bounds.  If the aspect ratios and relative
        // orientations are correct, this is fine.
        //
        // However, if the device orientation has been rotated relative to its native
        // orientation so that the TextureView's dimensions are swapped relative to the
        // native device orientation, we must do the following to ensure the output stream
        // images are not incorrectly scaled by the TextureView:
        //   - Undo the scale-to-fill from the output buffer's dimensions (i.e. its dimensions
        //     in the native device orientation) to the TextureView's dimension.
        //   - Apply a scale-to-fill from the output buffer's rotated dimensions
        //     (i.e. its dimensions in the current device orientation) to the TextureView's
        //     dimensions.
        //   - Apply the rotation from the native device orientation to the current device
        //     rotation.
        if (Surface.ROTATION_90 == deviceRotation || Surface.ROTATION_270 == deviceRotation) {
            bufferRect.offset(centerX - bufferRect.centerX(), centerY - bufferRect.centerY());
            matrix.setRectToRect(viewRect, bufferRect, Matrix.ScaleToFit.FILL);
            float scale = Math.max((float) viewHeight / previewSize.getHeight(),
                    (float) viewWidth / previewSize.getWidth());
            matrix.postScale(scale, scale, centerX, centerY);

        }
        matrix.postRotate(rotation, centerX, centerY);

        mTextureView.setTransform(matrix);

        // Start or restart the active capture session if the preview was initialized or
        // if its aspect ratio changed significantly.
        if (mPreviewSize == null || !checkAspectsEqual(previewSize, mPreviewSize)) {
            mPreviewSize = previewSize;
            if (mState != STATE_CLOSED) {
                createCameraPreviewSessionLocked();
            }
        }
    }
}

From source file:com.pdftron.pdf.tools.Tool.java

public RectF calculateQMAnchor(RectF anchor_rect) {
    if (anchor_rect != null) {
        int left = (int) anchor_rect.left;
        int top = (int) anchor_rect.top;
        int right = (int) anchor_rect.right;
        int bottom = (int) anchor_rect.bottom;

        try {/*from   www .  j  av a 2 s .co  m*/
            // normalize the rect
            com.pdftron.pdf.Rect rect = new com.pdftron.pdf.Rect((double) anchor_rect.left,
                    (double) anchor_rect.top, (double) anchor_rect.right, (double) anchor_rect.bottom);
            rect.normalize();
            left = (int) rect.getX1();
            top = (int) rect.getY1();
            right = (int) rect.getX2();
            bottom = (int) rect.getY2();
        } catch (PDFNetException e) {
        }

        int[] location = new int[2];
        mPDFView.getLocationInWindow(location);

        int atop = top + location[1];
        int aleft = left + location[0];
        int aright = right + location[0];
        int abottom = bottom + location[1];

        RectF qmAnchor = new RectF(aleft, atop, aright, abottom);
        return qmAnchor;
    }
    return null;
}

From source file:com.pdftron.pdf.tools.Tool.java

/**
 * Gets a rectangle to use when selecting text.
 *//*w ww. j  av  a2 s .  c o m*/
protected RectF getTextSelectRect(float x, float y) {
    float delta = 0.5f;
    float x2 = x + delta;
    float y2 = y + delta;
    delta *= 2;
    float x1 = x2 - delta >= 0 ? x2 - delta : 0;
    float y1 = y2 - delta >= 0 ? y2 - delta : 0;

    return new RectF(x1, y1, x2, y2);
}

From source file:com.lt.adamlee.aagame.GameView.java

public boolean onTouchEvent(MotionEvent event) {
    int i;/*w w  w .  j av a2s.c  o  m*/
    int j;
    if (mainpage == -1 && event.getAction() == 1) {
        this.touchx = (int) event.getX();
        this.touchy = (int) event.getY();
        if (new Rect(screenW / 16,
                (int) (((double) ((screenH * 5) / 8)) - (1.5d * ((double) ExitGame.exittextsize))),
                (int) (((float) (screenW / 6))
                        + (ExitGame.pcolored.measureText(ctx.getString(R.string.yes)) / 2.0f)),
                (int) (((double) ((screenH * 5) / 8)) + (0.5d * ((double) ExitGame.exittextsize))))
                        .contains((int) event.getX(), (int) event.getY())) {
            System.exit(0);
        }
        if (new Rect(
                (int) (((float) (screenW - (screenW / 5)))
                        - (ExitGame.pcolored.measureText(ctx.getString(R.string.cancel)) / 2.0f)),
                (int) (((double) ((screenH * 5) / 8)) - (1.5d * ((double) ExitGame.exittextsize))),
                screenW - (screenW / 16),
                (int) (((double) ((screenH * 5) / 8)) + (0.5d * ((double) ExitGame.exittextsize))))
                        .contains((int) event.getX(), (int) event.getY())) {
            mainpage = 1;
            reset();
        }
        if (new Rect(
                (int) (((float) (screenW / 2))
                        - (ExitGame.pcolored.measureText(ctx.getString(R.string.rateit)) / 2.0f)),
                (int) (((double) ((screenH * 5) / 8)) - (1.5d * ((double) ExitGame.exittextsize))),
                (int) (((float) (screenW / 2))
                        + (ExitGame.pcolored.measureText(ctx.getString(R.string.rateit)) / 2.0f)),
                (int) (((double) ((screenH * 5) / 8)) + (0.5d * ((double) ExitGame.exittextsize))))
                        .contains((int) event.getX(), (int) event.getY())) {
            ctx.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(DefaultData.RateUrl)));
        }
    }
    if (!bak2) {
        if (mainpage == 1) {
            errorcircle = false;
            linecounter = NoOfInitialLines - 1;
            for (i = 0; i < NoOfInitialLines; i++) {
                blinedraw[i] = true;
            }
            for (i = 0; i < rotation.length; i++) {
                rotation[i] = 0.0f;
            }
            for (i = 0; i < NoOfInitialLines; i++) {
                rotation[i] = (float) ((i + 1) * (360 / NoOfInitialLines));
                if (rotation[i] > 360.0f) {
                    rotation[i] = rotation[i] - 360.0f;
                }
            }
            if (!bak4 && event.getAction() == 0) {
                this.touchx = (int) event.getX();
                this.touchy = (int) event.getY();
                if (new RectF(F.wf(110.0f), F.hf(175.0f), F.wf(110.0f) + ((float) ((int) F.wf(90.0f))),
                        F.hf(175.0f) + ((float) ((int) F.wf(90.0f)))).contains((float) this.touchx,
                                (float) this.touchy)) {
                    levelcounter = GameActivity.gameLevel;
                    mainpage = 3;
                    //                        GameActivity.vimapad.isBottomAdVisible(true);
                    //                        GameActivity.vimapad.isTopAdVisible(false);
                    Circle.bak1 = true;
                }
            }
        }
        if (!bak4 && mainpage == 1 && event.getAction() == 0) {
            this.touchx = (int) event.getX();
            this.touchy = (int) event.getY();
            if (new Rect((int) F.wf(45.0f), (int) F.hf(340.0f), ((int) F.wf(85.0f)) + ((int) F.wf(70.0f)),
                    ((int) F.hf(340.0f)) + ((int) F.wf(70.0f))).contains(this.touchx, this.touchy)) {
                ctx.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(DefaultData.defaultUrl)));
            }
        }
    }
    if (!bak4 && mainpage == 1 && event.getAction() == 0) {
        this.touchx = (int) event.getX();
        this.touchy = (int) event.getY();
        if (new Rect((int) F.wf(130.0f), (int) F.hf(340.0f), ((int) F.wf(165.0f)) + ((int) F.wf(70.0f)),
                ((int) F.hf(340.0f)) + ((int) F.wf(70.0f))).contains(this.touchx, this.touchy)) {
            mainpage = 5;
        }
    }
    if (!bak4 && mainpage == 1 && event.getAction() == 0) {
        this.leaderx = (int) event.getX();
        this.leadery = (int) event.getY();
        if (new Rect((int) F.wf(215.0f), (int) F.hf(340.0f), ((int) F.wf(246.0f)) + ((int) F.wf(70.0f)),
                ((int) F.hf(340.0f)) + ((int) F.wf(70.0f))).contains(this.leaderx, this.leadery)) {
            GameActivity start = (GameActivity) ctx;
            //                start.checkGooglPlayService();
            //                start.beginUserInitiatedSignIn();
            //                start.onShowLeaderboardsRequested();
        }
    }
    if (Levelfailedanimation.holdanim >= 5 && mainpage == 6) {
        if (event.getAction() == 0) {
            this.animx = (int) event.getX();
            this.animy = (int) event.getY();
            if (new Rect((int) F.wf(140.0f), (int) F.hf(210.0f), (int) F.wf(190.0f), (int) F.hf(260.0f))
                    .contains(this.animx, this.animy)) {
                mainpage = 3;
                //                    GameActivity.vimapad.isBottomAdVisible(true);
                //                    GameActivity.vimapad.isTopAdVisible(false);
                circleblink = false;
                reset();
                errorcircle = false;
                linecounter = NoOfInitialLines - 1;
                for (j = 0; j < NoOfInitialLines; j++) {
                    blinedraw[j] = true;
                }
                for (j = 0; j < rotation.length; j++) {
                    rotation[j] = 0.0f;
                }
                for (j = 0; j < NoOfInitialLines; j++) {
                    rotation[j] = (float) ((j + 1) * (360 / NoOfInitialLines));
                    if (rotation[j] > 360.0f) {
                        rotation[j] = rotation[j] - 360.0f;
                    }
                    baka = true;
                    this.bakc = true;
                }
            }
        }
        if (event.getAction() == 1) {
            this.choosex = (int) event.getX();
            this.choosey = (int) event.getY();
            if (new Rect((int) F.wf(85.0f), (int) F.hf(290.0f), (int) F.wf(235.0f), (int) F.hf(310.0f))
                    .contains(this.choosex, this.choosey)) {
                //                    GameActivity.vimapad.isBottomAdVisible(true);
                //                    GameActivity.vimapad.isTopAdVisible(false);
                Levelfailedanimation.showtransparencyflag = false;
                Levelfailedanimation.holdlevelanim = 0;
                Levelfailedanimation.holdanim = 0;
                for (i = 0; i < Levelfailedanimation.animboolean.length; i++) {
                    Levelfailedanimation.animboolean[i] = false;
                }
                Levelfailedanimation.showtransparencyflag = false;
                mainpage = 7;
                baka = true;
                this.bakc = true;
            }
        }
    }
    if (!(baka || circleblink || colcircle || mainpage != 3 || Circle.bak1 || event.getAction() != 0)) {
        this.downx = (int) event.getX();
        this.downy = (int) event.getY();
        if (new RectF(0.0f, 0.0f, (float) (screenW + 0), ((float) (screenH / 2)) + F.hf(200.0f))
                .contains((float) this.downx, (float) this.downy)) {
            GameActivity mainActivity;
            linecounter++;
            if (!levelfailed) {
                circledrawboolean[linecounter] = true;
            }
            if (Circle.counter > (-Circle.var)) {
                Circle.value--;
            }
            if (linecounter > 0) {
                j = 0;
                while (j < linecounter) {
                    if ((rotation[j] >= 0.0f && ((rotation[j] < 180.0f
                            && getDistance(Math.abs((F.hf(272.0f) - F.hf(105.0f)) - F.hf(272.0f)) + F.wf(10.0f),
                                    rotation[j]) < ((double) (2.0f * F.wf(10.0f))))
                            || (rotation[j] > 180.0f && getDistance(
                                    Math.abs((F.hf(272.0f) - F.hf(105.0f)) - F.hf(272.0f)) + F.wf(10.0f),
                                    360.0f - rotation[j]) < ((double) (2.0f * F.wf(10.0f))))))
                            || (rotation[j] < 0.0f && ((rotation[j] > -180.0f && getDistance(
                                    Math.abs((F.hf(272.0f) - F.hf(105.0f)) - F.hf(272.0f)) + F.wf(10.0f),
                                    Math.abs(rotation[j])) < ((double) (2.0f * F.wf(10.0f))))
                                    || (rotation[j] < -180.0f && getDistance(
                                            Math.abs((F.hf(272.0f) - F.hf(105.0f)) - F.hf(272.0f))
                                                    + F.wf(10.0f),
                                            360.0f - Math
                                                    .abs(rotation[j])) < ((double) (2.0f * F.wf(10.0f))))))) {
                        errorcircle = true;
                        circleblink = true;
                    }
                    mainActivity = (GameActivity) ctx;
                    mainActivity.saveState();
                    mainActivity.getState();
                    j++;
                }
            }
            if (!circleblink && Circle.value == (-Circle.var)) {
                errorcircle = true;
                colcircle = true;
                //                    GameActivity.vimapad.isBottomAdVisible(true);
                //                    GameActivity.vimapad.isTopAdVisible(false);
                Circle.blink = true;
                if (levelcounter == 202) {
                    levelcounter = 1;
                }
                mainActivity = (GameActivity) ctx;
                mainActivity.saveState();
                mainActivity.getState();
            }
            bak2 = true;
        }
    }
    if (mainpage == 7 && !this.bakc) {
        this.level.onTouchEvent(event);
    }
    return true;
}