Source Code Cross Referenced for BevelArrowIcon.java in  » Graphic-Library » jcommon-components » org » jfree » ui » 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 » Graphic Library » jcommon components » org.jfree.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /* ========================================================================
002:         * JCommon : a free general purpose class library for the Java(tm) platform
003:         * ========================================================================
004:         *
005:         * (C) Copyright 2000-2005, by Object Refinery Limited and Contributors.
006:         * 
007:         * Project Info:  http://www.jfree.org/jcommon/index.html
008:         *
009:         * This library is free software; you can redistribute it and/or modify it 
010:         * under the terms of the GNU Lesser General Public License as published by 
011:         * the Free Software Foundation; either version 2.1 of the License, or 
012:         * (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful, but 
015:         * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
016:         * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 
017:         * License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library; if not, write to the Free Software
021:         * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, 
022:         * USA.  
023:         *
024:         * [Java is a trademark or registered trademark of Sun Microsystems, Inc. 
025:         * in the United States and other countries.]
026:         * 
027:         * -------------------
028:         * BevelArrowIcon.java
029:         * -------------------
030:         * (C) Copyright 2000-2004, by Nobuo Tamemasa and Contributors.
031:         *
032:         * Original Author:  Nobuo Tamemasa;
033:         * Contributor(s):   David Gilbert (for Object Refinery Limited);
034:         *
035:         * $Id: BevelArrowIcon.java,v 1.4 2005/11/16 15:58:41 taqua Exp $
036:         *
037:         * Changes (from 26-Oct-2001)
038:         * --------------------------
039:         * 26-Oct-2001 : Changed package to com.jrefinery.ui.*;
040:         * 13-Oct-2002 : Fixed errors reported by Checkstyle (DG);
041:         *
042:         */
043:
044:        package org.jfree.ui;
045:
046:        import java.awt.Color;
047:        import java.awt.Component;
048:        import java.awt.Graphics;
049:
050:        import javax.swing.Icon;
051:        import javax.swing.UIManager;
052:
053:        /**
054:         * An arrow icon that can point up or down (usually used to indicate the sort direction in a table).
055:         * <P>
056:         * This class (and also SortButtonRenderer) is based on original code by Nobuo Tamemasa (version
057:         * 1.0, 26-Feb-1999) posted on www.codeguru.com.
058:         *
059:         * @author Nobuo Tamemasa
060:         */
061:        public class BevelArrowIcon implements  Icon {
062:
063:            /** Constant indicating that the arrow is pointing up. */
064:            public static final int UP = 0;
065:
066:            /** Constant indicating that the arrow is pointing down. */
067:            public static final int DOWN = 1;
068:
069:            /** The default arrow size. */
070:            private static final int DEFAULT_SIZE = 11;
071:
072:            /** Edge color 1. */
073:            private Color edge1;
074:
075:            /** Edge color 2. */
076:            private Color edge2;
077:
078:            /** The fill color for the arrow icon. */
079:            private Color fill;
080:
081:            /** The size of the icon. */
082:            private int size;
083:
084:            /** The direction that the arrow is pointing (UP or DOWN). */
085:            private int direction;
086:
087:            /**
088:             * Standard constructor - builds an icon with the specified attributes.
089:             *
090:             * @param direction .
091:             * @param isRaisedView .
092:             * @param isPressedView .
093:             */
094:            public BevelArrowIcon(final int direction,
095:                    final boolean isRaisedView, final boolean isPressedView) {
096:                if (isRaisedView) {
097:                    if (isPressedView) {
098:                        init(UIManager.getColor("controlLtHighlight"),
099:                                UIManager.getColor("controlDkShadow"),
100:                                UIManager.getColor("controlShadow"),
101:                                DEFAULT_SIZE, direction);
102:                    } else {
103:                        init(UIManager.getColor("controlHighlight"), UIManager
104:                                .getColor("controlShadow"), UIManager
105:                                .getColor("control"), DEFAULT_SIZE, direction);
106:                    }
107:                } else {
108:                    if (isPressedView) {
109:                        init(UIManager.getColor("controlDkShadow"), UIManager
110:                                .getColor("controlLtHighlight"), UIManager
111:                                .getColor("controlShadow"), DEFAULT_SIZE,
112:                                direction);
113:                    } else {
114:                        init(UIManager.getColor("controlShadow"), UIManager
115:                                .getColor("controlHighlight"), UIManager
116:                                .getColor("control"), DEFAULT_SIZE, direction);
117:                    }
118:                }
119:            }
120:
121:            /**
122:             * Standard constructor - builds an icon with the specified attributes.
123:             *
124:             * @param edge1  the color of edge1.
125:             * @param edge2  the color of edge2.
126:             * @param fill  the fill color.
127:             * @param size  the size of the arrow icon.
128:             * @param direction  the direction that the arrow points.
129:             */
130:            public BevelArrowIcon(final Color edge1, final Color edge2,
131:                    final Color fill, final int size, final int direction) {
132:                init(edge1, edge2, fill, size, direction);
133:            }
134:
135:            /**
136:             * Paints the icon at the specified position.  Supports the Icon interface.
137:             *
138:             * @param c .
139:             * @param g .
140:             * @param x .
141:             * @param y .
142:             */
143:            public void paintIcon(final Component c, final Graphics g,
144:                    final int x, final int y) {
145:                switch (this .direction) {
146:                case DOWN:
147:                    drawDownArrow(g, x, y);
148:                    break;
149:                case UP:
150:                    drawUpArrow(g, x, y);
151:                    break;
152:                }
153:            }
154:
155:            /**
156:             * Returns the width of the icon.  Supports the Icon interface.
157:             *
158:             * @return the icon width.
159:             */
160:            public int getIconWidth() {
161:                return this .size;
162:            }
163:
164:            /**
165:             * Returns the height of the icon.  Supports the Icon interface.
166:             * @return the icon height.
167:             */
168:            public int getIconHeight() {
169:                return this .size;
170:            }
171:
172:            /**
173:             * Initialises the attributes of the arrow icon.
174:             *
175:             * @param edge1  the color of edge1.
176:             * @param edge2  the color of edge2.
177:             * @param fill  the fill color.
178:             * @param size  the size of the arrow icon.
179:             * @param direction  the direction that the arrow points.
180:             */
181:            private void init(final Color edge1, final Color edge2,
182:                    final Color fill, final int size, final int direction) {
183:                this .edge1 = edge1;
184:                this .edge2 = edge2;
185:                this .fill = fill;
186:                this .size = size;
187:                this .direction = direction;
188:            }
189:
190:            /**
191:             * Draws the arrow pointing down.
192:             *
193:             * @param g  the graphics device.
194:             * @param xo  ??
195:             * @param yo  ??
196:             */
197:            private void drawDownArrow(final Graphics g, final int xo,
198:                    final int yo) {
199:                g.setColor(this .edge1);
200:                g.drawLine(xo, yo, xo + this .size - 1, yo);
201:                g.drawLine(xo, yo + 1, xo + this .size - 3, yo + 1);
202:                g.setColor(this .edge2);
203:                g.drawLine(xo + this .size - 2, yo + 1, xo + this .size - 1,
204:                        yo + 1);
205:                int x = xo + 1;
206:                int y = yo + 2;
207:                int dx = this .size - 6;
208:                while (y + 1 < yo + this .size) {
209:                    g.setColor(this .edge1);
210:                    g.drawLine(x, y, x + 1, y);
211:                    g.drawLine(x, y + 1, x + 1, y + 1);
212:                    if (0 < dx) {
213:                        g.setColor(this .fill);
214:                        g.drawLine(x + 2, y, x + 1 + dx, y);
215:                        g.drawLine(x + 2, y + 1, x + 1 + dx, y + 1);
216:                    }
217:                    g.setColor(this .edge2);
218:                    g.drawLine(x + dx + 2, y, x + dx + 3, y);
219:                    g.drawLine(x + dx + 2, y + 1, x + dx + 3, y + 1);
220:                    x += 1;
221:                    y += 2;
222:                    dx -= 2;
223:                }
224:                g.setColor(this .edge1);
225:                g.drawLine(xo + (this .size / 2), yo + this .size - 1, xo
226:                        + (this .size / 2), yo + this .size - 1);
227:            }
228:
229:            /**
230:             * Draws the arrow pointing up.
231:             *
232:             * @param g  the graphics device.
233:             * @param xo  ??
234:             * @param yo  ??
235:             */
236:            private void drawUpArrow(final Graphics g, final int xo,
237:                    final int yo) {
238:                g.setColor(this .edge1);
239:                int x = xo + (this .size / 2);
240:                g.drawLine(x, yo, x, yo);
241:                x--;
242:                int y = yo + 1;
243:                int dx = 0;
244:                while (y + 3 < yo + this .size) {
245:                    g.setColor(this .edge1);
246:                    g.drawLine(x, y, x + 1, y);
247:                    g.drawLine(x, y + 1, x + 1, y + 1);
248:                    if (0 < dx) {
249:                        g.setColor(this .fill);
250:                        g.drawLine(x + 2, y, x + 1 + dx, y);
251:                        g.drawLine(x + 2, y + 1, x + 1 + dx, y + 1);
252:                    }
253:                    g.setColor(this .edge2);
254:                    g.drawLine(x + dx + 2, y, x + dx + 3, y);
255:                    g.drawLine(x + dx + 2, y + 1, x + dx + 3, y + 1);
256:                    x -= 1;
257:                    y += 2;
258:                    dx += 2;
259:                }
260:                g.setColor(this .edge1);
261:                g.drawLine(xo, yo + this .size - 3, xo + 1, yo + this .size - 3);
262:                g.setColor(this .edge2);
263:                g.drawLine(xo + 2, yo + this .size - 2, xo + this .size - 1, yo
264:                        + this .size - 2);
265:                g.drawLine(xo, yo + this .size - 1, xo + this .size, yo
266:                        + this .size - 1);
267:            }
268:
269:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.