Source Code Cross Referenced for WingLabel.java in  » Web-Framework » wingS » com » javujavu » javux » wings » 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 » Web Framework » wingS » com.javujavu.javux.wings 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         *	Javu WingS - Lightweight Java Component Set
003:         *	Copyright (c) 2005-2007 Krzysztof A. Sadlocha
004:         *	e-mail: ksadlocha@programics.com
005:         *
006:         *	This library is free software; you can redistribute it and/or
007:         *	modify it under the terms of the GNU Lesser General Public
008:         *	License as published by the Free Software Foundation; either
009:         *	version 2.1 of the License, or (at your option) any later version.
010:         *
011:         *	This library is distributed in the hope that it will be useful,
012:         *	but WITHOUT ANY WARRANTY; without even the implied warranty of
013:         *	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014:         *	Lesser General Public License for more details.
015:         *
016:         *	You should have received a copy of the GNU Lesser General Public
017:         *	License along with this library; if not, write to the Free Software
018:         *	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
019:         */
020:
021:        package com.javujavu.javux.wings;
022:
023:        import java.awt.Dimension;
024:        import java.awt.Graphics;
025:        import java.awt.Image;
026:        import java.awt.Rectangle;
027:        import com.javujavu.javux.wings.item.DefaultItemRenderer;
028:        import com.javujavu.javux.wings.item.ItemRenderer;
029:
030:        /**
031:         * A display area for a label. It can be text, image or any object
032:         * that can be rendered with <code>{@link ItemRenderer}</code> set to this component.
033:         *
034:         * <br>
035:         * <b>This is one of the core WingS classes required by all the components</b><br>
036:         * <br>
037:         * <b>This class is thread safe.</b>
038:         * @see ItemRenderer
039:         * @see DefaultItemRenderer
040:         **/
041:        public class WingLabel extends WingComponent {
042:            protected Object label;
043:            protected int alignment;
044:            protected int textPosition;
045:
046:            /**
047:             * Constructs an empty label.
048:             **/
049:            public WingLabel() {
050:                this (null, LEFT);
051:            }
052:
053:            /**
054:             * Constructs a new label with the specified <code>label</code> item.
055:             * @param label label item usually String
056:             **/
057:            public WingLabel(Object label) {
058:                this (label, LEFT);
059:            }
060:
061:            /**
062:             * Constructs a new label with the specified <code>label</code> item
063:             *  with the specified alignment
064:             * @param label label item usually String
065:             * @param alignment the alignment value.
066:             **/
067:            public WingLabel(Object label, int alignment) {
068:                this .label = label;
069:                this .alignment = alignment;
070:                this .textPosition = RIGHT;
071:            }
072:
073:            /**
074:             * Loads skin resources.<br>
075:             * <pre>
076:             * styles:
077:             * [optional styleID.]label.normal
078:             * [optional styleID.]label.disabled
079:             * </pre>
080:             * @see Style
081:             * @see WingSkin
082:             */
083:            public void loadSkin() {
084:                stNormal = WingSkin.getStyle(styleId, "label", NORMAL, null);
085:                stDisabled = WingSkin.getStyle(styleId, "label", DISABLED,
086:                        stNormal).merge(stTop);
087:                stNormal = stNormal.merge(stTop);
088:            }
089:
090:            /**
091:             * Sets the label item for this label to the specified value.
092:             * @param      label the label item that this label displays.
093:             */
094:            public void setLabel(Object label) {
095:                if ((this .label == null && label == null)
096:                        || this .label == label) {
097:                    return;
098:                }
099:                this .label = label;
100:                revalidateAndRepaint();
101:            }
102:
103:            /**
104:             * Returns the label item of this label.
105:             * @return     the label item of this label
106:             */
107:            public Object getLabel() {
108:                return label;
109:            }
110:
111:            /**
112:             * Sets the alignment of the label's contents along the X axis.
113:             * @param alignment  One of the following constants
114:             *           <code>WingConst.LEFT</code>,
115:             *           <code>WingConst.CENTER</code>
116:             *           <code>WingConst.RIGHT</code>
117:             */
118:            public void setHorizontalAlignment(int alignment) {
119:                this .alignment = alignment;
120:                repaintVisible();
121:            }
122:
123:            /**
124:             * Sets the horizontal position of the label's text,
125:             * relative to its image.
126:             *
127:             * @param textPosition  One of the following constants
128:             *           <code>WingConst.LEFT</code>,
129:             *           <code>WingConst.RIGHT</code>
130:             */
131:            public void setTextPosition(int textPosition) {
132:                this .textPosition = textPosition;
133:                repaintVisible();
134:            }
135:
136:            public Dimension getPreferredSize() {
137:                Dimension prefSize = wingPrefSize;
138:                if (prefSize == null) {
139:                    wingPrefSize = prefSize = getRenderer().getItemSize(label,
140:                            this , getStyle(), null);
141:                }
142:                return prefSize;
143:            }
144:
145:            /**
146:             * @see com.javujavu.javux.wings.WingComponent#paintBackground(java.awt.Graphics)
147:             */
148:            public void paintBackground(Graphics g) {
149:                Style st = getStyle();
150:                Dimension size = getSize();
151:                getRenderer().drawItem(g, 0, 0, size.width, size.height, label,
152:                        this , st, st.margin, alignment, textPosition, null);
153:            }
154:
155:            /**
156:             * @see com.javujavu.javux.wings.WingComponent#imageUpdate(java.awt.Image, int, int, int, int, int)
157:             */
158:            public boolean imageUpdate(Image img, int infoflags, int x, int y,
159:                    int width, int height) {
160:                return isShowing()
161:                        && getRenderer().imageUpdate(img, infoflags, x, y,
162:                                width, height, label, this , getStyle(),
163:                                new Rectangle(getSize()));
164:            }
165:
166:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.