com.blogspot.applications4android.comicreader.zoom
Class PanZoomView

java.lang.Object
  extended by View
      extended by com.blogspot.applications4android.comicreader.zoom.PanZoomView

public class PanZoomView
extends View

Main class responsible for holding a bitmap in order to zoom and pan on it. It's the responsibility of the PanZoomControl to call 'invalidate' when there's something to be updated on the view!


Constructor Summary
PanZoomView(Context context, AttributeSet attrs)
          Constructor.
 
Method Summary
 float getAspectRatio()
          Get the current value of aspect ratio.
 PanZoomControl getController()
          Give the controller for pan/zoom
 Bitmap getImageBitmap()
          current bitmap
 int getImageHeight()
          Get the image height (in pixels)
 int getImageWidth()
          Get the image width (in pixels)
 float getPanX()
          Get the current pan-x value.
 float getPanY()
          Get the current pan-y value
 float getZoom()
          Get the current zoom level.
 float getZoomX()
          Get the current value of zoom along X-axis.
 float getZoomY()
          Get the current value of zoom along Y-axis.
protected  void onDraw(Canvas canvas)
          How to draw this view?
protected  void onLayout(boolean changed, int left, int top, int right, int bottom)
          updates the aspect ratio in event of a layout change.
 void setController(PanZoomControl mc)
          Set the controller for this view
 void setImageBitmap(Bitmap bm)
          bitmap which needs to be zoomed and/or panned.
 void setPanXY(float panx, float pany)
          Set the value of pan along X-axis and Y-axis.
 void setZoom(float zoom)
          Set the value of zoom level.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PanZoomView

public PanZoomView(Context context,
                   AttributeSet attrs)
Constructor. Just calls the parent class constructor

Parameters:
context - context of the activity.
attrs - attributes for this view.
Method Detail

getController

public PanZoomControl getController()
Give the controller for pan/zoom

Returns:
the desired controller

setController

public void setController(PanZoomControl mc)
Set the controller for this view

Parameters:
mc - controller

setImageBitmap

public void setImageBitmap(Bitmap bm)
bitmap which needs to be zoomed and/or panned.

Parameters:
bm - the bitmap of interest.

getImageBitmap

public Bitmap getImageBitmap()
current bitmap

Returns:
the bitmap of interest.

onDraw

protected void onDraw(Canvas canvas)
How to draw this view?

Parameters:
canvas - canvas where to draw

onLayout

protected void onLayout(boolean changed,
                        int left,
                        int top,
                        int right,
                        int bottom)
updates the aspect ratio in event of a layout change.

Parameters:
changed - whether the orientation changed or not
left - leftmost part of the rectangle
top - topmost part of the rectangle
right - rightmost part of the rectangle
bottom - bottom-most part of the rectangle

getImageWidth

public int getImageWidth()
Get the image width (in pixels)

Returns:
image width

getImageHeight

public int getImageHeight()
Get the image height (in pixels)

Returns:
image height

getPanX

public float getPanX()
Get the current pan-x value.

Returns:
pan-x value

getPanY

public float getPanY()
Get the current pan-y value

Returns:
pan-y value

getZoomX

public float getZoomX()
Get the current value of zoom along X-axis.

Returns:
zoom-x value

getZoomY

public float getZoomY()
Get the current value of zoom along Y-axis.

Returns:
zoom-y value

getZoom

public float getZoom()
Get the current zoom level.

Returns:
zoom level

getAspectRatio

public float getAspectRatio()
Get the current value of aspect ratio.

Returns:
aspect ratio

setPanXY

public void setPanXY(float panx,
                     float pany)
Set the value of pan along X-axis and Y-axis.

Parameters:
panx - value of pan along X-axis.
pany - value of pan along Y-axis.

setZoom

public void setZoom(float zoom)
Set the value of zoom level.

Parameters:
zoom - value of zoom level.