Source Code Cross Referenced for XViewBoxModifier.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) 


01:        /*
02:         * ViewBoxPosition.java
03:         *
04:         * Created on 31 January 2007, 11:13
05:         *
06:         * To change this template, choose Tools | Template Manager
07:         * and open the template in the editor.
08:         */
09:
10:        package com.xoetrope.svg;
11:
12:        import com.kitfox.svg.SVGRoot;
13:        import com.kitfox.svg.animation.AnimationElement;
14:        import com.xoetrope.carousel.build.BuildProperties;
15:        import com.xoetrope.svg.XSvgImageMap;
16:        import java.awt.geom.Point2D;
17:
18:        /**
19:         *
20:         *
21:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
22:         * the GNU Public License (GPL), please see license.txt for more details. If
23:         * you make commercial use of this software you must purchase a commercial
24:         * license from Xoetrope.</p>
25:         * <p> $Revision: 1.2 $</p>
26:         */
27:        public class XViewBoxModifier {
28:            protected XSvgImageMap imageMap;
29:            protected XPointSystem pointSystem;
30:
31:            /** 
32:             * Creates a new instance of ViewBoxPosition 
33:             * @param imageMap the <CODE>XSvgImageMap</CODE> instance used by this class.
34:             */
35:            public XViewBoxModifier(XSvgImageMap imageMap) {
36:                this .imageMap = imageMap;
37:                pointSystem = new XPointSystem(imageMap);
38:            }
39:
40:            /**
41:             * Sets the viewboxs centre position on the map.
42:             * @param x <CODE>double</CODE> specifying the x coordinate of the view box's centre position.
43:             * @param y <CODE>double</CODE> specifying the y coordinate of the view box's centre position.
44:             */
45:            public void setPosition(double x, double y) {
46:                SVGRoot root = imageMap.getSvgDiagram().getRoot();
47:                double[] attr = root.getPresAbsolute("viewBox").getDoubleList();
48:
49:                Point2D centre = pointSystem.glassPaneToSvg(x, y);
50:
51:                double newX = (centre.getX() - ((attr[2] + attr[0]) / 2.0));
52:                double newY = (centre.getY() - ((attr[3] + attr[1]) / 2.0));
53:
54:                String viewBox = newX + " " + newY + " " + attr[2] + " "
55:                        + attr[3];
56:
57:                try {
58:                    root.setAttribute("viewBox", AnimationElement.AT_XML,
59:                            viewBox);
60:                    root.build(); // rebuild root of svg image
61:                    imageMap.resetBuffer();
62:                    imageMap.repaint();
63:                } catch (Exception ex) {
64:                    if (BuildProperties.DEBUG)
65:                        ex.printStackTrace();
66:                }
67:            }
68:
69:            /**
70:             * Sets the size of the view box.
71:             * @param w <CODE>double</CODE> specifying the new width of the viewBox.
72:             * @param h <CODE>double</CODE> specifying the new width of the viewBox.
73:             */
74:            public void setSize(double w, double h) {
75:                SVGRoot root = imageMap.getSvgDiagram().getRoot();
76:                double[] attr = root.getPresAbsolute("viewBox").getDoubleList();
77:
78:                String viewBox = attr[0] + " " + attr[1] + " " + w + " " + h;
79:
80:                try {
81:                    root.setAttribute("viewBox", AnimationElement.AT_XML,
82:                            viewBox);
83:                    root.build(); // rebuild root of svg image
84:                    imageMap.resetBuffer();
85:                    imageMap.repaint();
86:                } catch (Exception ex) {
87:                    if (BuildProperties.DEBUG)
88:                        ex.printStackTrace();
89:                }
90:            }
91:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.