j3d.org Code

org.j3d.renderer.java3d.overlay
Class ImageButtonOverlay

java.lang.Object
  extended byorg.j3d.renderer.java3d.overlay.OverlayBase
      extended byorg.j3d.renderer.java3d.overlay.InteractiveOverlayBase
          extended byorg.j3d.renderer.java3d.overlay.MouseOverlay
              extended byorg.j3d.renderer.java3d.overlay.ImageButtonOverlay
All Implemented Interfaces:
java.awt.event.ComponentListener, java.util.EventListener, InteractiveOverlay, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, Overlay, ScreenComponent, UpdatableEntity

public class ImageButtonOverlay
extends MouseOverlay

An overlay with a clickable image that acts like a button.

The overlay will take up to four images. These images are supplied in an array in the order:

  1. Inactive
  2. Active
  3. Clicked (mouse pressed)
  4. Mouseover (mouse over but no button press)
Any of these images can be left as null in the array and the result is that the image will not change for that particular action.

Version:
$Revision: 1.1 $
Author:
Will Holcomb, Justin Couch

Field Summary
static int ACTIVE_IMAGE
          Index of the active image
static int CLICKED_IMAGE
          Index of the mouse clicked image
static int INACTIVE_IMAGE
          Index of the inactive image
static int MOUSEOVER_IMAGE
          Index of the mouse over image
 
Fields inherited from class org.j3d.renderer.java3d.overlay.OverlayBase
activeBuffer, backgroundColor, backgroundMode, bottomInset, canvas, componentSize, consoleBG, consoleTG, DEFAULT_INSET, DIRTY_ACTIVE_BUFFER, DIRTY_POSITION, DIRTY_SIZE, DIRTY_VISIBLE, fieldOfView, fixedSize, leftInset, overlayBounds, overlayTexGrp, rightInset, subOverlay, topInset
 
Fields inherited from interface org.j3d.renderer.java3d.overlay.Overlay
BACKGROUND_COPY, BACKGROUND_NONE
 
Constructor Summary
ImageButtonOverlay(javax.media.j3d.Canvas3D canvas, java.awt.Dimension size, boolean clipAlpha, boolean blendAlpha, java.awt.image.BufferedImage[] images)
          Create a new button overlay where you get to control the alpha setting with the images.
ImageButtonOverlay(javax.media.j3d.Canvas3D canvas, java.awt.Dimension size, java.awt.image.BufferedImage[] images)
          Create a new overlay that uses the given images placed in the space.
 
Method Summary
 void initialize()
          Initialise the overlay to build mouse input support
 void mouseClicked(java.awt.event.MouseEvent evt)
          Process a mouse click event.
 void mouseEntered(java.awt.event.MouseEvent evt)
          Process a mouse enter event.
 void mouseExited(java.awt.event.MouseEvent evt)
          Process a mouse exited event.
 void mousePressed(java.awt.event.MouseEvent evt)
          Process a mouse press event.
 void mouseReleased(java.awt.event.MouseEvent evt)
          Process a mouse release event.
 void repaint()
          This is called to trigger a repaint of the overlay.
 
Methods inherited from class org.j3d.renderer.java3d.overlay.MouseOverlay
mouseDragged, mouseMoved
 
Methods inherited from class org.j3d.renderer.java3d.overlay.InteractiveOverlayBase
addKeyListener, addMouseListener, addMouseMotionListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, requestFocus, setInputRequester
 
Methods inherited from class org.j3d.renderer.java3d.overlay.OverlayBase
componentHidden, componentMoved, componentResized, componentShown, contains, dirty, getBackgroundImage, getBounds, getGraphics, getRoot, getUpdateManager, isAntialiased, isVisible, paint, setActiveBuffer, setAntialiased, setBackgroundColor, setBackgroundImage, setBackgroundMode, setComponentDetails, setInsets, setInsets, setLocation, setSize, setUpdateManager, setVisible, update, updateBuffer
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.j3d.renderer.java3d.overlay.Overlay
contains, getBounds, getRoot, getUpdateManager, isAntialiased, isVisible, setAntialiased, setComponentDetails, setLocation, setSize, setUpdateManager, setVisible
 
Methods inherited from interface org.j3d.renderer.java3d.overlay.UpdatableEntity
update
 

Field Detail

INACTIVE_IMAGE

public static final int INACTIVE_IMAGE
Index of the inactive image

See Also:
Constant Field Values

ACTIVE_IMAGE

public static final int ACTIVE_IMAGE
Index of the active image

See Also:
Constant Field Values

CLICKED_IMAGE

public static final int CLICKED_IMAGE
Index of the mouse clicked image

See Also:
Constant Field Values

MOUSEOVER_IMAGE

public static final int MOUSEOVER_IMAGE
Index of the mouse over image

See Also:
Constant Field Values
Constructor Detail

ImageButtonOverlay

public ImageButtonOverlay(javax.media.j3d.Canvas3D canvas,
                          java.awt.Dimension size,
                          java.awt.image.BufferedImage[] images)
Create a new overlay that uses the given images placed in the space. Alpha is assumed to be on, but there is no blending.

Parameters:
canvas - The canvas to put the overlay on
size - The size of the overlay in pixels
images - The array of images to use (non-null)

ImageButtonOverlay

public ImageButtonOverlay(javax.media.j3d.Canvas3D canvas,
                          java.awt.Dimension size,
                          boolean clipAlpha,
                          boolean blendAlpha,
                          java.awt.image.BufferedImage[] images)
Create a new button overlay where you get to control the alpha setting with the images.

Parameters:
canvas - The canvas to put the overlay on
size - The size of the overlay in pixels
clipAlpha - true if the image contains alpha
blendAlpha - true if you want to blend the image with the background of the overlay (ie let the color show through)
images - The array of images to use (non-null)
Method Detail

initialize

public void initialize()
Initialise the overlay to build mouse input support

Specified by:
initialize in interface Overlay
Overrides:
initialize in class OverlayBase

mousePressed

public void mousePressed(java.awt.event.MouseEvent evt)
Process a mouse press event.

Specified by:
mousePressed in interface java.awt.event.MouseListener
Overrides:
mousePressed in class MouseOverlay
Parameters:
evt - The event that caused this method to be called

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent evt)
Process a mouse release event.

Specified by:
mouseReleased in interface java.awt.event.MouseListener
Overrides:
mouseReleased in class MouseOverlay
Parameters:
evt - The event that caused this method to be called

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent evt)
Process a mouse click event.

Specified by:
mouseClicked in interface java.awt.event.MouseListener
Overrides:
mouseClicked in class MouseOverlay
Parameters:
evt - The event that caused this method to be called

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent evt)
Process a mouse enter event.

Specified by:
mouseEntered in interface java.awt.event.MouseListener
Overrides:
mouseEntered in class MouseOverlay
Parameters:
evt - The event that caused this method to be called

mouseExited

public void mouseExited(java.awt.event.MouseEvent evt)
Process a mouse exited event.

Specified by:
mouseExited in interface java.awt.event.MouseListener
Overrides:
mouseExited in class MouseOverlay
Parameters:
evt - The event that caused this method to be called

repaint

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

Overrides:
repaint in class OverlayBase

j3d.org Code

Latest Info from http://code.j3d.org/
Copyright © 2001 - j3d.org