Class ScaleController

  • Direct Known Subclasses:
    AnimatedScaleController

    public class ScaleController
    extends java.lang.Object
    The ScaleController makes it possible to control the scale of the image in an EditableImageRenderer. In order to be used, you just have to create a new instance passing the EditableImageRenderer as a parameter:
     EditableImageRenderer renderer = ...;
     ScaleController scaleController = new ScaleController(renderer);
     ...
     scaleController.setScale(2.5);
     
    Author:
    Fabrizio Giudici
    • 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 by zoomIn() and zoomOut.
      void showActualPixels()
      Sets the scale to 1:1.
      void zoomIn()
      Zooms in.
      void zoomOut()
      Zooms out.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • 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 scale
        pivot - 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 by zoomIn() and zoomOut.
        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.