net.xoetrope.awt
Class XHotspotImage

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Canvas
          extended by net.xoetrope.awt.XImage
              extended by net.xoetrope.awt.XHotspotImage
All Implemented Interfaces:
java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.util.EventListener, javax.accessibility.Accessible, XAttributedComponent, XImageHolder
Direct Known Subclasses:
XImageMap

public class XHotspotImage
extends XImage
implements java.awt.event.MouseMotionListener

A widget for displaying an image and associating hotspots at coordinates specified in an external file

Copyright: Copyright (c) Xoetrope Ltd., 1998-2003
License: see license.txt

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Nested classes/interfaces inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BaselineResizeBehavior, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
protected static java.awt.Cursor defaultCursor
          The default mouse over cursor - the arrow
protected  java.util.Hashtable disabled
          The disabled hotspots
protected static java.awt.Cursor handCursor
          The hand cursor - the normal pointer for a hotspot
protected  java.util.Vector hotspots
          The hotspots
protected  java.util.Vector images
          The images
protected  java.util.Vector names
          The hotspot names
 
Fields inherited from class net.xoetrope.awt.XImage
currentProject
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
XHotspotImage()
          Constructor.
 
Method Summary
 int checkHotspot(java.awt.Point p)
          Check the Point p to see if any of the polygons in the hotspots Vector contain it.
 void disableHotspot(java.lang.String name)
          Create a hashtable to store the disabled hotspots and move the disabled one into it from the main Vector.
 void enableHotspot(java.lang.String name)
          Move the hotspot from the disabled Hashtable to the main Vector
 java.lang.String getName(int i)
          Get the name of the hotspot in element i of the names vector
protected  void handleElement(XmlElement ele)
          Not implemented
protected  void hotspotDisabled(java.lang.String name, int idx)
          Convenience method to inform subclasses when a hotspot has been disabled
protected  void hotspotEnabled(java.lang.String name)
          Convenience method to inform subclasses when a hotspot has been enabled
 void mouseDragged(java.awt.event.MouseEvent e)
          Unused method.
 void mouseMoved(java.awt.event.MouseEvent e)
          Call the checkHotSpot function to change the cursor
 void read(java.io.Reader r)
          Reads the hotspot information from the reader parameter and adds them to the names and hotspots vectors.
 
Methods inherited from class net.xoetrope.awt.XImage
addNotify, getImageName, getPreferredSize, imageUpdate, paint, setAttribute, setImage, update
 
Methods inherited from class java.awt.Canvas
createBufferStrategy, createBufferStrategy, getAccessibleContext, getBufferStrategy
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

handCursor

protected static java.awt.Cursor handCursor
The hand cursor - the normal pointer for a hotspot


defaultCursor

protected static java.awt.Cursor defaultCursor
The default mouse over cursor - the arrow


hotspots

protected java.util.Vector hotspots
The hotspots


images

protected java.util.Vector images
The images


names

protected java.util.Vector names
The hotspot names


disabled

protected java.util.Hashtable disabled
The disabled hotspots

Constructor Detail

XHotspotImage

public XHotspotImage()
Constructor. Sets cursors and creates the Vector which stores the hotspots. Adds a new MouseMotionListener to the image

Method Detail

enableHotspot

public void enableHotspot(java.lang.String name)
Move the hotspot from the disabled Hashtable to the main Vector

Parameters:
name - the name of the hotspot to enable

hotspotEnabled

protected void hotspotEnabled(java.lang.String name)
Convenience method to inform subclasses when a hotspot has been enabled

Parameters:
name - the name of the hotspot being enabled.

disableHotspot

public void disableHotspot(java.lang.String name)
Create a hashtable to store the disabled hotspots and move the disabled one into it from the main Vector.

Parameters:
name - the name of the hotspot to be disabled

hotspotDisabled

protected void hotspotDisabled(java.lang.String name,
                               int idx)
Convenience method to inform subclasses when a hotspot has been disabled

Parameters:
name - the name of the hotspot being disabled.
idx - the index of the hotspot being disabled

getName

public java.lang.String getName(int i)
Get the name of the hotspot in element i of the names vector

Parameters:
i - The index of the hotspot
Returns:
The Name of the hotspot

read

public void read(java.io.Reader r)
Reads the hotspot information from the reader parameter and adds them to the names and hotspots vectors.

Parameters:
r - Reader of the file.

handleElement

protected void handleElement(XmlElement ele)
Not implemented

Parameters:
ele - an XML element

checkHotspot

public int checkHotspot(java.awt.Point p)
Check the Point p to see if any of the polygons in the hotspots Vector contain it. If so return the index of the Vector element.

Parameters:
p - The Point which we are checking
Returns:
The index of the polygon which contains the point or -1 if none of the polygons contain the Point

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Call the checkHotSpot function to change the cursor

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener
Parameters:
e - MouseEvent

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Unused method.

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener
Parameters:
e - the mouse event