/* @(#)ImageTile.java 1.0 12 October 2004 */ import edu.neu.ccs.gui.*; import java.awt.*; import java.awt.geom.*; /** *
Class ImageTile is a special purpose class for the
* construction of tile objects based on images.
Constructs an image tile using the given image, * the given tile background, * the given tile width and height, * the initial visibility setting for the tile image, * and the initial mouse activity setting.
*/ public ImageTile( Image image, Color background, int width, int height, boolean visible, boolean active) { super(new ImagePaintable(image), background, true); this.image = image; this.active = active; ImagePaintable paintable = (ImagePaintable) getPaintable(); Rectangle2D bounds = new Rectangle2D.Double(0, 0, width, height); paintable.setDefaultBounds2D(bounds); paintable.setVisible(visible); } /** Returns the encapsulated image. */ public Image getImage() { return image; } /** Returns the visibility of the tile image. */ public boolean isTileVisible() { return getPaintable().isVisible(); } /** Sets the visibility of the tile image. */ public void setTileVisible(boolean visible) { getPaintable().setVisible(visible); } /** Returns whether or not the tile should respond to mouse clicks. */ public boolean isMouseActive() { return active; } /** Sets whether or not the tile should respond to mouse clicks. */ public void setMouseActive(boolean active) { this.active = active; } /** * Tests equality of two image tiles by testing if their encapsulated * images are identical. */ public boolean isEqualTo(ImageTile tile) { if (tile == null) return false; return image == tile.getImage(); } }