Source Code Cross Referenced for XRolloverComponent.java in  » XML-UI » xui32 » com » xoetrope » svg » 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 » XML UI » xui32 » com.xoetrope.svg 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * XRolloverComponent.java
003:         *
004:         * Created on 12 February 2007, 11:40
005:         *
006:         * To change this template, choose Tools | Template Manager
007:         * and open the template in the editor.
008:         */
009:
010:        package com.xoetrope.svg;
011:
012:        import com.xoetrope.swing.XGraph;
013:        import java.awt.BorderLayout;
014:        import java.awt.Color;
015:        import java.awt.Component;
016:        import java.awt.Graphics;
017:        import java.awt.Image;
018:        import java.awt.event.MouseEvent;
019:        import java.awt.event.MouseListener;
020:        import javax.swing.Icon;
021:        import javax.swing.ImageIcon;
022:        import javax.swing.JComponent;
023:        import javax.swing.JLabel;
024:
025:        /**
026:         * 
027:         *
028:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
029:         * the GNU Public License (GPL), please see license.txt for more details. If
030:         * you make commercial use of this software you must purchase a commercial
031:         * license from Xoetrope.</p>
032:         * <p> $Revision: 1.2 $</p>
033:         */
034:        public class XRolloverComponent extends JComponent implements 
035:                MouseListener {
036:            protected int x, y;
037:            protected String path;
038:            protected JComponent[] components;
039:            protected JLabel marker;
040:            ImageIcon icon;
041:
042:            /** 
043:             * Creates a new instance of XRolloverComponent 
044:             * @param x the x-coordinate of this component.
045:             * @param y the y-coordinate of this component.
046:             * @param component the <CODE>Component</CODE> that will be displayed when there is a rollover event.
047:             */
048:            public XRolloverComponent(JComponent[] components) {
049:                this .components = components;
050:                icon = new ImageIcon(getClass().getResource(
051:                        "images/marker2.gif"));
052:                marker = new JLabel(icon);
053:                marker.addMouseListener(this );
054:            }
055:
056:            /**
057:             * If the mouse is detected entering this component, display the rollover event component.
058:             * @param e the fired <CODE>MouseEvent</CODE>.
059:             */
060:            public void mouseEntered(MouseEvent e) {
061:                try {
062:                    Thread.sleep(200);
063:                } catch (InterruptedException ex) {
064:                    ex.printStackTrace();
065:                }
066:
067:                int parentWidth = getParent().getWidth();
068:                int parentHeight = getParent().getHeight();
069:                double x = 0, y = 0;
070:
071:                for (int i = 0; i < components.length; i++) {
072:                    if (i == 0) {
073:                        if (getX() < (parentWidth / 2)
074:                                && getY() < (parentHeight / 2)) { // 1
075:                            x = getX() + 20;
076:                            y = getY();
077:                        } else if (getX() >= (parentWidth / 2)
078:                                && getY() < (parentHeight / 2)) { // 2
079:                            x = getX() - (components[i].getWidth() + 10);
080:                            y = getY();
081:                        } else if (getX() < (parentWidth / 2)
082:                                && getY() >= (parentHeight / 2)) { // 3
083:                            x = getX() + 20;
084:                            y = getY() - (components[i].getHeight() - 10);
085:                        } else if (getX() >= (parentWidth / 2)
086:                                && getY() >= (parentHeight / 2)) { // 4
087:                            x = getX() - (components[i].getWidth() + 10);
088:                            y = getY() - (components[i].getHeight() - 10);
089:                        }
090:                    } else {
091:                        if (getX() < (parentWidth / 2)
092:                                && getY() < (parentHeight / 2)) { // 1
093:                            x = getX() + components[i - 1].getWidth() + 30;
094:                            y = getY();
095:                        } else if (getX() >= (parentWidth / 2)
096:                                && getY() < (parentHeight / 2)) { // 2
097:                            x = getX()
098:                                    - (components[i].getWidth() + 20 + components[i - 1]
099:                                            .getWidth());
100:                            y = getY();
101:                        } else if (getX() < (parentWidth / 2)
102:                                && getY() >= (parentHeight / 2)) { // 3
103:                            x = getX() + components[i - 1].getWidth() + 30;
104:                            y = getY() - (components[i].getHeight() - 10);
105:                        } else if (getX() >= (parentWidth / 2)
106:                                && getY() >= (parentHeight / 2)) { // 4
107:                            x = getX()
108:                                    - (components[i].getWidth()
109:                                            + components[i - 1].getWidth() + 20);
110:                            y = getY() - (components[i].getHeight() - 10);
111:                        }
112:                    }
113:
114:                    components[i].setBounds((int) x, (int) y, components[i]
115:                            .getWidth(), components[i].getHeight());
116:                    getParent().add(components[i], 0);
117:                    components[i].repaint();
118:                }
119:                getParent().repaint();
120:            }
121:
122:            /**
123:             * If the mouse is detected exiting this component, hide the rollover event component.
124:             * @param e the fired <CODE>MouseEvent</CODE>.
125:             */
126:            public void mouseExited(MouseEvent e) {
127:                try {
128:                    Thread.sleep(400);
129:                } catch (InterruptedException ex) {
130:                    ex.printStackTrace();
131:                }
132:
133:                for (int i = 0; i < components.length; i++) {
134:                    getParent().remove(components[i]);
135:                }
136:                getParent().repaint();
137:            }
138:
139:            /**
140:             * Sets the size of the component when it is painted.
141:             */
142:            public void paintComponent(Graphics g) {
143:                marker.setBounds(0, 0, 10, 10);
144:                add(marker);
145:            }
146:
147:            public void mouseClicked(MouseEvent e) {
148:            }
149:
150:            public void mousePressed(MouseEvent e) {
151:            }
152:
153:            public void mouseReleased(MouseEvent e) {
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.