本文整理汇总了Java中com.edmodo.cropper.cropwindow.edge.Edge类的典型用法代码示例。如果您正苦于以下问题:Java Edge类的具体用法?Java Edge怎么用?Java Edge使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Edge类属于com.edmodo.cropper.cropwindow.edge包,在下文中一共展示了Edge类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: updateCropWindow
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
/**
* Updates the crop window by directly setting the Edge coordinates.
*
* @param x the new x-coordinate of this handle
* @param y the new y-coordinate of this handle
* @param imageRect the bounding rectangle of the image
* @param parentView the parent View containing the image
* @param snapRadius the maximum distance (in pixels) at which the crop
* window should snap to the image
*/
void updateCropWindow(float x,
float y,
Rect imageRect,
float snapRadius) {
final EdgePair activeEdges = getActiveEdges();
final Edge primaryEdge = activeEdges.primary;
final Edge secondaryEdge = activeEdges.secondary;
if (primaryEdge != null)
primaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, UNFIXED_ASPECT_RATIO_CONSTANT);
if (secondaryEdge != null)
secondaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, UNFIXED_ASPECT_RATIO_CONSTANT);
}
示例2: updateCropWindow
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
@Override
void updateCropWindow(float x,
float y,
float targetAspectRatio,
Rect imageRect,
float snapRadius) {
final EdgePair activeEdges = getActiveEdges(x, y, targetAspectRatio);
final Edge primaryEdge = activeEdges.primary;
final Edge secondaryEdge = activeEdges.secondary;
primaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, targetAspectRatio);
secondaryEdge.adjustCoordinate(targetAspectRatio);
if (secondaryEdge.isOutsideMargin(imageRect, snapRadius)) {
secondaryEdge.snapToRect(imageRect);
primaryEdge.adjustCoordinate(targetAspectRatio);
}
}
示例3: drawRuleOfThirdsGuidelines
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
private void drawRuleOfThirdsGuidelines(Canvas canvas) {
final float left = Edge.LEFT.getCoordinate();
final float top = Edge.TOP.getCoordinate();
final float right = Edge.RIGHT.getCoordinate();
final float bottom = Edge.BOTTOM.getCoordinate();
// Draw vertical guidelines.
final float oneThirdCropWidth = Edge.getWidth() / 3;
final float x1 = left + oneThirdCropWidth;
canvas.drawLine(x1, top, x1, bottom, mGuidelinePaint);
final float x2 = right - oneThirdCropWidth;
canvas.drawLine(x2, top, x2, bottom, mGuidelinePaint);
// Draw horizontal guidelines.
final float oneThirdCropHeight = Edge.getHeight() / 3;
final float y1 = top + oneThirdCropHeight;
canvas.drawLine(left, y1, right, y1, mGuidelinePaint);
final float y2 = bottom - oneThirdCropHeight;
canvas.drawLine(left, y2, right, y2, mGuidelinePaint);
}
示例4: onActionDown
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
/**
* Handles a {@link android.view.MotionEvent#ACTION_DOWN} event.
*
* @param x the x-coordinate of the down action
* @param y the y-coordinate of the down action
*/
private void onActionDown(float x, float y) {
final float left = Edge.LEFT.getCoordinate();
final float top = Edge.TOP.getCoordinate();
final float right = Edge.RIGHT.getCoordinate();
final float bottom = Edge.BOTTOM.getCoordinate();
mPressedHandle = HandleUtil.getPressedHandle(x, y, left, top, right, bottom, mHandleRadius);
if (mPressedHandle == null)
return;
// Calculate the offset of the touch point from the precise location
// of the handle. Save these values in a member variable since we want
// to maintain this offset as we drag the handle.
mTouchOffset = HandleUtil.getOffset(mPressedHandle, x, y, left, top, right, bottom);
invalidate();
}
示例5: updateCropWindow
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
/**
* Updates the crop window by directly setting the Edge coordinates.
*
* @param x the new x-coordinate of this handle
* @param y the new y-coordinate of this handle
* @param imageRect the bounding rectangle of the image
* @param parentView the parent View containing the image
* @param snapRadius the maximum distance (in pixels) at which the crop
* window should snap to the image
*/
void updateCropWindow(float x,
float y,
Rect imageRect,
float snapRadius) {
final EdgePair activeEdges = getActiveEdges();
final Edge primaryEdge = activeEdges.primary;
final Edge secondaryEdge = activeEdges.secondary;
if (primaryEdge != null)
primaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, UNFIXED_ASPECT_RATIO_CONSTANT);
if (secondaryEdge != null)
secondaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, UNFIXED_ASPECT_RATIO_CONSTANT);
}
示例6: onActionDown
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
/**
* Handles a {@link MotionEvent#ACTION_DOWN} event.
*
* @param x the x-coordinate of the down action
* @param y the y-coordinate of the down action
*/
private void onActionDown(float x, float y) {
final float left = Edge.LEFT.getCoordinate();
final float top = Edge.TOP.getCoordinate();
final float right = Edge.RIGHT.getCoordinate();
final float bottom = Edge.BOTTOM.getCoordinate();
mPressedHandle = HandleUtil.getPressedHandle(x, y, left, top, right, bottom, mHandleRadius);
if (mPressedHandle == null)
return;
// Calculate the offset of the touch point from the precise location
// of the handle. Save these values in a member variable since we want
// to maintain this offset as we drag the handle.
mTouchOffset = HandleUtil.getOffset(mPressedHandle, x, y, left, top, right, bottom);
invalidate();
}
示例7: a
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的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);
}
}
示例8: a
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的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);
}
}
示例9: a
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
private void a(float f1, float f2)
{
float f3 = Edge.LEFT.getCoordinate();
float f4 = Edge.TOP.getCoordinate();
float f5 = Edge.RIGHT.getCoordinate();
float f6 = Edge.BOTTOM.getCoordinate();
v = HandleUtil.getPressedHandle(f1, f2, f3, f4, f5, f6, s);
if (v == null)
{
return;
} else
{
u = HandleUtil.getOffset(v, f1, f2, f3, f4, f5, f6);
invalidate();
return;
}
}
示例10: updateCropWindow
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
/**
* Updates the crop window by directly setting the Edge coordinates.
*
* @param x the new x-coordinate of this handle
* @param y the new y-coordinate of this handle
* @param imageRect the bounding rectangle of the image
* @param snapRadius the maximum distance (in pixels) at which the crop window should snap to
* the image
*/
void updateCropWindow(float x,
float y,
@NonNull RectF imageRect,
float snapRadius) {
final EdgePair activeEdges = getActiveEdges();
final Edge primaryEdge = activeEdges.primary;
final Edge secondaryEdge = activeEdges.secondary;
if (primaryEdge != null)
primaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, UNFIXED_ASPECT_RATIO_CONSTANT);
if (secondaryEdge != null)
secondaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, UNFIXED_ASPECT_RATIO_CONSTANT);
}
示例11: updateCropWindow
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
@Override
void updateCropWindow(float x,
float y,
float targetAspectRatio,
@NonNull RectF imageRect,
float snapRadius) {
final EdgePair activeEdges = getActiveEdges(x, y, targetAspectRatio);
final Edge primaryEdge = activeEdges.primary;
final Edge secondaryEdge = activeEdges.secondary;
primaryEdge.adjustCoordinate(x, y, imageRect, snapRadius, targetAspectRatio);
secondaryEdge.adjustCoordinate(targetAspectRatio);
if (secondaryEdge.isOutsideMargin(imageRect, snapRadius)) {
secondaryEdge.snapToRect(imageRect);
primaryEdge.adjustCoordinate(targetAspectRatio);
}
}
示例12: initCropWindow
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
/**
* Initialize the crop window by setting the proper {@link Edge} values.
* <p/>
* If fixed aspect ratio is turned off, the initial crop window will be set to the displayed
* image with 10% margin. If fixed aspect ratio is turned on, the initial crop window will
* conform to the aspect ratio with at least one dimension maximized.
*/
private void initCropWindow(@NonNull RectF bitmapRect) {
if (mFixAspectRatio) {
// Initialize the crop window with the proper aspect ratio.
initCropWindowWithFixedAspectRatio(bitmapRect);
} else {
// Initialize crop window to have 10% padding w/ respect to Drawable's bounds.
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);
}
}
示例13: initCropWindowWithFixedAspectRatio
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的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);
}
}
示例14: onActionDown
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的package包/类
/**
* Handles a {@link MotionEvent#ACTION_DOWN} event.
*
* @param x the x-coordinate of the down action
* @param y the y-coordinate of the down action
*/
private void onActionDown(float x, float y) {
final float left = Edge.LEFT.getCoordinate();
final float top = Edge.TOP.getCoordinate();
final float right = Edge.RIGHT.getCoordinate();
final float bottom = Edge.BOTTOM.getCoordinate();
mPressedHandle = HandleUtil.getPressedHandle(x, y, left, top, right, bottom, mHandleRadius);
// Calculate the offset of the touch point from the precise location of the handle.
// Save these values in member variable 'mTouchOffset' so that we can maintain this offset as we drag the handle.
if (mPressedHandle != null) {
HandleUtil.getOffset(mPressedHandle, x, y, left, top, right, bottom, mTouchOffset);
invalidate();
}
}
示例15: getAspectRatio
import com.edmodo.cropper.cropwindow.edge.Edge; //导入依赖的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;
}