-
public interface ZoomApiAn interface for zoom controls.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public @interfaceZoomApi.RealZoomAnnotation to indicate a RealZoom value.
public @interfaceZoomApi.ZoomAnnotation to indicate a zoom value.
public @interfaceZoomApi.AbsolutePanAnnotation to indicate an AbsolutePan value.
public @interfaceZoomApi.ScaledPanAnnotation to indicate a ScaledPan value.
public @interfaceZoomApi.ZoomTypeDefines the available zoom types
public @interfaceZoomApi.TransformationDefines the available transformation types
public @interfaceZoomApi.AlignmentDefines the available alignments
public classZoomApi.Companion
-
Method Summary
Modifier and Type Method Description abstract UnitsetOverScrollHorizontal(Boolean overScroll)Controls whether the content should be over-scrollable horizontally. abstract UnitsetOverScrollVertical(Boolean overScroll)Controls whether the content should be over-scrollable vertically. abstract UnitsetOverPanRange(OverPanRangeProvider provider)Set the OverPanRangeProvider that specifies the amount of overpan to allow. abstract UnitsetHorizontalPanEnabled(Boolean enabled)Controls whether horizontal panning using gestures is enabled. abstract UnitsetVerticalPanEnabled(Boolean enabled)Controls whether vertical panning using gestures is enabled. abstract UnitsetZoomEnabled(Boolean enabled)Controls whether zoom using pinch gesture is enabled or not. abstract UnitsetOverPinchable(Boolean overPinchable)Controls whether the content should be overPinchable. abstract UnitsetOverZoomRange(OverZoomRangeProvider provider)Set the OverZoomRangeProvider that specifies the amount of overzoom to allow. abstract UnitsetFlingEnabled(Boolean enabled)Controls whether fling gesture is enabled or not. abstract UnitsetScrollEnabled(Boolean enabled)Controls whether scroll gesture is enabled or not. abstract UnitsetOneFingerScrollEnabled(Boolean enabled)Controls whether one finger scroll gesture is enabled or not. abstract UnitsetTwoFingersScrollEnabled(Boolean enabled)Controls whether two fingers scroll gesture is enabled or not. abstract UnitsetThreeFingersScrollEnabled(Boolean enabled)Controls whether three fingers scroll gesture is enabled or not. abstract UnitsetAllowFlingInOverscroll(Boolean allow)Controls whether fling events are allowed when the view is in an overscrolled state. UnitsetTransformation(Integer transformation)Sets the base transformation to be applied to the content. abstract UnitsetTransformation(Integer transformation, Integer gravity)Sets the base transformation to be applied to the content. abstract UnitsetAlignment(Integer alignment)Sets the content alignment. abstract UnitmoveTo(Float zoom, Float x, Float y, Boolean animate)A low level API that can animate both zoom and pan at the same time. abstract UnitmoveToCenter(Float zoom, Boolean animate)Moves to the center of the content. abstract UnitpanTo(Float x, Float y, Boolean animate)Pans the content until the top-left coordinates match the given x-y values. abstract UnitpanBy(Float dx, Float dy, Boolean animate)Pans the content by the given quantity in dx-dy values. abstract UnitzoomTo(Float zoom, Boolean animate)Zooms to the given scale. abstract UnitzoomBy(Float zoomFactor, Boolean animate)Applies the given factor to the current zoom. abstract UnitzoomIn()Applies a small, animated zoom-in. abstract UnitzoomOut()Applies a small, animated zoom-out. abstract UnitrealZoomTo(Float realZoom, Boolean animate)Animates the actual matrix zoom to the given value. abstract FloatgetMaxZoom()Get the currently allowed max zoom. abstract IntegergetMaxZoomType()Get the currently set max zoom type. UnitsetMaxZoom(Float maxZoom)Which is the max zoom that should be allowed. abstract UnitsetMaxZoom(Float maxZoom, Integer type)Which is the max zoom that should be allowed. abstract FloatgetMinZoom()Get the currently allowed min zoom. abstract IntegergetMinZoomType()Get the currently set min zoom type. UnitsetMinZoom(Float minZoom)Which is the min zoom that should be allowed. abstract UnitsetMinZoom(Float minZoom, Integer type)Which is the min zoom that should be allowed. abstract UnitsetAnimationDuration(Long duration)Sets the duration of animations triggered by zoom and pan APIs. abstract BooleancancelAnimations()Cancels all currently active animations triggered by either API calls with animate = trueor touch input flings.abstract FloatgetZoom()Gets the current zoom value, which can be used as a reference when calling ZoomApi.zoomTo or ZoomApi.zoomBy. abstract FloatgetRealZoom()Gets the current zoom value, including the base zoom that was eventually applied when initializing to respect the "center inside" policy. abstract AbsolutePointgetPan()The current pan as an AbsolutePoint. abstract FloatgetPanX()Returns the current horizontal pan value, in content absolute coordinates (that is, as if there was no zoom at all). abstract FloatgetPanY()Returns the current vertical pan value, in content absolute coordinates (that is, as if there was no zoom at all). abstract ScaledPointgetScaledPan()The current pan as a ScaledPoint, that is, taking into account the current zoom. abstract FloatgetScaledPanX()Returns the current horizontal pan value, in content scaled coordinates (that is, including the current zoom). abstract FloatgetScaledPanY()Returns the current vertical pan value, in content scaled coordinates (that is, including the current zoom). -
-
Method Detail
-
setOverScrollHorizontal
abstract Unit setOverScrollHorizontal(Boolean overScroll)
Controls whether the content should be over-scrollable horizontally. If it is, drag and fling horizontal events can scroll the content outside the safe area, then return to safe values.
- Parameters:
overScroll- whether to allow horizontal over scrolling
-
setOverScrollVertical
abstract Unit setOverScrollVertical(Boolean overScroll)
Controls whether the content should be over-scrollable vertically. If it is, drag and fling vertical events can scroll the content outside the safe area, then return to safe values.
- Parameters:
overScroll- whether to allow vertical over scrolling
-
setOverPanRange
abstract Unit setOverPanRange(OverPanRangeProvider provider)
Set the OverPanRangeProvider that specifies the amount of overpan to allow.
-
setHorizontalPanEnabled
abstract Unit setHorizontalPanEnabled(Boolean enabled)
Controls whether horizontal panning using gestures is enabled.
- Parameters:
enabled- true enables horizontal panning, false disables it
-
setVerticalPanEnabled
abstract Unit setVerticalPanEnabled(Boolean enabled)
Controls whether vertical panning using gestures is enabled.
- Parameters:
enabled- true enables vertical panning, false disables it
-
setZoomEnabled
abstract Unit setZoomEnabled(Boolean enabled)
Controls whether zoom using pinch gesture is enabled or not.
- Parameters:
enabled- true enables zooming, false disables it
-
setOverPinchable
abstract Unit setOverPinchable(Boolean overPinchable)
Controls whether the content should be overPinchable. If it is, pinch events can change the zoom outside the safe bounds, than return to safe values.
- Parameters:
overPinchable- whether to allow over pinching
-
setOverZoomRange
abstract Unit setOverZoomRange(OverZoomRangeProvider provider)
Set the OverZoomRangeProvider that specifies the amount of overzoom to allow.
- Parameters:
provider- the range provider
-
setFlingEnabled
abstract Unit setFlingEnabled(Boolean enabled)
Controls whether fling gesture is enabled or not.
- Parameters:
enabled- true enables fling gesture, false disables it
-
setScrollEnabled
abstract Unit setScrollEnabled(Boolean enabled)
Controls whether scroll gesture is enabled or not.
- Parameters:
enabled- true enables scroll gesture, false disables it
-
setOneFingerScrollEnabled
abstract Unit setOneFingerScrollEnabled(Boolean enabled)
Controls whether one finger scroll gesture is enabled or not.
- Parameters:
enabled- true enables one finger scroll gesture, false disables it
-
setTwoFingersScrollEnabled
abstract Unit setTwoFingersScrollEnabled(Boolean enabled)
Controls whether two fingers scroll gesture is enabled or not.
- Parameters:
enabled- true enables two fingers scroll gesture, false disables it
-
setThreeFingersScrollEnabled
abstract Unit setThreeFingersScrollEnabled(Boolean enabled)
Controls whether three fingers scroll gesture is enabled or not.
- Parameters:
enabled- true enables three fingers scroll gesture, false disables it
-
setAllowFlingInOverscroll
abstract Unit setAllowFlingInOverscroll(Boolean allow)
Controls whether fling events are allowed when the view is in an overscrolled state.
- Parameters:
allow- true allows fling in overscroll, false disables it
-
setTransformation
Unit setTransformation(Integer transformation)
Sets the base transformation to be applied to the content. See setTransformation.
- Parameters:
transformation- the transformation type
-
setTransformation
abstract Unit setTransformation(Integer transformation, Integer gravity)
Sets the base transformation to be applied to the content. Defaults to TRANSFORMATION_CENTER_INSIDE with android.view.Gravity.CENTER, which means that the content will be zoomed so that it fits completely inside the container.
- Parameters:
transformation- the transformation typegravity- the transformation gravity.
-
setAlignment
abstract Unit setAlignment(Integer alignment)
Sets the content alignment. Can be any of the constants defined in com.otaliastudios.zoom.Alignment. The content will be aligned and forced to the specified side of the container. Defaults to ALIGNMENT_DEFAULT.
Keep in mind that this is disabled when the content is larger than the container, because a forced alignment in this case would result in part of the content being unreachable.
- Parameters:
alignment- the new alignment
-
moveTo
abstract Unit moveTo(Float zoom, Float x, Float y, Boolean animate)
A low level API that can animate both zoom and pan at the same time. Zoom might not be the actual matrix scale, see ZoomApi.zoom and ZoomApi.realZoom. The coordinates are referred to the content size so they do not depend on current zoom.
- Parameters:
zoom- the desired zoom valuex- the desired left coordinatey- the desired top coordinateanimate- whether to animate the transition
-
moveToCenter
abstract Unit moveToCenter(Float zoom, Boolean animate)
Moves to the center of the content.
- Parameters:
zoom- the desired zoom valueanimate- whether to animate the transition
-
panTo
abstract Unit panTo(Float x, Float y, Boolean animate)
Pans the content until the top-left coordinates match the given x-y values. These are referred to the content size so they do not depend on current zoom.
- Parameters:
x- the desired left coordinatey- the desired top coordinateanimate- whether to animate the transition
-
panBy
abstract Unit panBy(Float dx, Float dy, Boolean animate)
Pans the content by the given quantity in dx-dy values. These are referred to the content size so they do not depend on current zoom.
In other words, asking to pan by 1 pixel might result in a bigger pan, if the content was zoomed in.
- Parameters:
dx- the desired delta xdy- the desired delta yanimate- whether to animate the transition
-
zoomTo
abstract Unit zoomTo(Float zoom, Boolean animate)
Zooms to the given scale. This might not be the actual matrix zoom, see ZoomApi.zoom and ZoomApi.realZoom.
- Parameters:
zoom- the new scale valueanimate- whether to animate the transition
-
zoomBy
abstract Unit zoomBy(Float zoomFactor, Boolean animate)
Applies the given factor to the current zoom.
- Parameters:
zoomFactor- a multiplicative factoranimate- whether to animate the transition
-
realZoomTo
abstract Unit realZoomTo(Float realZoom, Boolean animate)
Animates the actual matrix zoom to the given value.
- Parameters:
realZoom- the new real zoom valueanimate- whether to animate the transition
-
getMaxZoom
abstract Float getMaxZoom()
Get the currently allowed max zoom. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time.
-
getMaxZoomType
abstract Integer getMaxZoomType()
Get the currently set max zoom type.
-
setMaxZoom
Unit setMaxZoom(Float maxZoom)
Which is the max zoom that should be allowed. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time.
- Parameters:
maxZoom- the max zoom
-
setMaxZoom
abstract Unit setMaxZoom(Float maxZoom, Integer type)
Which is the max zoom that should be allowed. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time.
- Parameters:
maxZoom- the max zoomtype- the constraint mode
-
getMinZoom
abstract Float getMinZoom()
Get the currently allowed min zoom. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time.
-
getMinZoomType
abstract Integer getMinZoomType()
Get the currently set min zoom type.
-
setMinZoom
Unit setMinZoom(Float minZoom)
Which is the min zoom that should be allowed. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time.
- Parameters:
minZoom- the min zoom
-
setMinZoom
abstract Unit setMinZoom(Float minZoom, Integer type)
Which is the min zoom that should be allowed. If ZoomApi.setOverPinchable is set to true, this can be over-pinched for a brief time.
- Parameters:
minZoom- the min zoomtype- the constraint mode
-
setAnimationDuration
abstract Unit setAnimationDuration(Long duration)
Sets the duration of animations triggered by zoom and pan APIs. Defaults to ZoomEngine.DEFAULT_ANIMATION_DURATION.
- Parameters:
duration- new animation duration
-
cancelAnimations
abstract Boolean cancelAnimations()
Cancels all currently active animations triggered by either API calls with
animate = trueor touch input flings. If no animation is currently active this is a no-op.
-
getZoom
abstract Float getZoom()
Gets the current zoom value, which can be used as a reference when calling ZoomApi.zoomTo or ZoomApi.zoomBy.
This can be different than the actual scale you get in the matrix, because at startup we apply a base zoom to respect the "center inside" policy. All zoom calls, including min zoom and max zoom, refer to this axis, where zoom is set to 1 right after the initial transformation.
-
getRealZoom
abstract Float getRealZoom()
Gets the current zoom value, including the base zoom that was eventually applied when initializing to respect the "center inside" policy. This will match the scaleX - scaleY values you get into the Matrix, and is the actual scale value of the content from its original size.
-
getPan
abstract AbsolutePoint getPan()
The current pan as an AbsolutePoint.
-
getPanX
abstract Float getPanX()
Returns the current horizontal pan value, in content absolute coordinates (that is, as if there was no zoom at all).
-
getPanY
abstract Float getPanY()
Returns the current vertical pan value, in content absolute coordinates (that is, as if there was no zoom at all).
-
getScaledPan
abstract ScaledPoint getScaledPan()
The current pan as a ScaledPoint, that is, taking into account the current zoom. This basically returns the pan value multiplied by the current realZoom.
-
getScaledPanX
abstract Float getScaledPanX()
Returns the current horizontal pan value, in content scaled coordinates (that is, including the current zoom). This is equivalent to panX multiplied by realZoom.
-
getScaledPanY
abstract Float getScaledPanY()
Returns the current vertical pan value, in content scaled coordinates (that is, including the current zoom). This is equivalent to panY multiplied by realZoom.
-
-
-
-