Source Code Cross Referenced for SoftBevelBorder.java in  » 6.0-JDK-Core » swing » javax » swing » border » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Home
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
26.ERP CRM Financial
27.ESB
28.Forum
29.Game
30.GIS
31.Graphic 3D
32.Graphic Library
33.Groupware
34.HTML Parser
35.IDE
36.IDE Eclipse
37.IDE Netbeans
38.Installer
39.Internationalization Localization
40.Inversion of Control
41.Issue Tracking
42.J2EE
43.J2ME
44.JBoss
45.JMS
46.JMX
47.Library
48.Mail Clients
49.Music
50.Net
51.Parser
52.PDF
53.Portal
54.Profiler
55.Project Management
56.Report
57.RSS RDF
58.Rule Engine
59.Science
60.Scripting
61.Search Engine
62.Security
63.Sevlet Container
64.Source Control
65.Swing Library
66.Template Engine
67.Test Coverage
68.Testing
69.UML
70.Web Crawler
71.Web Framework
72.Web Mail
73.Web Server
74.Web Services
75.Web Services apache cxf 2.2.6
76.Web Services AXIS2
77.Wiki Engine
78.Workflow Engines
79.XML
80.XML UI
Java Source Code / Java Documentation » 6.0 JDK Core » swing » javax.swing.border 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001        /*
002         * Copyright 1997-2007 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 javax.swing.border;
026
027        import java.awt.Graphics;
028        import java.awt.Insets;
029        import java.awt.Rectangle;
030        import java.awt.Color;
031        import java.awt.Component;
032        import java.beans.ConstructorProperties;
033
034        /**
035         * A class which implements a raised or lowered bevel with
036         * softened corners.
037         * <p>
038         * <strong>Warning:</strong>
039         * Serialized objects of this class will not be compatible with
040         * future Swing releases. The current serialization support is
041         * appropriate for short term storage or RMI between applications running
042         * the same version of Swing.  As of 1.4, support for long term storage
043         * of all JavaBeans<sup><font size="-2">TM</font></sup>
044         * has been added to the <code>java.beans</code> package.
045         * Please see {@link java.beans.XMLEncoder}.
046         *
047         * @version 1.22 05/05/07
048         * @author Amy Fowler
049         * @author Chester Rose
050         */
051        public class SoftBevelBorder extends BevelBorder {
052
053            /**
054             * Creates a bevel border with the specified type and whose
055             * colors will be derived from the background color of the
056             * component passed into the paintBorder method.
057             * @param bevelType the type of bevel for the border
058             */
059            public SoftBevelBorder(int bevelType) {
060                super (bevelType);
061            }
062
063            /**
064             * Creates a bevel border with the specified type, highlight and
065             * shadow colors.
066             * @param bevelType the type of bevel for the border
067             * @param highlight the color to use for the bevel highlight
068             * @param shadow the color to use for the bevel shadow
069             */
070            public SoftBevelBorder(int bevelType, Color highlight, Color shadow) {
071                super (bevelType, highlight, shadow);
072            }
073
074            /**
075             * Creates a bevel border with the specified type, highlight
076             * shadow colors.
077             * @param bevelType the type of bevel for the border
078             * @param highlightOuterColor the color to use for the bevel outer highlight
079             * @param highlightInnerColor the color to use for the bevel inner highlight
080             * @param shadowOuterColor the color to use for the bevel outer shadow
081             * @param shadowInnerColor the color to use for the bevel inner shadow
082             */
083            @ConstructorProperties({"bevelType","highlightOuterColor","highlightInnerColor","shadowOuterColor","shadowInnerColor"})
084            public SoftBevelBorder(int bevelType, Color highlightOuterColor,
085                    Color highlightInnerColor, Color shadowOuterColor,
086                    Color shadowInnerColor) {
087                super (bevelType, highlightOuterColor, highlightInnerColor,
088                        shadowOuterColor, shadowInnerColor);
089            }
090
091            /**
092             * Paints the border for the specified component with the specified
093             * position and size.
094             * @param c the component for which this border is being painted
095             * @param g the paint graphics
096             * @param x the x position of the painted border
097             * @param y the y position of the painted border
098             * @param width the width of the painted border
099             * @param height the height of the painted border
100             */
101            public void paintBorder(Component c, Graphics g, int x, int y,
102                    int width, int height) {
103                Color oldColor = g.getColor();
104                g.translate(x, y);
105
106                if (bevelType == RAISED) {
107                    g.setColor(getHighlightOuterColor(c));
108                    g.drawLine(0, 0, width - 2, 0);
109                    g.drawLine(0, 0, 0, height - 2);
110                    g.drawLine(1, 1, 1, 1);
111
112                    g.setColor(getHighlightInnerColor(c));
113                    g.drawLine(2, 1, width - 2, 1);
114                    g.drawLine(1, 2, 1, height - 2);
115                    g.drawLine(2, 2, 2, 2);
116                    g.drawLine(0, height - 1, 0, height - 2);
117                    g.drawLine(width - 1, 0, width - 1, 0);
118
119                    g.setColor(getShadowOuterColor(c));
120                    g.drawLine(2, height - 1, width - 1, height - 1);
121                    g.drawLine(width - 1, 2, width - 1, height - 1);
122
123                    g.setColor(getShadowInnerColor(c));
124                    g.drawLine(width - 2, height - 2, width - 2, height - 2);
125
126                } else if (bevelType == LOWERED) {
127                    g.setColor(getShadowOuterColor(c));
128                    g.drawLine(0, 0, width - 2, 0);
129                    g.drawLine(0, 0, 0, height - 2);
130                    g.drawLine(1, 1, 1, 1);
131
132                    g.setColor(getShadowInnerColor(c));
133                    g.drawLine(2, 1, width - 2, 1);
134                    g.drawLine(1, 2, 1, height - 2);
135                    g.drawLine(2, 2, 2, 2);
136                    g.drawLine(0, height - 1, 0, height - 2);
137                    g.drawLine(width - 1, 0, width - 1, 0);
138
139                    g.setColor(getHighlightOuterColor(c));
140                    g.drawLine(2, height - 1, width - 1, height - 1);
141                    g.drawLine(width - 1, 2, width - 1, height - 1);
142
143                    g.setColor(getHighlightInnerColor(c));
144                    g.drawLine(width - 2, height - 2, width - 2, height - 2);
145                }
146                g.translate(-x, -y);
147                g.setColor(oldColor);
148            }
149
150            /**
151             * Returns the insets of the border.
152             * @param c the component for which this border insets value applies
153             */
154            public Insets getBorderInsets(Component c) {
155                return getBorderInsets(c, new Insets(0, 0, 0, 0));
156            }
157
158            /** 
159             * Reinitialize the insets parameter with this Border's current Insets. 
160             * @param c the component for which this border insets value applies
161             * @param insets the object to be reinitialized
162             */
163            public Insets getBorderInsets(Component c, Insets insets) {
164                insets.top = insets.left = insets.bottom = insets.right = 3;
165                return insets;
166            }
167
168            /**
169             * Returns whether or not the border is opaque.
170             */
171            public boolean isBorderOpaque() {
172                return false;
173            }
174
175        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.