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


001:        package com.xoetrope.swing;
002:
003:        import java.awt.Component;
004:        import java.awt.Container;
005:        import java.awt.Dimension;
006:        import java.awt.Point;
007:        import java.awt.Polygon;
008:        import java.awt.Rectangle;
009:        import java.awt.geom.Area;
010:        import java.util.StringTokenizer;
011:        import net.xoetrope.xui.XAttributedComponent;
012:
013:        /**
014:         * A component that flows text in a user defined area. The area is a polygon and 
015:         * need not be composed of rectangular blocks.
016:         *
017:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
018:         * the GNU Public License (GPL), please see license.txt for more details. If
019:         * you make commercial use of this software you must purchase a commercial
020:         * license from Xoetrope.</p>
021:         * <p> $Revision: 1.14 $</p>
022:         */
023:        public class XPolygonalTextArea extends XFlowedTextComponent implements 
024:                XAttributedComponent {
025:            /**
026:             * Create a new polygonal test area
027:             */
028:            public XPolygonalTextArea() {
029:            }
030:
031:            /**
032:             * Set one or more attributes of the component. Currently this handles the
033:             * attributes
034:             * <OL>
035:             * <li>text - set the text</li>
036:             * <li>content - set the text</li>
037:             * <li>increment - set the step size</li>
038:             * <li>points - the set of points that forms the polygon into which the text 
039:             * is flowed</li>
040:             * </OL>
041:             * @param attribName the attribute name
042:             * @param attribValue the attribute value
043:             * @return 0 for success, non zero otherwise
044:             */
045:            public int setAttribute(String attribName, Object attribValue) {
046:                String attribNameLwr = attribName.toLowerCase();
047:                String attribValueStr = (String) attribValue;
048:                String attribValueLwr = attribValueStr.toLowerCase();
049:                if (attribNameLwr.equals("points"))
050:                    setPoints(attribValueStr);
051:
052:                super .setAttribute(attribName, attribValue);
053:
054:                return 0;
055:            }
056:
057:            /**
058:             * Attempts to load and reference the associated view/datastore.
059:             */
060:            public void init() {
061:                super .init();
062:                Point p = getLocation();
063:                Dimension size = getSize();
064:                oX = p.x;
065:                oY = p.y;
066:                oW = size.width;
067:                oH = size.height;
068:
069:                if (polyArea == null)
070:                    polyArea = new Polygon();
071:
072:                flowArea = new Area(polyArea);
073:                if (!clip)
074:                    return;
075:
076:                Container parent = (Container) getParent();
077:                int count = parent.getComponentCount();
078:                try {
079:                    for (int i = 0; i < count; i++) {
080:                        Component cc = parent.getComponent(i);
081:                        if ((cc != this ) && cc.isVisible()) {
082:                            Rectangle rCC = cc.getBounds();
083:                            rCC.grow(10, 15);
084:                            if (flowArea != null)
085:                                flowArea.subtract(new Area(rCC));
086:                        }
087:                    }
088:                } catch (Exception ex1) {
089:                }
090:            }
091:
092:            /**
093:             * Add a point to teh polygon
094:             * @param x the x position of the point
095:             * @param y the y position of the point
096:             */
097:            public void addPoint(int x, int y) {
098:                Point p = getLocation();
099:                if (polyArea == null)
100:                    polyArea = new Polygon();
101:                polyArea.addPoint(p.x + x, p.y + y);
102:            }
103:
104:            /**
105:             * Set the polygon point as a string of comma separated x-y values
106:             * @param pts the xy pairs
107:             */
108:            public void setPoints(String pts) {
109:                StringTokenizer tokenizer = new StringTokenizer(pts, ",");
110:                while (tokenizer.hasMoreTokens()) {
111:                    int x = Integer.parseInt(tokenizer.nextToken());
112:                    int y = Integer.parseInt(tokenizer.nextToken());
113:                    addPoint(x, y);
114:                }
115:            }
116:
117:            public String getPoints() {
118:                String s = "";
119:                if (polyArea != null) {
120:                    for (int i = 0; i < polyArea.npoints; i++)
121:                        s += (i > 0 ? "," : "") + polyArea.xpoints[i] + ","
122:                                + polyArea.ypoints[i];
123:                }
124:                return s;
125:            }
126:
127:            /**
128:             * The polygonal area
129:             */
130:            protected Polygon polyArea;
131:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.