com.xith.java3d.overlay
Class OverlayBase

java.lang.Object
  |
  +--com.xith.java3d.overlay.OverlayBase
All Implemented Interfaces:
Overlay, ScreenComponent, UpdatableEntity
Direct Known Subclasses:
ImageButtonOverlay, LabelOverlay

public class OverlayBase
extends java.lang.Object
implements Overlay, ScreenComponent

Copyright: Copyright (c) 2000,2001 Company: Teseract Software, LLP

Author:
David Yazel, Will Holcomb

Field Summary
static int ACTIVE_BUFFER
           
protected  int activeBuffer
           
protected  int backgroundMode
           
protected  java.awt.image.BufferedImage canvas
           
protected  javax.media.j3d.BranchGroup consoleBranchGroup
           
protected  javax.media.j3d.TransformGroup consoleTransformGroup
           
static int POSITION
           
protected  int[] relativePosition
           
protected  com.xith.java3d.overlay.SubOverlay[] subOverlay
           
static int VISIBLE
           
 
Fields inherited from interface com.xith.java3d.overlay.Overlay
BACKGROUND_COPY, BACKGROUND_NONE, PLACE_BOTTOM, PLACE_CENTER, PLACE_LEFT, PLACE_RIGHT, PLACE_TOP, X_PLACEMENT, Y_PLACEMENT
 
Constructor Summary
OverlayBase(javax.media.j3d.Canvas3D canvas3D, java.awt.Rectangle bounds)
          Creates a new overlay covering the given canvas bounds.
OverlayBase(javax.media.j3d.Canvas3D canvas3D, java.awt.Rectangle bounds, boolean clipAlpha, boolean blendAlpha)
           
OverlayBase(javax.media.j3d.Canvas3D canvas3D, java.awt.Rectangle bounds, boolean clipAlpha, boolean blendAlpha, UpdateManager updateManager)
           
OverlayBase(javax.media.j3d.Canvas3D canvas3D, java.awt.Rectangle bounds, boolean clipAlpha, boolean blendAlpha, UpdateManager updateManager, int numBuffers)
          Constructs an overlay window.
OverlayBase(javax.media.j3d.Canvas3D canvas3D, java.awt.Rectangle bounds, UpdateManager manager)
           
 
Method Summary
 void addMouseListener(java.awt.event.MouseListener listener)
           
 void dirty(int property)
           
 java.awt.image.BufferedImage getBackgroundImage()
          Returns the background for the overlay.
 java.awt.Rectangle getBounds()
          Returns the rectangular portion of the canvas that this overlay covers.
 javax.media.j3d.Canvas3D getCanvas()
          Returns the canvas being drawn on.
protected  java.awt.Graphics2D getGraphics()
          Prepares the canvas to be painted.
 javax.media.j3d.PolygonAttributes getPolygonAttributes()
          Return the polygon attributes shared by all the sub-overlays
 javax.media.j3d.RenderingAttributes getRenderingAttributes()
          Return the rendering attributes shared by all sub-overlays
 javax.media.j3d.BranchGroup getRoot()
          Return the root of the overlay and its sub-overlays so it can be added to the scene graph
 javax.media.j3d.TextureAttributes getTextureAttributes()
          Return the texture attributes shared by all the sub-overlays
 javax.media.j3d.TransparencyAttributes getTransparencyAttributes()
          Return the transparency attributes
 UpdateManager getUpdateManager()
          Returns the UpdateManager responsible for seeing that updates to the Overlay only take place between frames.
 boolean hasAlphaComponent()
          Returns if the Overlay may be semi-transparent
protected  void initialize()
           
 boolean isAntialiased()
          Returns whether drawing on this overlay is anti-aliased
 boolean isVisible()
          Returns the visiblity of the Overlay.
 void paint(java.awt.Graphics2D g)
          This is where the actualy drawing of the window takes place.
 void removeMouseListener(java.awt.event.MouseListener listener)
           
 void repaint()
          This is called to trigger a repaint of the overlay.
protected  void setActiveBuffer(int activeBuffer)
           
 void setAntialiased(boolean antialiased)
          Sets whether drawing onto this Overlay is anialiased.
 void setBackgroundColor(java.awt.Color color)
          Sets the background to a solid color.
 void setBackgroundImage(java.awt.image.BufferedImage backgroundImage)
          Sets the background image to the one specified.
 void setBackgroundMode(int mode)
          Sets the background mode.
 void setOffset(java.awt.Dimension offset)
          Sets the relative offset of the overlay.
 void setOffset(int width, int height)
          Sets the relative offset of the overlay.
 void setRelativePosition(int[] relativePositon)
          Sets the relative position of the overlay on the screen using a 2 dimensional array.
 void setRelativePosition(int xType, int yType)
          Sets the relative position of the overlay on the screen.
 void setUpdateManager(UpdateManager updateManager)
          Sets the UpdateManager
 void setVisible(boolean visible)
          Changes the visibility of the overlay.
 void update()
          Any changes that will affect the screen appearance should be made in here.
protected  void updateBuffer(java.awt.image.BufferedImage image, int bufferIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

backgroundMode

protected int backgroundMode

relativePosition

protected int[] relativePosition

canvas

protected java.awt.image.BufferedImage canvas

subOverlay

protected com.xith.java3d.overlay.SubOverlay[] subOverlay

activeBuffer

protected int activeBuffer

consoleBranchGroup

protected javax.media.j3d.BranchGroup consoleBranchGroup

consoleTransformGroup

protected javax.media.j3d.TransformGroup consoleTransformGroup

VISIBLE

public static final int VISIBLE

POSITION

public static final int POSITION

ACTIVE_BUFFER

public static final int ACTIVE_BUFFER
Constructor Detail

OverlayBase

public OverlayBase(javax.media.j3d.Canvas3D canvas3D,
                   java.awt.Rectangle bounds)
Creates a new overlay covering the given canvas bounds. Updates are managed automatically. This Overlay must still be attached to the view platform transform.
Parameters:
canvas3D - Canvas being drawn onto
bounds - Bounds on the canvas covered by the overlay

OverlayBase

public OverlayBase(javax.media.j3d.Canvas3D canvas3D,
                   java.awt.Rectangle bounds,
                   UpdateManager manager)

OverlayBase

public OverlayBase(javax.media.j3d.Canvas3D canvas3D,
                   java.awt.Rectangle bounds,
                   boolean clipAlpha,
                   boolean blendAlpha)

OverlayBase

public OverlayBase(javax.media.j3d.Canvas3D canvas3D,
                   java.awt.Rectangle bounds,
                   boolean clipAlpha,
                   boolean blendAlpha,
                   UpdateManager updateManager)

OverlayBase

public OverlayBase(javax.media.j3d.Canvas3D canvas3D,
                   java.awt.Rectangle bounds,
                   boolean clipAlpha,
                   boolean blendAlpha,
                   UpdateManager updateManager,
                   int numBuffers)
Constructs an overlay window. This window will not be visible unless it is added to the scene under the view platform transform
Parameters:
canvas3D - The canvas the overlay is drawn on
bounds - The part of the canvas covered by the overlay
clipAlpha - Should the polygon clip where alpha is zero
blendAlpha - Should we blend to background where alpha is < 1
updateManager - Responsible for allowing the Overlay to update between renders. If this is null a default manager is created.
numBuffers - The number of buffers to generate, the default is two.
Method Detail

initialize

protected void initialize()

getBounds

public java.awt.Rectangle getBounds()
Description copied from interface: Overlay
Returns the rectangular portion of the canvas that this overlay covers.
Specified by:
getBounds in interface Overlay

getUpdateManager

public UpdateManager getUpdateManager()
Description copied from interface: Overlay
Returns the UpdateManager responsible for seeing that updates to the Overlay only take place between frames.
Specified by:
getUpdateManager in interface Overlay

setUpdateManager

public void setUpdateManager(UpdateManager updateManager)
Description copied from interface: Overlay
Sets the UpdateManager
Specified by:
setUpdateManager in interface Overlay

setOffset

public void setOffset(java.awt.Dimension offset)
Sets the relative offset of the overlay. How this translates into screen coordinates depends on the value of relativePosition()
Specified by:
setOffset in interface Overlay

setOffset

public void setOffset(int width,
                      int height)
Sets the relative offset of the overlay. How this translates into screen coordinates depends on the value of relativePosition()
Specified by:
setOffset in interface Overlay

setRelativePosition

public void setRelativePosition(int[] relativePositon)
Sets the relative position of the overlay on the screen using a 2 dimensional array.
Specified by:
setRelativePosition in interface Overlay
Parameters:
relativePosition[X_PLACEMENT] - May be PLACE_LEFT, PLACE_RIGHT, or PLACE_CENTER
relativePosition[Y_PLACEMENT] - May be PLACE_TOP, PLACE_BOTTOM, or PLACE_CENTER

setRelativePosition

public void setRelativePosition(int xType,
                                int yType)
Sets the relative position of the overlay on the screen.
Specified by:
setRelativePosition in interface Overlay
Parameters:
xType - May be PLACE_LEFT, PLACE_RIGHT, or PLACE_CENTER
yType - May be PLACE_TOP, PLACE_BOTTOM, or PLACE_CENTER

getRoot

public javax.media.j3d.BranchGroup getRoot()
Return the root of the overlay and its sub-overlays so it can be added to the scene graph
Specified by:
getRoot in interface Overlay

hasAlphaComponent

public boolean hasAlphaComponent()
Returns if the Overlay may be semi-transparent

setAntialiased

public void setAntialiased(boolean antialiased)
Sets whether drawing onto this Overlay is anialiased.
Specified by:
setAntialiased in interface Overlay

isAntialiased

public boolean isAntialiased()
Description copied from interface: Overlay
Returns whether drawing on this overlay is anti-aliased
Specified by:
isAntialiased in interface Overlay

getCanvas

public javax.media.j3d.Canvas3D getCanvas()
Returns the canvas being drawn on.
Specified by:
getCanvas in interface Overlay

getRenderingAttributes

public javax.media.j3d.RenderingAttributes getRenderingAttributes()
Return the rendering attributes shared by all sub-overlays

getPolygonAttributes

public javax.media.j3d.PolygonAttributes getPolygonAttributes()
Return the polygon attributes shared by all the sub-overlays

getTextureAttributes

public javax.media.j3d.TextureAttributes getTextureAttributes()
Return the texture attributes shared by all the sub-overlays

getTransparencyAttributes

public javax.media.j3d.TransparencyAttributes getTransparencyAttributes()
Return the transparency attributes

getGraphics

protected java.awt.Graphics2D getGraphics()
Prepares the canvas to be painted. This should only be called internally or from an owner like the ScrollingOverlay class. paint(Graphics2D g) should be used to paint the OverlayBase.

repaint

public void repaint()
This is called to trigger a repaint of the overlay. This will return once the back buffer has been built, but before the swap.

updateBuffer

protected void updateBuffer(java.awt.image.BufferedImage image,
                            int bufferIndex)

setVisible

public void setVisible(boolean visible)
Changes the visibility of the overlay.
Specified by:
setVisible in interface Overlay

isVisible

public boolean isVisible()
Description copied from interface: Overlay
Returns the visiblity of the Overlay.
Specified by:
isVisible in interface Overlay

paint

public void paint(java.awt.Graphics2D g)
This is where the actualy drawing of the window takes place. Override this to alter the contents of what is show in the window.

setActiveBuffer

protected void setActiveBuffer(int activeBuffer)

setBackgroundColor

public void setBackgroundColor(java.awt.Color color)
Sets the background to a solid color. If a background image already exists then it will be overwritten with this solid color. It is completely appropriate to have an alpha component in the color if this is a alpha capable overlay. In general you should only use background images if this is an overlay that is called frequently, since you could always paint it inside the paint() method. BackgroundMode must be in BACKGROUND_COPY for the background to be shown.

getBackgroundImage

public java.awt.image.BufferedImage getBackgroundImage()
Returns the background for the overlay. Updates to this image will not be shown in the overlay until repaint() is called. BackgroundMode must be in BACKGROUND_COPY for the background to be shown.

setBackgroundImage

public void setBackgroundImage(java.awt.image.BufferedImage backgroundImage)
Sets the background image to the one specified. It does not have to be the same size as the overlay but the it should be at least as big. BackgroundMode must be in BACKGROUND_COPY for the background to be shown.

setBackgroundMode

public void setBackgroundMode(int mode)
Sets the background mode. BACKGROUND_COPY will copy the raster data from the background into the canvas before paint() is called. BACKGROUND_NONE will cause the background to be disabled and not used.

addMouseListener

public void addMouseListener(java.awt.event.MouseListener listener)

removeMouseListener

public void removeMouseListener(java.awt.event.MouseListener listener)

dirty

public void dirty(int property)

update

public void update()
Description copied from interface: Overlay
Any changes that will affect the screen appearance should be made in here. The UpdateManager is responsible for guearanteeing that this is executed in between frmaes.
Specified by:
update in interface Overlay