< prev index next >
src/java.desktop/share/classes/sun/swing/CachedPainter.java
Print this page
*** 30,54 ****
/**
* A base class used for icons or images that are expensive to paint.
* A subclass will do the following:
* <ol>
! * <li>Invoke <code>paint</code> when you want to paint the image,
! * if you are implementing <code>Icon</code> you'll invoke this from
! * <code>paintIcon</code>.
* The args argument is useful when additional state is needed.
! * <li>Override <code>paintToImage</code> to render the image. The code that
* lives here is equivalent to what previously would go in
! * <code>paintIcon</code>, for an <code>Icon</code>.
* </ol>
* The two ways to use this class are:
* <ol>
! * <li>Invoke <code>paint</code> to draw the cached reprensentation at
* the specified location.
! * <li>Invoke <code>getImage</code> to get the cached reprensentation and
* draw the image yourself. This is primarly useful when you are not
! * using <code>VolatileImage</code>.
* </ol>
*
*
*/
public abstract class CachedPainter {
--- 30,54 ----
/**
* A base class used for icons or images that are expensive to paint.
* A subclass will do the following:
* <ol>
! * <li>Invoke {@code paint} when you want to paint the image,
! * if you are implementing {@code Icon} you'll invoke this from
! * {@code paintIcon}.
* The args argument is useful when additional state is needed.
! * <li>Override {@code paintToImage} to render the image. The code that
* lives here is equivalent to what previously would go in
! * {@code paintIcon}, for an {@code Icon}.
* </ol>
* The two ways to use this class are:
* <ol>
! * <li>Invoke {@code paint} to draw the cached reprensentation at
* the specified location.
! * <li>Invoke {@code getImage} to get the cached reprensentation and
* draw the image yourself. This is primarly useful when you are not
! * using {@code VolatileImage}.
* </ol>
*
*
*/
public abstract class CachedPainter {
*** 67,89 ****
return cache;
}
}
/**
! * Creates an instance of <code>CachedPainter</code> that will cache up
! * to <code>cacheCount</code> images of this class.
*
* @param cacheCount Max number of images to cache
*/
public CachedPainter(int cacheCount) {
getCache(getClass()).setMaxCount(cacheCount);
}
/**
! * Renders the cached image to the passed in <code>Graphic</code>.
! * If there is no cached image <code>paintToImage</code> will be invoked.
! * <code>paintImage</code> is invoked to paint the cached image.
*
* @param c Component rendering to, this may be null.
* @param g Graphics to paint to
* @param x X-coordinate to render to
* @param y Y-coordinate to render to
--- 67,89 ----
return cache;
}
}
/**
! * Creates an instance of {@code CachedPainter} that will cache up
! * to {@code cacheCount} images of this class.
*
* @param cacheCount Max number of images to cache
*/
public CachedPainter(int cacheCount) {
getCache(getClass()).setMaxCount(cacheCount);
}
/**
! * Renders the cached image to the passed in {@code Graphic}.
! * If there is no cached image {@code paintToImage} will be invoked.
! * {@code paintImage} is invoked to paint the cached image.
*
* @param c Component rendering to, this may be null.
* @param g Graphics to paint to
* @param x X-coordinate to render to
* @param y Y-coordinate to render to
*** 163,173 ****
* @param c Component painting to, may be null.
* @param image Image to paint to
* @param g Graphics to paint to, obtained from the passed in Image.
* @param w Width to paint to
* @param h Height to paint to
! * @param args Arguments supplied to <code>paint</code>
*/
protected abstract void paintToImage(Component c, Image image, Graphics g,
int w, int h, Object[] args);
--- 163,173 ----
* @param c Component painting to, may be null.
* @param image Image to paint to
* @param g Graphics to paint to, obtained from the passed in Image.
* @param w Width to paint to
* @param h Height to paint to
! * @param args Arguments supplied to {@code paint}
*/
protected abstract void paintToImage(Component c, Image image, Graphics g,
int w, int h, Object[] args);
*** 179,189 ****
* @param x X coordinate to paint to
* @param y Y coordinate to paint to
* @param w Width to paint to
* @param h Height to paint to
* @param image Image to paint
! * @param args Arguments supplied to <code>paint</code>
*/
protected void paintImage(Component c, Graphics g,
int x, int y, int w, int h, Image image,
Object[] args) {
g.drawImage(image, x, y, null);
--- 179,189 ----
* @param x X coordinate to paint to
* @param y Y coordinate to paint to
* @param w Width to paint to
* @param h Height to paint to
* @param image Image to paint
! * @param args Arguments supplied to {@code paint}
*/
protected void paintImage(Component c, Graphics g,
int x, int y, int w, int h, Image image,
Object[] args) {
g.drawImage(image, x, y, null);
< prev index next >