Example usage for android.graphics RectF height

List of usage examples for android.graphics RectF height

Introduction

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

Prototype

public final float height() 

Source Link

Usage

From source file:com.huyn.demogroup.leaveblank.PhotoViewAttacher.java

private boolean checkMatrixBounds() {

    final RectF rect = getDisplayRect(getDrawMatrix());
    if (rect == null) {
        return false;
    }/*w  ww  .j  a  va 2  s . c  o  m*/

    final float height = rect.height(), width = rect.width();
    float deltaX = 0, deltaY = 0;

    final int viewHeight = getImageViewHeight(mImageView);
    if (height <= viewHeight) {
        switch (mScaleType) {
        case FIT_START:
            deltaY = -rect.top;
            break;
        case FIT_END:
            deltaY = viewHeight - height - rect.top;
            break;
        default:
            deltaY = (viewHeight - height) / 2 - rect.top;
            break;
        }
    } else if (rect.top > 0) {
        deltaY = -rect.top;
    } else if (rect.bottom < viewHeight) {
        deltaY = viewHeight - rect.bottom;
    }

    final int viewWidth = getImageViewWidth(mImageView);
    if (width <= viewWidth) {
        switch (mScaleType) {
        case FIT_START:
            deltaX = -rect.left;
            break;
        case FIT_END:
            deltaX = viewWidth - width - rect.left;
            break;
        default:
            deltaX = (viewWidth - width) / 2 - rect.left;
            break;
        }
        mScrollEdge = EDGE_BOTH;
    } else if (rect.left > 0) {
        mScrollEdge = EDGE_LEFT;
        deltaX = -rect.left;
    } else if (rect.right < viewWidth) {
        deltaX = viewWidth - rect.right;
        mScrollEdge = EDGE_RIGHT;
    } else {
        mScrollEdge = EDGE_NONE;
    }

    // Finally actually translate the matrix
    if (!mStable) {
        System.out.println("+++++++++++deltaX:" + deltaX + "/deltaY:" + deltaY + "---" + getScale());
        mSuppMatrix.postTranslate(deltaX, deltaY);
    }
    return true;
}

From source file:de.vanita5.twittnuker.view.ColorPickerView.java

private Point hueToPoint(final float hue) {

    final RectF rect = mHueRect;
    final float height = rect.height();

    final Point p = new Point();

    p.y = (int) (height - hue * height / 360f + rect.top);
    p.x = (int) rect.left;

    return p;/*  w  w w . j  ava  2 s.c o m*/
}

From source file:de.vanita5.twittnuker.view.ColorPickerView.java

private Point satValToPoint(final float sat, final float val) {

    final RectF rect = mSatValRect;
    final float height = rect.height();
    final float width = rect.width();

    final Point p = new Point();

    p.x = (int) (sat * width + rect.left);
    p.y = (int) ((1f - val) * height + rect.top);

    return p;//from   www.  ja va  2 s .  co m
}

From source file:de.vanita5.twittnuker.view.ColorPickerView.java

private float pointToHue(float y) {

    final RectF rect = mHueRect;

    final float height = rect.height();

    if (y < rect.top) {
        y = 0f;// w w w  .  j  a  v a  2s .  co m
    } else if (y > rect.bottom) {
        y = height;
    } else {
        y = y - rect.top;
    }

    return 360f - y * 360f / height;
}

From source file:de.vanita5.twittnuker.view.ColorPickerView.java

private void setUpSatValRect() {

    final RectF dRect = mDrawingRect;
    float panelSide = dRect.height() - BORDER_WIDTH_PX * 2;

    if (mShowAlphaPanel) {
        panelSide -= PANEL_SPACING + ALPHA_PANEL_HEIGHT;
    }// w ww.j av  a 2  s. c om

    final float left = dRect.left + BORDER_WIDTH_PX;
    final float top = dRect.top + BORDER_WIDTH_PX;
    final float bottom = top + panelSide;
    final float right = left + panelSide;

    mSatValRect = new RectF(left, top, right, bottom);
}

From source file:com.goka.flickableview.ImageViewTouchBase.java

protected RectF getCenter(Matrix supportMatrix, boolean horizontal, boolean vertical) {
    final Drawable drawable = getDrawable();

    if (drawable == null) {
        return new RectF(0, 0, 0, 0);
    }//  w ww  .j a va2  s.com

    mCenterRect.set(0, 0, 0, 0);
    RectF rect = getBitmapRect(supportMatrix);
    float height = rect.height();
    float width = rect.width();
    float deltaX = 0, deltaY = 0;
    if (vertical) {
        if (height < mViewPort.height()) {
            deltaY = (mViewPort.height() - height) / 2 - (rect.top - mViewPort.top);
        } else if (rect.top > mViewPort.top) {
            deltaY = -(rect.top - mViewPort.top);
        } else if (rect.bottom < mViewPort.bottom) {
            deltaY = mViewPort.bottom - rect.bottom;
        }
    }
    if (horizontal) {
        if (width < mViewPort.width()) {
            deltaX = (mViewPort.width() - width) / 2 - (rect.left - mViewPort.left);
        } else if (rect.left > mViewPort.left) {
            deltaX = -(rect.left - mViewPort.left);
        } else if (rect.right < mViewPort.right) {
            deltaX = mViewPort.right - rect.right;
        }
    }
    mCenterRect.set(deltaX, deltaY, 0, 0);
    return mCenterRect;
}

From source file:com.frank.protean.photoview.PhotoViewAttacher.java

private boolean checkMatrixBounds() {

    final RectF rect = getDisplayRect(getDrawMatrix());
    if (rect == null) {
        return false;
    }//from w  w  w  . j  av a2  s. c  o m

    final float height = rect.height(), width = rect.width();
    float deltaX = 0, deltaY = 0;

    final int viewHeight = getImageViewHeight(mImageView);
    if (height <= viewHeight) {
        switch (mScaleType) {
        case FIT_START:
            deltaY = -rect.top;
            break;
        case FIT_END:
            deltaY = viewHeight - height - rect.top;
            break;
        default:
            deltaY = (viewHeight - height) / 2 - rect.top;
            break;
        }
    } else if (rect.top > 0) {
        deltaY = -rect.top;
    } else if (rect.bottom < viewHeight) {
        deltaY = viewHeight - rect.bottom;
    }

    final int viewWidth = getImageViewWidth(mImageView);
    if (width <= viewWidth) {
        switch (mScaleType) {
        case FIT_START:
            deltaX = -rect.left;
            break;
        case FIT_END:
            deltaX = viewWidth - width - rect.left;
            break;
        default:
            deltaX = (viewWidth - width) / 2 - rect.left;
            break;
        }
        mScrollEdge = EDGE_BOTH;
    } else if (rect.left > 0) {
        mScrollEdge = EDGE_LEFT;
        deltaX = -rect.left;
    } else if (rect.right < viewWidth) {
        deltaX = viewWidth - rect.right;
        mScrollEdge = EDGE_RIGHT;
    } else {
        mScrollEdge = EDGE_NONE;
    }

    // Finally actually translate the matrix
    mSuppMatrix.postTranslate(deltaX, deltaY);
    return true;
}

From source file:it.configure.imageloader.zoom.PhotoViewAttacher.java

private void checkMatrixBounds() {
    final ImageView imageView = getImageView();
    if (null == imageView) {
        return;/*www. j ava2  s .  c  om*/
    }

    final RectF rect = getDisplayRect(getDisplayMatrix());
    if (null == rect) {
        return;
    }

    final float height = rect.height(), width = rect.width();
    float deltaX = 0, deltaY = 0;

    final int viewHeight = imageView.getHeight();
    if (height <= viewHeight) {
        switch (mScaleType) {
        case FIT_START:
            deltaY = -rect.top;
            break;
        case FIT_END:
            deltaY = viewHeight - height - rect.top;
            break;
        default:
            deltaY = (viewHeight - height) / 2 - rect.top;
            break;
        }
    } else if (rect.top > 0) {
        deltaY = -rect.top;
    } else if (rect.bottom < viewHeight) {
        deltaY = viewHeight - rect.bottom;
    }

    final int viewWidth = imageView.getWidth();
    if (width <= viewWidth) {
        switch (mScaleType) {
        case FIT_START:
            deltaX = -rect.left;
            break;
        case FIT_END:
            deltaX = viewWidth - width - rect.left;
            break;
        default:
            deltaX = (viewWidth - width) / 2 - rect.left;
            break;
        }
        mScrollEdge = EDGE_BOTH;
    } else if (rect.left > 0) {
        mScrollEdge = EDGE_LEFT;
        deltaX = -rect.left;
    } else if (rect.right < viewWidth) {
        deltaX = viewWidth - rect.right;
        mScrollEdge = EDGE_RIGHT;
    } else {
        mScrollEdge = EDGE_NONE;
    }

    // Finally actually translate the matrix
    mSuppMatrix.postTranslate(deltaX, deltaY);
}

From source file:de.vanita5.twittnuker.view.ColorPickerView.java

private float[] pointToSatVal(float x, float y) {

    final RectF rect = mSatValRect;
    final float[] result = new float[2];

    final float width = rect.width();
    final float height = rect.height();

    if (x < rect.left) {
        x = 0f;/*from  w  ww  .  ja v  a  2s  .c  om*/
    } else if (x > rect.right) {
        x = width;
    } else {
        x = x - rect.left;
    }

    if (y < rect.top) {
        y = 0f;
    } else if (y > rect.bottom) {
        y = height;
    } else {
        y = y - rect.top;
    }

    result[0] = 1.f / width * x;
    result[1] = 1.f - 1.f / height * y;

    return result;
}

From source file:org.stockchart.StockChartView.java

public void resetPositions() {
    float y = 0f;
    float pxAutoHeight = this.getAreaAutoHeightInPixels();
    float pxWidth = this.getWidth();
    float pxHeight = this.getHeight();

    final float[] lr = getLeftRightMargins();

    for (Area a : fAreas) {
        if (!a.isVisible())
            continue;

        float height = a.isAutoHeight() ? pxAutoHeight : a.getHeightInPercents() * pxHeight;

        RectF rect = new RectF(0, y, pxWidth, y + height);

        a.setGlobalMargins(lr[0], lr[1]);

        a.setBounds(0f, rect.top, rect.width(), rect.height());

        y += height;//from   www .  j  a va  2s . c  o m
    }
}