net.tmachine.gpg.hue
Class ContextManager

java.lang.Object
  extended bynet.tmachine.gpg.hue.ContextManager
All Implemented Interfaces:
java.util.EventListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener

public class ContextManager
extends java.lang.Object
implements java.awt.event.MouseListener, java.awt.event.MouseMotionListener

All input for the viewport is directed to this class, enabling it to keep track of cursor position, current button and keystates, etc.


Field Summary
protected  javax.swing.JComponent controlSurface
           
protected  Document currentDocument
           
protected  int mx
           
protected  int my
           
 
Constructor Summary
ContextManager()
           
 
Method Summary
 int[] getCursorPosition()
           
 Document getDocument()
          The Document is a simple MVC Model containing data on what shapes there are, where they are, etc; it has all the data that would be "saved" if there were a load/save feature in this demo!
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged(java.awt.event.MouseEvent e)
          Automatically updates its knowledge of the mouse cursor position
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved(java.awt.event.MouseEvent e)
          Automatically updates its knowledge of the mouse cursor position
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void setControlComponent(javax.swing.JComponent c)
          Informs this class which component it has to listen to to get input events etc so that it can correctly maintain it's context
 void setDocument(Document d)
          The Document is a simple MVC Model containing data on what shapes there are, where they are, etc; it has all the data that would be "saved" if there were a load/save feature in this demo!
 void setRelativeCursorPosition(int x, int y)
          Sets cursor position ignoring any special transformations performed on the rendering surface (this method then automatically applies those transformations to the incoming co-ords before storing them)
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

mx

protected int mx

my

protected int my

controlSurface

protected javax.swing.JComponent controlSurface

currentDocument

protected Document currentDocument
Constructor Detail

ContextManager

public ContextManager()
Method Detail

setDocument

public void setDocument(Document d)
The Document is a simple MVC Model containing data on what shapes there are, where they are, etc; it has all the data that would be "saved" if there were a load/save feature in this demo!

Parameters:
d -

getDocument

public Document getDocument()
The Document is a simple MVC Model containing data on what shapes there are, where they are, etc; it has all the data that would be "saved" if there were a load/save feature in this demo!


setControlComponent

public void setControlComponent(javax.swing.JComponent c)
Informs this class which component it has to listen to to get input events etc so that it can correctly maintain it's context

Parameters:
c - Generally the main renderer component (i.e. this class will listen to key and mouse events that happen on the main renderer)

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Automatically updates its knowledge of the mouse cursor position

Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Automatically updates its knowledge of the mouse cursor position

Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

getCursorPosition

public int[] getCursorPosition()
Returns:
the (x,y) co-ords of the cursor in the same co-ord system used by the painting/rendering logic

setRelativeCursorPosition

public void setRelativeCursorPosition(int x,
                                      int y)
Sets cursor position ignoring any special transformations performed on the rendering surface (this method then automatically applies those transformations to the incoming co-ords before storing them)

Needed because Sun's windowing system for Java is incapable of maintaining a single consistent co-ordinate space for rendering and events.

TODO: doesn't currently do anything special; transformed-painting-surface support isn't added yet

Parameters:
x -
y -