Source Code Cross Referenced for LabelItem.java in  » Web-Framework » wingS » com » javujavu » javux » wings » item » 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.item 
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.item;
022:
023:        import java.awt.Dimension;
024:        import java.awt.Graphics;
025:        import java.awt.Image;
026:        import java.awt.Insets;
027:        import java.awt.Rectangle;
028:        import com.javujavu.javux.wings.Style;
029:        import com.javujavu.javux.wings.WingComponent;
030:        import com.javujavu.javux.wings.WingImage;
031:        import com.javujavu.javux.wings.WingToolkit;
032:
033:        /**
034:         * This class is a self-rendering label implementing <code>ItemRederer</code>,
035:         * that can display multiline text and image icon with specified horizontal
036:         * alignment and text position.<br>
037:         * Object of this class can be used instead of String labels
038:         * in labels, buttons, checkboxes, menus and so on, and as an item
039:         * in lists, combo boxes, tables and so on.
040:         * <br>
041:         * <b>This class is thread safe.</b>
042:         **/
043:        public class LabelItem implements  ItemRenderer {
044:            public WingImage icon;
045:            public String text;
046:            public Object userData;
047:            public int alignment;
048:            public int textPosition;
049:
050:            /**
051:             * Creates a new label displaying specified text and icon
052:             * @param text text of the label, null is allowed
053:             * @param icon icon image of the label, null is allowed
054:             */
055:            public LabelItem(String text, WingImage icon) {
056:                this (text, icon, null);
057:            }
058:
059:            /**
060:             * Creates a new label displaying specified text and icon
061:             * @param text text of the label, null is allowed
062:             * @param icon icon image of the label, null is allowed
063:             * @param userData custom user data object
064:             */
065:            public LabelItem(String text, WingImage icon, Object userData) {
066:                this (text, icon, -1, -1, userData);
067:            }
068:
069:            /**
070:             * Creates a new label displaying specified text and icon
071:             * @param text text of the label, null is allowed
072:             * @param icon icon image of the label, null is allowed
073:             * @param alignment label alignment <code>WingConst.LEFT, RIGHT or CENTER</code>
074:             * @param textPosition text position <code>WingConst.LEFT or RIGHT</code>
075:             */
076:            public LabelItem(String text, WingImage icon, int alignment,
077:                    int textPosition) {
078:                this (text, icon, alignment, textPosition, null);
079:            }
080:
081:            /**
082:             * Creates a new label displaying specified text and icon
083:             * @param text text of the label, null is allowed
084:             * @param icon icon image of the label, null is allowed
085:             * @param alignment label alignment <code>WingConst.LEFT, RIGHT or CENTER</code>
086:             * @param textPosition text position <code>WingConst.LEFT or RIGHT</code>
087:             * @param userData custom user data object
088:             */
089:            public LabelItem(String text, WingImage icon, int alignment,
090:                    int textPosition, Object userData) {
091:                this .text = text;
092:                this .icon = icon;
093:                this .userData = userData;
094:                this .alignment = alignment;
095:                this .textPosition = textPosition;
096:            }
097:
098:            public String toString() {
099:                return text;
100:            }
101:
102:            /**
103:             * @see com.javujavu.javux.wings.item.ItemRenderer#getItemSize(java.lang.Object, com.javujavu.javux.wings.WingComponent, com.javujavu.javux.wings.Style, java.lang.Object)
104:             */
105:            public Dimension getItemSize(Object item, WingComponent owner,
106:                    Style style, Object context) {
107:                return WingToolkit.calcLabelSize(icon, text, style
108:                        .getFont(owner.getWingFont()), style.margin, style.gap,
109:                        owner);
110:            }
111:
112:            /**
113:             * @see com.javujavu.javux.wings.item.ItemRenderer#drawItem(java.awt.Graphics, int, int, int, int, java.lang.Object, com.javujavu.javux.wings.WingComponent, com.javujavu.javux.wings.Style, java.awt.Insets, int, int, java.lang.Object)
114:             */
115:            public void drawItem(Graphics g, int x, int y, int width,
116:                    int height, Object item, WingComponent owner, Style style,
117:                    Insets margin, int alignment, int textPosition,
118:                    Object context) {
119:                WingToolkit
120:                        .drawBackground(g, x, y, width, height, style, owner);
121:                WingImage icon = this .icon;
122:                if (icon == null)
123:                    icon = style.icon;
124:
125:                int a = this .alignment;
126:                if (a == -1)
127:                    a = alignment;
128:                int tp = this .textPosition;
129:                if (tp == -1)
130:                    tp = textPosition;
131:                WingToolkit.drawLabel(g, x, y, width, height, icon, text, style
132:                        .getFont(owner.getWingFont()), style
133:                        .getForeground(owner.getForeground()), style.focus,
134:                        margin, style.gap, a, tp, owner);
135:            }
136:
137:            /**
138:             * @see com.javujavu.javux.wings.item.ItemRenderer#imageUpdate(java.awt.Image, int, int, int, int, int, java.lang.Object, com.javujavu.javux.wings.WingComponent, com.javujavu.javux.wings.Style, java.awt.Rectangle)
139:             */
140:            public boolean imageUpdate(Image img, int infoflags, int x, int y,
141:                    int width, int height, Object item, WingComponent owner,
142:                    Style style, Rectangle itemBounds) {
143:                WingImage icon = this .icon;
144:                if ((icon != null && icon.getImage().equals(img))
145:                        || (style.image != null && style.image.getImage()
146:                                .equals(img))
147:                        || (style.icon != null && style.icon.getImage().equals(
148:                                img))) {
149:                    return owner.repaintVisible(itemBounds.x, itemBounds.y,
150:                            itemBounds.width, itemBounds.height)
151:                            && ((infoflags & (WingComponent.ALLBITS | WingComponent.ABORT)) == 0);
152:                }
153:                return false;
154:            }
155:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.