## org.j3d.geom.overlay
Class ImageButtonOverlay

public class ImageButtonOverlay
extends org.j3d.geom.overlay.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.3 $
Author:
  Will Holcomb, Justin Couch

Field Detail

### NUM_BUFFERS

    private static final int NUM_BUFFERS

  Total number of buffers we need for the images

### INACTIVE_IMAGE

    public static final int INACTIVE_IMAGE

  Index of the inactive image

### ACTIVE_IMAGE

    public static final int ACTIVE_IMAGE

  Index of the active image

### CLICKED_IMAGE

    public static final int CLICKED_IMAGE

  Index of the mouse clicked image

### MOUSEOVER_IMAGE

    public static final int MOUSEOVER_IMAGE

  Index of the mouse over image

### hasImage

    private boolean[] hasImage

  Set of flags indicating which images were provided

### mouseOver

    private boolean mouseOver

  Flag indicating the mouse is over the button currently

### stuck

    private boolean stuck

  Flag indicating the mouse has clicked the button to a permanently down state like a toggle button action.

### clicked

    private boolean clicked

  Flag indicating the button has been clicked

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

### mousePressed

    public void mousePressed(java.awt.event.MouseEvent evt)

  Process a mouse press event.

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.

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.

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.

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.

Parameters:
  `evt` - The event that caused this method to be called

### switchButtons

    private synchronized void switchButtons()

  Called on a state change to update the buttons