edu.umd.cs.jazz.event
Class ZLinkEventHandler

java.lang.Object
  |
  +--edu.umd.cs.jazz.event.ZLinkEventHandler
All Implemented Interfaces:
java.util.EventListener, java.awt.event.KeyListener, java.io.Serializable, ZEventHandler, ZMouseListener, ZMouseMotionListener

public class ZLinkEventHandler
extends java.lang.Object
implements ZEventHandler, ZMouseListener, ZMouseMotionListener, java.awt.event.KeyListener, java.io.Serializable

ZLinkEventHandler is a simple event handler for interactively creating hyperlinks. This supports clicking on an object to define a link from that object, and then click on another object to define a link to that second object as a destination. This inserts a ZAnchorGroup which can then be used to follow the link. Links are also created by pressing on one object, dragging, then releasing on another object.

Warning: Serialized and ZSerialized objects of this class will not be compatible with future Jazz releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Jazz. A future release of Jazz will provide support for long term persistence.

Author:
Benjamin B. Bederson
See Also:
Serialized Form

Constructor Summary
ZLinkEventHandler(ZNode node, ZCanvas canvas)
          This method creates a new link event handler.
 
Method Summary
protected  void finishLink(ZMouseEvent e)
          This method finishes the process of link creating a link.
protected  ZNode getNodeUnderMouse(ZMouseEvent e)
          This method returns the current pickable node that is under the mouse cursor even in the case when the mouse is being dragged.
protected  void hideLink(ZAnchorGroup aLink)
          This method finishes the process of link creating a link.
 void hideVisibleLinksAndHighlight()
          Hides all links that have been made visible by this event handler.
protected  void hilite(ZNode aNode, ZCamera aCamera)
          This method will hilite the passed in node selecting it.
 boolean isActive()
          Determines if this event handler is active.
 boolean isDefiningLink()
          Determines if this event handler is currently defining a new link.
 void keyPressed(java.awt.event.KeyEvent e)
          Key press event handler
 void keyReleased(java.awt.event.KeyEvent e)
          Key release event handler
 void keyTyped(java.awt.event.KeyEvent e)
          Key typed event handler
 void mouseClicked(ZMouseEvent e)
          Invoked when the mouse has been clicked on a component.
 void mouseDragged(ZMouseEvent e)
          When the mouse is dragged the current node under the mouse cursor is updated and the curent link if one is being created is updated.
 void mouseEntered(ZMouseEvent e)
          Invoked when the mouse enters a component.
 void mouseExited(ZMouseEvent e)
          Invoked when the mouse exits a component.
 void mouseMoved(ZMouseEvent e)
          When the mouse is moved the current node under the mouse cursor is updated and the curent link if one is being created is updated.
 void mousePressed(ZMouseEvent e)
          When the mouse is pressed the event handler tries to start creating a new link.
 void mouseReleased(ZMouseEvent e)
          When the mouse is released the event handler checks to see if a link is being created and if so it finishes that link.
 void setActive(boolean active)
          Specifies whether this event handler is active or not.
protected  void startLink(ZMouseEvent e)
          This will start a link, anchored at the current node under the cursor.
protected  void unhilite(ZNode aNode, ZCamera aCamera)
          This method will unhilite the passed in node by deselecting it.
protected  void updateCurrentLink(ZMouseEvent e)
          This method updates the link that is currently being defined so that it follows the mouse cursor.
protected  void updateCurrentNode(ZMouseEvent e)
          This method updates the current node so that it is always the node under the cursor.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZLinkEventHandler

public ZLinkEventHandler(ZNode node,
                         ZCanvas canvas)
This method creates a new link event handler. It handles the interaction to interactively create a hyperlink.

Method Detail

setActive

public void setActive(boolean active)
Specifies whether this event handler is active or not.

Specified by:
setActive in interface ZEventHandler
Parameters:
active - True to make this event handler active

isActive

public boolean isActive()
Determines if this event handler is active.

Specified by:
isActive in interface ZEventHandler
Returns:
True if active

keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Key press event handler

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Key release event handler

Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Key typed event handler

Specified by:
keyTyped in interface java.awt.event.KeyListener

mouseMoved

public void mouseMoved(ZMouseEvent e)
When the mouse is moved the current node under the mouse cursor is updated and the curent link if one is being created is updated.

Specified by:
mouseMoved in interface ZMouseMotionListener

mousePressed

public void mousePressed(ZMouseEvent e)
When the mouse is pressed the event handler tries to start creating a new link.

Specified by:
mousePressed in interface ZMouseListener

mouseDragged

public void mouseDragged(ZMouseEvent e)
When the mouse is dragged the current node under the mouse cursor is updated and the curent link if one is being created is updated.

Specified by:
mouseDragged in interface ZMouseMotionListener

mouseReleased

public void mouseReleased(ZMouseEvent e)
When the mouse is released the event handler checks to see if a link is being created and if so it finishes that link.

Specified by:
mouseReleased in interface ZMouseListener

mouseEntered

public void mouseEntered(ZMouseEvent e)
Invoked when the mouse enters a component.

Specified by:
mouseEntered in interface ZMouseListener

mouseExited

public void mouseExited(ZMouseEvent e)
Invoked when the mouse exits a component.

Specified by:
mouseExited in interface ZMouseListener

mouseClicked

public void mouseClicked(ZMouseEvent e)
Invoked when the mouse has been clicked on a component.

Specified by:
mouseClicked in interface ZMouseListener

finishLink

protected void finishLink(ZMouseEvent e)
This method finishes the process of link creating a link. If the current node is null then the link will be removed. If the current node is not null then it will be set as the links destination node.


getNodeUnderMouse

protected ZNode getNodeUnderMouse(ZMouseEvent e)
This method returns the current pickable node that is under the mouse cursor even in the case when the mouse is being dragged.


hilite

protected void hilite(ZNode aNode,
                      ZCamera aCamera)
This method will hilite the passed in node selecting it. It will also set the anchor group for that node to visible if the node has an anchor group.


isDefiningLink

public boolean isDefiningLink()
Determines if this event handler is currently defining a new link.

Returns:
boolean

startLink

protected void startLink(ZMouseEvent e)
This will start a link, anchored at the current node under the cursor.


unhilite

protected void unhilite(ZNode aNode,
                        ZCamera aCamera)
This method will unhilite the passed in node by deselecting it. It will also check to see if the anchor group for that node has a link. If the the anchor group does not have a link it will be removed.


updateCurrentLink

protected void updateCurrentLink(ZMouseEvent e)
This method updates the link that is currently being defined so that it follows the mouse cursor.


updateCurrentNode

protected void updateCurrentNode(ZMouseEvent e)
This method updates the current node so that it is always the node under the cursor. If the current node changes the old on is unhilted and the new one hilited.


hideLink

protected void hideLink(ZAnchorGroup aLink)
This method finishes the process of link creating a link. If the current node is null then the link will be removed. If the current node is not null then it will be set as the links destination node.


hideVisibleLinksAndHighlight

public void hideVisibleLinksAndHighlight()
Hides all links that have been made visible by this event handler.



Copyright � 2003 by University of Maryland, College Park, MD 20742, USA All rights reserved.