uk.ac.kcl.cch.jb.pliny.figures
Class ScalableImageFigure

java.lang.Object
  extended byuk.ac.kcl.cch.jb.pliny.figures.ScalableImageFigure

public class ScalableImageFigure
extends Object

Manages the scaling of an image. Used within Pliny figures that display a zoomable base image upon which annotations can be attached. The zoom size can be changed after the area is set up -- the code will dispose of the image at the old size and produce a new one at the new size.

Size of the scaled image is given in terms of pixel width and height. Note that scaled image held by this object is disposed of when needed, and when this object itself is disposed. However, the main un-scaled image is not disposed.

Author:
John Bradley

Constructor Summary
ScalableImageFigure()
          constructor for an instance of this data where an image for zooming will be provided later.
ScalableImageFigure(org.eclipse.swt.graphics.Image originalImage)
          constructor for an instance of this data where the image to be scaled can be provided at construction time.
ScalableImageFigure(org.eclipse.swt.graphics.Image originalImage, int width, int height)
          constructor for an instance of this data where the image to be scaled can be provided at construction time, and the zoomed size that is needed is already known too.
 
Method Summary
 void dispose()
           
 int getDisplayHeight()
          returns height in pixels of the scaled image.
 int getDisplayWidth()
          returns width in pixels of the scaled image.
 org.eclipse.draw2d.ImageFigure getFigure()
          fetches the scaled image as a draw2d ImageFigure according to the scaling information currently stored here.
 int getOriginalHeight()
          returns height in pixels of the unscaled image.
 int getOriginalWidth()
          returns width in pixels of the unscaled image.
 void setDimensions(org.eclipse.draw2d.geometry.Dimension dim)
          sets the width and height the image is to scaled to.
 void setDimensions(int width, int height)
          sets the width and height the image is to scaled to.
 void setHeight(int height)
          sets the height the image is to scaled to.
 void setImage(org.eclipse.swt.graphics.Image originalImage)
          sets the unscaled image that is to be scaled by this item.
 void setWidth(int width)
          sets the width the image is to scaled to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScalableImageFigure

public ScalableImageFigure()
constructor for an instance of this data where an image for zooming will be provided later. To subsequently provide the image call setImage(Image).


ScalableImageFigure

public ScalableImageFigure(org.eclipse.swt.graphics.Image originalImage)
constructor for an instance of this data where the image to be scaled can be provided at construction time.


ScalableImageFigure

public ScalableImageFigure(org.eclipse.swt.graphics.Image originalImage,
                           int width,
                           int height)
constructor for an instance of this data where the image to be scaled can be provided at construction time, and the zoomed size that is needed is already known too.

Method Detail

setImage

public void setImage(org.eclipse.swt.graphics.Image originalImage)
sets the unscaled image that is to be scaled by this item. Normally this method is only used once if the constructor without parameters was used to create this object.

Parameters:
originalImage - SWT unscaled Image

getOriginalWidth

public int getOriginalWidth()
returns width in pixels of the unscaled image.

Returns:
int the width of the unscaled image in pixels

getOriginalHeight

public int getOriginalHeight()
returns height in pixels of the unscaled image.

Returns:
int the height of the unscaled image in pixels

getDisplayWidth

public int getDisplayWidth()
returns width in pixels of the scaled image.

Returns:
int the width of the scaled image in pixels

getDisplayHeight

public int getDisplayHeight()
returns height in pixels of the scaled image.

Returns:
int the height of the scaled image in pixels

setWidth

public void setWidth(int width)
sets the width the image is to scaled to. This method may be called any time the width of the image needs to change.

Parameters:
width - int new width for the scaled image.

setHeight

public void setHeight(int height)
sets the height the image is to scaled to. This method may be called any time the height of the image needs to change.

Parameters:
height - int new height for the scaled image.

setDimensions

public void setDimensions(int width,
                          int height)
sets the width and height the image is to scaled to. This method may be called any time the width and/or height of the image needs to change.

Parameters:
width - int new width for the scaled image.
height - int new height for the scaled image.

setDimensions

public void setDimensions(org.eclipse.draw2d.geometry.Dimension dim)
sets the width and height the image is to scaled to. This method may be called any time the width and/or height of the image needs to change.

Parameters:
dim - desired Dimension of scaled image.

getFigure

public org.eclipse.draw2d.ImageFigure getFigure()
fetches the scaled image as a draw2d ImageFigure according to the scaling information currently stored here.

Returns:
ImageFigure the scaled version of the image as a draw2d ImageFigure.

dispose

public void dispose()