home *** CD-ROM | disk | FTP | other *** search
Java Source | 1998-03-20 | 5.6 KB | 147 lines |
- /*
- * @(#)WritableRenderedImage.java 1.7 98/03/18
- *
- * Copyright 1997 by Sun Microsystems, Inc.,
- * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
- * All rights reserved.
- *
- * This software is the confidential and proprietary information
- * of Sun Microsystems, Inc. ("Confidential Information"). You
- * shall not disclose such Confidential Information and shall use
- * it only in accordance with the terms of the license agreement
- * you entered into with Sun.
- */
-
- /* ****************************************************************
- ******************************************************************
- ******************************************************************
- *** COPYRIGHT (c) Eastman Kodak Company, 1997
- *** As an unpublished work pursuant to Title 17 of the United
- *** States Code. All rights reserved.
- ******************************************************************
- ******************************************************************
- ******************************************************************/
-
- package java.awt.image;
- import java.awt.Point;
-
- /**
- * WriteableRenderedImage is a common interface for objects which
- * contain or can produce image data which can be modified and/or
- * written over.
- *
- * WritableRenderedImage provides notification to other interested
- * objects when a tile is checked out for writing (via the
- * getWritableTile method) and when the last writer of a particular
- * tile relinquishes its access (via a call to releaseWritableTile).
- * Additionally, it allows any caller to determine whether any tiles
- * are currently checked out (via hasTileWriters), and to obtain a
- * list of such tiles (from getWritableTiles, in the form of a Vector
- * of Point objects).
- *
- * Object wishing to be notified of changes in tile writability must
- * implement the TileChangeListener interface, and are added by a
- * call to addTileChangeListener. Multiple calls to
- * addTileChangeListener for the same object will result in multiple
- * notifications. An existing listener may reduce its notifications
- * by calling removeTileChangeListener; if the listener had no
- * notifications the operation is a no-op. A Vector of the current
- * TileChangeListeners is obtained by calling getTileChangeListeners.
- *
- * It is necessary for a WritableRenderedImage to ensure that
- * notifications occur only when the first writer acquires a tile and
- * the last writer deacquires it. To simplify the necessary
- * bookkeeping, the TileChangeMulticaster class is available. Calls to
- * getWritableTile are forwarded to calls to addTileWriter and calls
- * to releaseWritableTile are forwared to calls to removeTileWriter;
- * other listener-related calls are trivially forwarded (see
- * BufferedImage for an example of this style of implementation).
- * A TileChangeMulticaster may be used to inform a number of objects
- * of a tile change event from a single notification.
- *
- */
-
- public interface WritableRenderedImage extends RenderedImage
- {
-
- /**
- * Add a listener. If the listener is already present,
- * it will receive multiple notifications.
- */
- public void addTileChangeListener(TileChangeListener tcl);
-
- /**
- * Remove a listener. If the listener was not registered,
- * nothing happens. If the listener was registered for multiple
- * notifications, it will now be registered for one fewer.
- */
- public void removeTileChangeListener(TileChangeListener tcl);
-
- /**
- * Return a Vector of TileChangeListener objects.
- * Listeners registered multiple times will appear
- * a corresponding number of times in the list.
- */
- public TileChangeListener[] getTileChangeListeners();
-
- /**
- * Check out a tile for writing. This method is already part of
- * the WritableRenderedImage interface.
- *
- * The WritableRenderedImage is responsible for notifying all
- * of its TileChangeListeners when a tile goes from having
- * no writers to having one writer. A simple way to fulfill this
- * contract is to instantiate a TileChangeFilter and to call
- * its addTileWriter method every time this method is called.
- *
- * @param tileX the X index of the tile.
- * @param tileY the Y index of the tile.
- */
- public WritableRaster getWritableTile(int tileX, int tileY);
-
- /**
- * Relinquish the right to write to a tile. If the caller
- * continues to write to the tile, the results are undefined.
- * Calls to his method should only appear in matching pairs
- * with calls to getWritableTile; any other use will lead
- * to undefined results.
- *
- * The WritableRenderedImage is responsible for notifying all of
- * its TileChangeListeners when a tile goes from having one writer
- * to having no writers. A simple way to fulfill this contract is
- * to instantiate a TileChangeFilter and to call its removeTileWriter
- * method every time this method is called.
- *
- * @param tileX the X index of the tile.
- * @param tileY the Y index of the tile.
- */
- public void releaseWritableTile(int tileX, int tileY);
-
- /**
- * Return whether a tile is currently checked out for writing.
- * This may be implemented by delegation to a TileChangeFilter.
- *
- * @param tileX the X index of the tile.
- * @param tileY the Y index of the tile.
- */
- public boolean isTileWritable(int tileX, int tileY);
-
- /**
- * Return a array of Point objects indicating which tiles
- * are checked out for writing.
- */
- public Point[] getWritableTiles();
-
- /**
- * Return whether any tile is checked out for writing.
- * Equivalent to (getWritableTiles().size() != 0).
- */
- public boolean hasTileWriters();
-
- /**
- * Set a rect of the image to the contents of rb.
- */
- public void setRect(Raster rb);
-
- }
-