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


001:        /*
002:         * Magnification.java
003:         *
004:         * Created on 16 March 2007, 15:32
005:         *
006:         * To change this template, choose Tools | Template Manager
007:         * and open the template in the editor.
008:         */
009:
010:        package com.xoetrope.svgcomponentswizard;
011:
012:        import com.kitfox.svg.SVGDiagram;
013:        import com.xoetrope.svg.XSvgImageMap;
014:        import com.xoetrope.svg.XSvgMagnifyingGlass;
015:        import com.xoetrope.svg.XSvgMagnifyingWindow;
016:        import java.awt.BorderLayout;
017:        import java.awt.Color;
018:        import java.awt.Point;
019:        import java.awt.event.MouseEvent;
020:        import java.awt.event.MouseListener;
021:        import java.awt.event.MouseMotionListener;
022:        import javax.swing.BorderFactory;
023:        import javax.swing.JComponent;
024:        import net.xoetrope.swing.XApplet;
025:        import net.xoetrope.swing.XComboBox;
026:        import net.xoetrope.swing.XPanel;
027:        import net.xoetrope.swing.XRadioButton;
028:        import net.xoetrope.xui.XPage;
029:        import net.xoetrope.xui.XPageManager;
030:        import net.xoetrope.xui.XProjectManager;
031:        import net.xoetrope.xui.data.XBaseModel;
032:        import net.xoetrope.xui.data.XModel;
033:
034:        /**
035:         *
036:         * @author kingsley.elmes
037:         */
038:        public class Magnification extends XPage implements 
039:                MouseMotionListener, MouseListener {
040:            protected XPanel mainPanel, imageMapPanel;
041:            protected XSvgImageMap imageMap;
042:            protected XSvgMagnifyingWindow magWindow;
043:            protected XSvgMagnifyingGlass magGlass;
044:            protected XComboBox svgSelect;
045:            protected XRadioButton glassButton, windowButton;
046:            protected JComponent glassPane;
047:            protected boolean finished, magGlassRunning, magWindowRunning;
048:            protected int c;
049:
050:            /** Creates a new instance of Magnification */
051:            public Magnification() {
052:            }
053:
054:            /**
055:             * Set-up magnifying glass and add mouse listeners to svg image map.
056:             */
057:            public void pageCreated() {
058:                imageMapPanel = (XPanel) findComponent("imageMapPanel");
059:                imageMap = (XSvgImageMap) findComponent("imageMap");
060:                magWindow = (XSvgMagnifyingWindow) findComponent("magWindow");
061:                svgSelect = (XComboBox) findComponent("svgSelect");
062:                windowButton = (XRadioButton) findComponent("windowButton");
063:                glassButton = (XRadioButton) findComponent("glassButton");
064:                glassPane = (XPanel) findComponent("glassPane");
065:
066:                windowButton.setFocusable(false);
067:                glassButton.setFocusable(false);
068:                svgSelect.setFocusable(false);
069:                glassPane.setLayout(new BorderLayout());
070:
071:                imageMap.addMouseMotionListener(this );
072:                imageMap.addMouseListener(this );
073:
074:                SVGDiagram diagram = imageMap.getSvgDiagram();
075:
076:                magWindow.setBorder(BorderFactory.createLineBorder(Color.GRAY,
077:                        2));
078:                magWindow.setDiagram(diagram);
079:                magWindow.setImageMap(imageMap);
080:                magWindow.setScaleFactor(5.0F);
081:                magWindowRunning = true;
082:
083:                magGlass = new XSvgMagnifyingGlass();
084:                magGlass.setDiagram(diagram);
085:                magGlass.setImageMap(imageMap);
086:                magGlass.setScaleFactor(5.0F);
087:                magGlass.setRotational(true);
088:                magGlassRunning = false;
089:
090:                finished = true;
091:            }
092:
093:            /**
094:             * Updates the displayed svg image with a differnt svg image.
095:             */
096:            public void drawSvg() {
097:                if (finished) {
098:                    XBaseModel rootModel = (XBaseModel) XProjectManager
099:                            .getModel();
100:                    XModel m2 = (XModel) rootModel.get("svgs/"
101:                            + (svgSelect.getSelectedIndex() + 1));
102:                    String svgFile = (String) m2.getAttribValue(m2
103:                            .getAttribute("image"));
104:
105:                    imageMap.setURL(project.findResource(svgFile));
106:                    SVGDiagram diagram = imageMap.display();
107:                    imageMap.resetBuffer();
108:                    imageMap.resize();
109:                    imageMap.repaint();
110:
111:                    magWindow.setDiagram(diagram);
112:                    magGlass.setDiagram(diagram);
113:                }
114:            }
115:
116:            /**
117:             * Use the magnifying window for displaying the magnified svg.
118:             */
119:            public void selectWindow() {
120:                magGlass.stopThreads();
121:                glassPane.setVisible(false);
122:                glassPane.remove(magGlass);
123:                magWindow.setVisible(true);
124:                magWindowRunning = true;
125:            }
126:
127:            /**
128:             * Use the magnifying glass for displaying the magnified svg.
129:             */
130:            public void selectGlass() {
131:                magWindow.setVisible(false);
132:                magWindow.stopRenderer();
133:                glassPane.add(magGlass);
134:
135:                new Thread(magGlass).start();
136:
137:                glassPane.setComponentZOrder(magGlass, 0);
138:                glassPane.setVisible(true);
139:
140:                magWindowRunning = false;
141:            }
142:
143:            /**
144:             * Show the welcome page if the back button is pressed.
145:             */
146:            public void showPage() {
147:                XPageManager pageMgr = XProjectManager.getPageManager();
148:                pageMgr.showPage("Welcome");
149:            }
150:
151:            /**
152:             * Pass the mouse dragged event to the mouseMoved method.
153:             * @param e the passed <CODE>MouseEvent</CODE>.
154:             */
155:            public void mouseDragged(MouseEvent e) {
156:                mouseMoved(e);
157:            }
158:
159:            /**
160:             * Pass the current mouse location to the magnifictaion components.
161:             * @param e the passed <CODE>MouseEvent</CODE>.
162:             */
163:            public void mouseMoved(MouseEvent e) {
164:                if (magWindowRunning) {
165:                    magWindow.setZoomPoint(e.getPoint());
166:                } else {
167:                    Point mouseLocation = new Point((int) (e.getPoint().getX()
168:                            + imageMapPanel.getX() + imageMap.getX()), (int) (e
169:                            .getPoint().getY()
170:                            + imageMapPanel.getY() + imageMap.getY()));
171:                    magGlass.setZoomPoint(e.getPoint(), mouseLocation);
172:                }
173:            }
174:
175:            /**
176:             * Run the fade-in animation on the magnifying glass if the mouse enters the svg image.
177:             */
178:            public void mouseEntered(MouseEvent e) {
179:                magGlass.setAnimationMode(XSvgMagnifyingGlass.FADE_IN, 20F);
180:            }
181:
182:            /**
183:             * Run the fade-out animation on the magnifying glass if the mouse exits the svg image.
184:             */
185:            public void mouseExited(MouseEvent e) {
186:                magGlass.setAnimationMode(XSvgMagnifyingGlass.FADE_OUT, 10F);
187:            }
188:
189:            public void mouseClicked(MouseEvent e) {
190:            }
191:
192:            public void mousePressed(MouseEvent e) {
193:            }
194:
195:            public void mouseReleased(MouseEvent e) {
196:            }
197:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.