Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

oracle.cabo.image.painter
Class ImagePainter

java.lang.Object
  |
  +--oracle.cabo.image.painter.AbstractPainter
        |
        +--oracle.cabo.image.painter.ImagePainter
All Implemented Interfaces:
Painter

public class ImagePainter
extends AbstractPainter

A painter capable of painting an image.


Field Summary
static int DONT_SCALE
          A scaling constant - the image will not be scaled at all.
static int PRESERVE_ASPECT_RATIO
          A scaling constant - the image will be scaled, but its aspect ratio will be maintained.
static int SCALE_TO_FIT
          A scaling constant - the image is scaled to fit the entire area.
 
Fields inherited from interface oracle.cabo.image.painter.Painter
STATE_ACTIVE_CHANGED, STATE_ARMED_CHANGED, STATE_BACKGROUND_CHANGED, STATE_ENABLED_CHANGED, STATE_FOCUSED_CHANGED, STATE_FONT_CHANGED, STATE_FOREGROUND_CHANGED, STATE_ISDEFAULT_CHANGED, STATE_MOUSE_OVER_CHANGED, STATE_READING_DIRECTION_CHANGED, STATE_SELECTED_CHANGED, STATE_SET_CHANGED, STATE_SIZE_CHANGED, STATE_XALIGNMENT_CHANGED, STATE_YALIGNMENT_CHANGED
 
Constructor Summary
ImagePainter()
          Creates an ImagePainter object, using the default Image Data Key, scaling the Image to fit the area to be drawn.
ImagePainter(int scalingMode)
          Creates an ImagePainter object, using the default Image Data Key and the specified scaling mode.
ImagePainter(java.lang.Object dataKey)
          Creates an ImagePainter object, using the specified data key to retrieve its Image from its PaintContext and scaling the image to fit.
ImagePainter(java.lang.Object dataKey, int scalingMode)
          Creates an ImagePainter object, using the specified data key to retrieve its Image from its PaintContext and scaling mode to specify how it handles scaling.
 
Method Summary
protected  java.lang.Object getData(PaintContext context)
           
protected  java.lang.Object getDataKey()
           
protected  java.awt.Image getImageData(PaintContext context)
          Typesafe method to return the Image to Paint.
 java.awt.Dimension getMinimumSize(PaintContext context)
          Returns the minimum size of the ImagePainter.
 boolean getProgressiveLoading()
          Returns whether the ImagePainter allows images to be progressively loaded.
 int getRepaintFlags(PaintContext context)
          Returns the flags indicating the conditions under which the Painter must be repainted.
 java.awt.Dimension getSize(PaintContext context, int availableWidth, int availableHeight)
          Returns the size of the Painter for the specified amount of availableWidth and availableHeight.
 boolean isTransparent(PaintContext context)
          Returns true if the Painter doesn't paint all of its pixels.
 void paint(PaintContext context, java.awt.Graphics g, int x, int y, int width, int height)
          Paints the ImagePainter at the given location.
 void setProgressiveLoading(boolean progressive)
          Sets whether the ImagePainter always forces images to be fully loaded, or whether it allows progressive loading.
 
Methods inherited from class oracle.cabo.image.painter.AbstractPainter
contains, getInvalidateFlags, getMaximumSize, getPainterAt, getPreferredSize
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DONT_SCALE

public static final int DONT_SCALE
A scaling constant - the image will not be scaled at all. Use this constant to allow tiling.

PRESERVE_ASPECT_RATIO

public static final int PRESERVE_ASPECT_RATIO
A scaling constant - the image will be scaled, but its aspect ratio will be maintained. The image will be scaled up until it occupies all of one dimension of its area.

SCALE_TO_FIT

public static final int SCALE_TO_FIT
A scaling constant - the image is scaled to fit the entire area. Aspect ratio is not preserved.
Constructor Detail

ImagePainter

public ImagePainter()
Creates an ImagePainter object, using the default Image Data Key, scaling the Image to fit the area to be drawn.

ImagePainter

public ImagePainter(int scalingMode)
Creates an ImagePainter object, using the default Image Data Key and the specified scaling mode.

ImagePainter

public ImagePainter(java.lang.Object dataKey)
Creates an ImagePainter object, using the specified data key to retrieve its Image from its PaintContext and scaling the image to fit.

ImagePainter

public ImagePainter(java.lang.Object dataKey,
                    int scalingMode)
Creates an ImagePainter object, using the specified data key to retrieve its Image from its PaintContext and scaling mode to specify how it handles scaling.
Method Detail

setProgressiveLoading

public void setProgressiveLoading(boolean progressive)
Sets whether the ImagePainter always forces images to be fully loaded, or whether it allows progressive loading. By default, forces images to fully load.
Parameters:
progressive - if true, uses progressive loading

getProgressiveLoading

public boolean getProgressiveLoading()
Returns whether the ImagePainter allows images to be progressively loaded.

getSize

public java.awt.Dimension getSize(PaintContext context,
                                  int availableWidth,
                                  int availableHeight)
Returns the size of the Painter for the specified amount of availableWidth and availableHeight.

Overrides:
getSize in class AbstractPainter
Parameters:
context - Context for deterimining the size.
availableWidth - Amount of width available to the Painter.
availableHeight - Amount of height available to the Painter.

Returns:
The size of the Painter.

getMinimumSize

public java.awt.Dimension getMinimumSize(PaintContext context)
Returns the minimum size of the ImagePainter.

Parameters:
context - Context for determining the minimum size.
Returns:
The minimum size of the Painter.

paint

public void paint(PaintContext context,
                  java.awt.Graphics g,
                  int x,
                  int y,
                  int width,
                  int height)
Paints the ImagePainter at the given location.

Parameters:
context - Context for painting.
g - Graphics object to draw into.
x - X position to draw at.
y - Y position to draw at.
width - Width to draw into.
height - Height to draw into.

getRepaintFlags

public int getRepaintFlags(PaintContext context)
Returns the flags indicating the conditions under which the Painter must be repainted.

Overrides:
getRepaintFlags in class AbstractPainter
Parameters:
context - Context to use for determining the conditions under which repainting is required.

Returns:
Flags indicating the conditions under which this Painter must be repainted.

isTransparent

public boolean isTransparent(PaintContext context)
Returns true if the Painter doesn't paint all of its pixels.

Overrides:
isTransparent in class AbstractPainter
Parameters:
context - Context for determining transparency.

Returns:
True if the Painter is transparent.

getImageData

protected java.awt.Image getImageData(PaintContext context)
Typesafe method to return the Image to Paint. Subclasses that do not use data keys to retrieve their data should override this method, rather than getData(), as overriding getImageData() directly is more efficient.

Parameters:
context - PaintContext to use to retrieve the TextPainter's Image data.

Returns:
The Image to paint.

See Also:
getData(oracle.cabo.image.painter.PaintContext)

getDataKey

protected java.lang.Object getDataKey()
Overrides:
getDataKey in class AbstractPainter

getData

protected java.lang.Object getData(PaintContext context)
Overrides:
getData in class AbstractPainter

Oracle UIX API Reference
Release 2.1.22.0.0
B12196-01

Copyright © 2002,2003, Oracle. All Rights Reserved.