Source Code Cross Referenced for ClassicTheme.java in  » Swing-Library » InfoNode-Docking-Windows » net » infonode » tabbedpanel » theme » 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 Docking Windows » net.infonode.tabbedpanel.theme 
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: ClassicTheme.java,v 1.14 2005/12/04 13:46:05 jesper Exp $
023:        package net.infonode.tabbedpanel.theme;
024:
025:        import net.infonode.gui.GraphicsUtil;
026:        import net.infonode.gui.colorprovider.ColorProvider;
027:        import net.infonode.gui.colorprovider.UIManagerColorProvider;
028:        import net.infonode.tabbedpanel.TabbedPanel;
029:        import net.infonode.tabbedpanel.TabbedPanelProperties;
030:        import net.infonode.tabbedpanel.TabbedUIDefaults;
031:        import net.infonode.tabbedpanel.TabbedUtils;
032:        import net.infonode.tabbedpanel.border.OpenContentBorder;
033:        import net.infonode.tabbedpanel.internal.TwoColoredLineBorder;
034:        import net.infonode.tabbedpanel.titledtab.TitledTabBorderSizePolicy;
035:        import net.infonode.tabbedpanel.titledtab.TitledTabProperties;
036:        import net.infonode.util.Direction;
037:
038:        import javax.swing.border.Border;
039:        import javax.swing.border.CompoundBorder;
040:        import java.awt.*;
041:
042:        /**
043:         * A theme with a "classic" look and with round edges for the titled tabs.
044:         *
045:         * @author $Author: jesper $
046:         * @version $Revision: 1.14 $
047:         * @since ITP 1.2.0
048:         */
049:        public class ClassicTheme extends TabbedPanelTitledTabTheme {
050:            private TabbedPanelProperties tabbedPanelProperties = new TabbedPanelProperties();
051:            private TitledTabProperties titledTabProperties = new TitledTabProperties();
052:            private ColorProvider highlightColor = UIManagerColorProvider.TABBED_PANE_HIGHLIGHT;
053:            private ColorProvider shadowColor = UIManagerColorProvider.TABBED_PANE_SHADOW;
054:            private ColorProvider darkShadow = UIManagerColorProvider.TABBED_PANE_DARK_SHADOW;
055:            private int raised;
056:
057:            private Border shadowBorder;
058:
059:            /**
060:             * Constructs a default Classic Theme
061:             */
062:            public ClassicTheme() {
063:                this (2);
064:            }
065:
066:            /**
067:             * Constructs a Classic Theme
068:             *
069:             * @param raised number of pixels for the highlight raised effect
070:             */
071:            public ClassicTheme(final int raised) {
072:                this .raised = raised;
073:
074:                shadowBorder = new Border() {
075:                    public boolean isBorderOpaque() {
076:                        return false;
077:                    }
078:
079:                    public void paintBorder(Component c, Graphics g, int x,
080:                            int y, int width, int height) {
081:                        TabbedPanel tp = TabbedUtils.getParentTabbedPanel(c);
082:                        if (tp != null) {
083:                            Direction d = tp.getProperties()
084:                                    .getTabAreaOrientation();
085:                            g.setColor(shadowColor.getColor());
086:
087:                            if (d == Direction.UP || d == Direction.DOWN)
088:                                GraphicsUtil.drawOptimizedLine(g,
089:                                        x + width - 1, y, x + width - 1, y
090:                                                + height - 1);
091:                            else
092:                                GraphicsUtil.drawOptimizedLine(g, x, y + height
093:                                        - 1, x + width - 1, y + height - 1);
094:                        }
095:                    }
096:
097:                    public Insets getBorderInsets(Component c) {
098:                        TabbedPanel tp = TabbedUtils.getParentTabbedPanel(c);
099:                        if (tp != null) {
100:                            Direction d = tp.getProperties()
101:                                    .getTabAreaOrientation();
102:                            return new Insets(
103:                                    0,
104:                                    0,
105:                                    (d == Direction.LEFT || d == Direction.RIGHT) ? 1
106:                                            : 0,
107:                                    (d == Direction.UP || d == Direction.DOWN) ? 1
108:                                            : 0);
109:                        }
110:                        return new Insets(0, 0, 0, 0);
111:                    }
112:                };
113:
114:                Border contentBorder = contentBorder = new CompoundBorder(
115:                        new OpenContentBorder(highlightColor, darkShadow, null,
116:                                1), new OpenContentBorder(null, shadowColor,
117:                                null, 1));
118:                tabbedPanelProperties.getContentPanelProperties()
119:                        .getComponentProperties().setBorder(contentBorder)
120:                        .setInsets(new Insets(1, 1, 1, 1));
121:
122:                tabbedPanelProperties.setTabSpacing(-raised - 1)
123:                        .setShadowEnabled(false);
124:
125:                tabbedPanelProperties.getTabAreaComponentsProperties()
126:                        .getComponentProperties().setBorder(
127:                                doCreateTabBorder(false, false, true, true));
128:
129:                Border normalBorder = createInsetsTabBorder(true, true, false);
130:                Border highlightBorder = doCreateTabBorder(true, true, true,
131:                        false);
132:                Insets normalInsets = new Insets(0, 3, 0, 3);
133:                Insets highlightInsets = new Insets(0,
134:                        (raised + 1) / 2 + (((raised + 1) & 1) == 1 ? 1 : 0)
135:                                + normalInsets.left, 1, (raised + 1) / 2
136:                                + normalInsets.right);
137:
138:                titledTabProperties.setHighlightedRaised(raised)
139:                        .setBorderSizePolicy(
140:                                TitledTabBorderSizePolicy.INDIVIDUAL_SIZE);
141:                titledTabProperties.getNormalProperties()
142:                        .getComponentProperties().setBorder(normalBorder)
143:                        .setInsets(normalInsets);
144:                titledTabProperties.getHighlightedProperties()
145:                        .getComponentProperties().setBorder(highlightBorder)
146:                        .setInsets(highlightInsets);
147:            }
148:
149:            /**
150:             * Gets the name for this theme
151:             *
152:             * @return the name
153:             */
154:            public String getName() {
155:                return "Classic Theme";
156:            }
157:
158:            /**
159:             * Gets the TabbedPanelProperties for this theme
160:             *
161:             * @return the TabbedPanelProperties
162:             */
163:            public TabbedPanelProperties getTabbedPanelProperties() {
164:                return tabbedPanelProperties;
165:            }
166:
167:            /**
168:             * Gets the TitledTabProperties for this theme
169:             *
170:             * @return the TitledTabProperties
171:             */
172:            public TitledTabProperties getTitledTabProperties() {
173:                return titledTabProperties;
174:            }
175:
176:            /**
177:             * Creates a tab border with extra insets border
178:             *
179:             * @param roundEdges true for round edges
180:             * @param open       true for open
181:             * @param highlight  true for highlight
182:             * @return the created border
183:             */
184:            public Border createInsetsTabBorder(boolean roundEdges,
185:                    boolean open, boolean highlight) {
186:                Border insetsBorder = new Border() {
187:                    public boolean isBorderOpaque() {
188:                        return false;
189:                    }
190:
191:                    public void paintBorder(Component c, Graphics g, int x,
192:                            int y, int width, int height) {
193:                    }
194:
195:                    public Insets getBorderInsets(Component c) {
196:                        TabbedPanel tp = TabbedUtils.getParentTabbedPanel(c);
197:                        if (tp != null) {
198:                            Direction d = tp.getProperties()
199:                                    .getTabAreaOrientation();
200:                            return new Insets(
201:                                    d == Direction.RIGHT || d == Direction.LEFT ? raised
202:                                            : 0,
203:                                    d == Direction.UP || d == Direction.DOWN ? raised
204:                                            : 0,
205:                                    d == Direction.RIGHT || d == Direction.LEFT ? 1
206:                                            : 0,
207:                                    d == Direction.UP || d == Direction.DOWN ? 1
208:                                            : 0);
209:                        }
210:                        return new Insets(0, 0, 0, 0);
211:                    }
212:                };
213:                return new CompoundBorder(insetsBorder, doCreateTabBorder(
214:                        roundEdges, open, highlight, true));
215:            }
216:
217:            /**
218:             * Creates a tab border without extra insets border
219:             *
220:             * @param roundEdges true for round edges
221:             * @param open       true for open
222:             * @param highlight  true for highlight
223:             * @return the created border
224:             */
225:            public Border createTabBorder(boolean roundEdges, boolean open,
226:                    boolean highlight) {
227:                return doCreateTabBorder(roundEdges, open, true, highlight);
228:            }
229:
230:            private ColorProvider createNormalHighlightColorProvider() {
231:                return new ColorProvider() {
232:                    public Color getColor() {
233:                        Color highlightBackground = TabbedUIDefaults
234:                                .getHighlightedStateBackground();
235:                        highlightBackground = new Color(highlightBackground
236:                                .getRed() == 0 ? 1 : highlightBackground
237:                                .getRed(),
238:                                highlightBackground.getGreen() == 0 ? 1
239:                                        : highlightBackground.getGreen(),
240:                                highlightBackground.getBlue() == 0 ? 1
241:                                        : highlightBackground.getBlue());
242:
243:                        Color normalBackgroundColor = TabbedUIDefaults
244:                                .getNormalStateBackground();
245:
246:                        Color color = highlightColor.getColor();
247:
248:                        int r = (int) (normalBackgroundColor.getRed() * ((float) (color
249:                                .getRed()) / (float) (highlightBackground
250:                                .getRed())));
251:                        int g = (int) (normalBackgroundColor.getGreen() * ((float) (color
252:                                .getGreen()) / (float) (highlightBackground
253:                                .getGreen())));
254:                        int b = (int) (normalBackgroundColor.getBlue() * ((float) (color
255:                                .getBlue()) / (float) (highlightBackground
256:                                .getBlue())));
257:
258:                        r = (r + color.getRed()) / 2;
259:                        g = (g + color.getGreen()) / 2;
260:                        b = (b + color.getBlue()) / 2;
261:
262:                        return new Color(r > 255 ? 255 : r, g > 255 ? 255 : g,
263:                                b > 255 ? 255 : b);
264:                    }
265:
266:                    public Color getColor(Component component) {
267:                        return getColor();
268:                    }
269:                };
270:            }
271:
272:            private Border doCreateTabBorder(boolean roundEdges, boolean open,
273:                    boolean highlight, final boolean equalInset) {
274:                return new CompoundBorder(new TwoColoredLineBorder(
275:                        highlight ? highlightColor
276:                                : createNormalHighlightColorProvider(),
277:                        darkShadow, roundEdges, open) {
278:                    protected Insets getShapedBorderInsets(Component c) {
279:                        return equalInset ? new Insets(1, 1, 1, 1) : super
280:                                .getShapedBorderInsets(c);
281:                    }
282:                }, shadowBorder);
283:            }
284:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.