Class ImageFigure

    • Field Summary

      • Fields inherited from interface java.awt.image.ImageObserver

        ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageFigure()
      Create an empty image figure.
      ImageFigure​(java.awt.Image i)
      Create an image figure displaying the given image.
    • Constructor Detail

      • ImageFigure

        public ImageFigure()
        Create an empty image figure.
      • ImageFigure

        public ImageFigure​(java.awt.Image i)
        Create an image figure displaying the given image. This needs to be called in the Swing thread.
    • Method Detail

      • getImage

        public java.awt.Image getImage()
        Return the figure's image.
      • getOrigin

        public java.awt.geom.Point2D getOrigin()
        Return the origin of the figure in the enclosing transform context. This overrides the base class to return the center of the shape, if the figure is centered, or the origin of the shape if the figure is not centered.
        Specified by:
        getOrigin in interface Figure
        Overrides:
        getOrigin in class AbstractFigure
        Returns:
        The origin of the figure.
        See Also:
        AbstractFigure.getBounds()
      • getShape

        public java.awt.Shape getShape()
        Return the rectangular shape of the image, or a small rectangle if the image is null. NOTE: You cannot rely on the return value unless the image has been fully rendered.
        Specified by:
        getShape in interface Figure
        Specified by:
        getShape in class AbstractFigure
        Returns:
        the outline shape of this figure
      • imageUpdate

        public boolean imageUpdate​(java.awt.Image image,
                                   int infoflags,
                                   int x,
                                   int y,
                                   int width,
                                   int height)
        This method, which is required by the ImageObserver interface, is called if something has changed in a background loading of the image. It simply calls repaint().
        Specified by:
        imageUpdate in interface java.awt.image.ImageObserver
        Parameters:
        image - The image being observed.
        infoflags - The bitwise inclusive OR of the following flags: WIDTH, HEIGHT, PROPERTIES, SOMEBITS, FRAMEBITS, ALLBITS, ERROR, ABORT.
        x - The x coordinate of the image.
        y - The y coordinate of the image.
        width - The width of the image.
        height - The height of the image.
        Returns:
        False if the infoflags indicate that the image is completely loaded; true otherwise.
      • isCentered

        public boolean isCentered()
        Return whether the figure should be centered on its origin.
        Returns:
        False If the origin of the figure, as returned by getOrigin(), is the upper left corner.
        See Also:
        getOrigin(), setCentered(boolean)
      • paint

        public void paint​(java.awt.Graphics2D g)
        Paint the figure's image.
        Specified by:
        paint in interface VisibleComponent
        Specified by:
        paint in class AbstractFigure
        Parameters:
        g - The 2D graphics object that this object it to be painted upon.
      • setCentered

        public void setCentered​(boolean centered)
        Specify whether the figure should be centered on its origin. By default, it is.
        Parameters:
        centered - False to make the origin of the figure, as returned by getOrigin(), be the upper left corner.
        See Also:
        getOrigin()
      • setImage

        public void setImage​(java.awt.Image i)
        Set the figure's image. This should be called only from the Swing thread.
        Parameters:
        i - The image.
      • transform

        public void transform​(java.awt.geom.AffineTransform t)
        Perform an affine transform on this image.
        Specified by:
        transform in interface Figure
        Specified by:
        transform in class AbstractFigure
        Parameters:
        t - The transform to be used.