Android Open Source - GuiLib Photo View






From Project

Back to project page GuiLib.

License

The source code is released under:

Apache License

If you think the Android project GuiLib listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

/*******************************************************************************
 * Copyright 2011, 2012 Chris Banes.// ww w . j ava  2  s.  c  om
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *******************************************************************************/
package uk.co.senab.photoview;

import uk.co.senab.photoview.PhotoViewAttacher.OnMatrixChangedListener;
import uk.co.senab.photoview.PhotoViewAttacher.OnPhotoTapListener;
import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;

@TargetApi(9)
public class PhotoView extends ImageView {

  private final PhotoViewAttacher mAttacher;

  public PhotoView(Context context) {
    super(context);
    super.setScaleType(ScaleType.MATRIX);
    mAttacher = new PhotoViewAttacher(this);
  }

  public PhotoView(Context context, AttributeSet attr) {
    super(context, attr);
    super.setScaleType(ScaleType.MATRIX);
    mAttacher = new PhotoViewAttacher(this);
  }

  /**
   * Returns true if the PhotoView is set to allow zooming of Photos.
   * 
   * @return true if the PhotoView allows zooming.
   */
  public boolean canZoom() {
    return mAttacher.canZoom();
  }

  /**
   * Gets the Display Rectangle of the currently displayed Drawable. The
   * Rectangle is relative to this View and includes all scaling and
   * translations.
   * 
   * @return - RectF of Displayed Drawable
   */
  public RectF getDisplayRect() {
    return mAttacher.getDisplayRect();
  }

  /**
   * Returns the current scale value
   * 
   * @return float - current scale value
   */
  public float getScale() {
    return mAttacher.getScale();
  }
  
  @Override
  public ScaleType getScaleType() {
    return mAttacher.getScaleType();
  }

  @Override
  public void setImageDrawable(Drawable drawable) {
    super.setImageDrawable(drawable);
    if(mAttacher != null) {
      mAttacher.update();
    }
  }

  /**
   * Register a callback to be invoked when the Matrix has changed for this
   * View. An example would be the user panning or scaling the Photo.
   * 
   * @param listener
   *            - Listener to be registered.
   */
  public void setOnMatrixChangeListener(OnMatrixChangedListener listener) {
    mAttacher.setOnMatrixChangeListener(listener);
  }

  /**
   * Register a callback to be invoked when the Photo displayed by this View
   * is tapped with a single tap.
   * 
   * @param listener
   *            - Listener to be registered.
   */
  public void setOnPhotoTapListener(OnPhotoTapListener listener) {
    mAttacher.setOnPhotoTapListener(listener);
  }
  
  @Override
  public void setScaleType(ScaleType scaleType) {
    mAttacher.setScaleType(scaleType);
  }

  /**
   * Allows you to enable/disable the zoom functionality on the ImageView.
   * When disable the ImageView reverts to using the FIT_CENTER matrix.
   * 
   * @param zoomable
   *            - Whether the zoom functionality is enabled.
   */
  public void setZoomable(boolean zoomable) {
    mAttacher.setZoomable(zoomable);
  }

  /**
   * Zooms to the specified scale, around the focal point given.
   * 
   * @param scale
   *            - Scale to zoom to
   * @param focalX
   *            - X Focus Point
   * @param focalY
   *            - Y Focus Point
   */
  public void zoomTo(float scale, float focalX, float focalY) {
    mAttacher.zoomTo(scale, focalX, focalY);
  }

}




Java Source Code List

au.com.bytecode.opencsv.CSVReader.java
com.ecloud.pulltozoomview.PullToZoomScrollView.java
com.gandulf.guilib.data.OpenArrayAdapter.java
com.gandulf.guilib.data.OpenFilter.java
com.gandulf.guilib.download.AbstractDownloader.java
com.gandulf.guilib.download.DownloadBroadcastReceiver.java
com.gandulf.guilib.download.DownloaderGinger.java
com.gandulf.guilib.download.DownloaderWrapper.java
com.gandulf.guilib.download.Downloader.java
com.gandulf.guilib.download.MediaScannerWrapper.java
com.gandulf.guilib.download.UnzipIntentService.java
com.gandulf.guilib.listener.CheckableListenable.java
com.gandulf.guilib.listener.OnCheckedChangeListener.java
com.gandulf.guilib.util.ColorUtil.java
com.gandulf.guilib.util.Debug.java
com.gandulf.guilib.util.DefaultTextWatcher.java
com.gandulf.guilib.util.DirectoryFileFilter.java
com.gandulf.guilib.util.FileFileFilter.java
com.gandulf.guilib.util.ListViewCompat.java
com.gandulf.guilib.util.MathUtil.java
com.gandulf.guilib.util.ResUtil.java
com.gandulf.guilib.view.ColorPickerDialog.java
com.gandulf.guilib.view.DynamicListViewEx.java
com.gandulf.guilib.view.HackeyDrawerLayout.java
com.gandulf.guilib.view.SeekBarEx.java
com.gandulf.guilib.view.VersionInfoDialog.java
com.gandulf.guilib.view.ViewScroller.java
com.gandulf.guilib.view.adapter.MultiFragmentPagerAdapter.java
com.getbase.floatingactionbutton.AddFloatingActionButton.java
com.getbase.floatingactionbutton.FloatingActionButton.java
com.getbase.floatingactionbutton.FloatingActionsMenu.java
com.github.amlcurran.showcaseview.AnimationFactory.java
com.github.amlcurran.showcaseview.AnimatorAnimationFactory.java
com.github.amlcurran.showcaseview.ApiUtils.java
com.github.amlcurran.showcaseview.Calculator.java
com.github.amlcurran.showcaseview.NewShowcaseDrawer.java
com.github.amlcurran.showcaseview.OnShowcaseEventListener.java
com.github.amlcurran.showcaseview.ShotStateStore.java
com.github.amlcurran.showcaseview.ShowcaseAreaCalculator.java
com.github.amlcurran.showcaseview.ShowcaseDrawer.java
com.github.amlcurran.showcaseview.ShowcaseView.java
com.github.amlcurran.showcaseview.StandardShowcaseDrawer.java
com.github.amlcurran.showcaseview.TextDrawer.java
com.github.amlcurran.showcaseview.targets.ActionBarReflector.java
com.github.amlcurran.showcaseview.targets.ActionBarViewWrapper.java
com.github.amlcurran.showcaseview.targets.ActionItemTarget.java
com.github.amlcurran.showcaseview.targets.ActionViewTarget.java
com.github.amlcurran.showcaseview.targets.AppCompatReflector.java
com.github.amlcurran.showcaseview.targets.PointTarget.java
com.github.amlcurran.showcaseview.targets.ReflectorFactory.java
com.github.amlcurran.showcaseview.targets.Reflector.java
com.github.amlcurran.showcaseview.targets.SherlockReflector.java
com.github.amlcurran.showcaseview.targets.Target.java
com.github.amlcurran.showcaseview.targets.ViewTarget.java
com.sothree.slidinguppanel.SlidingUpPanelLayout.java
com.sothree.slidinguppanel.ViewDragHelper.java
com.thebnich.floatinghintedittext.FloatingHintEditText.java
com.thebnich.floatinghintedittext.FloatingHintTextView.java
com.wefika.flowlayout.FlowLayout.java
de.hdodenhof.circleimageview.CircleImageView.java
uk.co.senab.photoview.Compat.java
uk.co.senab.photoview.PhotoViewAttacher.java
uk.co.senab.photoview.PhotoView.java
uk.co.senab.photoview.SDK16.java
uk.co.senab.photoview.ScrollerProxy.java
uk.co.senab.photoview.VersionedGestureDetector.java
uk.me.lewisdeane.ldialogs.BaseDialog.java
uk.me.lewisdeane.ldialogs.CustomDialog.java
uk.me.lewisdeane.ldialogs.CustomListAdapter.java