Source Code Cross Referenced for AnchorUpdateControl.java in  » Database-Client » prefuse » prefuse » controls » 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 » Database Client » prefuse » prefuse.controls 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package prefuse.controls;
002:
003:        import java.awt.event.MouseEvent;
004:        import java.awt.geom.Point2D;
005:
006:        import prefuse.Display;
007:        import prefuse.action.layout.Layout;
008:        import prefuse.visual.VisualItem;
009:
010:        /**
011:         * Follows the mouse cursor, updating the anchor parameter for any number
012:         * of layout instances to match the current cursor position. Will also
013:         * run a given activity in response to cursor updates.
014:         * 
015:         * @author <a href="http://jheer.org">jeffrey heer</a>
016:         */
017:        public class AnchorUpdateControl extends ControlAdapter {
018:
019:            private boolean m_anchorOverItem;
020:            private Layout[] m_layouts;
021:            private String m_action;
022:            private Point2D m_tmp = new Point2D.Double();
023:
024:            /**
025:             * Create a new AnchorUpdateControl.
026:             * @param layout the layout for which to update the anchor point
027:             */
028:            public AnchorUpdateControl(Layout layout) {
029:                this (layout, null);
030:            }
031:
032:            /**
033:             * Create a new AnchorUpdateControl.
034:             * @param layout the layout for which to update the anchor point
035:             * @param action the name of an action to run upon anchor updates
036:             */
037:            public AnchorUpdateControl(Layout layout, String action) {
038:                this (new Layout[] { layout }, action);
039:            }
040:
041:            /**
042:             * Create a new AnchorUpdateControl.
043:             * @param layout the layout for which to update the anchor point
044:             * @param action the name of an action to run upon anchor updates
045:             * @param overItem indicates if anchor update events should be processed
046:             * while the mouse cursor is hovered over a VisualItem.
047:             */
048:            public AnchorUpdateControl(Layout layout, String action,
049:                    boolean overItem) {
050:                this (new Layout[] { layout }, action, overItem);
051:            }
052:
053:            /**
054:             * Create a new AnchorUpdateControl.
055:             * @param layout the layouts for which to update the anchor point
056:             * @param action the name of an action to run upon anchor updates
057:             */
058:            public AnchorUpdateControl(Layout[] layout, String action) {
059:                this (layout, action, true);
060:            }
061:
062:            /**
063:             * Create a new AnchorUpdateControl.
064:             * @param layout the layouts for which to update the anchor point
065:             * @param action the name of an action to run upon anchor updates
066:             * @param overItem indicates if anchor update events should be processed
067:             * while the mouse cursor is hovered over a VisualItem.
068:             */
069:            public AnchorUpdateControl(Layout[] layout, String action,
070:                    boolean overItem) {
071:                m_layouts = (Layout[]) layout.clone();
072:                m_action = action;
073:                m_anchorOverItem = overItem;
074:            }
075:
076:            // ------------------------------------------------------------------------
077:
078:            /**
079:             * @see java.awt.event.MouseListener#mouseExited(java.awt.event.MouseEvent)
080:             */
081:            public void mouseExited(MouseEvent e) {
082:                for (int i = 0; i < m_layouts.length; i++)
083:                    m_layouts[i].setLayoutAnchor(null);
084:                runAction(e);
085:            }
086:
087:            /**
088:             * @see java.awt.event.MouseMotionListener#mouseMoved(java.awt.event.MouseEvent)
089:             */
090:            public void mouseMoved(MouseEvent e) {
091:                moveEvent(e);
092:            }
093:
094:            /**
095:             * @see java.awt.event.MouseMotionListener#mouseDragged(java.awt.event.MouseEvent)
096:             */
097:            public void mouseDragged(MouseEvent e) {
098:                moveEvent(e);
099:            }
100:
101:            /**
102:             * @see prefuse.controls.Control#itemDragged(prefuse.visual.VisualItem, java.awt.event.MouseEvent)
103:             */
104:            public void itemDragged(VisualItem item, MouseEvent e) {
105:                if (m_anchorOverItem)
106:                    moveEvent(e);
107:            }
108:
109:            /**
110:             * @see prefuse.controls.Control#itemMoved(prefuse.visual.VisualItem, java.awt.event.MouseEvent)
111:             */
112:            public void itemMoved(VisualItem item, MouseEvent e) {
113:                if (m_anchorOverItem)
114:                    moveEvent(e);
115:            }
116:
117:            /**
118:             * Registers a mouse move event, updating the anchor point for all
119:             * registered layout instances.
120:             * @param e the MouseEvent
121:             */
122:            public void moveEvent(MouseEvent e) {
123:                Display d = (Display) e.getSource();
124:                d.getAbsoluteCoordinate(e.getPoint(), m_tmp);
125:                for (int i = 0; i < m_layouts.length; i++)
126:                    m_layouts[i].setLayoutAnchor(m_tmp);
127:                runAction(e);
128:            }
129:
130:            /**
131:             * Runs an optional action upon anchor update.
132:             * @param e MouseEvent
133:             */
134:            private void runAction(MouseEvent e) {
135:                if (m_action != null) {
136:                    Display d = (Display) e.getSource();
137:                    d.getVisualization().run(m_action);
138:                }
139:            }
140:
141:        } // end of class AnchorUpdateControl
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.