当前位置: 首页>>代码示例>>Java>>正文


Java Handle类代码示例

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


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

示例1: getPressedHandle

import com.edmodo.cropper.cropwindow.handle.Handle; //导入依赖的package包/类
/**
 * Determines which, if any, of the handles are pressed given the touch
 * coordinates, the bounding box, and the touch radius.
 *
 * @param x            the x-coordinate of the touch point
 * @param y            the y-coordinate of the touch point
 * @param left         the x-coordinate of the left bound
 * @param top          the y-coordinate of the top bound
 * @param right        the x-coordinate of the right bound
 * @param bottom       the y-coordinate of the bottom bound
 * @param targetRadius the target radius in pixels
 * @return the Handle that was pressed; null if no Handle was pressed
 */
public static Handle getPressedHandle(float x,
                                      float y,
                                      float left,
                                      float top,
                                      float right,
                                      float bottom,
                                      float targetRadius) {

    Handle pressedHandle = null;

    // Note: corner-handles take precedence, then side-handles, then center.

    if (HandleUtil.isInCornerTargetZone(x, y, left, top, targetRadius)) {
        pressedHandle = Handle.TOP_LEFT;
    } else if (HandleUtil.isInCornerTargetZone(x, y, right, top, targetRadius)) {
        pressedHandle = Handle.TOP_RIGHT;
    } else if (HandleUtil.isInCornerTargetZone(x, y, left, bottom, targetRadius)) {
        pressedHandle = Handle.BOTTOM_LEFT;
    } else if (HandleUtil.isInCornerTargetZone(x, y, right, bottom, targetRadius)) {
        pressedHandle = Handle.BOTTOM_RIGHT;
    } else if (HandleUtil.isInCenterTargetZone(x, y, left, top, right, bottom) && focusCenter()) {
        pressedHandle = Handle.CENTER;
    } else if (HandleUtil.isInHorizontalTargetZone(x, y, left, right, top, targetRadius)) {
        pressedHandle = Handle.TOP;
    } else if (HandleUtil.isInHorizontalTargetZone(x, y, left, right, bottom, targetRadius)) {
        pressedHandle = Handle.BOTTOM;
    } else if (HandleUtil.isInVerticalTargetZone(x, y, left, top, bottom, targetRadius)) {
        pressedHandle = Handle.LEFT;
    } else if (HandleUtil.isInVerticalTargetZone(x, y, right, top, bottom, targetRadius)) {
        pressedHandle = Handle.RIGHT;
    } else if (HandleUtil.isInCenterTargetZone(x, y, left, top, right, bottom) && !focusCenter()) {
        pressedHandle = Handle.CENTER;

    }

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

示例2: getPressedHandle

import com.edmodo.cropper.cropwindow.handle.Handle; //导入依赖的package包/类
/**
 * Determines which, if any, of the handles are pressed given the touch
 * coordinates, the bounding box, and the touch radius.
 * 
 * @param x the x-coordinate of the touch point
 * @param y the y-coordinate of the touch point
 * @param left the x-coordinate of the left bound
 * @param top the y-coordinate of the top bound
 * @param right the x-coordinate of the right bound
 * @param bottom the y-coordinate of the bottom bound
 * @param targetRadius the target radius in pixels
 * @return the Handle that was pressed; null if no Handle was pressed
 */
public static Handle getPressedHandle(float x,
                                      float y,
                                      float left,
                                      float top,
                                      float right,
                                      float bottom,
                                      float targetRadius) {

    Handle pressedHandle = null;

    // Note: corner-handles take precedence, then side-handles, then center.

    if (HandleUtil.isInCornerTargetZone(x, y, left, top, targetRadius)) {
        pressedHandle = Handle.TOP_LEFT;
    } else if (HandleUtil.isInCornerTargetZone(x, y, right, top, targetRadius)) {
        pressedHandle = Handle.TOP_RIGHT;
    } else if (HandleUtil.isInCornerTargetZone(x, y, left, bottom, targetRadius)) {
        pressedHandle = Handle.BOTTOM_LEFT;
    } else if (HandleUtil.isInCornerTargetZone(x, y, right, bottom, targetRadius)) {
        pressedHandle = Handle.BOTTOM_RIGHT;
    } else if (HandleUtil.isInCenterTargetZone(x, y, left, top, right, bottom) && focusCenter()) {
        pressedHandle = Handle.CENTER;
    } else if (HandleUtil.isInHorizontalTargetZone(x, y, left, right, top, targetRadius)) {
        pressedHandle = Handle.TOP;
    } else if (HandleUtil.isInHorizontalTargetZone(x, y, left, right, bottom, targetRadius)) {
        pressedHandle = Handle.BOTTOM;
    } else if (HandleUtil.isInVerticalTargetZone(x, y, left, top, bottom, targetRadius)) {
        pressedHandle = Handle.LEFT;
    } else if (HandleUtil.isInVerticalTargetZone(x, y, right, top, bottom, targetRadius)) {
        pressedHandle = Handle.RIGHT;
    } else if (HandleUtil.isInCenterTargetZone(x, y, left, top, right, bottom) && !focusCenter()) {
        pressedHandle = Handle.CENTER;

    }

    return pressedHandle;
}
 
开发者ID:wangeason,项目名称:PhotoViewCropper,代码行数:51,代码来源:HandleUtil.java

示例3: getOffset

import com.edmodo.cropper.cropwindow.handle.Handle; //导入依赖的package包/类
/**
 * Calculates the offset of the touch point from the precise location of the
 * specified handle.
 *
 * @return the offset as a Pair where the x-offset is the first value and
 * the y-offset is the second value; null if the handle is null
 */
public static Pair<Float, Float> getOffset(Handle handle,
                                           float x,
                                           float y,
                                           float left,
                                           float top,
                                           float right,
                                           float bottom) {

    if (handle == null) {
        return null;
    }

    float touchOffsetX = 0;
    float touchOffsetY = 0;

    // Calculate the offset from the appropriate handle.
    switch (handle) {

        case TOP_LEFT:
            touchOffsetX = left - x;
            touchOffsetY = top - y;
            break;
        case TOP_RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = top - y;
            break;
        case BOTTOM_LEFT:
            touchOffsetX = left - x;
            touchOffsetY = bottom - y;
            break;
        case BOTTOM_RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = bottom - y;
            break;
        case LEFT:
            touchOffsetX = left - x;
            touchOffsetY = 0;
            break;
        case TOP:
            touchOffsetX = 0;
            touchOffsetY = top - y;
            break;
        case RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = 0;
            break;
        case BOTTOM:
            touchOffsetX = 0;
            touchOffsetY = bottom - y;
            break;
        case CENTER:
            final float centerX = (right + left) / 2;
            final float centerY = (top + bottom) / 2;
            touchOffsetX = centerX - x;
            touchOffsetY = centerY - y;
            break;
    }

    final Pair<Float, Float> result = new Pair<Float, Float>(touchOffsetX, touchOffsetY);
    return result;
}
 
开发者ID:g82,项目名称:open-mygirl-android-gradle,代码行数:69,代码来源:HandleUtil.java

示例4: getOffset

import com.edmodo.cropper.cropwindow.handle.Handle; //导入依赖的package包/类
/**
 * Calculates the offset of the touch point from the precise location of the
 * specified handle.
 *
 * @param handle
 * @param x
 * @param y
 * @param left
 * @param top
 * @param right
 * @param bottom
 * @return the offset as a Pair where the x-offset is the first value and
 *         the y-offset is the second value; null if the handle is null
 */
public static Pair<Float, Float> getOffset(Handle handle,
                                           float x,
                                           float y,
                                           float left,
                                           float top,
                                           float right,
                                           float bottom) {

    if (handle == null) {
        return null;
    }

    float touchOffsetX = 0;
    float touchOffsetY = 0;

    // Calculate the offset from the appropriate handle.
    switch (handle) {

        case TOP_LEFT:
            touchOffsetX = left - x;
            touchOffsetY = top - y;
            break;
        case TOP_RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = top - y;
            break;
        case BOTTOM_LEFT:
            touchOffsetX = left - x;
            touchOffsetY = bottom - y;
            break;
        case BOTTOM_RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = bottom - y;
            break;
        case LEFT:
            touchOffsetX = left - x;
            touchOffsetY = 0;
            break;
        case TOP:
            touchOffsetX = 0;
            touchOffsetY = top - y;
            break;
        case RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = 0;
            break;
        case BOTTOM:
            touchOffsetX = 0;
            touchOffsetY = bottom - y;
            break;
        case CENTER:
            final float centerX = (right + left) / 2;
            final float centerY = (top + bottom) / 2;
            touchOffsetX = centerX - x;
            touchOffsetY = centerY - y;
            break;
    }

    final Pair<Float, Float> result = new Pair<Float, Float>(touchOffsetX, touchOffsetY);
    return result;
}
 
开发者ID:wangeason,项目名称:PhotoViewCropper,代码行数:76,代码来源:HandleUtil.java

示例5: getOffset

import com.edmodo.cropper.cropwindow.handle.Handle; //导入依赖的package包/类
public static Pair getOffset(Handle handle, float f, float f1, float f2, float f3, float f4, float f5)
    {
        float f6;
        f6 = 0.0F;
        if (handle == null)
        {
            return null;
        }
        a.a[handle.ordinal()];
        JVM INSTR tableswitch 1 9: default 68
    //                   1 89
    //                   2 103
    //                   3 118
    //                   4 132
    //                   5 147
    //                   6 158
    //                   7 170
    //                   8 182
    //                   9 194;
           goto _L1 _L2 _L3 _L4 _L5 _L6 _L7 _L8 _L9 _L10
_L1:
        float f9 = 0.0F;
_L12:
        return new Pair(Float.valueOf(f9), Float.valueOf(f6));
_L2:
        f9 = f2 - f;
        f6 = f3 - f1;
        continue; /* Loop/switch isn't completed */
_L3:
        f9 = f4 - f;
        f6 = f3 - f1;
        continue; /* Loop/switch isn't completed */
_L4:
        f9 = f2 - f;
        f6 = f5 - f1;
        continue; /* Loop/switch isn't completed */
_L5:
        f9 = f4 - f;
        f6 = f5 - f1;
        continue; /* Loop/switch isn't completed */
_L6:
        f9 = f2 - f;
        f6 = 0.0F;
        continue; /* Loop/switch isn't completed */
_L7:
        f6 = f3 - f1;
        f9 = 0.0F;
        continue; /* Loop/switch isn't completed */
_L8:
        f9 = f4 - f;
        f6 = 0.0F;
        continue; /* Loop/switch isn't completed */
_L9:
        f6 = f5 - f1;
        f9 = 0.0F;
        continue; /* Loop/switch isn't completed */
_L10:
        float f7 = (f4 + f2) / 2.0F;
        float f8 = (f3 + f5) / 2.0F;
        f9 = f7 - f;
        f6 = f8 - f1;
        if (true) goto _L12; else goto _L11
_L11:
    }
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:65,代码来源:HandleUtil.java

示例6: getPressedHandle

import com.edmodo.cropper.cropwindow.handle.Handle; //导入依赖的package包/类
public static Handle getPressedHandle(float f, float f1, float f2, float f3, float f4, float f5, float f6)
{
    if (a(f, f1, f2, f3, f6))
    {
        return Handle.TOP_LEFT;
    }
    if (a(f, f1, f4, f3, f6))
    {
        return Handle.TOP_RIGHT;
    }
    if (a(f, f1, f2, f5, f6))
    {
        return Handle.BOTTOM_LEFT;
    }
    if (a(f, f1, f4, f5, f6))
    {
        return Handle.BOTTOM_RIGHT;
    }
    if (c(f, f1, f2, f3, f4, f5) && a())
    {
        return Handle.CENTER;
    }
    if (a(f, f1, f2, f4, f3, f6))
    {
        return Handle.TOP;
    }
    if (a(f, f1, f2, f4, f5, f6))
    {
        return Handle.BOTTOM;
    }
    if (b(f, f1, f2, f3, f5, f6))
    {
        return Handle.LEFT;
    }
    if (b(f, f1, f4, f3, f5, f6))
    {
        return Handle.RIGHT;
    }
    if (c(f, f1, f2, f3, f4, f5) && !a())
    {
        return Handle.CENTER;
    } else
    {
        return null;
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:47,代码来源:HandleUtil.java

示例7: getOffset

import com.edmodo.cropper.cropwindow.handle.Handle; //导入依赖的package包/类
/**
 * Calculates the offset of the touch point from the precise location of the
 * specified handle.
 * 
 * @return the offset as a Pair where the x-offset is the first value and
 *         the y-offset is the second value; null if the handle is null
 */
public static Pair<Float, Float> getOffset(Handle handle,
                                           float x,
                                           float y,
                                           float left,
                                           float top,
                                           float right,
                                           float bottom) {

    if (handle == null) {
        return null;
    }

    float touchOffsetX = 0;
    float touchOffsetY = 0;

    // Calculate the offset from the appropriate handle.
    switch (handle) {

        case TOP_LEFT:
            touchOffsetX = left - x;
            touchOffsetY = top - y;
            break;
        case TOP_RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = top - y;
            break;
        case BOTTOM_LEFT:
            touchOffsetX = left - x;
            touchOffsetY = bottom - y;
            break;
        case BOTTOM_RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = bottom - y;
            break;
        case LEFT:
            touchOffsetX = left - x;
            touchOffsetY = 0;
            break;
        case TOP:
            touchOffsetX = 0;
            touchOffsetY = top - y;
            break;
        case RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = 0;
            break;
        case BOTTOM:
            touchOffsetX = 0;
            touchOffsetY = bottom - y;
            break;
        case CENTER:
            final float centerX = (right + left) / 2;
            final float centerY = (top + bottom) / 2;
            touchOffsetX = centerX - x;
            touchOffsetY = centerY - y;
            break;
    }

    final Pair<Float, Float> result = new Pair<Float, Float>(touchOffsetX, touchOffsetY);
    return result;
}
 
开发者ID:qbeenslee,项目名称:Nepenthes-Android,代码行数:69,代码来源:HandleUtil.java

示例8: getPressedHandle

import com.edmodo.cropper.cropwindow.handle.Handle; //导入依赖的package包/类
/**
 * Determines which, if any, of the handles are pressed given the touch coordinates, the
 * bounding box, and the touch radius.
 *
 * @param x            the x-coordinate of the touch point
 * @param y            the y-coordinate of the touch point
 * @param left         the x-coordinate of the left bound
 * @param top          the y-coordinate of the top bound
 * @param right        the x-coordinate of the right bound
 * @param bottom       the y-coordinate of the bottom bound
 * @param targetRadius the target radius in pixels
 *
 * @return the Handle that was pressed; null if no Handle was pressed
 */
public static Handle getPressedHandle(float x,
                                      float y,
                                      float left,
                                      float top,
                                      float right,
                                      float bottom,
                                      float targetRadius) {

    // Find the closest corner handle to the touch point.
    // If the touch point is in the target zone of this closest handle, then this is the pressed handle.
    // Else, check if any of the edges are in the target zone of the touch point.
    // Else, check if the touch point is within the crop window bounds; if so, then choose the center handle.

    Handle closestHandle = null;
    float closestDistance = Float.POSITIVE_INFINITY;

    final float distanceToTopLeft = MathUtil.calculateDistance(x, y, left, top);
    if (distanceToTopLeft < closestDistance) {
        closestDistance = distanceToTopLeft;
        closestHandle = Handle.TOP_LEFT;
    }

    final float distanceToTopRight = MathUtil.calculateDistance(x, y, right, top);
    if (distanceToTopRight < closestDistance) {
        closestDistance = distanceToTopRight;
        closestHandle = Handle.TOP_RIGHT;
    }

    final float distanceToBottomLeft = MathUtil.calculateDistance(x, y, left, bottom);
    if (distanceToBottomLeft < closestDistance) {
        closestDistance = distanceToBottomLeft;
        closestHandle = Handle.BOTTOM_LEFT;
    }

    final float distanceToBottomRight = MathUtil.calculateDistance(x, y, right, bottom);
    if (distanceToBottomRight < closestDistance) {
        closestDistance = distanceToBottomRight;
        closestHandle = Handle.BOTTOM_RIGHT;
    }

    if (closestDistance <= targetRadius) {
        return closestHandle;
    }

    // If we get to this point, none of the corner handles were in the touch target zone, so then we check the edges.
    if (HandleUtil.isInHorizontalTargetZone(x, y, left, right, top, targetRadius)) {
        return Handle.TOP;
    } else if (HandleUtil.isInHorizontalTargetZone(x, y, left, right, bottom, targetRadius)) {
        return Handle.BOTTOM;
    } else if (HandleUtil.isInVerticalTargetZone(x, y, left, top, bottom, targetRadius)) {
        return Handle.LEFT;
    } else if (HandleUtil.isInVerticalTargetZone(x, y, right, top, bottom, targetRadius)) {
        return Handle.RIGHT;
    }

    // If we get to this point, none of the corners or edges are in the touch target zone.
    // Check to see if the touch point is within the bounds of the crop window. If so, choose the center handle.
    if (isWithinBounds(x, y, left, top, right, bottom)) {
        return Handle.CENTER;
    }

    return null;
}
 
开发者ID:edmodo,项目名称:cropper,代码行数:78,代码来源:HandleUtil.java

示例9: getOffset

import com.edmodo.cropper.cropwindow.handle.Handle; //导入依赖的package包/类
/**
 * Calculates the offset of the touch point from the precise location of the specified handle.
 * <p/>
 * The offset will be returned in the 'touchOffsetOutput' parameter; the x-offset will be the
 * first value and the y-offset will be the second value.
 */
public static void getOffset(@NonNull Handle handle,
                             float x,
                             float y,
                             float left,
                             float top,
                             float right,
                             float bottom,
                             @NonNull PointF touchOffsetOutput) {

    float touchOffsetX = 0;
    float touchOffsetY = 0;

    // Calculate the offset from the appropriate handle.
    switch (handle) {

        case TOP_LEFT:
            touchOffsetX = left - x;
            touchOffsetY = top - y;
            break;
        case TOP_RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = top - y;
            break;
        case BOTTOM_LEFT:
            touchOffsetX = left - x;
            touchOffsetY = bottom - y;
            break;
        case BOTTOM_RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = bottom - y;
            break;
        case LEFT:
            touchOffsetX = left - x;
            touchOffsetY = 0;
            break;
        case TOP:
            touchOffsetX = 0;
            touchOffsetY = top - y;
            break;
        case RIGHT:
            touchOffsetX = right - x;
            touchOffsetY = 0;
            break;
        case BOTTOM:
            touchOffsetX = 0;
            touchOffsetY = bottom - y;
            break;
        case CENTER:
            final float centerX = (right + left) / 2;
            final float centerY = (top + bottom) / 2;
            touchOffsetX = centerX - x;
            touchOffsetY = centerY - y;
            break;
    }

    touchOffsetOutput.x = touchOffsetX;
    touchOffsetOutput.y = touchOffsetY;
}
 
开发者ID:edmodo,项目名称:cropper,代码行数:65,代码来源:HandleUtil.java


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