Package de.sciss.gui

Class TiledImage


  • public class TiledImage
    extends java.lang.Object
    An Image wrapper that generates a virtual grid of sub images which are accessible by x and y offset and paintable through a custom paintTile method.
    • Constructor Summary

      Constructors 
      Constructor Description
      TiledImage​(java.awt.Image img, int tileWidth, int tileHeight)
      Creates a new TiledImage from an image applies a custom tiling grid.
      TiledImage​(java.lang.String imagePath, int tileWidth, int tileHeight)
      Creates a new TiledImage from an image file on harddisc and applies a custom tiling grid.
      TiledImage​(java.net.URL imagePath, int tileWidth, int tileHeight)
      Creates a new TiledImage from an image URL and applies a custom tiling grid.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      de.sciss.gui.TiledImage.Icon createIcon​(int col, int row)
      Creates a new Icon from this TiledImage, using one particular tile of this image.
      int getTileHeight()
      Queries the tile height
      int getTileWidth()
      Queries the tile width
      boolean paintTile​(java.awt.Graphics g, int x, int y, int tileX, int tileY, java.awt.image.ImageObserver o)
      Paints a tile onto a graphics surface.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • TiledImage

        public TiledImage​(java.lang.String imagePath,
                          int tileWidth,
                          int tileHeight)
        Creates a new TiledImage from an image file on harddisc and applies a custom tiling grid. This method waits until the image was loaded.
        Parameters:
        imagePath - file name to the image (can be relative to the application path). allowed image formats are GIF, PNG, JPG
        tileWidth - horizontal width of each tile. thus number of columns = image width / tile width
        tileHeight - vertical height of each tile. thus number of rows = image height / tile height
        See Also:
        Toolkit.getDefaultToolkit(), Toolkit.getImage( String )
      • TiledImage

        public TiledImage​(java.net.URL imagePath,
                          int tileWidth,
                          int tileHeight)
        Creates a new TiledImage from an image URL and applies a custom tiling grid. This method waits until the image was loaded.
        Parameters:
        imagePath - URL the image. allowed image formats are GIF, PNG, JPG
        tileWidth - horizontal width of each tile. thus number of columns = image width / tile width
        tileHeight - vertical height of each tile. thus number of rows = image height / tile height
      • TiledImage

        public TiledImage​(java.awt.Image img,
                          int tileWidth,
                          int tileHeight)
        Creates a new TiledImage from an image applies a custom tiling grid. This method waits until the image was loaded.
        Parameters:
        img - the image to use.
        tileWidth - horizontal width of each tile. thus number of columns = image width / tile width
        tileHeight - vertical height of each tile. thus number of rows = image height / tile height
    • Method Detail

      • getTileWidth

        public int getTileWidth()
        Queries the tile width
        Returns:
        the width of each tile in pixels, as specified in the constructor
      • getTileHeight

        public int getTileHeight()
        Queries the tile height
        Returns:
        the height of each tile in pixels, as specified in the constructor
      • paintTile

        public boolean paintTile​(java.awt.Graphics g,
                                 int x,
                                 int y,
                                 int tileX,
                                 int tileY,
                                 java.awt.image.ImageObserver o)
        Paints a tile onto a graphics surface.
        Parameters:
        g - Graphics used to draw the image
        x - x offset in the graphics context
        y - y offset in the graphics context
        tileX - column index of the tile (starting at zero)
        tileY - row index of the tile (starting at zero)
        o - asynchronous image update notification receiver
        Returns:
        true if the current output representation is complete; false otherwise.
        See Also:
        Graphics.drawImage( Image, int, int, int, int, int, int, int, int, ImageObserver )
      • createIcon

        public de.sciss.gui.TiledImage.Icon createIcon​(int col,
                                                       int row)
        Creates a new Icon from this TiledImage, using one particular tile of this image. In this way multiply icons can share the same image file and just use bits of it.
        Parameters:
        col - tile column index in the tiled image (starting at zero)
        row - tile row index in the tiled image (starting at zero)