Source Code Cross Referenced for HTMLTabbedPaneUI.java in  » Swing-Library » Swinglets » com » javelin » swinglets » plaf » html » 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 » Swinglets » com.javelin.swinglets.plaf.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright Javelin Software, All rights reserved.
003:         */
004:
005:        package com.javelin.swinglets.plaf.html;
006:
007:        import java.awt.*;
008:        import java.util.*;
009:        import java.io.*;
010:
011:        import com.javelin.swinglets.*;
012:        import com.javelin.swinglets.tabbed.*;
013:        import com.javelin.swinglets.plaf.*;
014:        import com.javelin.swinglets.theme.*;
015:
016:        /**
017:         * HTMLTabbedPaneUI defines a look and feel for default HTML. 
018:         * 
019:         * @author Robin Sharp
020:         */
021:
022:        public class HTMLTabbedPaneUI extends HTMLContainerUI {
023:            /**
024:             * Render the UI on the Output
025:             */
026:            public void updateHeader(PrintWriter out, SComponent c) {
027:                if (!c.isVisible())
028:                    return;
029:
030:                STabbedPane tabbedPane = (STabbedPane) c;
031:                tabbedPane.getSelectedComponent().paintHeader(out);
032:            }
033:
034:            /**
035:             * Render the UI on the PrintWriter
036:             */
037:            public void update(PrintWriter out, SComponent c) {
038:                if (!c.isVisible())
039:                    return;
040:
041:                out
042:                        .print("<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0 WIDTH=100% >");
043:
044:                STabbedPane tabbedPane = (STabbedPane) c;
045:
046:                if (tabbedPane.getTabPlacement() == SConstants.LEFT) {
047:                    out.print("<TR><TD VALIGN=TOP WIDTH=1>");
048:                    paintTabs(out, tabbedPane);
049:                    out.print("</TD><TD VALIGN=TOP WIDTH=100%>");
050:                    tabbedPane.getSelectedComponent().paint(out);
051:                    out.print("</TD></TR>");
052:                } else if (tabbedPane.getTabPlacement() == SConstants.RIGHT) {
053:                    out.print("<TR><TD VALIGN=TOP WIDTH=100%>");
054:                    tabbedPane.getSelectedComponent().paint(out);
055:                    out.print("</TD><TD VALIGN=TOP WIDTH=1>");
056:                    paintTabs(out, tabbedPane);
057:                    out.print("</TD></TR>");
058:                } else if (tabbedPane.getTabPlacement() == SConstants.TOP) {
059:                    out.print("<TR><TD ALIGN=LEFT>");
060:                    paintTabs(out, tabbedPane);
061:                    out.print("</TD></TR><TR><TD ALIGN=LEFT>");
062:                    tabbedPane.getSelectedComponent().paint(out);
063:                    out.print("</TD></TR>");
064:                } else if (tabbedPane.getTabPlacement() == SConstants.BOTTOM) {
065:                    out.print("<TR><TD ALIGN=LEFT>");
066:                    tabbedPane.getSelectedComponent().paint(out);
067:                    out.print("</TD></TR><TR><TD ALIGN=LEFT>");
068:                    paintTabs(out, tabbedPane);
069:                    out.print("</TD></TR>");
070:                }
071:
072:                out.print("</TABLE>");
073:
074:            }
075:
076:            /**
077:             * Paint the tabs 
078:             */
079:            public void paintTabs(PrintWriter out, STabbedPane tabbedPane) {
080:                if (!tabbedPane.isVisible())
081:                    return;
082:
083:                //TABS IN TABLE
084:                if (tabbedPane.getTabPlacement() == SConstants.TOP
085:                        || tabbedPane.getTabPlacement() == SConstants.BOTTOM) {
086:                    out.print("<TABLE BORDER=");
087:                    if (tabbedPane.isBorderPainted()) {
088:                        out.print("1");
089:                    } else {
090:                        out.print("0");
091:                    }
092:
093:                    out.print(" CELLSPACING=0 CELLPADDING=0");
094:
095:                } else {
096:                    out.print("<TABLE BORDER=");
097:                    if (tabbedPane.isBorderPainted()) {
098:                        out.print("1");
099:                    } else {
100:                        out.print("0");
101:                    }
102:
103:                    out.print(" CELLSPACING=0 CELLPADDING=0");
104:
105:                }
106:
107:                if (tabbedPane.getTabPlacement() == SConstants.TOP
108:                        || tabbedPane.getTabPlacement() == SConstants.BOTTOM) {
109:                    if (tabbedPane.getSize() == null
110:                            || tabbedPane.getSize().width == 0) {
111:                        //AUTO
112:                    } else if (tabbedPane.getSize().width > 0) {
113:                        out.print(" WIDTH=\"");
114:                        out.print(tabbedPane.getSize().width);
115:                        out.print("\"");
116:                    } else if (tabbedPane.getSize().width < 0) {
117:                        out.print(" WIDTH=\"");
118:                        out.print((0 - tabbedPane.getSize().width));
119:                        out.print("%\"");
120:                    }
121:                }
122:
123:                if (tabbedPane.getTabPlacement() == SConstants.LEFT
124:                        || tabbedPane.getTabPlacement() == SConstants.RIGHT) {
125:                    if (tabbedPane.getSize() == null
126:                            || tabbedPane.getSize().width == 0) {
127:                        //AUTO
128:                    } else if (tabbedPane.getSize().height > 0) {
129:                        out.print(" HEIGHT=\"");
130:                        out.print(tabbedPane.getSize().height);
131:                        out.print("\"");
132:                    } else if (tabbedPane.getSize().height < 0) {
133:                        out.print(" HEIGHT=\"");
134:                        out.print((0 - tabbedPane.getSize().height));
135:                        out.print("%\"");
136:                    }
137:
138:                }
139:
140:                out.println(" >");
141:
142:                out.println("<TR>");
143:
144:                STabbedCellRenderer tabbedCellRenderer = tabbedPane
145:                        .getTabbedCellRenderer();
146:                SComponent component = null;
147:                STheme theme = getTheme();
148:
149:                //Paint each tab
150:                for (int index = 0; index < tabbedPane.getTabCount(); index++) {
151:                    component = tabbedCellRenderer
152:                            .getTabbedCellRendererComponent(tabbedPane, index,
153:                                    getLink(tabbedPane, index));
154:
155:                    if (component == null)
156:                        continue;
157:
158:                    component.setLookAndFeel(tabbedPane.getLookAndFeel());
159:
160:                    //Need to sniff browser profile - Netscape is POO
161:                    if (tabbedPane.getSwingletManager().getBrowserProfile().isNS) {
162:                        //works with NS
163:                        out.print("<TD WIDTH=1 NOWRAP");
164:                    } else {
165:                        //works with IE
166:                        out.print("<TD WIDTH=1% NOWRAP");
167:                    }
168:
169:                    //Paint the background color
170:                    if (!component.isOpaque()) {
171:                    } else if (component.getBackground() != null) {
172:                        out.print(" BGCOLOR=\"#");
173:                        out
174:                                .print(SColor.toHexString(component
175:                                        .getBackground()));
176:                        out.print("\"");
177:                    } else if (tabbedPane.getBackgroundAt(index) != null) {
178:                        out.print(" BGCOLOR=\"#");
179:                        if (index == tabbedPane.getSelectedIndex()) {
180:                            out.print(SColor.toInverseHexString(tabbedPane
181:                                    .getBackgroundAt(index)));
182:                        } else {
183:                            out.print(SColor.toHexString(tabbedPane
184:                                    .getBackgroundAt(index)));
185:                        }
186:                        out.print("\"");
187:                    } else if (tabbedPane.getBackground() != null) {
188:                        out.print(" BGCOLOR=\"#");
189:                        if (index == tabbedPane.getSelectedIndex()) {
190:                            out.print(SColor.toInverseHexString(tabbedPane
191:                                    .getBackground()));
192:                        } else {
193:                            out.print(SColor.toHexString(tabbedPane
194:                                    .getBackground()));
195:                        }
196:                        out.print("\"");
197:                    } else {
198:                        out.print(" BGCOLOR=\"#");
199:                        if (index == tabbedPane.getSelectedIndex()) {
200:                            out.print(SColor.toHexString(theme
201:                                    .getMenuSelectedBackground()));
202:                        } else {
203:                            out.print(SColor.toHexString(theme
204:                                    .getMenuBackground()));
205:                        }
206:                        out.print("\"");
207:                    }
208:                    out.print(" >");
209:
210:                    if (component != null) {
211:                        //Paint the foreground color
212:                        if (component.getForeground() != null) {
213:                        } else if (tabbedPane.getForegroundAt(index) != null) {
214:                            if (index == tabbedPane.getSelectedIndex()) {
215:                                component.setForeground(SColor
216:                                        .toInverse(tabbedPane
217:                                                .getForegroundAt(index)));
218:                            } else {
219:                                component.setForeground(tabbedPane
220:                                        .getForegroundAt(index));
221:                            }
222:                        } else if (tabbedPane.getForeground() != null) {
223:                            if (index == tabbedPane.getSelectedIndex()) {
224:                                component.setForeground(SColor
225:                                        .toInverse(tabbedPane.getForeground()));
226:                            } else {
227:                                component.setForeground(tabbedPane
228:                                        .getForeground());
229:                            }
230:                        } else {
231:                            if (index == tabbedPane.getSelectedIndex()) {
232:                                component.setForeground(theme
233:                                        .getMenuSelectedForeground());
234:                            } else {
235:                                component.setForeground(theme
236:                                        .getMenuForeground());
237:                            }
238:                        }
239:
240:                        component.setEnabled(tabbedPane.isEnabledAt(index));
241:                        component.paint(out);
242:                        component.setForeground(null);
243:                    } else {
244:                        out.print(tabbedPane.getTitleAt(index));
245:                    }
246:
247:                    out.print("</TD>");
248:
249:                    if (tabbedPane.getTabPlacement() == SConstants.LEFT
250:                            || tabbedPane.getTabPlacement() == SConstants.RIGHT) {
251:                        out.println("</TR>");
252:                        out.print("<TR>");
253:                    }
254:
255:                }
256:
257:                //NEED TO ADD NEW COLUMN FOR SPACING
258:                if (tabbedPane.getTabPlacement() == SConstants.TOP
259:                        || tabbedPane.getTabPlacement() == SConstants.BOTTOM) {
260:                    //Print padding cell for % widths
261:                    if (tabbedPane.getSize() != null
262:                            && tabbedPane.getSize().width != 0) {
263:                        out.print("<TD WIDTH=100%");
264:
265:                        //Paint the background color
266:                        if (!component.isOpaque()) {
267:                        } else if (component.getBackground() != null) {
268:                            out.print(" BGCOLOR=\"#");
269:                            out.print(SColor.toHexString(component
270:                                    .getBackground()));
271:                            out.print("\"");
272:                        } else if (tabbedPane.getBackground() != null) {
273:                            out.print(" BGCOLOR=\"#");
274:                            out.print(SColor.toHexString(tabbedPane
275:                                    .getBackground()));
276:                            out.print("\"");
277:                        } else {
278:                            out.print(" BGCOLOR=\"#");
279:                            out.print(SColor.toHexString(theme
280:                                    .getMenuBackground()));
281:                            out.print("\"");
282:                        }
283:
284:                        out.println(">&nbsp;</TD>");
285:                    }
286:                }
287:
288:                out.println("</TR>");
289:
290:                //NEED TO ADD NEW ROW FOR SPACING
291:                if (tabbedPane.getTabPlacement() == SConstants.LEFT
292:                        || tabbedPane.getTabPlacement() == SConstants.RIGHT) {
293:                    //Print padding cell for % widths
294:                    if (tabbedPane.getSize() != null
295:                            && tabbedPane.getSize().height != 0) {
296:                        out.print("<TR><TD HEIGHT=100%");
297:
298:                        //Paint the background color
299:                        if (!component.isOpaque()) {
300:                        } else if (component.getBackground() != null) {
301:                            out.print(" BGCOLOR=\"#");
302:                            out.print(SColor.toHexString(component
303:                                    .getBackground()));
304:                            out.print("\"");
305:                        } else if (tabbedPane.getBackground() != null) {
306:                            out.print(" BGCOLOR=\"#");
307:                            out.print(SColor.toHexString(tabbedPane
308:                                    .getBackground()));
309:                            out.print("\"");
310:                        } else {
311:                            out.print(" BGCOLOR=\"#");
312:                            out.print(SColor.toHexString(theme
313:                                    .getMenuBackground()));
314:                            out.print("\"");
315:                        }
316:
317:                        out.println(" >&nbsp;</TD></TR>");
318:                    }
319:                }
320:
321:                out.print("</TABLE>");
322:            }
323:
324:            /**
325:             * Get the link for this cell. This caches the link string.
326:             * This can be made more efficient, so that it is done once.
327:             */
328:            protected SLink getLink(STabbedPane tabbedPane, int index) {
329:                if (vector.size() > index) {
330:                    return (SLink) vector.elementAt(index);
331:                }
332:
333:                //Create the link if the tabbed item is enabled
334:                //Make this more efficient **
335:                SLink link = new SLink();
336:
337:                if (linkBuffer == null) {
338:                    linkBuffer = new StringBuffer(tabbedPane.getComponentUrl());
339:                    linkLength = linkBuffer.length();
340:                }
341:
342:                //Remove the old column from the end of the buffer
343:                linkBuffer.setLength(linkLength);
344:
345:                //INDEX SPECIFIC - this is mostly what varies
346:                linkBuffer.append("&");
347:                linkBuffer.append(index);
348:                linkBuffer.append("=");
349:                linkBuffer.append(tabbedPane.getTitleAt(index));
350:
351:                link.setUrl(linkBuffer.toString());
352:
353:                vector.addElement(link);
354:
355:                return link;
356:            }
357:
358:            //Hash of links based on index
359:            protected Vector vector = new Vector();
360:
361:            protected StringBuffer linkBuffer;
362:            protected int linkLength;
363:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.