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


001:        package com.xoetrope.carousel.survey;
002:
003:        import java.awt.Color;
004:        import java.awt.Dimension;
005:        import java.awt.Graphics;
006:        import java.awt.Graphics2D;
007:        import java.awt.Polygon;
008:        import java.awt.RenderingHints;
009:        import javax.swing.JComponent;
010:
011:        /**
012:         * A view of an arrow button being used to scroll the content of components.
013:         *
014:         * <p> Copyright (c) Xoetrope Ltd., 2001-2006, This software is licensed under
015:         * the GNU Public License (GPL), please see license.txt for more details. If
016:         * you make commercial use of this software you must purchase a commercial
017:         * license from Xoetrope.</p>
018:         * <p> $Revision: 1.5 $</p>
019:         */
020:        public class XArrowButton extends JComponent {
021:
022:            public static final int UP = 1;
023:            public static final int DOWN = 2;
024:
025:            protected double yScale;
026:            protected Color backgroundColor, borderColor;
027:            protected int type;
028:            protected Polygon shape;
029:            protected int width, height;
030:
031:            protected static double getScale() {
032:                return XRulesEditorPane.SCALE;
033:            }
034:
035:            public XArrowButton(int w, int h, double ys, Color bgc, Color brc,
036:                    int t) {
037:                super ();
038:                width = w;
039:                height = h;
040:                yScale = ys;
041:                backgroundColor = bgc;
042:                borderColor = brc;
043:                type = t;
044:                setSize();
045:            }
046:
047:            public boolean contains(int x, int y) {
048:                return (isEnabled() && (shape != null) && shape.contains(x, y));
049:            }
050:
051:            public void paintArrow(Graphics2D g) {
052:                if (shape != null && isEnabled()) {
053:                    g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
054:                            RenderingHints.VALUE_ANTIALIAS_ON);
055:                    g.setColor(backgroundColor);
056:                    g.fillPolygon(shape);
057:                    g.setColor(borderColor);
058:                    g.drawPolygon(shape);
059:                }
060:            }
061:
062:            public void paint(Graphics g) {
063:                if (isEnabled()) {
064:                    Graphics2D g2d = (Graphics2D) g;
065:                    paintArrow(g2d);
066:                }
067:            }
068:
069:            public void setSize() {
070:                Dimension size = new Dimension(getWidth(), getHeight());
071:                setSize(size);
072:                setMinimumSize(size);
073:                setPreferredSize(size);
074:                createShape();
075:            }
076:
077:            protected void createShape() {
078:                int w = getWidth() - 1;
079:                int h = getHeight() - 1;
080:                int x1 = 0, y1 = 0;
081:                int x2 = 0, y2 = 0;
082:                int x3 = 0, y3 = 0;
083:                int x4 = 0, y4 = 0;
084:                int x5 = 0, y5 = 0;
085:                if (type == UP) {
086:                    x1 = w;
087:                    y1 = h;
088:                    x2 = w;
089:                    y2 = (int) ((1 - yScale) * h);
090:                    x3 = w / 2;
091:                    y3 = 0;
092:                    x4 = 0;
093:                    y4 = (int) ((1 - yScale) * h);
094:                    x5 = 0;
095:                    y5 = h;
096:                } else if (type == DOWN) {
097:                    x1 = w;
098:                    y1 = (int) (yScale * h);
099:                    x2 = w;
100:                    y2 = 0;
101:                    x3 = 0;
102:                    y3 = 0;
103:                    x4 = 0;
104:                    y4 = (int) (yScale * h);
105:                    x5 = (w / 2);
106:                    y5 = h;
107:                }
108:                int[] xPoints = { x1, x2, x3, x4, x5 };
109:                int[] yPoints = { y1, y2, y3, y4, y5 };
110:                shape = new Polygon(xPoints, yPoints, 5);
111:            }
112:
113:            public int getWidth() {
114:                return (int) (getScale() * width);
115:            }
116:
117:            public int getHeight() {
118:                return (int) (getScale() * height);
119:            }
120:
121:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.