Class ImageCanvas

java.lang.Object
java.awt.Component
java.awt.Canvas
net.sourceforge.jiu.gui.awt.ImageCanvas
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class ImageCanvas extends Canvas
An AWT canvas that displays an Image object. Capable to display at arbitrary zooming levels. Does not use rendering hints because they require Java 1.2 or higher (although bilinear and bicubic interpolation usually improve display quality when zooming at the cost of slowing down image drawing).
Author:
Marco Schmidt
See Also:
  • Field Details

    • image

      private Image image
    • width

      private int width
    • height

      private int height
    • scaledWidth

      private int scaledWidth
    • scaledHeight

      private int scaledHeight
    • zoomFactorX

      private double zoomFactorX
    • zoomFactorY

      private double zoomFactorY
    • zoomToFit

      private boolean zoomToFit
    • myScrollPane

      private ScrollPane myScrollPane
  • Constructor Details

    • ImageCanvas

      public ImageCanvas(ScrollPane scrollPane)
  • Method Details

    • computeZoomToFitSize

      public void computeZoomToFitSize()
    • getZoomPercentageX

      public int getZoomPercentageX()
    • getZoomPercentageY

      public int getZoomPercentageY()
    • getPreferredSize

      public Dimension getPreferredSize()
      Overrides:
      getPreferredSize in class Component
    • paint

      public void paint(Graphics g)
      Draws image to upper left corner.
      Overrides:
      paint in class Canvas
    • setImage

      public void setImage(Image newImage)
      Specifies a new Image object to be displayed in this canvas.
      Parameters:
      newImage - the new Image object, potentially null
    • setOriginalSize

      public void setOriginalSize()
      Sets both zoom factors to 1.0.
    • getZoomFactorX

      public double getZoomFactorX()
    • getZoomFactorY

      public double getZoomFactorY()
    • setInterpolation

      public void setInterpolation(int newType)
      Sets the interpolation type used for drawing to the argument (must be one of the INTERPOLATION_xyz constants of EditorState), but does not do a redraw.
    • setZoomFactor

      public void setZoomFactor(double newZoomFactor)
    • setZoomFactors

      public void setZoomFactors(double newZoomFactorX, double newZoomFactorY)
    • setZoomToFit

      public void setZoomToFit(boolean newValue)
    • update

      public void update(Graphics g)
      Simply calls paint(Graphics) with the argument.
      Overrides:
      update in class Canvas
      Parameters:
      g - Graphics context