Source Code Cross Referenced for MultipleSelectionHelper.java in  » XML-UI » XUI » net » xoetrope » builder » editor » components » 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 » XML UI » XUI » net.xoetrope.builder.editor.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package net.xoetrope.builder.editor.components;
002:
003:        import java.util.Vector;
004:        import java.awt.Component;
005:        import net.xoetrope.builder.editor.XComponentSizer;
006:        import net.xoetrope.xui.style.XStyle;
007:        import net.xoetrope.xui.style.XStyleManager;
008:        import java.awt.Font;
009:        import java.awt.Color;
010:        import net.xoetrope.xui.XProjectManager;
011:
012:        /**
013:         * A helper to help in the manipulation of multiple components
014:         * <p> Copyright (c) Xoetrope Ltd., 2002-2003</p>
015:         * <p> $Revision: 1.5 $</p>
016:         */
017:        public class MultipleSelectionHelper extends PropertyHelper {
018:            protected final static String propertyName[] = { "Type", "Name",
019:                    "Left", "Top", "Width", "Height", "Style" };
020:            protected final static int numBasicProperties = 7;
021:
022:            protected final static int LEFT_VALUE = 0;
023:            protected final static int TOP_VALUE = 1;
024:            protected final static int WIDTH_VALUE = 2;
025:            protected final static int HEIGHT_VALUE = 3;
026:
027:            private Vector selectedComponents;
028:
029:            /**
030:             * A helper for multiple component types
031:             */
032:            public MultipleSelectionHelper() {
033:            }
034:
035:            /**
036:             * Get the class name for this component type
037:             * @return
038:             */
039:            public String getClassName() {
040:                return Vector.class.getName();
041:            }
042:
043:            /**
044:             * Get the friendly type name for this component
045:             * @return "Multiple"
046:             */
047:            public String getComponentType() {
048:                return "Multiple";
049:            }
050:
051:            public void setSelectedComponents(Vector comps) {
052:                selectedComponents = comps;
053:            }
054:
055:            /**
056:             * Get the value of the property exposed by the component
057:             * @param comp the component instance
058:             * @param i the component property index
059:             * @return the value
060:             */
061:            public String getPropertyValue(Component comp, int i) {
062:                switch (i) {
063:                case 0: {
064:                    return "Multiple";
065:                }
066:                case 1:
067:                    return "Multiple";
068:                case 2:
069:                    return new Integer(getValue(LEFT_VALUE)).toString();
070:                case 3:
071:                    return new Integer(getValue(TOP_VALUE)).toString();
072:                case 4:
073:                    return new Integer(getValue(WIDTH_VALUE)).toString();
074:                case 5:
075:                    return new Integer(getValue(HEIGHT_VALUE)).toString();
076:                case 6:
077:                    return "";
078:                }
079:                return null;
080:            }
081:
082:            /**
083:             * Set the value of the property exposed by the component
084:             * @param comp the component instance
085:             * @param i the component property index
086:             * @return the value
087:             */
088:            public void setPropertyValue(Component comp, int i, String value) {
089:                switch (i) {
090:                case 0:
091:                    break;
092:                case 1:
093:                    comp.setName(value);
094:                    break;
095:                case 2:
096:                    comp.setLocation(new Integer(value).intValue(), comp
097:                            .getLocation().y);
098:                    break;
099:                case 3:
100:                    comp.setLocation(comp.getLocation().x, new Integer(value)
101:                            .intValue());
102:                    break;
103:                case 4:
104:                    comp.setSize(new Integer(value).intValue(),
105:                            comp.getSize().height);
106:                    break;
107:                case 5:
108:                    comp.setSize(comp.getSize().width, new Integer(value)
109:                            .intValue());
110:                    break;
111:                case 6: {
112:                    XStyle style = XProjectManager.getStyleManager().getStyle(
113:                            value);
114:                    int fontStyle = 0;
115:                    if (style.getStyleAsInt(XStyle.FONT_WEIGHT) == 1)
116:                        fontStyle = Font.BOLD;
117:                    if (style.getStyleAsInt(XStyle.FONT_ITALIC) == 1)
118:                        fontStyle = fontStyle | Font.ITALIC;
119:
120:                    Font font = new Font(style
121:                            .getStyleAsString(XStyle.FONT_FACE), fontStyle,
122:                            style.getStyleAsInt(XStyle.FONT_SIZE));
123:                    Color fgColor = style.getStyleAsColor(XStyle.COLOR_FORE);
124:                    Color bkColor = style.getStyleAsColor(XStyle.COLOR_BACK);
125:
126:                    setForeground(fgColor);
127:                    setBackground(bkColor);
128:                    setFont(font);
129:                }
130:                    break;
131:                }
132:            }
133:
134:            private int getValue(int type) {
135:                int value = 100000;
136:                if ((type == WIDTH_VALUE) || (type == HEIGHT_VALUE))
137:                    value = -100000;
138:
139:                if (selectedComponents == null)
140:                    return 0;
141:
142:                int numComponents = selectedComponents.size();
143:                for (int i = 0; i < numComponents; i++) {
144:                    if (type == LEFT_VALUE)
145:                        value = Math.min(value,
146:                                ((XComponentSizer) selectedComponents
147:                                        .elementAt(i)).getTarget()
148:                                        .getLocation().x);
149:                    else if (type == TOP_VALUE)
150:                        value = Math.min(value,
151:                                ((XComponentSizer) selectedComponents
152:                                        .elementAt(i)).getTarget()
153:                                        .getLocation().y);
154:                    else if (type == WIDTH_VALUE)
155:                        value = Math
156:                                .max(value,
157:                                        ((XComponentSizer) selectedComponents
158:                                                .elementAt(i)).getTarget()
159:                                                .getSize().width);
160:                    else if (type == HEIGHT_VALUE)
161:                        value = Math
162:                                .max(value,
163:                                        ((XComponentSizer) selectedComponents
164:                                                .elementAt(i)).getTarget()
165:                                                .getSize().height);
166:                }
167:
168:                return value;
169:            }
170:
171:            private void setValue(int type, int newValue) {
172:                int numComponents = selectedComponents.size();
173:                for (int i = 0; i < numComponents; i++) {
174:                    XComponentSizer sizer = ((XComponentSizer) selectedComponents
175:                            .elementAt(i));
176:                    if (type == LEFT_VALUE)
177:                        sizer.setLocation(newValue, sizer.getLocation().y);
178:                    else if (type == TOP_VALUE)
179:                        sizer.setLocation(sizer.getLocation().x, newValue);
180:                    else if (type == WIDTH_VALUE)
181:                        sizer.setSize(newValue, sizer.getSize().height);
182:                    else if (type == HEIGHT_VALUE)
183:                        sizer.setSize(sizer.getSize().width, newValue);
184:
185:                    sizer.repositionTarget();
186:                }
187:            }
188:
189:            private void setForeground(Color fgColor) {
190:                int numComponents = selectedComponents.size();
191:                for (int i = 0; i < numComponents; i++) {
192:                    XComponentSizer sizer = ((XComponentSizer) selectedComponents
193:                            .elementAt(i));
194:                    sizer.getTarget().setForeground(fgColor);
195:                }
196:            }
197:
198:            private void setBackground(Color bkColor) {
199:                int numComponents = selectedComponents.size();
200:                for (int i = 0; i < numComponents; i++) {
201:                    XComponentSizer sizer = ((XComponentSizer) selectedComponents
202:                            .elementAt(i));
203:                    sizer.getTarget().setBackground(bkColor);
204:                }
205:            }
206:
207:            private void setFont(Font font) {
208:                int numComponents = selectedComponents.size();
209:                for (int i = 0; i < numComponents; i++) {
210:                    XComponentSizer sizer = ((XComponentSizer) selectedComponents
211:                            .elementAt(i));
212:                    sizer.getTarget().setFont(font);
213:                }
214:            }
215:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.