本文整理汇总了Java中com.alexvasilkov.gestures.Settings.getImageH方法的典型用法代码示例。如果您正苦于以下问题:Java Settings.getImageH方法的具体用法?Java Settings.getImageH怎么用?Java Settings.getImageH使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.alexvasilkov.gestures.Settings
的用法示例。
在下文中一共展示了Settings.getImageH方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setImageDrawable
import com.alexvasilkov.gestures.Settings; //导入方法依赖的package包/类
@Override
public void setImageDrawable(Drawable dr) {
super.setImageDrawable(dr);
// Method setImageDrawable can be called from super constructor,
// so we have to ensure controller instance is created at this point.
ensureControllerCreated();
Settings settings = mController.getSettings();
int oldW = settings.getImageW(), oldH = settings.getImageH();
if (dr == null) {
settings.setImage(0, 0);
} else if (dr.getIntrinsicWidth() == -1 || dr.getIntrinsicHeight() == -1) {
settings.setImage(settings.getMovementAreaW(), settings.getMovementAreaH());
} else {
settings.setImage(dr.getIntrinsicWidth(), dr.getIntrinsicHeight());
}
if (oldW != settings.getImageW() || oldH != settings.getImageH()) {
mController.resetState();
}
}
示例2: setImageDrawable
import com.alexvasilkov.gestures.Settings; //导入方法依赖的package包/类
@Override
public void setImageDrawable(Drawable drawable) {
super.setImageDrawable(drawable);
// Method setImageDrawable can be called from super constructor,
// so we have to ensure controller instance is created at this point.
ensureControllerCreated();
Settings settings = controller.getSettings();
// Saving old image size
float oldWidth = settings.getImageW();
float oldHeight = settings.getImageH();
// Setting image size
if (drawable == null) {
settings.setImage(0, 0);
} else if (drawable.getIntrinsicWidth() == -1 || drawable.getIntrinsicHeight() == -1) {
settings.setImage(settings.getMovementAreaW(), settings.getMovementAreaH());
} else {
settings.setImage(drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
}
// Getting new image size
float newWidth = settings.getImageW();
float newHeight = settings.getImageH();
if (newWidth > 0f && newHeight > 0f && oldWidth > 0f && oldHeight > 0f) {
float scaleFactor = Math.min(oldWidth / newWidth, oldHeight / newHeight);
controller.getStateController().setTempZoomPatch(scaleFactor);
controller.updateState();
controller.getStateController().setTempZoomPatch(0f);
} else {
controller.resetState();
}
}
示例3: updateFromState
import com.alexvasilkov.gestures.Settings; //导入方法依赖的package包/类
private void updateFromState() {
if (isFromUpdated) {
return;
}
Settings settings = toController == null ? null : toController.getSettings();
if (fromNonePos && settings != null && toPos != null) {
fromPos = fromPos == null ? ViewPosition.newInstance() : fromPos;
GravityUtils.getDefaultPivot(settings, tmpPoint);
tmpPoint.offset(toPos.view.left, toPos.view.top); // Ensure we're in correct coordinates
ViewPosition.apply(fromPos, tmpPoint);
}
if (toPos == null || fromPos == null || settings == null || !settings.hasImageSize()) {
return;
}
// 'From' pivot point is a center of image in 'To' viewport coordinates
fromPivotX = fromPos.image.centerX() - toPos.viewport.left;
fromPivotY = fromPos.image.centerY() - toPos.viewport.top;
// Computing starting zoom level
float imageWidth = settings.getImageW();
float imageHeight = settings.getImageH();
float zoomW = imageWidth == 0f ? 1f : fromPos.image.width() / imageWidth;
float zoomH = imageHeight == 0f ? 1f : fromPos.image.height() / imageHeight;
float zoom = Math.max(zoomW, zoomH);
// Computing 'From' image in 'To' viewport coordinates.
// If 'To' image has different aspect ratio it will be centered within the 'From' image.
float fromX = fromPos.image.centerX() - 0.5f * imageWidth * zoom - toPos.viewport.left;
float fromY = fromPos.image.centerY() - 0.5f * imageHeight * zoom - toPos.viewport.top;
fromState.set(fromX, fromY, zoom, 0f);
// 'From' clip is 'From' view rect in 'To' view coordinates
fromClip.set(fromPos.viewport);
fromClip.offset(-toPos.view.left, -toPos.view.top);
// 'From' bounds clip is a part of 'To' view which considered to be visible.
// Meaning that if 'From' view is truncated in any direction this clipping should be
// animated, otherwise it will look like part of 'From' view is instantly becoming visible.
fromBoundsClip.set(0f, 0f, toPos.view.width(), toPos.view.height());
fromBoundsClip.left = compareAndSetClipBound(
fromBoundsClip.left, fromPos.view.left, fromPos.visible.left, toPos.view.left);
fromBoundsClip.top = compareAndSetClipBound(
fromBoundsClip.top, fromPos.view.top, fromPos.visible.top, toPos.view.top);
fromBoundsClip.right = compareAndSetClipBound(
fromBoundsClip.right, fromPos.view.right, fromPos.visible.right, toPos.view.left);
fromBoundsClip.bottom = compareAndSetClipBound(
fromBoundsClip.bottom, fromPos.view.bottom, fromPos.visible.bottom, toPos.view.top);
isFromUpdated = true;
if (GestureDebug.isDebugAnimator()) {
Log.d(TAG, "'From' state updated");
}
}
示例4: update
import com.alexvasilkov.gestures.Settings; //导入方法依赖的package包/类
/**
* Applies area size, area position and corners rounding with optional animation.
*
* @param animate Whether to animate changes when applying new cropping area settings
*/
public void update(boolean animate) {
final Settings settings =
imageView == null ? null : imageView.getController().getSettings();
if (settings != null && getWidth() > 0 && getHeight() > 0) {
// If aspect is specified we will automatically adjust movement area settings
if (aspect > 0f || aspect == ORIGINAL_ASPECT) {
final int width = getWidth() - getPaddingLeft() - getPaddingRight();
final int height = getHeight() - getPaddingTop() - getPaddingBottom();
final float realAspect = aspect == ORIGINAL_ASPECT
? settings.getImageW() / (float) settings.getImageH() : aspect;
// Setting movement area
if (realAspect > (float) width / (float) height) {
// Cropping area is wider
settings.setMovementArea(width, (int) (width / realAspect));
} else {
// Cropping area is higher
settings.setMovementArea((int) (height * realAspect), height);
}
// Animating image to fit new movement area
if (animate) {
imageView.getController().animateKeepInBounds();
} else {
imageView.getController().updateState();
}
}
startRect.set(areaRect);
GravityUtils.getMovementAreaPosition(settings, tmpRect);
endRect.set(tmpRect);
stateScroller.forceFinished();
if (animate) {
stateScroller.setDuration(settings.getAnimationsDuration());
stateScroller.startScroll(0f, 1f);
animationEngine.start();
} else {
setBounds(endRect, endRounding);
}
}
}
示例5: 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;
}
}