Source Code Cross Referenced for TabLineBorder.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: TabLineBorder.java,v 1.27 2005/07/19 14:17:31 johan Exp $
023:        package net.infonode.tabbedpanel.border;
024:
025:        import net.infonode.gui.colorprovider.ColorProvider;
026:        import net.infonode.gui.colorprovider.ColorProviderUtil;
027:        import net.infonode.gui.colorprovider.UIManagerColorProvider;
028:        import net.infonode.tabbedpanel.Tab;
029:        import net.infonode.tabbedpanel.TabbedPanel;
030:        import net.infonode.tabbedpanel.TabbedUtils;
031:        import net.infonode.util.Direction;
032:
033:        import javax.swing.border.Border;
034:        import javax.swing.border.CompoundBorder;
035:        import java.awt.*;
036:        import java.io.Serializable;
037:
038:        /**
039:         * TabLineBorder draws a 1 pixel wide line around a {@link Tab}. If tab spacing in the
040:         * tabbed panel is 0 then the border will only draw a single line between two adjacent tabs.
041:         *
042:         * @author $Author: johan $
043:         * @version $Revision: 1.27 $
044:         * @see Tab
045:         * @see TabbedPanel
046:         * @deprecated As of ITP 1.2.0 use {@link TabAreaLineBorder} instead with
047:         *             {@link net.infonode.tabbedpanel.TabbedPanelProperties#TAB_SPACING} set to -1.
048:         */
049:        public class TabLineBorder implements  Border, Serializable {
050:            private static final long serialVersionUID = 1;
051:
052:            private ColorProvider color;
053:            private Border border;
054:            private boolean last;
055:            private boolean afterHighlighted;
056:            private boolean highlighted;
057:            private boolean drawTopLine;
058:            private boolean drawBottomLine;
059:            private int index;
060:            private boolean tabSpacing;
061:
062:            private class LineBorder implements  Border {
063:
064:                LineBorder() {
065:                }
066:
067:                public void paintBorder(Component component, Graphics g, int x,
068:                        int y, int width, int height) {
069:                    Color c = color.getColor(component);
070:                    Tab tab = TabbedUtils.getParentTab(component);
071:                    if (tab != null && tab.getTabbedPanel() != null) {
072:                        Direction d = tab.getTabbedPanel().getProperties()
073:                                .getTabAreaOrientation();
074:                        tabSpacing = tab.getTabbedPanel().getProperties()
075:                                .getTabSpacing() > 0;
076:                        initialize(tab);
077:                        if (d == Direction.UP)
078:                            paintUpBorder(g, x, y, width, height, c);
079:                        else if (d == Direction.LEFT)
080:                            paintLeftBorder(g, x, y, width, height, c);
081:                        else if (d == Direction.DOWN)
082:                            paintDownBorder(g, x, y, width, height, c);
083:                        else
084:                            // RIGHT
085:                            paintRightBorder(g, x, y, width, height, c);
086:                    }
087:                }
088:
089:                public Insets getBorderInsets(Component c) {
090:                    Tab tab = TabbedUtils.getParentTab(c);
091:                    if (tab != null && tab.getTabbedPanel() != null
092:                            && tab.getParent() != null) {
093:                        int top;
094:                        int left;
095:                        int bottom;
096:                        int right;
097:                        Direction d = tab.getTabbedPanel().getProperties()
098:                                .getTabAreaOrientation();
099:                        initialize(tab);
100:                        if (d == Direction.UP) {
101:                            top = drawTopLine ? 1 : 0;
102:                            left = 1;
103:                            bottom = 0;
104:                            right = 1;
105:                        } else if (d == Direction.LEFT) {
106:                            top = 1;
107:                            left = drawTopLine ? 1 : 0;
108:                            bottom = 1;
109:                            right = 0;
110:                        } else if (d == Direction.DOWN) {
111:                            top = 0;
112:                            left = 1;
113:                            bottom = drawTopLine ? 1 : 0;
114:                            right = 1;
115:                        } else {
116:                            top = 1;
117:                            left = 0;
118:                            bottom = 1;
119:                            right = drawTopLine ? 1 : 0;
120:                        }
121:
122:                        return new Insets(top, left, bottom, right);
123:                    }
124:
125:                    return new Insets(0, 0, 0, 0);
126:                }
127:
128:                public boolean isBorderOpaque() {
129:                    return true;
130:                }
131:
132:                private void paintUpBorder(Graphics g, int x, int y, int width,
133:                        int height, Color color) {
134:                    g.setColor(color);
135:
136:                    // Left Line
137:                    if (!afterHighlighted || tabSpacing)
138:                        g.drawLine(x, y, x, y + height - 1);
139:
140:                    // Right line
141:                    if (highlighted || last || tabSpacing)
142:                        g.drawLine(x + width - 1, y, x + width - 1, y + height
143:                                - 1);
144:
145:                    // Top Line
146:                    if (drawTopLine)
147:                        g.drawLine(x, y, x + width - 1, y);
148:
149:                    if (drawBottomLine)
150:                        g.drawLine(x, y + height - 1, x + width - 1, y + height
151:                                - 1);
152:                }
153:
154:                private void paintLeftBorder(Graphics g, int x, int y,
155:                        int width, int height, Color color) {
156:                    g.setColor(color);
157:
158:                    // Top Line
159:                    if (!afterHighlighted || tabSpacing)
160:                        g.drawLine(x, y, x + width - 1, y);
161:
162:                    // Left Line
163:                    if (drawTopLine)
164:                        g.drawLine(x, y, x, y + height - 1);
165:
166:                    // Bottom Line
167:                    if (highlighted || last || tabSpacing)
168:                        g.drawLine(x, y + height - 1, x + width - 1, y + height
169:                                - 1);
170:
171:                    if (drawBottomLine)
172:                        g.drawLine(x + width - 1, y, x + width - 1, y + height
173:                                - 1);
174:                }
175:
176:                private void paintDownBorder(Graphics g, int x, int y,
177:                        int width, int height, Color color) {
178:                    g.setColor(color);
179:
180:                    // Left Line
181:                    if (!afterHighlighted || tabSpacing)
182:                        g.drawLine(x, y, x, y + height - 1);
183:
184:                    // Right line
185:                    if (highlighted || last || tabSpacing)
186:                        g.drawLine(x + width - 1, y, x + width - 1, y + height
187:                                - 1);
188:
189:                    // Bottom Line
190:                    if (drawTopLine)
191:                        g
192:                                .drawLine(x, y + height - 1, x + width, y
193:                                        + height - 1);
194:
195:                    if (drawBottomLine)
196:                        g.drawLine(x, y, x + width, y);
197:                }
198:
199:                private void paintRightBorder(Graphics g, int x, int y,
200:                        int width, int height, Color color) {
201:                    g.setColor(color);
202:
203:                    // Top Line
204:                    if (!afterHighlighted || tabSpacing)
205:                        g.drawLine(x, y, x + width - 1, y);
206:
207:                    // Right Line
208:                    if (drawTopLine)
209:                        g.drawLine(x + width - 1, y, x + width - 1, y + height
210:                                - 1);
211:
212:                    // Bottom Line
213:                    if (highlighted || last || tabSpacing)
214:                        g.drawLine(x, y + height - 1, x + width - 1, y + height
215:                                - 1);
216:
217:                    if (drawBottomLine)
218:                        g.drawLine(x, y, x, y + height - 1);
219:                }
220:            }
221:
222:            /**
223:             * Constructor. Uses the TabbedPane.darkShadow color from the UIManager as line color.
224:             */
225:            public TabLineBorder() {
226:                this (null);
227:            }
228:
229:            /**
230:             * Constructs a TabLineBorder that draws lines on three sides of the tab.
231:             * No line will be drawn on the side towards the TabbedPanel's content area.
232:             *
233:             * @param color the line color
234:             */
235:            public TabLineBorder(Color color) {
236:                this (color, false);
237:            }
238:
239:            /**
240:             * Constructs a TabLineBorder that draws lines on three or four sides of the tab.
241:             *
242:             * @param color          the line color
243:             * @param drawBottomLine true if a line should be drawn on the side towards the
244:             *                       tabbed panel's content area, otherwise false
245:             */
246:            public TabLineBorder(Color color, boolean drawBottomLine) {
247:                this (color, drawBottomLine, true);
248:            }
249:
250:            /**
251:             * Constructs a TabLineBorder that draws lines on two, three or four sides of the
252:             * tab.
253:             *
254:             * @param drawBottomLine true if a line should be drawn on the side towards the
255:             *                       tabbed panel's content area, otherwise false
256:             * @param drawTopLine    true if a line should be drawn on the side opposite to
257:             *                       the tabbed panel's content area, otherwise false
258:             */
259:            public TabLineBorder(boolean drawBottomLine, boolean drawTopLine) {
260:                this ((Color) null, drawBottomLine, drawTopLine);
261:            }
262:
263:            /**
264:             * Constructs a TabLineBorder that draws lines on two, three or four sides of the
265:             * tab.
266:             *
267:             * @param color          the line color
268:             * @param drawBottomLine true if a line should be drawn on the side towards the
269:             *                       tabbed panel's content area, otherwise false
270:             * @param drawTopLine    true if a line should be drawn on the side opposite to
271:             *                       the tabbed panel's content area, otherwise false
272:             */
273:            public TabLineBorder(Color color, boolean drawBottomLine,
274:                    boolean drawTopLine) {
275:                this (ColorProviderUtil.getColorProvider(color,
276:                        UIManagerColorProvider.TABBED_PANE_DARK_SHADOW),
277:                        drawBottomLine, drawTopLine);
278:            }
279:
280:            /**
281:             * Constructs a TabLineBorder that draws lines on two, three or four sides of the
282:             * tab.
283:             *
284:             * @param colorProvider  the line color provider
285:             * @param drawBottomLine true if a line should be drawn on the side towards the
286:             *                       tabbed panel's content area, otherwise false
287:             * @param drawTopLine    true if a line should be drawn on the side opposite to
288:             *                       the tabbed panel's content area, otherwise false
289:             */
290:            public TabLineBorder(ColorProvider colorProvider,
291:                    boolean drawBottomLine, boolean drawTopLine) {
292:                this .color = colorProvider;
293:                border = new LineBorder();
294:                this .drawBottomLine = drawBottomLine;
295:                this .drawTopLine = drawTopLine;
296:            }
297:
298:            /**
299:             * Constructs a TabLineBorder that draws lines on three sides of the tab.
300:             * No line will be drawn on the side towards the tabbed panel's content area.
301:             * The inner border will be drawn inside of this TabLineBorder.
302:             *
303:             * @param color       the line color
304:             * @param innerBorder border to draw inside of this TabLineBorder
305:             */
306:            public TabLineBorder(Color color, Border innerBorder) {
307:                this (color, innerBorder, false);
308:            }
309:
310:            /**
311:             * Constructs a TabLineBorder that draws lines on three or four sides of the tab.
312:             * The inner border will be drawn inside of this TabLineBorder.
313:             *
314:             * @param color          the line color
315:             * @param innerBorder    border to draw inside of this TabLineBorder
316:             * @param drawBottomLine true if a line should be drawn on the side towards the
317:             *                       tabbed panel's content area, otherwise false
318:             */
319:            public TabLineBorder(Color color, Border innerBorder,
320:                    boolean drawBottomLine) {
321:                this (color, drawBottomLine);
322:                if (innerBorder != null)
323:                    border = new CompoundBorder(border, innerBorder);
324:            }
325:
326:            /**
327:             * Constructs a TabLineBorder that draws lines on three or four sides of the tab.
328:             * The inner border will be drawn inside of this TabLineBorder.
329:             *
330:             * @param colorProvider  the line color
331:             * @param innerBorder    border to draw inside of this TabLineBorder
332:             * @param drawBottomLine true if a line should be drawn on the side towards the
333:             *                       tabbed panel's content area, otherwise false
334:             * @param drawTopLine    true if a line should be drawn on the side opposite to
335:             *                       the tabbed panel's content area, otherwise false
336:             */
337:            public TabLineBorder(ColorProvider colorProvider,
338:                    Border innerBorder, boolean drawBottomLine,
339:                    boolean drawTopLine) {
340:                this (colorProvider, drawBottomLine, drawTopLine);
341:                if (innerBorder != null)
342:                    border = new CompoundBorder(border, innerBorder);
343:            }
344:
345:            public void paintBorder(Component c, Graphics g, int x, int y,
346:                    int width, int height) {
347:                border.paintBorder(c, g, x, y, width, height);
348:            }
349:
350:            public Insets getBorderInsets(Component c) {
351:                return border.getBorderInsets(c);
352:            }
353:
354:            public boolean isBorderOpaque() {
355:                return false;
356:            }
357:
358:            private void initialize(Tab tab) {
359:                index = tab.getTabbedPanel().getTabIndex(tab);
360:                last = index == tab.getTabbedPanel().getTabCount() - 1;
361:                afterHighlighted = index > 0
362:                        && tab.getTabbedPanel().getTabAt(index - 1) == tab
363:                                .getTabbedPanel().getHighlightedTab();
364:                highlighted = tab == tab.getTabbedPanel().getHighlightedTab();
365:            }
366:
367:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.