Source Code Cross Referenced for TabAreaLineBorder.java in  » Swing-Library » InfoNode-Tabbed-Panel » net » infonode » tabbedpanel » border » 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 » Swing Library » InfoNode Tabbed Panel » net.infonode.tabbedpanel.border 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright (C) 2004 NNL Technology AB
003:         * Visit www.infonode.net for information about InfoNode(R) 
004:         * products and how to contact NNL Technology AB.
005:         *
006:         * This program is free software; you can redistribute it and/or
007:         * modify it under the terms of the GNU General Public License
008:         * as published by the Free Software Foundation; either version 2
009:         * of the License, or (at your option) any later version.
010:         *
011:         * This program is distributed in the hope that it will be useful,
012:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014:         * GNU General Public License for more details.
015:         *
016:         * You should have received a copy of the GNU General Public License
017:         * along with this program; if not, write to the Free Software
018:         * Foundation, Inc., 59 Temple Place - Suite 330, Boston, 
019:         * MA 02111-1307, USA.
020:         */
021:
022:        // $Id: TabAreaLineBorder.java,v 1.19 2005/12/04 13:46:05 jesper Exp $
023:        package net.infonode.tabbedpanel.border;
024:
025:        import net.infonode.gui.GraphicsUtil;
026:        import net.infonode.gui.colorprovider.*;
027:        import net.infonode.tabbedpanel.*;
028:        import net.infonode.util.Direction;
029:
030:        import javax.swing.*;
031:        import javax.swing.border.Border;
032:        import java.awt.*;
033:        import java.io.Serializable;
034:
035:        /**
036:         * TabAreaLineBorder draws a 1 pixel wide border on all sides except the side towards
037:         * the content area of a tabbed panel.
038:         *
039:         * @author $Author: jesper $
040:         * @author $Author: jesper $
041:         * @version $Revision: 1.19 $
042:         * @see Tab
043:         * @see TabbedPanel
044:         * @see TabbedPanelProperties
045:         * @see TabAreaProperties
046:         * @see TabAreaComponentsProperties
047:         * @since ITP 1.1.0
048:         */
049:        public class TabAreaLineBorder implements  Border, Serializable {
050:            private static final long serialVersionUID = 1;
051:
052:            private ColorProvider color;
053:            private boolean drawTop;
054:            private boolean drawLeft;
055:            private boolean drawRight;
056:            private boolean flipLeftRight;
057:
058:            /**
059:             * Constructs a TabAreaLineBorder with color based on the look and feel
060:             */
061:            public TabAreaLineBorder() {
062:                this (null);
063:            }
064:
065:            /**
066:             * Constructs a TabAreaLineBorder with the give color
067:             *
068:             * @param color color for the border
069:             */
070:            public TabAreaLineBorder(Color color) {
071:                this (color, true, true, true, false);
072:            }
073:
074:            /**
075:             * Constructor.
076:             *
077:             * @param drawTop       draw the top line
078:             * @param drawLeft      draw the left line
079:             * @param drawRight     draw the right line
080:             * @param flipLeftRight if true the left line is rotated so that it is always to the left or at the top and
081:             *                      vice versa for the right line, if false the left and right lines are rotated the same way as
082:             *                      the other lines
083:             */
084:            public TabAreaLineBorder(boolean drawTop, boolean drawLeft,
085:                    boolean drawRight, boolean flipLeftRight) {
086:                this ((Color) null, drawTop, drawLeft, drawRight, flipLeftRight);
087:            }
088:
089:            /**
090:             * Constructor.
091:             *
092:             * @param color         the line color
093:             * @param drawTop       draw the top line
094:             * @param drawLeft      draw the left line
095:             * @param drawRight     draw the right line
096:             * @param flipLeftRight if true the left line is rotated so that it is always to the left or at the top and
097:             *                      vice versa for the right line, if false the left and right lines are rotated the same way as
098:             *                      the other lines
099:             */
100:            public TabAreaLineBorder(Color color, boolean drawTop,
101:                    boolean drawLeft, boolean drawRight, boolean flipLeftRight) {
102:                this (ColorProviderUtil.getColorProvider(color,
103:                        new ColorProviderList(
104:                                UIManagerColorProvider.TABBED_PANE_DARK_SHADOW,
105:                                UIManagerColorProvider.CONTROL_DARK_SHADOW,
106:                                FixedColorProvider.BLACK)), drawTop, drawLeft,
107:                        drawRight, flipLeftRight);
108:            }
109:
110:            /**
111:             * Constructor.
112:             *
113:             * @param colorProvider the line color provider
114:             * @param drawTop       draw the top line
115:             * @param drawLeft      draw the left line
116:             * @param drawRight     draw the right line
117:             * @param flipLeftRight if true the left line is rotated so that it is always to the left or at the top and
118:             *                      vice versa for the right line, if false the left and right lines are rotated the same way as
119:             *                      the other lines
120:             */
121:            public TabAreaLineBorder(ColorProvider colorProvider,
122:                    boolean drawTop, boolean drawLeft, boolean drawRight,
123:                    boolean flipLeftRight) {
124:                this .color = colorProvider;
125:                this .drawTop = drawTop;
126:                this .drawLeft = drawLeft;
127:                this .drawRight = drawRight;
128:                this .flipLeftRight = flipLeftRight;
129:            }
130:
131:            public boolean isBorderOpaque() {
132:                return true;
133:            }
134:
135:            public void paintBorder(Component c, Graphics g, int x, int y,
136:                    int width, int height) {
137:                Insets insets = getBorderInsets(c);
138:                g.setColor(color.getColor(c));
139:
140:                if (insets.top == 1)
141:                    GraphicsUtil.drawOptimizedLine(g, x, y, x + width - 1, y);
142:
143:                if (insets.bottom == 1)
144:                    GraphicsUtil.drawOptimizedLine(g, x, y + height - 1, x
145:                            + width - 1, y + height - 1);
146:
147:                if (insets.left == 1)
148:                    GraphicsUtil.drawOptimizedLine(g, x, y, x, y + height - 1);
149:
150:                if (insets.right == 1)
151:                    GraphicsUtil.drawOptimizedLine(g, x + width - 1, y, x
152:                            + width - 1, y + height - 1);
153:            }
154:
155:            private boolean drawTop(Direction orientation) {
156:                return orientation == Direction.UP ? drawTop
157:                        : orientation == Direction.LEFT ? (flipLeftRight ? drawLeft
158:                                : drawRight)
159:                                : orientation == Direction.RIGHT ? drawLeft
160:                                        : false;
161:            }
162:
163:            private boolean drawLeft(Direction orientation) {
164:                return orientation == Direction.UP ? drawLeft
165:                        : orientation == Direction.LEFT ? drawTop
166:                                : orientation == Direction.DOWN ? (flipLeftRight ? drawLeft
167:                                        : drawRight)
168:                                        : false;
169:            }
170:
171:            private boolean drawRight(Direction orientation) {
172:                return orientation == Direction.UP ? drawRight
173:                        : orientation == Direction.LEFT ? false
174:                                : orientation == Direction.DOWN ? (flipLeftRight ? drawRight
175:                                        : drawLeft)
176:                                        : drawTop;
177:            }
178:
179:            private boolean drawBottom(Direction orientation) {
180:                return orientation == Direction.UP ? false
181:                        : orientation == Direction.LEFT ? (flipLeftRight ? drawRight
182:                                : drawLeft)
183:                                : orientation == Direction.RIGHT ? drawRight
184:                                        : drawTop;
185:            }
186:
187:            public Insets getBorderInsets(Component c) {
188:                if (c instanceof  JComponent
189:                        && ((JComponent) c).getComponentCount() == 0)
190:                    return new Insets(0, 0, 0, 0);
191:
192:                Direction orientation = getTabAreaDirection(c);
193:
194:                return orientation != null ? new Insets(
195:                        drawTop(orientation) ? 1 : 0, drawLeft(orientation) ? 1
196:                                : 0, drawBottom(orientation) ? 1 : 0,
197:                        drawRight(orientation) ? 1 : 0)
198:                        : new Insets(0, 0, 0, 0);
199:            }
200:
201:            private static Direction getTabAreaDirection(Component c) {
202:                TabbedPanel tp = TabbedUtils.getParentTabbedPanel(c);
203:                return tp != null ? tp.getProperties().getTabAreaOrientation()
204:                        : null;
205:
206:            }
207:
208:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.