Source Code Cross Referenced for PgsSplitPaneDivider.java in  » Swing-Library » pgslookandfeel » com » pagosoft » plaf » 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 » pgslookandfeel » com.pagosoft.plaf 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2005 Patrick Gotthardt
003:         *
004:         * Licensed under the Apache License, Version 2.0 (the "License");
005:         * you may not use this file except in compliance with the License.
006:         * You may obtain a copy of the License at
007:         *
008:         *     http://www.apache.org/licenses/LICENSE-2.0
009:         *
010:         * Unless required by applicable law or agreed to in writing, software
011:         * distributed under the License is distributed on an "AS IS" BASIS,
012:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013:         * See the License for the specific language governing permissions and
014:         * limitations under the License.
015:         */
016:        package com.pagosoft.plaf;
017:
018:        import javax.swing.*;
019:        import javax.swing.border.*;
020:        import javax.swing.plaf.basic.*;
021:        import java.awt.*;
022:
023:        public class PgsSplitPaneDivider extends BasicSplitPaneDivider {
024:            public PgsSplitPaneDivider(BasicSplitPaneUI ui) {
025:                super (ui);
026:            }
027:
028:            public void paint(Graphics g) {
029:                Dimension size = getSize();
030:                Color bgColor = getBackground();
031:                if (bgColor != null) {
032:                    g.setColor(bgColor);
033:                    g.fillRect(0, 0, size.width, size.height);
034:                }
035:                super .paint(g);
036:            }
037:
038:            /**
039:             * Creates and return an instance of JButton that can be used to
040:             * collapse the left component in the metal split pane.
041:             */
042:            protected JButton createLeftOneTouchButton() {
043:                JButton b = new JButton() {
044:                    // Sprite buffer for the arrow image of the left button
045:                    int[][] buffer = { { 0, 0, 0, 2, 2, 0, 0, 0, 0 },
046:                            { 0, 0, 2, 1, 1, 1, 0, 0, 0 },
047:                            { 0, 2, 1, 1, 1, 1, 1, 0, 0 },
048:                            { 2, 1, 1, 1, 1, 1, 1, 1, 0 },
049:                            { 0, 3, 3, 3, 3, 3, 3, 3, 3 } };
050:
051:                    public void setBorder(Border b) {
052:                    }
053:
054:                    public void paint(Graphics g) {
055:                        JSplitPane splitPane = getSplitPaneFromSuper();
056:                        if (splitPane != null) {
057:                            int oneTouchSize = getOneTouchSizeFromSuper();
058:                            int orientation = getOrientationFromSuper();
059:                            int blockSize = Math.min(getDividerSize(),
060:                                    oneTouchSize);
061:
062:                            // Initialize the color array
063:                            Color[] colors = {
064:                                    this .getBackground(),
065:                                    PgsLookAndFeel
066:                                            .getPrimaryControlDarkShadow(),
067:                                    PgsLookAndFeel.getPrimaryControlInfo(),
068:                                    PgsLookAndFeel.getPrimaryControlHighlight() };
069:
070:                            // Fill the background first ...
071:                            g.setColor(this .getBackground());
072:                            if (isOpaque()) {
073:                                g.fillRect(0, 0, this .getWidth(), this 
074:                                        .getHeight());
075:                            }
076:
077:                            // ... then draw the arrow.
078:                            if (getModel().isPressed()) {
079:                                // Adjust color mapping for pressed button state
080:                                colors[1] = colors[2];
081:                            } else if (getModel().isRollover()) {
082:                                colors[1] = PgsLookAndFeel.getPrimaryControl();
083:                            }
084:                            if (orientation == JSplitPane.VERTICAL_SPLIT) {
085:                                // Draw the image for a vertical split
086:                                for (int i = 1; i <= buffer[0].length; i++) {
087:                                    for (int j = 1; j < blockSize; j++) {
088:                                        if (buffer[j - 1][i - 1] == 0) {
089:                                            continue;
090:                                        } else {
091:                                            g
092:                                                    .setColor(colors[buffer[j - 1][i - 1]]);
093:                                        }
094:                                        g.drawLine(i, j, i, j);
095:                                    }
096:                                }
097:                            } else {
098:                                // Draw the image for a horizontal split
099:                                // by simply swaping the i and j axis.
100:                                // Except the drawLine() call this code is
101:                                // identical to the code block above. This was done
102:                                // in order to remove the additional orientation
103:                                // check for each pixel.
104:                                for (int i = 1; i <= buffer[0].length; i++) {
105:                                    for (int j = 1; j < blockSize; j++) {
106:                                        if (buffer[j - 1][i - 1] == 0) {
107:                                            // Nothing needs
108:                                            // to be drawn
109:                                            continue;
110:                                        } else {
111:                                            // Set the color from the
112:                                            // color map
113:                                            g
114:                                                    .setColor(colors[buffer[j - 1][i - 1]]);
115:                                        }
116:                                        // Draw a pixel
117:                                        g.drawLine(j, i, j, i);
118:                                    }
119:                                }
120:                            }
121:                        }
122:                    }
123:
124:                    // Don't want the button to participate in focus traversable.
125:                    public boolean isFocusTraversable() {
126:                        return false;
127:                    }
128:                };
129:                b.setRequestFocusEnabled(false);
130:                b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
131:                b.setFocusPainted(false);
132:                b.setBorderPainted(false);
133:                maybeMakeButtonOpaque(b);
134:                return b;
135:            }
136:
137:            /**
138:             * Creates and return an instance of JButton that can be used to
139:             * collapse the right component in the metal split pane.
140:             */
141:            protected JButton createRightOneTouchButton() {
142:                JButton b = new JButton() {
143:                    // Sprite buffer for the arrow image of the right button
144:                    int[][] buffer = { { 2, 2, 2, 2, 2, 2, 2, 2 },
145:                            { 0, 1, 1, 1, 1, 1, 1, 3 },
146:                            { 0, 0, 1, 1, 1, 1, 3, 0 },
147:                            { 0, 0, 0, 1, 1, 3, 0, 0 },
148:                            { 0, 0, 0, 0, 3, 0, 0, 0 } };
149:
150:                    public void setBorder(Border border) {
151:                    }
152:
153:                    public void paint(Graphics g) {
154:                        JSplitPane splitPane = getSplitPaneFromSuper();
155:                        if (splitPane != null) {
156:                            int oneTouchSize = getOneTouchSizeFromSuper();
157:                            int orientation = getOrientationFromSuper();
158:                            int blockSize = Math.min(getDividerSize(),
159:                                    oneTouchSize);
160:
161:                            // Initialize the color array
162:                            Color[] colors = {
163:                                    this .getBackground(),
164:                                    PgsLookAndFeel
165:                                            .getPrimaryControlDarkShadow(),
166:                                    PgsLookAndFeel.getPrimaryControlInfo(),
167:                                    PgsLookAndFeel.getPrimaryControlHighlight() };
168:
169:                            // Fill the background first ...
170:                            g.setColor(this .getBackground());
171:                            if (isOpaque()) {
172:                                g.fillRect(0, 0, this .getWidth(), this 
173:                                        .getHeight());
174:                            }
175:
176:                            // ... then draw the arrow.
177:                            if (getModel().isPressed()) {
178:                                // Adjust color mapping for pressed button state
179:                                colors[1] = colors[2];
180:                            } else if (getModel().isRollover()) {
181:                                colors[1] = PgsLookAndFeel.getPrimaryControl();
182:                            }
183:                            if (orientation == JSplitPane.VERTICAL_SPLIT) {
184:                                // Draw the image for a vertical split
185:                                for (int i = 1; i <= buffer[0].length; i++) {
186:                                    for (int j = 1; j < blockSize; j++) {
187:                                        if (buffer[j - 1][i - 1] == 0) {
188:                                            continue;
189:                                        } else {
190:                                            g
191:                                                    .setColor(colors[buffer[j - 1][i - 1]]);
192:                                        }
193:                                        g.drawLine(i, j, i, j);
194:                                    }
195:                                }
196:                            } else {
197:                                // Draw the image for a horizontal split
198:                                // by simply swaping the i and j axis.
199:                                // Except the drawLine() call this code is
200:                                // identical to the code block above. This was done
201:                                // in order to remove the additional orientation
202:                                // check for each pixel.
203:                                for (int i = 1; i <= buffer[0].length; i++) {
204:                                    for (int j = 1; j < blockSize; j++) {
205:                                        if (buffer[j - 1][i - 1] == 0) {
206:                                            // Nothing needs
207:                                            // to be drawn
208:                                            continue;
209:                                        } else {
210:                                            // Set the color from the
211:                                            // color map
212:                                            g
213:                                                    .setColor(colors[buffer[j - 1][i - 1]]);
214:                                        }
215:                                        // Draw a pixel
216:                                        g.drawLine(j, i, j, i);
217:                                    }
218:                                }
219:                            }
220:                        }
221:                    }
222:
223:                    // Don't want the button to participate in focus traversable.
224:                    public boolean isFocusTraversable() {
225:                        return false;
226:                    }
227:                };
228:                b.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
229:                b.setFocusPainted(false);
230:                b.setBorderPainted(false);
231:                b.setRequestFocusEnabled(false);
232:                maybeMakeButtonOpaque(b);
233:                return b;
234:            }
235:
236:            private void maybeMakeButtonOpaque(JComponent c) {
237:                Object opaque = UIManager
238:                        .get("SplitPane.oneTouchButtonsOpaque");
239:                if (opaque != null) {
240:                    c.setOpaque(((Boolean) opaque).booleanValue());
241:                }
242:            }
243:
244:            int getOneTouchSizeFromSuper() {
245:                return super .ONE_TOUCH_SIZE;
246:            }
247:
248:            int getOneTouchOffsetFromSuper() {
249:                return super .ONE_TOUCH_OFFSET;
250:            }
251:
252:            int getOrientationFromSuper() {
253:                return super .orientation;
254:            }
255:
256:            JSplitPane getSplitPaneFromSuper() {
257:                return super .splitPane;
258:            }
259:
260:            JButton getLeftButtonFromSuper() {
261:                return super .leftButton;
262:            }
263:
264:            JButton getRightButtonFromSuper() {
265:                return super.rightButton;
266:            }
267:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.