Source Code Cross Referenced for XPopUpWindow.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:         * PopUpWindow.java
003:         *
004:         * Created on 30 January 2007, 15:55
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 java.awt.BasicStroke;
013:        import java.awt.BorderLayout;
014:        import java.awt.Color;
015:        import java.awt.Font;
016:        import java.awt.Graphics;
017:        import java.awt.Graphics2D;
018:        import java.awt.Rectangle;
019:        import java.awt.RenderingHints;
020:        import java.awt.Stroke;
021:        import java.awt.geom.Arc2D;
022:        import java.awt.geom.GeneralPath;
023:        import java.awt.geom.Line2D;
024:        import java.awt.geom.RoundRectangle2D;
025:        import javax.swing.BorderFactory;
026:        import javax.swing.JComponent;
027:        import javax.swing.JDialog;
028:        import javax.swing.JFrame;
029:        import javax.swing.JPanel;
030:        import javax.swing.JTextArea;
031:        import javax.swing.JTextField;
032:        import net.xoetrope.swing.XTextArea;
033:        import net.xoetrope.xui.XAttributedComponent;
034:        import net.xoetrope.xui.XProject;
035:        import net.xoetrope.xui.XProjectManager;
036:        import net.xoetrope.xui.XTextHolder;
037:        import net.xoetrope.xui.helper.XuiUtilities;
038:
039:        /**
040:         *
041:         *
042:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
043:         * the GNU Public License (GPL), please see license.txt for more details. If
044:         * you make commercial use of this software you must purchase a commercial
045:         * license from Xoetrope.</p>
046:         * <p> $Revision: 1.2 $</p>
047:         */
048:        public class XPopUpWindow extends JComponent implements 
049:                XAttributedComponent, XTextHolder {
050:            protected int fontSize;
051:            protected double x, y, width, height, scale1, scale2, scale3,
052:                    scale4, scale5, scale6, scale7, scale8;
053:            protected String text, captionStyle;
054:            protected Stroke stroke;
055:            protected XTextArea textArea;
056:            protected boolean first;
057:
058:            protected XProject currentProject = XProjectManager
059:                    .getCurrentProject();
060:
061:            /** Creates a new instance of PopUpWindow 
062:             * @param x <CODE>int</CODE> specifying the x-coordinate of the pop-up window.
063:             * @param y <CODE>int</CODE> specifying the y-coordinate of the pop-up window.
064:             * @param text <CODE>String</CODE> the text to be displayed in the pop-up window.
065:             */
066:            public XPopUpWindow() {
067:                first = true;
068:
069:                textArea = new XTextArea();
070:                stroke = new BasicStroke(2.0F);
071:                width = 180.0;
072:                height = 170.0;
073:                fontSize = 12;
074:
075:                scale1 = 0.33333333333333333333333333333333;
076:                scale2 = 0.52941176470588235294117647058824;
077:                scale3 = 0.47058823529411764705882352941176;
078:                scale4 = 0.63529411764705882352941176470588;
079:                scale5 = 0.88888888888888888888888888888889;
080:                scale6 = 0.41176470588235294117647058823529;
081:                scale7 = 0.27777777777777777777777777777778;
082:                scale8 = 0.94117647058823529411764705882353;
083:
084:                setSize(1, 1);
085:                setOpaque(true);
086:            }
087:
088:            /**
089:             * Set the size of the pop-up window.
090:             * @param x1 <CODE>int</CODE> specifying the x coordinate of the component.
091:             * @param y1 <CODE>int</CODE> specifying the y coordinate of the component.
092:             * @param w1 <CODE>int</CODE> specifying the width of the component.
093:             * @param h1 <CODE>int<CODE> specifying the height of the component.
094:             */
095:            public void setBounds(int x1, int y1, int w1, int h1) {
096:                super .setBounds(x1, y1, w1, h1);
097:
098:                x = w1 * 0.34;
099:                y = h1 + 1;
100:                width = w1 - 3.0;
101:                height = h1;
102:            }
103:
104:            /**
105:             * Sets the content of the pop-up window.
106:             * @param text <CODE>String</CODE> specifying the content.
107:             */
108:            public void setText(String text) {
109:                this .text = text;
110:                textArea.setText(text);
111:            }
112:
113:            /** 
114:             * Returns the content currently displayed in the pop-up window.
115:             * @return <CODE>String</CODE> containing the currently displayed text.  
116:             */
117:            public String getText() {
118:                return text;
119:            }
120:
121:            /**
122:             * Set one or more attributes of the component. Currently this handles the attributes
123:             * <OL>
124:             * <LI>content, value=The textual information displayed by the component or</LI>
125:             * <LI>text, value=The textual information displayed by the component</LI>
126:             * <LI>style, value=The style for the text </LI>
127:             * </OL> 
128:             * @param attribName the attribute name
129:             * @param attribValue the attribute value
130:             * @return 0 for success, non zero otherwise
131:             */
132:            public int setAttribute(String attribName, Object attribValue) {
133:                String attribNameLwr = attribName.toLowerCase();
134:                String attribValueStr = (String) attribValue;
135:                if (attribNameLwr.equals("content")
136:                        || attribNameLwr.equals("text"))
137:                    setText(attribValueStr);
138:                else if (attribNameLwr.equals("style"))
139:                    setStyle(attribValueStr);
140:
141:                return 0;
142:            }
143:
144:            /**
145:             * Sets the size of the font displayed in the pop-up window.
146:             * @param fontSize <CODE>String</CODE> specifying the size of the font.
147:             */
148:            public void setFontSize(String fontSize) {
149:                this .fontSize = Integer.parseInt(fontSize);
150:                textArea.setFont(new Font("Arial", Font.PLAIN, Integer
151:                        .parseInt(fontSize)));
152:            }
153:
154:            /**
155:             * Sets the size of the font displayed in the pop-up window.
156:             * @param fontSize <CODE>int</CODE> specifying the size of the font.
157:             */
158:            public void setFontSize(int fontSize) {
159:                this .fontSize = fontSize;
160:                textArea.setFont(new Font("Arial", Font.PLAIN, fontSize));
161:            }
162:
163:            /** 
164:             * Returns the font size of the currently displayed text.
165:             * @return <CODE>int</CODE> specifying the font size of the currently displayed text.  
166:             */
167:            public int getFontSize() {
168:                return fontSize;
169:            }
170:
171:            /** 
172:             * Set the text style
173:             * @param newStyle the new text style
174:             */
175:            public void setStyle(String newStyle) {
176:                captionStyle = newStyle;
177:                XuiUtilities.applyStyle(currentProject, textArea, newStyle);
178:            }
179:
180:            /**
181:             * Paints the pop-up window within its parent component.
182:             * @param g the delegate <CODE>Graphics</CODE> object.
183:             */
184:            public void paintComponent(Graphics g) {
185:                Graphics2D g2 = (Graphics2D) g.create();
186:                g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
187:                        RenderingHints.VALUE_ANTIALIAS_ON);
188:                g2.setStroke(stroke);
189:                g2.setColor(Color.gray);
190:
191:                GeneralPath path = new GeneralPath();
192:
193:                RoundRectangle2D.Double roundRect = new RoundRectangle2D.Double(
194:                        2, 2, width, (height * scale2), 20.0, 20.0);
195:                g2.draw(roundRect);
196:
197:                Line2D.Double line = new Line2D.Double((width * scale1),
198:                        height, (width * scale4), (height * scale2));
199:                path.append(line, true);
200:
201:                Line2D.Double line2 = new Line2D.Double((width * scale3),
202:                        (height * scale2), (width * scale1), height);
203:                path.append(line2, true);
204:
205:                g2.draw(path);
206:
207:                g2.setColor(Color.decode("#FFF6D5"));
208:                g2.fill(roundRect);
209:                g2.fill(path);
210:
211:                g2.setColor(Color.black);
212:
213:                if (first) {
214:                    textArea.setFont(new Font("Arial", Font.PLAIN, fontSize));
215:                    textArea.setLineWrap(true);
216:                    textArea.setWrapStyleWord(true);
217:                    textArea.setEditable(false);
218:                    textArea.setBackground(Color.decode("#FFF6D5"));
219:                    add(textArea);
220:                    first = false;
221:                }
222:
223:                textArea.setBounds((int) (x - (width * scale7)),
224:                        (int) (y - (height * scale8)), (int) (width * scale5),
225:                        (int) (height * scale6));
226:
227:                g2.dispose();
228:            }
229:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.