• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AspectRatioUtil类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.edmodo.cropper.util.AspectRatioUtil的典型用法代码示例。如果您正苦于以下问题:Java AspectRatioUtil类的具体用法?Java AspectRatioUtil怎么用?Java AspectRatioUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AspectRatioUtil类属于com.edmodo.cropper.util包,在下文中一共展示了AspectRatioUtil类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: a

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
void a(float f, float f1, float f2, Rect rect, float f3)
{
    a.adjustCoordinate(f, f1, rect, f3, f2);
    float f4 = Edge.LEFT.getCoordinate();
    float f5 = Edge.TOP.getCoordinate();
    float f6 = Edge.RIGHT.getCoordinate();
    float f7 = (AspectRatioUtil.calculateWidth(f5, Edge.BOTTOM.getCoordinate(), f2) - (f6 - f4)) / 2.0F;
    float f8 = f4 - f7;
    float f9 = f7 + f6;
    Edge.LEFT.setCoordinate(f8);
    Edge.RIGHT.setCoordinate(f9);
    if (Edge.LEFT.isOutsideMargin(rect, f3) && !a.isNewRectangleOutOfBounds(Edge.LEFT, rect, f2))
    {
        float f11 = Edge.LEFT.snapToRect(rect);
        Edge.RIGHT.offset(-f11);
        a.adjustCoordinate(f2);
    }
    if (Edge.RIGHT.isOutsideMargin(rect, f3) && !a.isNewRectangleOutOfBounds(Edge.RIGHT, rect, f2))
    {
        float f10 = Edge.RIGHT.snapToRect(rect);
        Edge.LEFT.offset(-f10);
        a.adjustCoordinate(f2);
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:25,代码来源:d.java


示例2: a

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
void a(float f, float f1, float f2, Rect rect, float f3)
{
    a.adjustCoordinate(f, f1, rect, f3, f2);
    float f4 = Edge.LEFT.getCoordinate();
    float f5 = Edge.TOP.getCoordinate();
    float f6 = Edge.RIGHT.getCoordinate();
    float f7 = Edge.BOTTOM.getCoordinate();
    float f8 = (AspectRatioUtil.calculateHeight(f4, f6, f2) - (f7 - f5)) / 2.0F;
    float f9 = f5 - f8;
    float f10 = f8 + f7;
    Edge.TOP.setCoordinate(f9);
    Edge.BOTTOM.setCoordinate(f10);
    if (Edge.TOP.isOutsideMargin(rect, f3) && !a.isNewRectangleOutOfBounds(Edge.TOP, rect, f2))
    {
        float f12 = Edge.TOP.snapToRect(rect);
        Edge.BOTTOM.offset(-f12);
        a.adjustCoordinate(f2);
    }
    if (Edge.BOTTOM.isOutsideMargin(rect, f3) && !a.isNewRectangleOutOfBounds(Edge.BOTTOM, rect, f2))
    {
        float f11 = Edge.BOTTOM.snapToRect(rect);
        Edge.TOP.offset(-f11);
        a.adjustCoordinate(f2);
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:26,代码来源:e.java


示例3: initCropWindowWithFixedAspectRatio

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
private void initCropWindowWithFixedAspectRatio(@NonNull RectF bitmapRect) {

        // If the image aspect ratio is wider than the crop aspect ratio,
        // then the image height is the determining initial length. Else, vice-versa.
        if (AspectRatioUtil.calculateAspectRatio(bitmapRect) > getTargetAspectRatio()) {

            final float cropWidth = AspectRatioUtil.calculateWidth(bitmapRect.height(), getTargetAspectRatio());

            Edge.LEFT.setCoordinate(bitmapRect.centerX() - cropWidth / 2f);
            Edge.TOP.setCoordinate(bitmapRect.top);
            Edge.RIGHT.setCoordinate(bitmapRect.centerX() + cropWidth / 2f);
            Edge.BOTTOM.setCoordinate(bitmapRect.bottom);

        } else {

            final float cropHeight = AspectRatioUtil.calculateHeight(bitmapRect.width(), getTargetAspectRatio());

            Edge.LEFT.setCoordinate(bitmapRect.left);
            Edge.TOP.setCoordinate(bitmapRect.centerY() - cropHeight / 2f);
            Edge.RIGHT.setCoordinate(bitmapRect.right);
            Edge.BOTTOM.setCoordinate(bitmapRect.centerY() + cropHeight / 2f);
        }
    }
 
开发者ID:edmodo,项目名称:cropper,代码行数:24,代码来源:CropImageView.java


示例4: getAspectRatio

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
/**
 * Gets the aspect ratio of the resulting crop window if this handle were
 * dragged to the given point.
 *
 * @param x the x-coordinate
 * @param y the y-coordinate
 * @return the aspect ratio
 */
private float getAspectRatio(float x, float y) {

    // Replace the active edge coordinate with the given touch coordinate.
    final float left = (mVerticalEdge == Edge.LEFT) ? x : Edge.LEFT.getCoordinate();
    final float top = (mHorizontalEdge == Edge.TOP) ? y : Edge.TOP.getCoordinate();
    final float right = (mVerticalEdge == Edge.RIGHT) ? x : Edge.RIGHT.getCoordinate();
    final float bottom = (mHorizontalEdge == Edge.BOTTOM) ? y : Edge.BOTTOM.getCoordinate();

    final float aspectRatio = AspectRatioUtil.calculateAspectRatio(left, top, right, bottom);

    return aspectRatio;
}
 
开发者ID:g82,项目名称:open-mygirl-android-gradle,代码行数:21,代码来源:HandleHelper.java


示例5: getAspectRatio

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
/**
 * Gets the aspect ratio of the resulting crop window if this handle were
 * dragged to the given point.
 * 
 * @param x the x-coordinate
 * @param y the y-coordinate
 * @return the aspect ratio
 */
private float getAspectRatio(float x, float y) {

    // Replace the active edge coordinate with the given touch coordinate.
    final float left = (mVerticalEdge == Edge.LEFT) ? x : Edge.LEFT.getCoordinate();
    final float top = (mHorizontalEdge == Edge.TOP) ? y : Edge.TOP.getCoordinate();
    final float right = (mVerticalEdge == Edge.RIGHT) ? x : Edge.RIGHT.getCoordinate();
    final float bottom = (mHorizontalEdge == Edge.BOTTOM) ? y : Edge.BOTTOM.getCoordinate();

    final float aspectRatio = AspectRatioUtil.calculateAspectRatio(left, top, right, bottom);

    return aspectRatio;
}
 
开发者ID:wangeason,项目名称:PhotoViewCropper,代码行数:21,代码来源:HandleHelper.java


示例6: a

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
private float a(float f, float f1)
{
    float f2;
    float f3;
    if (c == Edge.LEFT)
    {
        f2 = f;
    } else
    {
        f2 = Edge.LEFT.getCoordinate();
    }
    if (b == Edge.TOP)
    {
        f3 = f1;
    } else
    {
        f3 = Edge.TOP.getCoordinate();
    }
    if (c != Edge.RIGHT)
    {
        f = Edge.RIGHT.getCoordinate();
    }
    if (b != Edge.BOTTOM)
    {
        f1 = Edge.BOTTOM.getCoordinate();
    }
    return AspectRatioUtil.calculateAspectRatio(f2, f3, f, f1);
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:29,代码来源:c.java


示例7: adjustCoordinate

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
public void adjustCoordinate(float f)
{
    float f1 = LEFT.getCoordinate();
    float f2 = TOP.getCoordinate();
    float f3 = RIGHT.getCoordinate();
    float f4 = BOTTOM.getCoordinate();
    switch (a.a[ordinal()])
    {
    default:
        return;

    case 1: // '\001'
        a = AspectRatioUtil.calculateLeft(f2, f3, f4, f);
        return;

    case 2: // '\002'
        a = AspectRatioUtil.calculateTop(f1, f3, f4, f);
        return;

    case 3: // '\003'
        a = AspectRatioUtil.calculateRight(f1, f2, f4, f);
        return;

    case 4: // '\004'
        a = AspectRatioUtil.calculateBottom(f1, f2, f3, f);
        break;
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:29,代码来源:Edge.java


示例8: getAspectRatio

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
/**
 * Gets the aspect ratio of the resulting crop window if this handle were dragged to the given
 * point.
 *
 * @param x the x-coordinate
 * @param y the y-coordinate
 *
 * @return the aspect ratio
 */
private float getAspectRatio(float x, float y) {

    // Replace the active edge coordinate with the given touch coordinate.
    final float left = (mVerticalEdge == Edge.LEFT) ? x : Edge.LEFT.getCoordinate();
    final float top = (mHorizontalEdge == Edge.TOP) ? y : Edge.TOP.getCoordinate();
    final float right = (mVerticalEdge == Edge.RIGHT) ? x : Edge.RIGHT.getCoordinate();
    final float bottom = (mHorizontalEdge == Edge.BOTTOM) ? y : Edge.BOTTOM.getCoordinate();

    return AspectRatioUtil.calculateAspectRatio(left, top, right, bottom);
}
 
开发者ID:edmodo,项目名称:cropper,代码行数:20,代码来源:HandleHelper.java


示例9: initCropWindow

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
/**
 * Set the initial crop window size and position. This is dependent on the
 * size and position of the image being cropped.
 *
 * @param bitmapRect the bounding box around the image being cropped
 */
private void initCropWindow(Rect bitmapRect) {

    // Tells the attribute functions the crop window has already been
    // initialized
    if (initializedCropWindow == false)
        initializedCropWindow = true;

    if (mFixAspectRatio) {

        // If the image aspect ratio is wider than the crop aspect ratio,
        // then the image height is the determining initial length. Else,
        // vice-versa.
        if (AspectRatioUtil.calculateAspectRatio(bitmapRect) > mTargetAspectRatio) {

            Edge.TOP.setCoordinate(bitmapRect.top);
            Edge.BOTTOM.setCoordinate(bitmapRect.bottom);

            final float centerX = getWidth() / 2f;

            // Limits the aspect ratio to no less than 40 wide or 40 tall
            final float cropWidth = Math.max(Edge.MIN_CROP_LENGTH_PX,
                    AspectRatioUtil.calculateWidth(Edge.TOP.getCoordinate(),
                            Edge.BOTTOM.getCoordinate(),
                            mTargetAspectRatio));

            // Create new TargetAspectRatio if the original one does not fit
            // the screen
            if (cropWidth == Edge.MIN_CROP_LENGTH_PX)
                mTargetAspectRatio = (Edge.MIN_CROP_LENGTH_PX) / (Edge.BOTTOM.getCoordinate() - Edge.TOP.getCoordinate());

            final float halfCropWidth = cropWidth / 2f;
            Edge.LEFT.setCoordinate(centerX - halfCropWidth);
            Edge.RIGHT.setCoordinate(centerX + halfCropWidth);

        } else {

            Edge.LEFT.setCoordinate(bitmapRect.left);
            Edge.RIGHT.setCoordinate(bitmapRect.right);

            final float centerY = getHeight() / 2f;

            // Limits the aspect ratio to no less than 40 wide or 40 tall
            final float cropHeight = Math.max(Edge.MIN_CROP_LENGTH_PX,
                    AspectRatioUtil.calculateHeight(Edge.LEFT.getCoordinate(),
                            Edge.RIGHT.getCoordinate(),
                            mTargetAspectRatio));

            // Create new TargetAspectRatio if the original one does not fit
            // the screen
            if (cropHeight == Edge.MIN_CROP_LENGTH_PX)
                mTargetAspectRatio = (Edge.RIGHT.getCoordinate() - Edge.LEFT.getCoordinate()) / Edge.MIN_CROP_LENGTH_PX;

            final float halfCropHeight = cropHeight / 2f;
            Edge.TOP.setCoordinate(centerY - halfCropHeight);
            Edge.BOTTOM.setCoordinate(centerY + halfCropHeight);
        }

    } else { // ... do not fix aspect ratio...

        // Initialize crop window to have 10% padding w/ respect to image.
        final float horizontalPadding = 0.1f * bitmapRect.width();
        final float verticalPadding = 0.1f * bitmapRect.height();

        Edge.LEFT.setCoordinate(bitmapRect.left + horizontalPadding);
        Edge.TOP.setCoordinate(bitmapRect.top + verticalPadding);
        Edge.RIGHT.setCoordinate(bitmapRect.right - horizontalPadding);
        Edge.BOTTOM.setCoordinate(bitmapRect.bottom - verticalPadding);
    }
}
 
开发者ID:g82,项目名称:open-mygirl-android-gradle,代码行数:76,代码来源:CropOverlayView.java


示例10: initCropWindow

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
/**
 * Set the initial crop window size and position. This is dependent on the
 * size and position of the image being cropped.
 * 
 * @param bitmapRect the bounding box around the image being cropped
 */
private void initCropWindow(Rect bitmapRect) {

    // Tells the attribute functions the crop window has already been
    // initialized
    if (initializedCropWindow == false)
        initializedCropWindow = true;

    if (mFixAspectRatio) {

        // If the image aspect ratio is wider than the crop aspect ratio,
        // then the image height is the determining initial length. Else,
        // vice-versa.
        if (AspectRatioUtil.calculateAspectRatio(bitmapRect) > mTargetAspectRatio) {

            Edge.TOP.setCoordinate(bitmapRect.top);
            Edge.BOTTOM.setCoordinate(bitmapRect.bottom);

            final float centerX = getWidth() / 2f;

            // Limits the aspect ratio to no less than 40 wide or 40 tall
            final float cropWidth = Math.max(Edge.MIN_CROP_LENGTH_PX,
                                             AspectRatioUtil.calculateWidth(Edge.TOP.getCoordinate(),
                                                                            Edge.BOTTOM.getCoordinate(),
                                                                            mTargetAspectRatio));

            // Create new TargetAspectRatio if the original one does not fit
            // the screen
            if (cropWidth == Edge.MIN_CROP_LENGTH_PX)
                mTargetAspectRatio = (Edge.MIN_CROP_LENGTH_PX) / (Edge.BOTTOM.getCoordinate() - Edge.TOP.getCoordinate());

            final float halfCropWidth = cropWidth / 2f;
            Edge.LEFT.setCoordinate(centerX - halfCropWidth);
            Edge.RIGHT.setCoordinate(centerX + halfCropWidth);

        } else {

            Edge.LEFT.setCoordinate(bitmapRect.left);
            Edge.RIGHT.setCoordinate(bitmapRect.right);

            final float centerY = getHeight() / 2f;

            // Limits the aspect ratio to no less than 40 wide or 40 tall
            final float cropHeight = Math.max(Edge.MIN_CROP_LENGTH_PX,
                                              AspectRatioUtil.calculateHeight(Edge.LEFT.getCoordinate(),
                                                                              Edge.RIGHT.getCoordinate(),
                                                                              mTargetAspectRatio));

            // Create new TargetAspectRatio if the original one does not fit
            // the screen
            if (cropHeight == Edge.MIN_CROP_LENGTH_PX)
                mTargetAspectRatio = (Edge.RIGHT.getCoordinate() - Edge.LEFT.getCoordinate()) / Edge.MIN_CROP_LENGTH_PX;

            final float halfCropHeight = cropHeight / 2f;
            Edge.TOP.setCoordinate(centerY - halfCropHeight);
            Edge.BOTTOM.setCoordinate(centerY + halfCropHeight);
        }

    } else { // ... do not fix aspect ratio...

        // Initialize crop window to have 10% padding w/ respect to image.
        final float horizontalPadding = 0.1f * bitmapRect.width();
        final float verticalPadding = 0.1f * bitmapRect.height();

        Edge.LEFT.setCoordinate(bitmapRect.left + horizontalPadding);
        Edge.TOP.setCoordinate(bitmapRect.top + verticalPadding);
        Edge.RIGHT.setCoordinate(bitmapRect.right - horizontalPadding);
        Edge.BOTTOM.setCoordinate(bitmapRect.bottom - verticalPadding);
    }
}
 
开发者ID:wangeason,项目名称:PhotoViewCropper,代码行数:76,代码来源:CropOverlayView.java


示例11: a

import com.edmodo.cropper.util.AspectRatioUtil; //导入依赖的package包/类
private void a(Rect rect)
{
    if ((rect.right - rect.left) * (rect.bottom - rect.top) <= 0)
    {
        Debug.i("CropOverlayView", "initCropWindow skipped 'cause bitmapRect is empty");
        return;
    }
    if (!B)
    {
        B = true;
    }
    if (w)
    {
        if (AspectRatioUtil.calculateAspectRatio(rect) > z)
        {
            Edge.TOP.setCoordinate(rect.top);
            Edge.BOTTOM.setCoordinate(rect.bottom);
            float f6 = (float)getWidth() / 2.0F;
            float f7 = Math.max(60F, AspectRatioUtil.calculateWidth(Edge.TOP.getCoordinate(), Edge.BOTTOM.getCoordinate(), z));
            if (f7 == 60F)
            {
                z = 60F / (Edge.BOTTOM.getCoordinate() - Edge.TOP.getCoordinate());
            }
            float f8 = f7 / 2.0F;
            Edge.LEFT.setCoordinate(f6 - f8);
            Edge.RIGHT.setCoordinate(f6 + f8);
            return;
        }
        Edge.LEFT.setCoordinate(rect.left);
        Edge.RIGHT.setCoordinate(rect.right);
        float f3 = (float)getHeight() / 2.0F;
        float f4 = Math.max(60F, AspectRatioUtil.calculateHeight(Edge.LEFT.getCoordinate(), Edge.RIGHT.getCoordinate(), z));
        if (f4 == 60F)
        {
            z = (Edge.RIGHT.getCoordinate() - Edge.LEFT.getCoordinate()) / 60F;
        }
        float f5 = f4 / 2.0F;
        Edge.TOP.setCoordinate(f3 - f5);
        Edge.BOTTOM.setCoordinate(f3 + f5);
        return;
    } else
    {
        float f1 = 0.1F * (float)rect.width();
        float f2 = 0.1F * (float)rect.height();
        Edge.LEFT.setCoordinate(f1 + (float)rect.left);
        Edge.TOP.setCoordinate(f2 + (float)rect.top);
        Edge.RIGHT.setCoordinate((float)rect.right - f1);
        Edge.BOTTOM.setCoordinate((float)rect.bottom - f2);
        return;
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:52,代码来源:CropOverlayView.java



注:本文中的com.edmodo.cropper.util.AspectRatioUtil类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BitmapCanvasProvider类代码示例发布时间:2022-05-22
下一篇:
Java GeoRSSModule类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap