Source Code Cross Referenced for SlopedTabLineBorder.java in  » Swing-Library » InfoNode-Tabbed-Panel » net » infonode » tabbedpanel » internal » 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.internal 
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: SlopedTabLineBorder.java,v 1.3 2005/02/16 11:28:14 jesper Exp $
023:        package net.infonode.tabbedpanel.internal;
024:
025:        import net.infonode.gui.colorprovider.ColorProvider;
026:        import net.infonode.gui.colorprovider.UIManagerColorProvider;
027:        import net.infonode.gui.shaped.border.AbstractPolygonBorder;
028:
029:        import java.awt.*;
030:
031:        /**
032:         * @author johan
033:         * @since 1.2.0
034:         */
035:        public class SlopedTabLineBorder extends AbstractPolygonBorder {
036:            private static final long serialVersionUID = 1;
037:
038:            private static final int[][][] corners = {
039:                    { { 0, 0 }, { -1, 0, 0, -1 }, { -2, 0, -1, -1, 0, -1 },
040:                            { -4, 0, -3, -1, -2, -1, -1, -2, -1, -3, 0, -4 }, },
041:                    { { 0, 0 }, { 0, 0 }, { 0, 1, 1, 1, 2, 0 },
042:                            { 0, 4, 1, 3, 1, 2, 2, 1, 3, 1, 4, 0 }, },
043:                    { { 0, 0 }, { 0, 0 }, { -2, 0, -1, 1, 0, 1 },
044:                            { -4, 0, -3, 1, -2, 1, -1, 2, -1, 3, 0, 4 } },
045:                    { { 0, 0 }, { 0, -1, 1, 0 }, { 0, -1, 1, -1, 2, 0 },
046:                            { 0, -4, 1, -3, 1, -2, 2, -1, 3, -1, 4, 0 }, },
047:                    { { 0, 0 }, { 0, 0 }, { 0, 2, 1, 1, 1, 0 },
048:                            { 0, 4, 1, 3, 1, 2, 2, 1, 3, 1, 4, 0 }, },
049:                    { { 0, 0 }, { 0, 0 }, { -1, 0, -1, 1, 0, 2 },
050:                            { -4, 0, -3, 1, -2, 1, -1, 2, -1, 3, 0, 4 }, }, };
051:
052:            private boolean drawBottomLine;
053:            private float leftSlope;
054:            private float rightSlope;
055:            private boolean bottomLeftRounded;
056:            private boolean topLeftRounded;
057:            private boolean topRightRounded;
058:            private boolean bottomRightRounded;
059:            private int leftHeight;
060:            private int rightHeight;
061:
062:            private static int[] xCoords = new int[100];
063:            private static int[] yCoords = new int[100];
064:            private static int x;
065:            private static int y;
066:            private static int index;
067:
068:            public SlopedTabLineBorder() {
069:                this (0, 1);
070:            }
071:
072:            public SlopedTabLineBorder(float leftSlope, float rightSlope) {
073:                this (leftSlope, rightSlope, 22, 22);
074:            }
075:
076:            public SlopedTabLineBorder(float leftSlope, float rightSlope,
077:                    int leftHeight, int rightHeight) {
078:                this (leftSlope, rightSlope, leftHeight, rightHeight, false,
079:                        false, false, false);
080:            }
081:
082:            public SlopedTabLineBorder(float leftSlope, float rightSlope,
083:                    boolean bottomLeftRounded, boolean topLeftRounded,
084:                    boolean topRightRounded, boolean bottomRightRounded) {
085:                this (leftSlope, rightSlope, 22, 22, bottomLeftRounded,
086:                        topLeftRounded, topRightRounded, bottomRightRounded);
087:            }
088:
089:            public SlopedTabLineBorder(float leftSlope, float rightSlope,
090:                    int leftHeight, int rightHeight, boolean bottomLeftRounded,
091:                    boolean topLeftRounded, boolean topRightRounded,
092:                    boolean bottomRightRounded) {
093:                this (UIManagerColorProvider.TABBED_PANE_DARK_SHADOW,
094:                        UIManagerColorProvider.TABBED_PANE_HIGHLIGHT, false,
095:                        leftSlope, rightSlope, leftHeight, rightHeight,
096:                        bottomLeftRounded, topLeftRounded, topRightRounded,
097:                        bottomRightRounded);
098:            }
099:
100:            public SlopedTabLineBorder(ColorProvider lineColor,
101:                    ColorProvider highlightColor, boolean drawBottomLine,
102:                    float leftSlope, float rightSlope, int leftHeight,
103:                    int rightHeight, boolean bottomLeftRounded,
104:                    boolean topLeftRounded, boolean topRightRounded,
105:                    boolean bottomRightRounded) {
106:                super (lineColor, highlightColor);
107:                this .drawBottomLine = drawBottomLine;
108:                this .leftHeight = leftHeight;
109:                this .rightHeight = rightHeight;
110:                this .leftSlope = leftSlope;
111:                this .rightSlope = rightSlope;
112:                this .bottomLeftRounded = bottomLeftRounded;
113:                this .topLeftRounded = topLeftRounded;
114:                this .topRightRounded = topRightRounded;
115:                this .bottomRightRounded = bottomRightRounded;
116:            }
117:
118:            protected boolean lineIsDrawn(int index, Polygon polygon) {
119:                return drawBottomLine || index < polygon.npoints - 1;
120:            }
121:
122:            protected Insets getShapedBorderInsets(Component c) {
123:                return new Insets(1, (isBottomLeftRounded(c) ? 4 : 1)
124:                        + (topLeftRounded ? (leftSlope <= 0.5f ? 4 : 1) : 0)
125:                        + (int) (leftSlope * leftHeight), drawBottomLine ? 1
126:                        : 0, (bottomRightRounded ? 4 : 1)
127:                        + (topRightRounded ? (rightSlope <= 0.5f ? 4 : 1) : 0)
128:                        + (int) (rightSlope * rightHeight));
129:            }
130:
131:            protected boolean isBottomLeftRounded(Component c) {
132:                return bottomLeftRounded;
133:            }
134:
135:            private static int[] getCorner(int type, float slope,
136:                    boolean rounded) {
137:                return corners[type][!rounded ? 0 : type < 4 ? (slope >= 2f ? 1
138:                        : slope >= 1f ? 2 : 3) : (slope <= 0.5f ? 1
139:                        : slope <= 1f ? 2 : 3)];
140:            }
141:
142:            private static void addPoint(int px, int py) {
143:                xCoords[index] = px;
144:                yCoords[index++] = py;
145:                x = px;
146:                y = py;
147:            }
148:
149:            private static void addCorner(int px, int py, int[] c) {
150:                for (int i = 0; i < c.length; i++) {
151:                    addPoint(px + c[i++], py + c[i]);
152:                }
153:            }
154:
155:            private static int getStartY(int[] corner) {
156:                return corner[1];
157:            }
158:
159:            private static int getEndY(int[] corner) {
160:                return corner[corner.length - 1];
161:            }
162:
163:            protected Polygon createPolygon(Component c, int width, int height) {
164:                boolean bottomLeftRounded = isBottomLeftRounded(c);
165:                int leftX = (int) (leftHeight * leftSlope + (bottomLeftRounded ? 4
166:                        : 0));
167:                int rightX = width
168:                        - 1
169:                        - (int) (rightHeight * rightSlope + (bottomRightRounded ? 4
170:                                : 0));
171:                int bottomY = height - (drawBottomLine ? 1 : 0);
172:
173:                int[] topLeft = getCorner(1, leftSlope, topLeftRounded);
174:                int[] topRight = getCorner(2, rightSlope, topRightRounded);
175:                int[] bottomLeft = getCorner(0, leftSlope, bottomLeftRounded);
176:                int[] bottomRight = getCorner(3, rightSlope, bottomRightRounded);
177:
178:                index = 0;
179:                y = bottomY;
180:                int dy = height - getStartY(topLeft) + getEndY(bottomLeft);
181:
182:                if (dy <= leftHeight) {
183:                    x = leftX - (int) (dy * leftSlope);
184:                    addCorner(x, y, bottomLeft);
185:                } else {
186:                    x = leftX - (int) (leftHeight * leftSlope);
187:                    addCorner(x, y, getCorner(0, 0, bottomLeftRounded));
188:                    addPoint(x, getStartY(topLeft) + leftHeight);
189:                }
190:
191:                addCorner(leftX, 0, topLeft);
192:                addCorner(rightX, 0, topRight);
193:                dy = height - getEndY(topRight) + getStartY(bottomRight);
194:
195:                if (dy <= rightHeight) {
196:                    addCorner((int) (rightX + dy * rightSlope), bottomY,
197:                            bottomRight);
198:                } else {
199:                    addPoint((int) (rightX + rightSlope * rightHeight),
200:                            getEndY(topRight) + rightHeight);
201:                    addCorner(x, bottomY, getCorner(3, 0, bottomRightRounded));
202:                }
203:
204:                return new Polygon(xCoords, yCoords, index);
205:            }
206:
207:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.