Class sgraphics.ViewerImpl
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class sgraphics.ViewerImpl

java.lang.Object
   |
   +----sgraphics.GlyphImpl
           |
           +----sgraphics.MonoGlyph
                   |
                   +----sgraphics.ViewerImpl

public class ViewerImpl
extends MonoGlyph
implements Viewer
A viewer that is used to view a tree glyphs or figures. Viewers are chained by pick and processEvent(...) dispatches calls to handleEvent() when there is a hit by glyphs under the viewer. Another viewer qualifies as another glyph.

Note: The event MOUSE_DOWN calls grab() and the event MOUSE_UP calls ungrab(), therefore, calling grab() between these events has no effect. In other words, calling grab() in mouseDown(...), or mouseDrag(...) is pointless and useless.


Constructor Index

 o ViewerImpl(Glyph)
Make a viewer of a glyph.
 o ViewerImpl(Glyph, ViewerCallback)
Make a viewer of a glyph with a callback.

Method Index

 o action(GraphicsEvent, Object)
/** Called when an action occurs in the Component.
 o getHitList()
Gets an array of decendent glyphs that were hit after the last pick.
 o grabbing()
Ask if this viewer is grabbing the events.
 o handleEvent(GraphicsEvent)
Handles the event.
 o keyActionDown(GraphicsEvent, int)
Called when an action character is pressed.
 o keyActionUp(GraphicsEvent, int)
Called when an action character is released.
 o keyDown(GraphicsEvent, int)
Called when a character is pressed.
 o keyUp(GraphicsEvent, int)
Called when a character is released.
 o mouseDown(GraphicsEvent, float, float)
Called when the mouse is pressed.
 o mouseDrag(GraphicsEvent, float, float)
Called when the mouse is dragged (the mouse button is down).
 o mouseEnter(GraphicsEvent, float, float)
Called when the mouse enters the component.
 o mouseExit(GraphicsEvent, float, float)
Called when the mouse exits the component.
 o mouseMove(GraphicsEvent, float, float)
Called when the mouse moves (the mouse button is up).
 o mouseUp(GraphicsEvent, float, float)
Called when the mouse is released.
 o pick(Picker)
Checks for hits.
 o processPick(Picker, GraphicsEvent)
Process a pick.
 o removeCallback()
Remove the callback.
 o setCallback(ViewerCallback)
Set a callback.
 o setParent(Glyph)

Constructors

 o ViewerImpl
  public ViewerImpl(Glyph glyph)
Make a viewer of a glyph.
Parameters:
glyph - the viewed glyph.
 o ViewerImpl
  public ViewerImpl(Glyph glyph,
                    ViewerCallback callback)
Make a viewer of a glyph with a callback. As a side effect the ViewerCallback functions in Viewer will no longer be called.
Parameters:
glyph - the viewed glyph.
callback - the callback object.

Methods

 o setCallback
  public void setCallback(ViewerCallback callback)
Set a callback. As a side effect the ViewerCallback functions in Viewer will no longer be called.
Parameters:
callback - the callback object.
 o removeCallback
  public void removeCallback()
Remove the callback. The ViewerCallback methods in Viewer will then be called.
 o setParent
  public void setParent(Glyph parent)
Overrides:
setParent in class GlyphImpl
 o grabbing
  public boolean grabbing()
Ask if this viewer is grabbing the events.
Returns:
true if grabbing.
 o pick
  public void pick(Picker pick)
Checks for hits. Builds a chain of pickers.
Parameters:
pick - the picker.
Overrides:
pick in class MonoGlyph
 o getHitList
  public Glyph[] getHitList()
Gets an array of decendent glyphs that were hit after the last pick. If no glyphs were hit, this returns null.
Returns:
the hit list.
 o processPick
  public boolean processPick(Picker pick,
                             GraphicsEvent event)
Process a pick. Calls processPick(...) on the next viewer first. If processPick(...) on the next viewer returns false and this viewer has a hit, process the event.
Parameters:
pick - a picker chain with a path to all the hits.
event - the event.
return - true if the event was processed.
 o handleEvent
  public boolean handleEvent(GraphicsEvent evt)
Handles the event. Returns true if the event is handled. The default event handler calls some helper methods to make life easier on the programmer. If a callback was registered, then the helper methods of the callback object are called instead of the ones in this object.
Parameters:
evt - the event
Returns:
true if the event was handled.
See Also:
mouseEnter, mouseExit, mouseMove, mouseDown, mouseDrag, mouseUp, keyDown, action
 o mouseDown
  public boolean mouseDown(GraphicsEvent evt,
                           float X,
                           float Y)
Called when the mouse is pressed.
Parameters:
evt - the event
X - the x coordinate
Y - the y coordinate
See Also:
handleEvent
 o mouseDrag
  public boolean mouseDrag(GraphicsEvent evt,
                           float X,
                           float Y)
Called when the mouse is dragged (the mouse button is down).
Parameters:
evt - the event
X - the x coordinate
Y - the y coordinate
See Also:
handleEvent
 o mouseUp
  public boolean mouseUp(GraphicsEvent evt,
                         float X,
                         float Y)
Called when the mouse is released.
Parameters:
evt - the event
X - the x coordinate
Y - the y coordinate
See Also:
handleEvent
 o mouseMove
  public boolean mouseMove(GraphicsEvent evt,
                           float X,
                           float Y)
Called when the mouse moves (the mouse button is up).
Parameters:
evt - the event
X - the x coordinate
Y - the y coordinate
See Also:
handleEvent
 o mouseEnter
  public boolean mouseEnter(GraphicsEvent evt,
                            float X,
                            float Y)
Called when the mouse enters the component.
Parameters:
evt - the event
X - the x coordinate
Y - the y coordinate
See Also:
handleEvent
 o mouseExit
  public boolean mouseExit(GraphicsEvent evt,
                           float X,
                           float Y)
Called when the mouse exits the component.
Parameters:
evt - the event
X - the x coordinate
Y - the y coordinate
See Also:
handleEvent
 o keyDown
  public boolean keyDown(GraphicsEvent evt,
                         int key)
Called when a character is pressed.
Parameters:
evt - the event
key - the key that's pressed
See Also:
handleEvent
 o keyUp
  public boolean keyUp(GraphicsEvent evt,
                       int key)
Called when a character is released.
Parameters:
evt - the event
key - the key that's released
See Also:
handleEvent
 o keyActionDown
  public boolean keyActionDown(GraphicsEvent evt,
                               int key)
Called when an action character is pressed.
Parameters:
evt - the event
key - the key that's pressed
See Also:
handleEvent
 o keyActionUp
  public boolean keyActionUp(GraphicsEvent evt,
                             int key)
Called when an action character is released.
Parameters:
evt - the event
key - the key that's released
See Also:
handleEvent
 o action
  public boolean action(GraphicsEvent evt,
                        Object what)
/** Called when an action occurs in the Component.
Parameters:
evt - the event
what - the action that's occuring
See Also:
handleEvent

All Packages  Class Hierarchy  This Package  Previous  Next  Index