Package de.sciss.gui
Class TiledImage
- java.lang.Object
-
- de.sciss.gui.TiledImage
-
public class TiledImage extends java.lang.ObjectAnImagewrapper that generates a virtual grid of sub images which are accessible by x and y offset and paintable through a custompaintTilemethod.
-
-
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.IconcreateIcon(int col, int row)Creates a newIconfrom thisTiledImage, using one particular tile of this image.intgetTileHeight()Queries the tile heightintgetTileWidth()Queries the tile widthbooleanpaintTile(java.awt.Graphics g, int x, int y, int tileX, int tileY, java.awt.image.ImageObserver o)Paints a tile onto a graphics surface.
-
-
-
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, JPGtileWidth- horizontal width of each tile. thus number of columns = image width / tile widthtileHeight- 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-URLthe image. allowed image formats are GIF, PNG, JPGtileWidth- horizontal width of each tile. thus number of columns = image width / tile widthtileHeight- 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 widthtileHeight- 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-Graphicsused to draw the imagex- x offset in the graphics contexty- y offset in the graphics contexttileX- column index of the tile (starting at zero)tileY- row index of the tile (starting at zero)o- asynchronous image update notification receiver- Returns:
trueif the current output representation is complete;falseotherwise.- 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 newIconfrom thisTiledImage, 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)
-
-