Package it.tidalwave.image.render
Class ScaleController
- java.lang.Object
-
- it.tidalwave.image.render.ScaleController
-
- Direct Known Subclasses:
AnimatedScaleController
public class ScaleController extends java.lang.ObjectTheScaleControllermakes it possible to control the scale of the image in anEditableImageRenderer. In order to be used, you just have to create a new instance passing theEditableImageRendereras a parameter:EditableImageRenderer renderer = ...; ScaleController scaleController = new ScaleController(renderer); ... scaleController.setScale(2.5);
- Author:
- Fabrizio Giudici
-
-
Field Summary
Fields Modifier and Type Field Description protected EditableImageRendererimageRendererThe attached renderer.
-
Constructor Summary
Constructors Constructor Description ScaleController(EditableImageRenderer imageRenderer)Creates a new instance of this class, attached to the given renderer.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfitToView()Fits the image into the current view: the image is resized so it's not clipped, and it's centered on the screen.voidfitToView(double factor)protected EditableImageRenderergetImageRenderer()doublegetScale()Returns the current scale.doublegetZoomFactor()Returns the current zoom factor.voidsetScale(double scale)Sets the scale.voidsetScale(double scale, java.awt.Point pivot)Sets the scale using a pivot point.voidsetZoomFactor(double zoomFactor)Sets the zoom factor that is used byzoomIn()andzoomOut.voidshowActualPixels()Sets the scale to 1:1.voidzoomIn()Zooms in.voidzoomOut()Zooms out.
-
-
-
Field Detail
-
imageRenderer
protected final EditableImageRenderer imageRenderer
The attached renderer.
-
-
Constructor Detail
-
ScaleController
public ScaleController(EditableImageRenderer imageRenderer)
Creates a new instance of this class, attached to the given renderer.- Parameters:
imageRenderer- the image renderer
-
-
Method Detail
-
setScale
public final void setScale(double scale)
Sets the scale.- Parameters:
scale- the new scale
-
setScale
public void setScale(double scale, java.awt.Point pivot)Sets the scale using a pivot point. A null pivot means that the pivot will be placed on the center of the image.- Parameters:
scale- the new scalepivot- the pivot point (null means the center of the image)
-
getScale
public double getScale()
Returns the current scale.- Returns:
- the current scale
-
setZoomFactor
public void setZoomFactor(double zoomFactor)
Sets the zoom factor that is used byzoomIn()andzoomOut.- Parameters:
zoomFactor- the new zoom factor
-
getZoomFactor
public double getZoomFactor()
Returns the current zoom factor.- Returns:
- the currnet zoom factor
-
fitToView
public void fitToView()
Fits the image into the current view: the image is resized so it's not clipped, and it's centered on the screen.
-
fitToView
public void fitToView(double factor)
-
zoomOut
public void zoomOut()
Zooms out.
-
zoomIn
public void zoomIn()
Zooms in.
-
showActualPixels
public void showActualPixels()
Sets the scale to 1:1.
-
getImageRenderer
protected EditableImageRenderer getImageRenderer()
- Returns:
- the image renderer
-
-