|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.xith3d.ui.swingui.UIOverlay
public class UIOverlay
An overlay is 3d geometry which is aligned with the image plate. This is designed to be as simple as possible for the developer to use. All that is needed is to extend this class and override the paint function to update the image which will be written displayed on the screen. As a note: Displaying large overlays can use a *huge* amount of texture memory. If you created a pane which was 1024x768 you would consume over 3 mb of texture memory. Another thing to realize is that textures have to be a power of two. Because of this an overlay which was 513 x 257 would normally have to be generated using 1024 x 512. Unlike most textures, overlays cannot tolerate stretching and interpolation because of the fuzzyness which would result. So what the Xith overlay system attempts to do is break the overlay up into small pieces so that extra texture memory is not wasted. You are given a canvas which represents the entire overlay. After you finish updating it, the image is ripped apart and written to the underlying textures. Each of these underlying textures are double-buffered, so that switching them to the Xith3d engine is quick and does not involve having to continuously allocate and free large BufferedImages. This means, of course, that for every overlay you use 3 times (width * height * 4bytes) of system memory. So a chatbox which was 512 x 200 would use 3 * ( 512 * 200 *4) bytes or 1.2 MB of system memory. Updates to the actual textures are done within a behavior within a frame. This is very fast because all that is happening is that the buffers are getting swapped. We have to be certain that we are not in the process of copying the big buffer into the back buffer at the same time the behavior attempts to do a buffer swap. This is handled by the overlay by not updating texture if we are in the middle of drawing a new one. The drawback to this is that numerous updates per second to the overlay could result in several updates not get immediately reflected. But since the area is always completely redrawn this should not prove to be an issue. Soon as we hit a frame where we are not updating the buffer then it will be swapped. Remember, all you have to do to make translucent or non-square overlays is to use the alpha channel.
Originally Coded by David Yazel on Oct 4, 2003 at 9:59:54 PM.
| Field Summary | |
|---|---|
static int |
BACKGROUND_COPY
|
static int |
BACKGROUND_NONE
|
protected Group |
consoleBG
|
protected static java.lang.Boolean |
DEBUG
|
protected int |
height
|
protected int |
width
|
| Constructor Summary | |
|---|---|
UIOverlay(int width,
int height,
boolean clipAlpha,
boolean blendAlpha)
|
|
UIOverlay(int width,
int height,
boolean clipAlpha,
boolean blendAlpha,
boolean owned)
|
|
UIOverlay(int width,
int height,
boolean clipAlpha,
boolean blendAlpha,
boolean owned,
float offset,
boolean readDepthBuffer)
Constructs an overlay window. |
|
| Method Summary | |
|---|---|
protected void |
attachNode(Node node)
Allows an derived class to add a behavior or object to the same transform group that the sub-overlays use |
java.awt.image.BufferedImage |
getBackgroundImage()
|
boolean |
getBlendAlpha()
|
boolean |
getClipAlpha()
|
int |
getImageType()
|
PolygonAttributes |
getPolygonAttributes()
Return the polygon attributes shared by all the sub-overlays |
protected java.awt.Graphics2D |
getPreppedCanvas()
Prepares the canvas to be painted. |
RenderingAttributes |
getRenderingAttributes()
Return the rendering attributes shared by all sub-overlays |
Node |
getRoot()
Return the root of the overlay and its sub-overlays so it can be added to the scenegraph |
void |
getSize(java.awt.Dimension dim)
|
TextureAttributes |
getTextureAttributes()
Return the texture attributes shared by all the sub-overlays |
TransparencyAttributes |
getTransparencyAttributes()
Return the transparency attributes |
protected View |
getView()
Protected method to get the view which this overlay is matching |
protected void |
initialize()
This should be overwritten if you want to add any additional objects or behaviors or initialization before the overlay goes live |
boolean |
isOpaque()
|
boolean |
isOwned()
|
protected void |
moveToBackbuffer()
Move the contents of the drawing canvas into the various backbuffers. |
void |
paint(java.awt.Graphics2D g)
This is where the actualy drawing of the window takes place. |
void |
repaint()
This is called to trigger a repaint of the overlay. |
void |
repaint(java.awt.image.BufferedImage image)
|
void |
repaintChanged(java.awt.image.BufferedImage image,
java.util.ArrayList<?> dirtyAreas)
Moves the contents of the buffered image to the canvas and then updates the back buffers that have changed. |
void |
setBackgroundColor(java.awt.Color c)
Sets the background to a solid color. |
void |
setBackgroundImage(java.awt.image.BufferedImage bi)
Sets the background image to the one specified. |
void |
setBackgroundMode(int mode)
Sets the background mode. |
void |
setPosition(int x,
int y)
This sets the position of the overlay in screen coordinates. 0,0 is the upper left of the screen |
void |
setVisible(boolean yes)
Changes the visibility of the overlay. |
void |
update()
This method is ONLY called from the behavior. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected static final java.lang.Boolean DEBUG
public static final int BACKGROUND_NONE
public static final int BACKGROUND_COPY
protected int width
protected int height
protected Group consoleBG
| Constructor Detail |
|---|
public UIOverlay(int width,
int height,
boolean clipAlpha,
boolean blendAlpha,
boolean owned,
float offset,
boolean readDepthBuffer)
width - The width of the window in screen spaceheight - The height of the window in screen spaceclipAlpha - Should we apply a polygon clip where alpha is zeroblendAlpha - Should we blend to background if alpha is < 1owned - If this overlay is "owned" then no behavior will be built to update it since
it is assumed that the owner will handle the repaints. Also it will not be
attached to the view transform since it is assumed the owner will do that.offset - readDepthBuffer -
public UIOverlay(int width,
int height,
boolean clipAlpha,
boolean blendAlpha,
boolean owned)
public UIOverlay(int width,
int height,
boolean clipAlpha,
boolean blendAlpha)
| Method Detail |
|---|
public boolean isOwned()
public boolean isOpaque()
protected void initialize()
public void setPosition(int x,
int y)
x - y - public Node getRoot()
public boolean getClipAlpha()
public boolean getBlendAlpha()
public int getImageType()
public RenderingAttributes getRenderingAttributes()
public PolygonAttributes getPolygonAttributes()
public TextureAttributes getTextureAttributes()
public TransparencyAttributes getTransparencyAttributes()
protected void moveToBackbuffer()
protected java.awt.Graphics2D getPreppedCanvas()
public void repaintChanged(java.awt.image.BufferedImage image,
java.util.ArrayList<?> dirtyAreas)
image - dirtyAreas - public void repaint(java.awt.image.BufferedImage image)
public void repaint()
public void getSize(java.awt.Dimension dim)
public void update()
public void setVisible(boolean yes)
yes - public void paint(java.awt.Graphics2D g)
protected View getView()
protected void attachNode(Node node)
public java.awt.image.BufferedImage getBackgroundImage()
public void setBackgroundColor(java.awt.Color c)
public void setBackgroundImage(java.awt.image.BufferedImage bi)
public void setBackgroundMode(int mode)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||