prefuse.controls
Class FocusControl

java.lang.Object
  extended by prefuse.controls.ControlAdapter
      extended by prefuse.controls.FocusControl
All Implemented Interfaces:
java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.MouseWheelListener, java.util.EventListener, Control

public class FocusControl
extends ControlAdapter

Updates the contents of a TupleSet of focus items in response to mouse actions. For example, clicking a node or double-clicking a node could update its focus status. This Control supports monitoring a specified number of clicks to executing a focus change. By default a click pattern will cause a VisualItem to become the sole member of the focus group. Hold down the control key while clicking to add an item to a group without removing the current members.

Updating a focus group does not necessarily cause the display to change. For this functionality, either register an action with this control, or register a TupleSetListener with the focus group.

Author:
jeffrey heer

Field Summary
protected  java.lang.String activity
           
protected  int button
           
protected  int ccount
           
protected  VisualItem curFocus
           
protected  Predicate filter
           
 
Fields inherited from interface prefuse.controls.Control
LEFT_MOUSE_BUTTON, MIDDLE_MOUSE_BUTTON, RIGHT_MOUSE_BUTTON
 
Constructor Summary
FocusControl()
          Creates a new FocusControl that changes the focus to another item when that item is clicked once.
FocusControl(int clicks)
          Creates a new FocusControl that changes the focus when an item is clicked the specified number of times.
FocusControl(int clicks, java.lang.String act)
          Creates a new FocusControl that changes the focus when an item is clicked the specified number of times.
FocusControl(java.lang.String focusGroup)
          Creates a new FocusControl that changes the focus to another item when that item is clicked once.
FocusControl(java.lang.String focusGroup, int clicks)
          Creates a new FocusControl that changes the focus when an item is clicked the specified number of times.
FocusControl(java.lang.String focusGroup, int clicks, java.lang.String act)
          Creates a new FocusControl that changes the focus when an item is clicked the specified number of times.
 
Method Summary
protected  boolean filterCheck(VisualItem item)
          Perform a filtering check on the input item.
 Predicate getFilter()
          Get the filter for processing items by this focus control.
 void itemClicked(VisualItem item, java.awt.event.MouseEvent e)
          Invoked when the mouse button has been clicked (pressed and released) on a VisualItem.
 void itemEntered(VisualItem item, java.awt.event.MouseEvent e)
          Invoked when the mouse enters a VisualItem.
 void itemExited(VisualItem item, java.awt.event.MouseEvent e)
          Invoked when the mouse exits a VisualItem.
 void setFilter(Predicate p)
          Set a filter for processing items by this focus control.
 
Methods inherited from class prefuse.controls.ControlAdapter
isEnabled, itemDragged, itemKeyPressed, itemKeyReleased, itemKeyTyped, itemMoved, itemPressed, itemReleased, itemWheelMoved, keyPressed, keyReleased, keyTyped, mouseClicked, mouseDragged, mouseEntered, mouseExited, mouseMoved, mousePressed, mouseReleased, mouseWheelMoved, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

activity

protected java.lang.String activity

curFocus

protected VisualItem curFocus

ccount

protected int ccount

button

protected int button

filter

protected Predicate filter
Constructor Detail

FocusControl

public FocusControl()
Creates a new FocusControl that changes the focus to another item when that item is clicked once.


FocusControl

public FocusControl(java.lang.String focusGroup)
Creates a new FocusControl that changes the focus to another item when that item is clicked once.

Parameters:
focusGroup - the name of the focus group to use

FocusControl

public FocusControl(int clicks)
Creates a new FocusControl that changes the focus when an item is clicked the specified number of times. A click value of zero indicates that the focus should be changed in response to mouse-over events.

Parameters:
clicks - the number of clicks needed to switch the focus.

FocusControl

public FocusControl(java.lang.String focusGroup,
                    int clicks)
Creates a new FocusControl that changes the focus when an item is clicked the specified number of times. A click value of zero indicates that the focus should be changed in response to mouse-over events.

Parameters:
focusGroup - the name of the focus group to use
clicks - the number of clicks needed to switch the focus.

FocusControl

public FocusControl(int clicks,
                    java.lang.String act)
Creates a new FocusControl that changes the focus when an item is clicked the specified number of times. A click value of zero indicates that the focus should be changed in response to mouse-over events.

Parameters:
clicks - the number of clicks needed to switch the focus.
act - an action run to upon focus change

FocusControl

public FocusControl(java.lang.String focusGroup,
                    int clicks,
                    java.lang.String act)
Creates a new FocusControl that changes the focus when an item is clicked the specified number of times. A click value of zero indicates that the focus should be changed in response to mouse-over events.

Parameters:
focusGroup - the name of the focus group to use
clicks - the number of clicks needed to switch the focus.
act - an action run to upon focus change
Method Detail

setFilter

public void setFilter(Predicate p)
Set a filter for processing items by this focus control. Only items for which the predicate returns true (or doesn't throw an exception) will be considered by this control. A null value indicates that no filtering should be applied. That is, all items will be considered.

Parameters:
p - the filtering predicate to apply

getFilter

public Predicate getFilter()
Get the filter for processing items by this focus control. Only items for which the predicate returns true (or doesn't throw an exception) are considered by this control. A null value indicates that no filtering is applied.

Returns:
the filtering predicate

filterCheck

protected boolean filterCheck(VisualItem item)
Perform a filtering check on the input item.

Parameters:
item - the item to check against the filter
Returns:
true if the item should be considered, false otherwise

itemEntered

public void itemEntered(VisualItem item,
                        java.awt.event.MouseEvent e)
Description copied from interface: Control
Invoked when the mouse enters a VisualItem.

Specified by:
itemEntered in interface Control
Overrides:
itemEntered in class ControlAdapter
See Also:
Control.itemEntered(prefuse.visual.VisualItem, java.awt.event.MouseEvent)

itemExited

public void itemExited(VisualItem item,
                       java.awt.event.MouseEvent e)
Description copied from interface: Control
Invoked when the mouse exits a VisualItem.

Specified by:
itemExited in interface Control
Overrides:
itemExited in class ControlAdapter
See Also:
Control.itemExited(prefuse.visual.VisualItem, java.awt.event.MouseEvent)

itemClicked

public void itemClicked(VisualItem item,
                        java.awt.event.MouseEvent e)
Description copied from interface: Control
Invoked when the mouse button has been clicked (pressed and released) on a VisualItem.

Specified by:
itemClicked in interface Control
Overrides:
itemClicked in class ControlAdapter
See Also:
Control.itemClicked(prefuse.visual.VisualItem, java.awt.event.MouseEvent)


Copyright © 2007 Regents of the University of California