本文整理汇总了Java中com.alexvasilkov.gestures.Settings.getFitMethod方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.getFitMethod方法的具体用法?Java Settings.getFitMethod怎么用?Java Settings.getFitMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alexvasilkov.gestures.Settings
的用法示例。
在下文中一共展示了Settings.getFitMethod方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setValuesFrom
import com.alexvasilkov.gestures.Settings; //导入方法依赖的package包/类
public void setValuesFrom(Settings settings) {
isPanEnabled = settings.isPanEnabled();
isZoomEnabled = settings.isZoomEnabled();
isRotationEnabled = settings.isRotationEnabled();
isRestrictRotation = settings.isRestrictRotation();
isExitEnabled = settings.isExitEnabled();
isFillViewport = settings.isFillViewport();
fitMethod = settings.getFitMethod();
gravity = settings.getGravity();
}
示例2: setup
import com.alexvasilkov.gestures.Settings; //导入方法依赖的package包/类
/**
* Calculating bounds for {@link State#x} & {@link State#y} values to keep image within
* viewport and taking image gravity into account (see {@link Settings#setGravity(int)})
*/
public void setup(State state, Settings settings) {
RectF area = RECT_TMP_AREA;
area.set(getMovementAreaWithGravity(settings));
final Rect pos;
if (settings.getFitMethod() == Settings.Fit.OUTSIDE) {
// For OUTSIDE fit method we will rotate area rect instead of image rect,
// that will help us correctly fit movement area inside image rect
mRotation = state.getRotation();
mPivotX = area.centerX();
mPivotY = area.centerY();
state.get(MATRIX);
MATRIX.postRotate(-mRotation, mPivotX, mPivotY);
pos = getPositionWithGravity(MATRIX, settings);
MATRIX.setRotate(-mRotation, mPivotX, mPivotY);
MATRIX.mapRect(area);
} else {
mRotation = 0f;
state.get(MATRIX);
pos = getPositionWithGravity(MATRIX, settings);
}
// Calculating movement bounds for top-left corner of the scaled image
// horizontal bounds
if (area.width() < pos.width()) {
// image is bigger than movement area -> restricting image movement with moving area
mBounds.left = area.left - (pos.width() - area.width());
mBounds.right = area.left;
} else {
// image is smaller than viewport -> positioning image according to calculated gravity
// and restricting image movement in this direction
mBounds.left = mBounds.right = pos.left;
}
// vertical bounds
if (area.height() < pos.height()) {
// image is bigger than viewport -> restricting image movement with viewport bounds
mBounds.top = area.top - (pos.height() - area.height());
mBounds.bottom = area.top;
} else {
// image is smaller than viewport -> positioning image according to calculated gravity
// and restricting image movement in this direction
mBounds.top = mBounds.bottom = pos.top;
}
// We should also adjust bounds position, since top-left corner of rotated image rectangle
// will be somewhere on the edge of non-rotated bounding rectangle.
// Note: for OUTSIDE fit method image rotation was skipped above, so we will not need
// to adjust bounds here.
if (settings.getFitMethod() != Settings.Fit.OUTSIDE) {
state.get(MATRIX);
RECT_TMP_F.set(0, 0, settings.getImageW(), settings.getImageH());
MATRIX.mapRect(RECT_TMP_F);
POINT_ARR[0] = POINT_ARR[1] = 0f;
MATRIX.mapPoints(POINT_ARR);
mBounds.offset(POINT_ARR[0] - RECT_TMP_F.left, POINT_ARR[1] - RECT_TMP_F.top);
}
}
示例3: calculateZoomLevels
import com.alexvasilkov.gestures.Settings; //导入方法依赖的package包/类
/**
* Calculates min and max zoom levels.
*/
private void calculateZoomLevels(State state, Settings settings) {
maxZoom = settings.getMaxZoom();
float imageWidth = settings.getImageW();
float imageHeight = settings.getImageH();
float areaWidth = settings.getMovementAreaW();
float areaHeight = settings.getMovementAreaH();
final float rotation = state.getRotation();
if (settings.getFitMethod() == Settings.Fit.OUTSIDE) {
// Computing movement area size taking rotation into account. We need to inverse
// rotation, since it will be applied to the area, not to the image itself.
tmpMatrix.setRotate(-rotation);
tmpRectF.set(0, 0, areaWidth, areaHeight);
tmpMatrix.mapRect(tmpRectF);
areaWidth = tmpRectF.width();
areaHeight = tmpRectF.height();
} else {
// Computing image bounding size taking rotation into account.
tmpMatrix.setRotate(rotation);
tmpRectF.set(0, 0, imageWidth, imageHeight);
tmpMatrix.mapRect(tmpRectF);
imageWidth = tmpRectF.width();
imageHeight = tmpRectF.height();
}
final float fittingZoom;
switch (settings.getFitMethod()) {
case HORIZONTAL:
fittingZoom = areaWidth / imageWidth;
break;
case VERTICAL:
fittingZoom = areaHeight / imageHeight;
break;
case OUTSIDE:
fittingZoom = Math.max(areaWidth / imageWidth, areaHeight / imageHeight);
break;
case INSIDE:
default:
fittingZoom = Math.min(areaWidth / imageWidth, areaHeight / imageHeight);
break;
}
if (fittingZoom > maxZoom) {
if (settings.isFillViewport()) {
// zooming to fill entire viewport
minZoom = maxZoom = fittingZoom;
} else {
// restricting min zoom
minZoom = maxZoom;
}
} else {
minZoom = fittingZoom;
}
}
示例4: setup
import com.alexvasilkov.gestures.Settings; //导入方法依赖的package包/类
/**
* Calculating bounds for {@link State#x} & {@link State#y} values to keep image within
* viewport and taking image gravity into account (see {@link Settings#setGravity(int)}).
*
* @param state Current state
* @param settings Current settings
*/
public void setup(State state, Settings settings) {
RectF area = tmpRectF;
GravityUtils.getMovementAreaPosition(settings, tmpRect);
area.set(tmpRect);
final Rect pos = tmpRect;
if (settings.getFitMethod() == Settings.Fit.OUTSIDE) {
// For OUTSIDE fit method we will rotate area rect instead of image rect,
// that will help us correctly fit movement area inside image rect
boundsRotation = state.getRotation();
boundsPivotX = area.centerX();
boundsPivotY = area.centerY();
state.get(tmpMatrix);
tmpMatrix.postRotate(-boundsRotation, boundsPivotX, boundsPivotY);
GravityUtils.getImagePosition(tmpMatrix, settings, pos);
tmpMatrix.setRotate(-boundsRotation, boundsPivotX, boundsPivotY);
tmpMatrix.mapRect(area);
} else {
boundsRotation = 0f;
boundsPivotX = boundsPivotY = 0f;
GravityUtils.getImagePosition(state, settings, pos);
}
// Calculating movement bounds for top-left corner of the scaled image
// horizontal bounds
if (area.width() < pos.width()) {
// image is bigger than movement area -> restricting image movement with moving area
bounds.left = area.left - (pos.width() - area.width());
bounds.right = area.left;
} else {
// image is smaller than viewport -> positioning image according to calculated gravity
// and restricting image movement in this direction
bounds.left = bounds.right = pos.left;
}
// vertical bounds
if (area.height() < pos.height()) {
// image is bigger than viewport -> restricting image movement with viewport bounds
bounds.top = area.top - (pos.height() - area.height());
bounds.bottom = area.top;
} else {
// image is smaller than viewport -> positioning image according to calculated gravity
// and restricting image movement in this direction
bounds.top = bounds.bottom = pos.top;
}
// We should also adjust bounds position, since top-left corner of rotated image rectangle
// will be somewhere on the edge of non-rotated bounding rectangle.
// Note: for OUTSIDE fit method image rotation was skipped above, so we will not need
// to adjust bounds here.
if (settings.getFitMethod() != Settings.Fit.OUTSIDE) {
state.get(tmpMatrix);
RectF imageRect = tmpRectF;
imageRect.set(0, 0, settings.getImageW(), settings.getImageH());
tmpMatrix.mapRect(imageRect);
tmpPointArr[0] = tmpPointArr[1] = 0f;
tmpMatrix.mapPoints(tmpPointArr);
bounds.offset(tmpPointArr[0] - imageRect.left, tmpPointArr[1] - imageRect.top);
}
}