Source Code Cross Referenced for SubstanceEditorTabDisplayerUI.java in  » Swing-Library » substance-look-feel » org » jvnet » substance » netbeans » 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 » substance look feel » org.jvnet.substance.netbeans 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jvnet.substance.netbeans;
002:
003:        import java.awt.*;
004:        import java.awt.event.*;
005:        import javax.swing.*;
006:        import javax.swing.border.EmptyBorder;
007:        import javax.swing.plaf.ComponentUI;
008:        import org.jvnet.lafwidget.utils.RenderingUtils;
009:        import org.jvnet.substance.*;
010:        import org.jvnet.substance.theme.SubstanceTheme;
011:        import org.jvnet.substance.utils.MemoryAnalyzer;
012:        import org.netbeans.swing.tabcontrol.TabDisplayer;
013:        import org.netbeans.swing.tabcontrol.plaf.*;
014:
015:        /**
016:         * UI delegate for tab displayer. This class is based on code from
017:         * <code>org.netbeans.swing.tabcontrol.plaf.MetalEditorTabDisplayerUI</code>
018:         * from NetBeans source base.
019:         *
020:         * @author Kirill Grouchnikov
021:         */
022:        public class SubstanceEditorTabDisplayerUI extends
023:                BasicScrollingTabDisplayerUI {
024:
025:            private Rectangle scratch = new Rectangle();
026:
027:            /**
028:             * Simple constructor.
029:             */
030:            public SubstanceEditorTabDisplayerUI(TabDisplayer displayer) {
031:                super (displayer);
032:                if (MemoryAnalyzer.isRunning()) {
033:                    MemoryAnalyzer
034:                            .enqueueUsage("SubstanceEditorTabDisplayerUI initialized");
035:                }
036:            }
037:
038:            /* (non-Javadoc)
039:             * @see org.netbeans.swing.tabcontrol.plaf.BasicTabDisplayerUI#createDefaultRenderer()
040:             */
041:            protected TabCellRenderer createDefaultRenderer() {
042:                return new SubstanceTabCellRenderer();
043:            }
044:
045:            /* (non-Javadoc)
046:             * @see javax.swing.plaf.ComponentUI#createUI(javax.swing.JComponent)
047:             */
048:            public static ComponentUI createUI(JComponent c) {
049:                return new SubstanceEditorTabDisplayerUI((TabDisplayer) c);
050:            }
051:
052:            @Override
053:            protected Font createFont() {
054:                return SubstanceLookAndFeel.getFontPolicy().getFontSet(
055:                        "Substance", null).getControlFont();
056:            }
057:
058:            /* (non-Javadoc)
059:             * @see javax.swing.plaf.ComponentUI#getMinimumSize(javax.swing.JComponent)
060:             */
061:            public Dimension getMinimumSize(JComponent c) {
062:                return new Dimension(80, 28);
063:            }
064:
065:            /* (non-Javadoc)
066:             * @see javax.swing.plaf.ComponentUI#getPreferredSize(javax.swing.JComponent)
067:             */
068:            public Dimension getPreferredSize(JComponent c) {
069:                int prefHeight = 28;
070:                Graphics g = BasicScrollingTabDisplayerUI
071:                        .getOffscreenGraphics();
072:                if (g != null) {
073:                    FontMetrics fm = g.getFontMetrics(displayer.getFont());
074:                    Insets ins = getTabAreaInsets();
075:                    prefHeight = fm.getHeight() + ins.top + ins.bottom + 6;
076:                }
077:                return new Dimension(displayer.getWidth(), prefHeight);
078:            }
079:
080:            /* (non-Javadoc)
081:             * @see org.netbeans.swing.tabcontrol.plaf.BasicTabDisplayerUI#createRepaintPolicy()
082:             */
083:            protected int createRepaintPolicy() {
084:                return TabState.REPAINT_ALL_TABS_ON_ACTIVATION_CHANGE
085:                        | TabState.REPAINT_ALL_TABS_ON_SELECTION_CHANGE
086:                        | TabState.REPAINT_ON_MOUSE_ENTER_CLOSE_BUTTON;
087:            }
088:
089:            /* (non-Javadoc)
090:             * @see org.netbeans.swing.tabcontrol.plaf.BasicTabDisplayerUI#getTabAreaInsets()
091:             */
092:            public Insets getTabAreaInsets() {
093:                return new Insets(0, 0, 2, 70);
094:            }
095:
096:            @Override
097:            public void update(Graphics graphics, JComponent jComponent) {
098:                Graphics2D g2 = (Graphics2D) graphics.create();
099:                RenderingUtils.installDesktopHints(g2);
100:                //        displayer.setFont(SubstanceLookAndFeel.getFontPolicy().
101:                //                getFontSet("Substance", null).getControlFont());
102:                super .update(g2, jComponent);
103:                g2.dispose();
104:            }
105:
106:            /* (non-Javadoc)
107:             * @see org.netbeans.swing.tabcontrol.plaf.AbstractTabDisplayerUI#install()
108:             */
109:            public void install() {
110:                super .install();
111:                displayer.setBackground(UIManager.getColor("control")); // NOI18N
112:                displayer.setFont(SubstanceLookAndFeel.getFontPolicy()
113:                        .getFontSet("Substance", null).getControlFont());
114:            }
115:
116:            protected void paintAfterTabs(Graphics g) {
117:                Rectangle r = new Rectangle();
118:                getTabsVisibleArea(r);
119:                r.width = displayer.getWidth();
120:                g.setColor(SubstanceLookAndFeel.getDefaultColorScheme()
121:                        .getMidColor());
122:                g.drawLine(0, displayer.getHeight() - 1, displayer.getWidth(),
123:                        displayer.getHeight() - 1);
124:            }
125:
126:            /* (non-Javadoc)
127:             * @see org.netbeans.swing.tabcontrol.plaf.BasicScrollingTabDisplayerUI#createLayout()
128:             */
129:            protected LayoutManager createLayout() {
130:                return new SubstanceTabLayout();
131:            }
132:
133:            public Rectangle getTabRect(int idx, Rectangle rect) {
134:                Rectangle retValue;
135:
136:                retValue = super .getTabRect(idx, rect);
137:                //                if (selectionModel.getSelectedIndex() == idx) {
138:                //                    retValue.height+=4;
139:                //                    retValue.y -= 2;
140:                //                }
141:                retValue.width += 4;
142:                return retValue;
143:            }
144:
145:            @Override
146:            protected Component getControlButtons() {
147:                Component result = super .getControlButtons();
148:                //   this.configureButtons(result);
149:                return result;
150:            }
151:
152:            private void configureButtons(Component comp) {
153:                if (comp instanceof  JButton) {
154:                    configureControlButton((JButton) comp);
155:                }
156:                if (comp instanceof  Container) {
157:                    Container cont = (Container) comp;
158:                    for (int i = 0; i < cont.getComponentCount(); i++) {
159:                        configureButtons(cont.getComponent(i));
160:                    }
161:                }
162:            }
163:
164:            private void configureControlButton(JButton button) {
165:                button.setContentAreaFilled(true);
166:                //        button.putClientProperty(SubstanceLookAndFeel.FLAT_PROPERTY,
167:                //                Boolean.TRUE);
168:                button.setBorderPainted(true);
169:                button.setBorder(new EmptyBorder(0, 0, 0, 0));
170:            }
171:
172:            @Override
173:            public Icon getButtonIcon(int buttonId, int buttonState) {
174:                SubstanceTheme theme = SubstanceLookAndFeel.getTheme();
175:                Icon result = SubstanceNetbeansImageCreator.getTabIcon(theme,
176:                        buttonId);
177:                if (result == null) {
178:                    return super .getButtonIcon(buttonId, buttonState);
179:                }
180:                return result;
181:            }
182:
183:            /**
184:             * Layout manager for the tab component.
185:             *
186:             * @author Kirill Grouchnikov
187:             */
188:            private class SubstanceTabLayout implements  LayoutManager {
189:
190:                /* (non-Javadoc)
191:                 * @see java.awt.LayoutManager#addLayoutComponent(java.lang.String, java.awt.Component)
192:                 */
193:                public void addLayoutComponent(String name,
194:                        java.awt.Component comp) {
195:                }
196:
197:                /* (non-Javadoc)
198:                 * @see java.awt.LayoutManager#layoutContainer(java.awt.Container)
199:                 */
200:                public void layoutContainer(java.awt.Container parent) {
201:                    Insets in = getTabAreaInsets();
202:                    Component[] c = parent.getComponents();
203:                    int x = parent.getWidth() - in.right + 3;
204:                    int y = 0;
205:                    Dimension psize;
206:                    for (int i = 0; i < c.length; i++) {
207:                        psize = c[i].getPreferredSize();
208:                        y = in.top + 3; // hardcoded to spec
209:                        int w = Math.min(psize.width, parent.getWidth() - x);
210:                        c[i].setBounds(x, y, w, Math.min(psize.height, parent
211:                                .getHeight()));
212:                        x += psize.width;
213:                        if (i == 1) {
214:                            x += 3;
215:                        }
216:                    }
217:                }
218:
219:                /* (non-Javadoc)
220:                 * @see java.awt.LayoutManager#minimumLayoutSize(java.awt.Container)
221:                 */
222:                public Dimension minimumLayoutSize(java.awt.Container parent) {
223:                    return getPreferredSize((JComponent) parent);
224:                }
225:
226:                /* (non-Javadoc)
227:                 * @see java.awt.LayoutManager#preferredLayoutSize(java.awt.Container)
228:                 */
229:                public Dimension preferredLayoutSize(java.awt.Container parent) {
230:                    return getPreferredSize((JComponent) parent);
231:                }
232:
233:                /* (non-Javadoc)
234:                 * @see java.awt.LayoutManager#removeLayoutComponent(java.awt.Component)
235:                 */
236:                public void removeLayoutComponent(java.awt.Component comp) {
237:                }
238:            }
239:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.