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.Object
TheScaleController
makes 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 theEditableImageRenderer
as 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 EditableImageRenderer
imageRenderer
The 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 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.void
fitToView(double factor)
protected EditableImageRenderer
getImageRenderer()
double
getScale()
Returns the current scale.double
getZoomFactor()
Returns the current zoom factor.void
setScale(double scale)
Sets the scale.void
setScale(double scale, java.awt.Point pivot)
Sets the scale using a pivot point.void
setZoomFactor(double zoomFactor)
Sets the zoom factor that is used byzoomIn()
andzoomOut
.void
showActualPixels()
Sets the scale to 1:1.void
zoomIn()
Zooms in.void
zoomOut()
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
-
-