Class ImageCellRenderer

    • Constructor Detail

      • ImageCellRenderer

        public ImageCellRenderer​(CellGeometry geo,
                                 MagellanContext context)
        Creates a new ImageCellRenderer.
        Parameters:
        geo - The geometry object to use for rendering.
        context - Context to get settings from.
    • Method Detail

      • scale

        public void scale​(float scaleFactor)
        Scale all images this renderer uses to a certain scale factor.
        Specified by:
        scale in interface MapCellRenderer
        Overrides:
        scale in class HexCellRenderer
        Parameters:
        scaleFactor - the factor to scale the images with (a scaleFactor of 1.0 would scale all images to their original size). Must be > 0.
        Throws:
        java.lang.IllegalArgumentException - if scaleFactor <= 0.
      • scale

        public java.awt.Image scale​(java.awt.Image img)
        Return a scaled version of the supplied using the current scale factor. If there is no media tracker, this function enforces synchronous scaling.
        Parameters:
        img - the img to scale
        Returns:
        a scaled instance of img or null, if img is null.
      • reloadImages

        public void reloadImages()
        Make the renderer reload all of its cached images.
      • setTracker

        public static void setTracker​(java.awt.MediaTracker t)
        Set a media tracker that is used to track all images that are scaled. If no media tracker is present scaling is synchronous.
      • loadFile

        protected java.awt.Image loadFile​(java.lang.String fileName)
      • loadFile

        protected java.awt.Image loadFile​(java.lang.String fileName,
                                          boolean errorIfNotFound)
      • getImage

        protected java.awt.Image getImage​(java.lang.String name)
        Returns an image that is associated with name. If name has never been supplied to this function before, it attempts to load an image with a file name of name. If no such file exists, there will be no further attempts to load the file when this function is called with the same value for name.
        Parameters:
        name - a name identifying the image to get. This name is also used as a file name without extension to load the image from a file.
        Returns:
        the image associated with name or null, if there is no such image and it cannot be loaded.
      • getImage

        protected java.awt.Image getImage​(java.lang.String name,
                                          boolean errorIfNotFound)
        Returns an image that is associated with name. If name has never been supplied to this function before, it attempts to load an image with a file name of name. If no such file exists, there will be no further attempts to load the file when this function is called with the same value for name.
        Parameters:
        name - a name identifying the image to get. This name is also used as a file name without extension to load the image from a file.
        Returns:
        the image associated with name or null, if there is no such image and it cannot be loaded.