Tabnine Logo
SubsamplingScaleImageView.vTranslateForSCenter
Code IndexAdd Tabnine to your IDE (free)

How to use
vTranslateForSCenter
method
in
com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView

Best Java code snippets using com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView.vTranslateForSCenter (Showing top 4 results out of 315)

origin: davemorrissey/subsampling-scale-image-view

/**
 * Adjusts current scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale
 * is set so one dimension fills the view and the image is centered on the other dimension.
 * @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached.
 */
private void fitToBounds(boolean center) {
  boolean init = false;
  if (vTranslate == null) {
    init = true;
    vTranslate = new PointF(0, 0);
  }
  if (satTemp == null) {
    satTemp = new ScaleAndTranslate(0, new PointF(0, 0));
  }
  satTemp.scale = scale;
  satTemp.vTranslate.set(vTranslate);
  fitToBounds(center, satTemp);
  scale = satTemp.scale;
  vTranslate.set(satTemp.vTranslate);
  if (init && minimumScaleType != SCALE_TYPE_START) {
    vTranslate.set(vTranslateForSCenter(sWidth()/2, sHeight()/2, scale));
  }
}
origin: davemorrissey/subsampling-scale-image-view

/**
 * Given a requested source center and scale, calculate what the actual center will have to be to keep the image in
 * pan limits, keeping the requested center as near to the middle of the screen as allowed.
 */
@NonNull
private PointF limitedSCenter(float sCenterX, float sCenterY, float scale, @NonNull PointF sTarget) {
  PointF vTranslate = vTranslateForSCenter(sCenterX, sCenterY, scale);
  int vxCenter = getPaddingLeft() + (getWidth() - getPaddingRight() - getPaddingLeft())/2;
  int vyCenter = getPaddingTop() + (getHeight() - getPaddingBottom() - getPaddingTop())/2;
  float sx = (vxCenter - vTranslate.x)/scale;
  float sy = (vyCenter - vTranslate.y)/scale;
  sTarget.set(sx, sy);
  return sTarget;
}
origin: mozilla-tw/Rocket

/**
 * Adjusts current scale and translate values to keep scale within the allowed range and the image on screen. Minimum scale
 * is set so one dimension fills the view and the image is centered on the other dimension.
 * @param center Whether the image should be centered in the dimension it's too small to fill. While animating this can be false to avoid changes in direction as bounds are reached.
 */
private void fitToBounds(boolean center) {
  boolean init = false;
  if (vTranslate == null) {
    init = true;
    vTranslate = new PointF(0, 0);
  }
  if (satTemp == null) {
    satTemp = new ScaleAndTranslate(0, new PointF(0, 0));
  }
  satTemp.scale = scale;
  satTemp.vTranslate.set(vTranslate);
  fitToBounds(center, satTemp);
  scale = satTemp.scale;
  vTranslate.set(satTemp.vTranslate);
  if (init) {
    vTranslate.set(vTranslateForSCenter(sWidth()/2, sHeight()/2, scale));
  }
}
origin: mozilla-tw/Rocket

/**
 * Given a requested source center and scale, calculate what the actual center will have to be to keep the image in
 * pan limits, keeping the requested center as near to the middle of the screen as allowed.
 */
private PointF limitedSCenter(float sCenterX, float sCenterY, float scale, PointF sTarget) {
  PointF vTranslate = vTranslateForSCenter(sCenterX, sCenterY, scale);
  int vxCenter = getPaddingLeft() + (getWidth() - getPaddingRight() - getPaddingLeft())/2;
  int vyCenter = getPaddingTop() + (getHeight() - getPaddingBottom() - getPaddingTop())/2;
  float sx = (vxCenter - vTranslate.x)/scale;
  float sy = (vyCenter - vTranslate.y)/scale;
  sTarget.set(sx, sy);
  return sTarget;
}
com.davemorrissey.labs.subscaleviewSubsamplingScaleImageViewvTranslateForSCenter

Javadoc

Get the translation required to place a given source coordinate at the center of the screen, with the center adjusted for asymmetric padding. Accepts the desired scale as an argument, so this is independent of current translate and scale. The result is fitted to bounds, putting the image point as near to the screen center as permitted.

Popular methods of SubsamplingScaleImageView

  • setImage
    Set the image source from a bitmap, resource, asset, file or other URI, starting with a given orient
  • setDoubleTapZoomScale
    Set the scale the image will zoom in to when double tapped. This also the scale point where a double
  • setMaxScale
    Set the maximum scale allowed. A value of 1 means 1:1 pixels at maximum scale. You may wish to set t
  • setMinimumDpi
    This is a screen density aware alternative to #setMaxScale(float); it allows you to express the maxi
  • setScaleAndCenter
    Externally change the scale and translation of the source image. This may be used with getCenter() a
  • getWidth
  • setDoubleTapZoomDpi
    A density aware alternative to #setDoubleTapZoomScale(float); this allows you to express the scale t
  • setMinimumScaleType
    Set the minimum scale type. See static fields. Normally #SCALE_TYPE_CENTER_INSIDE is best, for image
  • setMinimumTileDpi
    By default, image tiles are at least as high resolution as the screen. For a retina screen this may
  • setPanEnabled
    Enable or disable pan gesture detection. Disabling pan causes the image to be centered.
  • setZoomEnabled
    Enable or disable zoom gesture detection. Disabling zoom locks the the current scale.
  • <init>
  • setZoomEnabled,
  • <init>,
  • getCenter,
  • getContext,
  • getHeight,
  • getOrientation,
  • getScale,
  • isReady,
  • onDraw,
  • onImageLoaded

Popular in Java

  • Reactive rest calls using spring rest template
  • findViewById (Activity)
  • getContentResolver (Context)
  • setRequestProperty (URLConnection)
  • Point (java.awt)
    A point representing a location in (x,y) coordinate space, specified in integer precision.
  • SocketTimeoutException (java.net)
    This exception is thrown when a timeout expired on a socket read or accept operation.
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Enumeration (java.util)
    A legacy iteration interface.New code should use Iterator instead. Iterator replaces the enumeration
  • BoxLayout (javax.swing)
  • JComboBox (javax.swing)
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now