Class 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:
    Serialized Form
    • Field Detail

      • 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
    • Constructor Detail

      • ImageCanvas

        public ImageCanvas​(ScrollPane scrollPane)
    • Method Detail

      • computeZoomToFitSize

        public void computeZoomToFitSize()
      • getZoomPercentageX

        public int getZoomPercentageX()
      • getZoomPercentageY

        public int getZoomPercentageY()
      • 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)