Source Code Cross Referenced for GTKGraphicsUtils.java in  » 6.0-JDK-Modules-com.sun.java » swing » com » sun » java » swing » plaf » gtk » 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 » 6.0 JDK Modules com.sun.java » swing » com.sun.java.swing.plaf.gtk 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Copyright 2002-2006 Sun Microsystems, Inc.  All Rights Reserved.
003:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004:         *
005:         * This code is free software; you can redistribute it and/or modify it
006:         * under the terms of the GNU General Public License version 2 only, as
007:         * published by the Free Software Foundation.  Sun designates this
008:         * particular file as subject to the "Classpath" exception as provided
009:         * by Sun in the LICENSE file that accompanied this code.
010:         *
011:         * This code is distributed in the hope that it will be useful, but WITHOUT
012:         * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013:         * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
014:         * version 2 for more details (a copy is included in the LICENSE file that
015:         * accompanied this code).
016:         *
017:         * You should have received a copy of the GNU General Public License version
018:         * 2 along with this work; if not, write to the Free Software Foundation,
019:         * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020:         *
021:         * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022:         * CA 95054 USA or visit www.sun.com if you need additional information or
023:         * have any questions.
024:         */
025:        package com.sun.java.swing.plaf.gtk;
026:
027:        import javax.swing.*;
028:        import javax.swing.plaf.synth.*;
029:        import java.awt.Color;
030:        import java.awt.Graphics;
031:        import java.awt.Rectangle;
032:
033:        /**
034:         * @version 1.25, 05/05/07
035:         * @author Joshua Outwater
036:         */
037:        class GTKGraphicsUtils extends SynthGraphicsUtils {
038:            public void paintText(SynthContext context, Graphics g,
039:                    String text, int x, int y, int mnemonicIndex) {
040:                if (text == null || text.length() <= 0) {
041:                    // We don't need to paint empty strings
042:                    return;
043:                }
044:
045:                if (context.getRegion() == Region.INTERNAL_FRAME_TITLE_PANE) {
046:                    // Metacity handles painting of text on internal frame title,
047:                    // ignore this.
048:                    return;
049:                }
050:                int componentState = context.getComponentState();
051:                if ((componentState & SynthConstants.DISABLED) == SynthConstants.DISABLED) {
052:                    Color orgColor = g.getColor();
053:                    g.setColor(context.getStyle().getColor(context,
054:                            GTKColorType.WHITE));
055:                    x += 1;
056:                    y += 1;
057:                    super .paintText(context, g, text, x, y, mnemonicIndex);
058:
059:                    g.setColor(orgColor);
060:                    x -= 1;
061:                    y -= 1;
062:                    super .paintText(context, g, text, x, y, mnemonicIndex);
063:                } else {
064:                    String themeName = GTKLookAndFeel.getGtkThemeName();
065:                    if (themeName != null
066:                            && themeName.startsWith("blueprint")
067:                            && shouldShadowText(context.getRegion(),
068:                                    componentState)) {
069:
070:                        g.setColor(Color.BLACK);
071:                        super .paintText(context, g, text, x + 1, y + 1,
072:                                mnemonicIndex);
073:                        g.setColor(Color.WHITE);
074:                    }
075:
076:                    super .paintText(context, g, text, x, y, mnemonicIndex);
077:                }
078:            }
079:
080:            /**
081:             * Paints text at the specified location. This will not attempt to
082:             * render the text as html nor will it offset by the insets of the
083:             * component.
084:             *
085:             * @param ss SynthContext
086:             * @param g Graphics used to render string in.
087:             * @param text Text to render
088:             * @param bounds Bounds of the text to be drawn.
089:             * @param mnemonicIndex Index to draw string at.
090:             */
091:            public void paintText(SynthContext context, Graphics g,
092:                    String text, Rectangle bounds, int mnemonicIndex) {
093:                if (text == null || text.length() <= 0) {
094:                    // We don't need to paint empty strings
095:                    return;
096:                }
097:
098:                Region id = context.getRegion();
099:                if ((id == Region.RADIO_BUTTON || id == Region.CHECK_BOX || id == Region.TABBED_PANE_TAB)
100:                        && (context.getComponentState() & SynthConstants.FOCUSED) != 0) {
101:                    JComponent source = context.getComponent();
102:                    if (!(source instanceof  AbstractButton)
103:                            || ((AbstractButton) source).isFocusPainted()) {
104:
105:                        // The "bounds" parameter encompasses only the actual text;
106:                        // when drawing the focus, we need to expand that bounding
107:                        // box by "focus-line-width" plus "focus-padding".  Note that
108:                        // the layout process for these components will have already
109:                        // taken these values into account, so there should always
110:                        // be enough space allocated for drawing the focus indicator.
111:                        int synthState = context.getComponentState();
112:                        GTKStyle style = (GTKStyle) context.getStyle();
113:                        int focusSize = style.getClassSpecificIntValue(context,
114:                                "focus-line-width", 1);
115:                        int focusPad = style.getClassSpecificIntValue(context,
116:                                "focus-padding", 1);
117:                        int totalFocus = focusSize + focusPad;
118:                        int x = bounds.x - totalFocus;
119:                        int y = bounds.y - totalFocus;
120:                        int w = bounds.width + (2 * totalFocus);
121:                        int h = bounds.height + (2 * totalFocus);
122:
123:                        Color color = g.getColor();
124:                        GTKPainter.INSTANCE.paintFocus(context, g, id,
125:                                synthState, "checkbutton", x, y, w, h);
126:                        g.setColor(color);
127:                    }
128:                }
129:                super .paintText(context, g, text, bounds, mnemonicIndex);
130:            }
131:
132:            private static boolean shouldShadowText(Region id, int state) {
133:                int gtkState = GTKLookAndFeel.synthStateToGTKState(id, state);
134:                return ((gtkState == SynthConstants.MOUSE_OVER) && (id == Region.MENU
135:                        || id == Region.MENU_ITEM
136:                        || id == Region.CHECK_BOX_MENU_ITEM || id == Region.RADIO_BUTTON_MENU_ITEM));
137:            }
138:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.