Java Doc for MouseTracker.java in  » Science » jcm1-source » edu » hws » jcm » draw » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Science » jcm1 source » edu.hws.jcm.draw 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


java.lang.Object
   edu.hws.jcm.draw.Drawable
      edu.hws.jcm.draw.MouseTracker

MouseTracker
public class MouseTracker extends Drawable implements MouseListener,MouseMotionListener,InputObject(Code)
A MouseTracker can be added to a CoordinateRect in a DisplayCanvas to respond to user mouse actions in the rectangular area occupied by the CoordinateRect. Two Variable objects, which can be retrieved by calling getXVar() and getYVar(), represent the location of the most recent mouse action in terms of the coordinates of the CoordinateRect. Note that these variables are Tieable objects, so they can be synchronized with other means of inputting the same information. The default names of the variables, if you don't change them, are "xMouse" and "yMouse".

A MouseTracker is an InputObject. The values of the variables associated with the MouseTracker can change only when the checkInput() method is called (or when the setVal() method of the variable is called to set its value explicitely). If you want the value of the variables to track the mouse, you must add the MouseTracker (or the DisplayCanvas that contains it) to a Controller and set that Controller to listen for changes from the MouseTracker object by passing the Controller to the setOnUserAction() method of this class.



Field Summary
protected  booleanclampX
     If thie is true, then the value of the variable associated with the x-ccordinate of the mouse is clamped to lie within the xmin and xmax of the coordinate rect.
protected  booleanclampY
     If thie is true, then the value of the variable associated with the y-ccordinate of the mouse is clamped to lie within the ymin and ymax of the coordinate rect.
protected  booleanlistenForDrags
     If true, the MouseTracker responds to both clicks and drags.
protected  ControlleronUserAction
     If this is non-null, then its compute() method is called when the user clicks the mouse and, if listenForDrags is also true, when the user drags and releases the mouse.
protected  booleanundefinedWhenNotDragging
     If true, the values of the associated variables are undefined except during the time that the user is clicking and dragging the mouse.

Constructor Summary
public  MouseTracker()
     Create a MouseTracker that responds to both clicks and drags.
public  MouseTracker(boolean listenForDrags, boolean undefinedWhenNotDragging)
     Creates a mouse tracker.

Method Summary
public  voidcheckInput()
     Set the values of the associated variables.
public  voiddraw(Graphics g, boolean coordsChanged)
     A MouseTracker doesn't actually draw anything, but this method is required in a Drawable object.
public  booleangetClampX()
     Get the "clampX" property of the MouseTracker.
public  booleangetClampY()
     Get the "clampY" property of the MouseTracker.
public  booleangetListenForDrags()
     Gets the "listenForDrags" property of the MouseTracker, which determines if the MouseTracker responds to both clicks and drags, or only to clicks.
public  ControllergetOnUserAction()
     Get the Controller that responds when a user mouse action is detected by this MouseTracker.
public  booleangetUndefinedWhenNotDragging()
     Gets the "undefinedWhenNotDragging" property of the MouseTracker.
public  VariablegetXVar()
     Get the variable whose value represents the x-coordinate of the MouseTracker. Note that this variable implements the Tieable interface, so can legally be type-cast to type Tieable.
public  VariablegetYVar()
     Get the variable whose value represents the y-coordinate of the MouseTracker. Note that this variable implements the Tieable interface, so can legally be type-cast to type Tieable.
public  voidmouseClicked(MouseEvent evt)
     Empty method, required by MouseListener interface.
public  voidmouseDragged(MouseEvent evt)
     Responds when the user drags the mouse.
public  voidmouseEntered(MouseEvent evt)
     Empty method, required by MouseMotionListener interface.
public  voidmouseExited(MouseEvent evt)
     Empty method, required by MouseMotionListener interface.
public  voidmouseMoved(MouseEvent evt)
     Empty method, required by MouseMotionListener interface.
public  voidmousePressed(MouseEvent evt)
     Responds when the user clicks the mouse in the rectangular area occupied by the CoordinateRect that contains this MouseTracker. Since the MouseTracker listens for clicks on the whole DisplayCanvas and the CoordinateRect might only occupy part of that, it is necessary to check whether the user click was in that rect.
public  voidmouseReleased(MouseEvent evt)
     Responds when the user releases the mouse.
public  voidnotifyControllerOnChange(Controller c)
     Method required by InputObject interface; in this class, it simply calls setOnUserAction(c).
public  voidsetClampX(boolean clamp)
     Set the "clampX" property of the MouseTracker.
public  voidsetClampY(boolean clamp)
     Set the "clampY" property of the MouseTracker.
public  voidsetListenForDrags(boolean listen)
     Sets the "listenForDrags" property of the MouseTracker.
public  voidsetOnUserAction(Controller onUserAction)
     Set a Controller to respond to user mouse actions tracked by this MouseTracker.
protected  voidsetOwnerData(DisplayCanvas canvas, CoordinateRect coords)
     This is called automatically by CoordinateRect when the MouseTracker is added to the CoordinateRect.
public  voidsetUndefinedWhenNotDragging(boolean b)
     Sets the "undefinedWhenNotDragging" property of the MouseTracker.

Field Detail
clampX
protected boolean clampX(Code)
If thie is true, then the value of the variable associated with the x-ccordinate of the mouse is clamped to lie within the xmin and xmax of the coordinate rect.



clampY
protected boolean clampY(Code)
If thie is true, then the value of the variable associated with the y-ccordinate of the mouse is clamped to lie within the ymin and ymax of the coordinate rect.



listenForDrags
protected boolean listenForDrags(Code)
If true, the MouseTracker responds to both clicks and drags. If false, it responds only to clicks.



onUserAction
protected Controller onUserAction(Code)
If this is non-null, then its compute() method is called when the user clicks the mouse and, if listenForDrags is also true, when the user drags and releases the mouse.



undefinedWhenNotDragging
protected boolean undefinedWhenNotDragging(Code)
If true, the values of the associated variables are undefined except during the time that the user is clicking and dragging the mouse. This is ignored if listenForDrags is false.




Constructor Detail
MouseTracker
public MouseTracker()(Code)
Create a MouseTracker that responds to both clicks and drags. The values of the associated variables remain defined even after the user stops dragging.



MouseTracker
public MouseTracker(boolean listenForDrags, boolean undefinedWhenNotDragging)(Code)
Creates a mouse tracker. The first parameter specifies whether the values of the variables change when the user drags the mouse, or only when the user clicks. The second parameter is only used if the first is true. It specifies whether the values of the variables become undefined after the user stops dragging the mouse.




Method Detail
checkInput
public void checkInput()(Code)
Set the values of the associated variables. This is part of the InputObject interface, and it is meant to be called by a Controller.



draw
public void draw(Graphics g, boolean coordsChanged)(Code)
A MouseTracker doesn't actually draw anything, but this method is required in a Drawable object.



getClampX
public boolean getClampX()(Code)
Get the "clampX" property of the MouseTracker.



getClampY
public boolean getClampY()(Code)
Get the "clampY" property of the MouseTracker.



getListenForDrags
public boolean getListenForDrags()(Code)
Gets the "listenForDrags" property of the MouseTracker, which determines if the MouseTracker responds to both clicks and drags, or only to clicks.



getOnUserAction
public Controller getOnUserAction()(Code)
Get the Controller that responds when a user mouse action is detected by this MouseTracker.



getUndefinedWhenNotDragging
public boolean getUndefinedWhenNotDragging()(Code)
Gets the "undefinedWhenNotDragging" property of the MouseTracker.



getXVar
public Variable getXVar()(Code)
Get the variable whose value represents the x-coordinate of the MouseTracker. Note that this variable implements the Tieable interface, so can legally be type-cast to type Tieable. It can be tied to other objects that implement the Tieable and Value interfaces to synchronize their values.



getYVar
public Variable getYVar()(Code)
Get the variable whose value represents the y-coordinate of the MouseTracker. Note that this variable implements the Tieable interface, so can legally be type-cast to type Tieable. It can be tied to other objects that implement the Tieable and Value interfaces to synchronize their values.



mouseClicked
public void mouseClicked(MouseEvent evt)(Code)
Empty method, required by MouseListener interface.



mouseDragged
public void mouseDragged(MouseEvent evt)(Code)
Responds when the user drags the mouse. This is not meant to be called directly.



mouseEntered
public void mouseEntered(MouseEvent evt)(Code)
Empty method, required by MouseMotionListener interface.



mouseExited
public void mouseExited(MouseEvent evt)(Code)
Empty method, required by MouseMotionListener interface.



mouseMoved
public void mouseMoved(MouseEvent evt)(Code)
Empty method, required by MouseMotionListener interface.



mousePressed
public void mousePressed(MouseEvent evt)(Code)
Responds when the user clicks the mouse in the rectangular area occupied by the CoordinateRect that contains this MouseTracker. Since the MouseTracker listens for clicks on the whole DisplayCanvas and the CoordinateRect might only occupy part of that, it is necessary to check whether the user click was in that rect. This is not meant to be called directly.



mouseReleased
public void mouseReleased(MouseEvent evt)(Code)
Responds when the user releases the mouse. This is not meant to be called directly.



notifyControllerOnChange
public void notifyControllerOnChange(Controller c)(Code)
Method required by InputObject interface; in this class, it simply calls setOnUserAction(c). This is meant to be called by JCMPanel.gatherInputs().



setClampX
public void setClampX(boolean clamp)(Code)
Set the "clampX" property of the MouseTracker. If set to true, which is the default, the value of the variable associated with the horizontal position of the mouse is clamped to lie within the containing CoordinateRect.



setClampY
public void setClampY(boolean clamp)(Code)
Set the "clampY" property of the MouseTracker. If set to true, which is the default, the value of the variable associated with the vertical position of the mouse is clamped to lie within the containing CoordinateRect.



setListenForDrags
public void setListenForDrags(boolean listen)(Code)
Sets the "listenForDrags" property of the MouseTracker. If set to true, then the MouseTracker responds to both clicks and drags if false, it responds only to clicks.



setOnUserAction
public void setOnUserAction(Controller onUserAction)(Code)
Set a Controller to respond to user mouse actions tracked by this MouseTracker. The MouseTracker should also be added to the Controller, so that the values of its variables will actually change when a user action occurs.



setOwnerData
protected void setOwnerData(DisplayCanvas canvas, CoordinateRect coords)(Code)
This is called automatically by CoordinateRect when the MouseTracker is added to the CoordinateRect. It is not meant to be used directly.



setUndefinedWhenNotDragging
public void setUndefinedWhenNotDragging(boolean b)(Code)
Sets the "undefinedWhenNotDragging" property of the MouseTracker. This is ignored if the MouseTracker is not listening for drags. If set to true, the values of the variables associated with this variable become undefined when the user is not dragging.



Fields inherited from edu.hws.jcm.draw.Drawable
protected DisplayCanvas canvas(Code)(Java Doc)
protected CoordinateRect coords(Code)(Java Doc)

Methods inherited from edu.hws.jcm.draw.Drawable
abstract public void draw(Graphics g, boolean coordsChanged)(Code)(Java Doc)
public boolean getVisible()(Code)(Java Doc)
public void needsRedraw()(Code)(Java Doc)
protected void setOwnerData(DisplayCanvas canvas, CoordinateRect coords)(Code)(Java Doc)
public void setVisible(boolean show)(Code)(Java Doc)

Methods inherited from java.lang.Object
native protected Object clone() throws CloneNotSupportedException(Code)(Java Doc)
public boolean equals(Object obj)(Code)(Java Doc)
protected void finalize() throws Throwable(Code)(Java Doc)
final native public Class getClass()(Code)(Java Doc)
native public int hashCode()(Code)(Java Doc)
final native public void notify()(Code)(Java Doc)
final native public void notifyAll()(Code)(Java Doc)
public String toString()(Code)(Java Doc)
final native public void wait(long timeout) throws InterruptedException(Code)(Java Doc)
final public void wait(long timeout, int nanos) throws InterruptedException(Code)(Java Doc)
final public void wait() throws InterruptedException(Code)(Java Doc)

www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.