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


001:        package com.xoetrope.awt;
002:
003:        import java.awt.Component;
004:        import java.awt.Dimension;
005:        import java.awt.Graphics;
006:
007:        import net.xoetrope.xui.XAttributedComponent;
008:
009:        /**
010:         * Draws a simple shape
011:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
012:         * the GNU Public License (GPL), please see license.txt for more details. If
013:         * you make commercial use of this software you must purchase a commercial
014:         * license from Xoetrope.</p>
015:         * <p>$Revision: 1.4 $</p>
016:         */
017:        public class XShape extends Component implements  XAttributedComponent {
018:            protected int mode = 0;
019:
020:            public static final int RECTANGLE = 0;
021:            public static final int ORTHO_LINE = 1;
022:            public static final int EXTRABOLD_HORIZONTAL = 2;
023:            public static final int BOLD_HORIZONTAL = 3;
024:            public static final int NORMAL_HORIZONTAL = 4;
025:            public static final int THIN_HORIZONTAL = 5;
026:            public static final int EXTRABOLD_VERTICAL = 6;
027:            public static final int BOLD_VERTICAL = 7;
028:            public static final int NORMAL_VERTICAL = 8;
029:            public static final int THIN_VERTICAL = 9;
030:            public static final int RIGHT_TOP_LINE = 10;
031:            public static final int LEFT_TOP_LINE = 11;
032:            public static final int ELLIPSE = 12;
033:            public static final int SOLID_ELLIPSE = 13;
034:            public static final int SOLID_DIAMOND = 14;
035:            public static final int DIAMOND = 15;
036:
037:            /**
038:             * Constructor for a new XShape
039:             */
040:            public XShape() {
041:            }
042:
043:            /**
044:             * Fills the shape with the background color
045:             * @param g the graphics context
046:             */
047:            public void paint(Graphics g) {
048:                Dimension d = getSize();
049:
050:                g.setColor(getForeground());
051:
052:                switch (mode) {
053:                case RECTANGLE:
054:                    g.fillRect(0, 0, d.width, d.height);
055:                    break;
056:                case ORTHO_LINE:
057:                    g.fillRect(0, 0, getSize().width, getSize().height);
058:                    break;
059:
060:                case EXTRABOLD_HORIZONTAL:
061:                    g.drawLine(0, 0 + 3, d.width, 3);
062:                case BOLD_HORIZONTAL:
063:                    g.drawLine(0, 0 + 2, d.width, 2);
064:                case NORMAL_HORIZONTAL:
065:                    g.drawLine(0, 0 + 1, d.width, 1);
066:                case THIN_HORIZONTAL:
067:                    g.drawLine(0, 0, d.width, 0);
068:                    break;
069:
070:                case EXTRABOLD_VERTICAL:
071:                    g.drawLine(3, 0, 3, d.height);
072:                case BOLD_VERTICAL:
073:                    g.drawLine(2, 0, 2, d.height);
074:                case NORMAL_VERTICAL:
075:                    g.drawLine(1, 0, 1, d.height);
076:                case THIN_VERTICAL:
077:                    g.drawLine(0, 0, 0, d.height);
078:                    break;
079:
080:                case RIGHT_TOP_LINE:
081:                    g.drawLine(d.width, 0, 0, d.height);
082:                    break;
083:                case LEFT_TOP_LINE:
084:                    g.drawLine(0, 0, d.width, d.height);
085:                    break;
086:
087:                case ELLIPSE:
088:                    g.drawOval(0, 0, d.width, d.height);
089:                    break;
090:                case SOLID_ELLIPSE:
091:                    g.fillOval(0, 0, d.width, d.height);
092:                    break;
093:
094:                case SOLID_DIAMOND:
095:                case DIAMOND: {
096:                    int[] xpts = new int[4];
097:                    int[] ypts = new int[4];
098:                    xpts[0] = 0 + d.width / 2;
099:                    xpts[1] = 0 + d.width;
100:                    xpts[2] = 0 + d.width / 2;
101:                    xpts[3] = 0;
102:                    ypts[0] = 0;
103:                    ypts[1] = 0 + d.height / 2;
104:                    ypts[2] = 0 + d.height;
105:                    ypts[3] = 0 + d.height / 2;
106:                    if (mode == SOLID_DIAMOND)
107:                        g.fillPolygon(xpts, ypts, 4);
108:                    else
109:                        g.drawPolygon(xpts, ypts, 4);
110:                }
111:                    break;
112:                }
113:            }
114:
115:            /**
116:             * Get shape identifier. The ID is an enumerated constant
117:             * @param shapeId the new shape ID.
118:             */
119:            public void setShape(int shapeId) {
120:                mode = shapeId;
121:                repaint();
122:            }
123:
124:            /**
125:             * Get shape identifier.
126:             * @return the enumerated constant for this shape
127:             */
128:            public int getShape() {
129:                return mode;
130:            }
131:
132:            /**
133:             * Set one or more attributes of the component. Currently this handles the
134:             * attributes
135:             * <OL>
136:             * <LI>cue, value=Cue image filename</LI>
137:             * <LI>bars, value=number of bars</LI>
138:             * <LI>progress, value=the current progress value</LI>
139:             * <LI>max, value=the maximum progress value</LI>
140:             * </OL>
141:             * @param attribName the attribute name
142:             * @param attribValue the attribute value
143:             * @return 0 for success, non zero otherwise
144:             */
145:            public int setAttribute(String attribName, Object attribValue) {
146:                if (attribName.equalsIgnoreCase("mode"))
147:                    mode = new Integer((String) attribValue).intValue();
148:
149:                repaint(100);
150:                return 0;
151:            }
152:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.