|
JSR-184 Public Review Draft - Apr. 30, 2003. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.microedition.m3d.Object3D | +--javax.microedition.m3d.Background
Attributes for clearing the color buffer. The color buffer can be cleared with a solid color or a background image. The image can be scaled to fit the screen, repeated, or centered separately in each of the horizontal and vertical directions. The image can also be further positioned by an offset.
The Background image is stored as a reference to an Image2D. The image may be in any of the formats defined in Image2D, with or without a palette. The width and height of the image are not limited in any way; in particular, they need not be powers of two.
If the referenced Image2D is modified by the application (by rendering into it), or a new Image2D is bound as the background image, the modifications are immediately reflected in the Background object.
Field Summary | |
static int |
CENTER
Specifies that the background image be centered in the viewport in the X or Y direction. |
static int |
FIT
Specifies that the background image be scaled to fit the viewport in the X or Y direction. |
static int |
TILE
Specifies that the background image be repeated (tiled) indefinitely in the X or Y direction. |
Fields inherited from class javax.microedition.m3d.Object3D |
userObject |
Constructor Summary | |
Background()
Constructs a new Background with default values. |
Method Summary | |
int |
getColor()
Retrieves the current background color. |
Image2D |
getImage()
Gets the current background image. |
int |
getImageModeX()
Gets the current X background image scaling mode. |
int |
getImageModeY()
Gets the current Y background image scaling mode. |
float |
getImageOffsetX()
Gets the X offset of the background image. |
float |
getImageOffsetY()
Gets the Y offset of the background image. |
void |
setColor(int ARGB)
Sets the background color. |
void |
setImage(Image2D image)
Sets the background image, or switches from background image mode to background color mode. |
void |
setImageMode(int modeX,
int modeY)
Sets the background image scaling modes for the X and Y directions. |
void |
setImageOffset(float offsetX,
float offsetY)
Sets the background image offset. |
Methods inherited from class javax.microedition.m3d.Object3D |
addAnimationTrack, animate, clone, find, getAnimationTrack, getAnimationTrackCount, getReferences, getUserID, removeAnimationTrack, setUserID |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int CENTER
Specifies that the background image be centered in the viewport in the X or Y direction.
public static final int TILE
Specifies that the background image be repeated (tiled) indefinitely in the X or Y direction.
public static final int FIT
Specifies that the background image be scaled to fit the viewport in the X or Y direction. NOTE: It is currently not possible to scale the image without distortion if its aspect ratio differs from the aspect ratio of the screen.
The image offset in this mode is calculated as fractions of
the scaled image size. The image also repeats to fill the
screen as in the TILE
mode.
Constructor Detail |
public Background()
Constructs a new Background with default values. The default values are:
CENTER, CENTER
Method Detail |
public void setColor(int ARGB)
Sets the background color. The parts of the viewport that are
not covered by the background image are cleared to the background
color when Graphics3D.clear(BUF_COLOR, Background)
or Graphics3D.render(World)
is called.
ARGB
- the new background color in 0xAARRGGBB formatgetColor()
public int getColor()
Retrieves the current background color.
setColor(int)
public void setImage(Image2D image)
Sets the background image, or switches from background image mode to background color mode.
image
- the background image, or null to disable the current
background image (if any) and clear with background color insteadgetImage()
public Image2D getImage()
Gets the current background image.
setImage(javax.microedition.m3d.Image2D)
public void setImageMode(int modeX, int modeY)
Sets the background image scaling modes for the X and Y directions.
modeX
- one of CENTER, TILE, FIT
modeY
- one of CENTER, TILE, FIT
java.lang.IllegalArgumentException
- if modeX
or
modeY
is not a legal scaling modepublic int getImageModeX()
Gets the current X background image scaling mode.
setImageMode
public int getImageModeY()
Gets the current Y background image scaling mode.
setImageMode
public void setImageOffset(float offsetX, float offsetY)
Sets the background image offset. This is specified as the position of the center of the viewport with respect to the top left corner of the background image, in fractions of (scaled) image size. The default value of (0.5, 0.5) places the center of the viewport at the center of the image; that is, centers the image in the viewport.
offsetX
- background image X offsetoffsetY
- background image Y offsetpublic float getImageOffsetX()
Gets the X offset of the background image.
setImageOffset
public float getImageOffsetY()
Gets the Y offset of the background image.
setImageOffset
|
JSR-184 Public Review Draft - Apr. 30, 2003. | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |