Source Code Cross Referenced for HoSwingBox.java in  » J2EE » WiSerFramework » de » ug2t » channel » ho » client » swing » 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 » J2EE » WiSerFramework » de.ug2t.channel.ho.client.swing 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        // @@
002:        // @@
003:        /*
004:         * Wi.Ser Framework
005:         *
006:         * LGPL Version: 1.8.1, 20-September-2007  
007:         * Copyright (C) 2005-2006 Dirk von der Weiden <dvdw@imail.de>
008:         *
009:         * This library is free software; you can redistribute it and/or
010:         * modify it under the terms of the GNU Lesser General Public
011:         * License as published by the Free Software Foundation; either
012:         * version 2 of the License, or (at your option) any later version.
013:         *
014:         * This library is distributed in the hope that it will be useful,
015:         * but WITHOUT ANY WARRANTY; without even the implied warranty of
016:         * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
017:         * Lesser General Public License for more details.
018:         *
019:         * You should have received a copy of the GNU Lesser General Public
020:         * License along with this library located in LGPL.txt in the 
021:         * license directory; if not, write to the 
022:         * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
023:         * Boston, MA  02111-1307, USA.
024:         * 
025:         * If this agreement does not cover your requirements, please contact us
026:         * via email to get detailed information about the commercial license 
027:         * or our service offerings!
028:         *
029:         */
030:        // @@
031:        package de.ug2t.channel.ho.client.swing;
032:
033:        import java.awt.*;
034:        import java.awt.event.*;
035:        import java.util.*;
036:
037:        import javax.swing.*;
038:
039:        import de.ug2t.channel.ho.session.*;
040:        import de.ug2t.kernel.*;
041:        import de.ug2t.unifiedGui.*;
042:        import de.ug2t.unifiedGui.interfaces.*;
043:        import de.ug2t.xmlScript.*;
044:
045:        public class HoSwingBox extends HoSwingComponent implements  IUnBox {
046:            class SwingBox extends JPanel {
047:                class BoxGridBag extends GridBagLayout {
048:                    public BoxGridBag() {
049:                        super ();
050:                    }
051:
052:                    public Dimension maximumLayoutSize(Container target) {
053:                        if (SwingBox.this .pem_type == IUnBox.LAYOUTED)
054:                            this .layoutContainer(target);
055:
056:                        return super .maximumLayoutSize(target);
057:                    }
058:
059:                    public Dimension minimumLayoutSize(Container parent) {
060:                        if (SwingBox.this .pem_type == IUnBox.LAYOUTED)
061:                            this .layoutContainer(parent);
062:
063:                        return super .minimumLayoutSize(parent);
064:                    }
065:
066:                    public Dimension preferredLayoutSize(Container parent) {
067:                        if (SwingBox.this .pem_type == IUnBox.LAYOUTED)
068:                            this .layoutContainer(parent);
069:
070:                        return super .preferredLayoutSize(parent);
071:                    }
072:
073:                    public void layoutContainer(Container parent) {
074:                        if (SwingBox.this .pem_type == IUnBox.LAYOUTED) {
075:                            if (!SwingBox.this .pem_layoutNeeded) {
076:                                super .layoutContainer(parent);
077:                                return;
078:                            }
079:
080:                            SwingBox.this .pem_layoutNeeded = false;
081:
082:                            SwingBox.this .pcmf_checkConstraints();
083:
084:                            int l_cnt = parent.getComponentCount();
085:                            if (l_cnt == 0) {
086:                                super .layoutContainer(parent);
087:                                return;
088:                            }
089:
090:                            for (int i = 0; i < l_cnt; i++) {
091:                                Component l_comp = parent.getComponent(i);
092:                                this .removeLayoutComponent(l_comp);
093:                                GridBagConstraints l_constr = new GridBagConstraints();
094:                                l_constr.anchor = SwingBox.this .pem_box
095:                                        .pcmf_getIAlign();
096:                                l_constr.weightx = 0.0001;
097:                                l_constr.weighty = 0.0001;
098:
099:                                if (SwingBox.this .pem_hvbox == IUnBox.HBOX) {
100:                                    l_constr.gridx = i;
101:                                    l_constr.insets = new Insets(0, 0, 0,
102:                                            SwingBox.this .pem_gap);
103:                                } else {
104:                                    l_constr.gridy = i;
105:                                    l_constr.insets = new Insets(0, 0,
106:                                            SwingBox.this .pem_gap, 0);
107:                                }
108:
109:                                HoSwingComponent l_peer = HoSwingBox.this 
110:                                        .pcmf_getUg2tPeer(l_comp);
111:                                if (l_peer != null) {
112:                                    int l_constraint = SwingBox.this 
113:                                            .pcmf_getConstaint(l_peer);
114:                                    switch (l_constraint) {
115:                                    case IUnBox.BOX_CONSTRAINT_FLEX:
116:                                        if (SwingBox.this .pem_hvbox == IUnBox.HBOX)
117:                                            l_constr.weightx = 1;
118:                                        else
119:                                            l_constr.weighty = 1;
120:
121:                                        break;
122:
123:                                    case IUnBox.BOX_CONSTRAINT_FLEXFILLX:
124:                                        l_constr.fill = GridBagConstraints.HORIZONTAL;
125:                                        l_constr.weightx = 1;
126:
127:                                        break;
128:
129:                                    case IUnBox.BOX_CONSTRAINT_FLEXFILLY:
130:                                        l_constr.fill = GridBagConstraints.VERTICAL;
131:                                        l_constr.weighty = 1;
132:
133:                                        break;
134:
135:                                    case IUnBox.BOX_CONSTRAINT_FLEXFILLXY:
136:                                        l_constr.fill = GridBagConstraints.BOTH;
137:                                        l_constr.weightx = 1;
138:                                        l_constr.weighty = 1;
139:
140:                                        break;
141:
142:                                    default:
143:                                    }
144:                                }
145:
146:                                this .addLayoutComponent(l_comp, l_constr);
147:                            }
148:                            ;
149:                        }
150:                        super .layoutContainer(parent);
151:                    }
152:                }
153:
154:                private UnBoxStyle pem_box = new UnBoxStyle();
155:                private ImageIcon pem_bg = null;
156:
157:                private int pem_gap = 0;
158:                private int pem_hvbox = IUnBox.HBOX;
159:                private int pem_type = IUnBox.LAYOUTED;
160:                private boolean pem_layoutNeeded = false;
161:                private HashMap pem_constraints = null;
162:
163:                public SwingBox() {
164:                    super ();
165:                    ContainerListener l_cl = new ContainerListener() {
166:                        public void componentAdded(ContainerEvent e) {
167:                            SwingBox.this .pem_layoutNeeded = true;
168:                        }
169:
170:                        public void componentRemoved(ContainerEvent e) {
171:                            SwingBox.this .pem_layoutNeeded = true;
172:                        }
173:                    };
174:
175:                    this .addContainerListener(l_cl);
176:                    this .setLayout(new BoxGridBag());
177:                }
178:
179:                public void pcmf_setContraint(UnComponent xObj, int xConstraint) {
180:                    if (this .pem_constraints == null)
181:                        this .pem_constraints = new HashMap();
182:
183:                    if (this .pem_type == IUnBox.SIMPLE) {
184:                        if (HoSwingBox.this .pcmf_contains(xObj)) {
185:                            JComponent l_comp = (JComponent) ((HoSwingComponent) xObj)
186:                                    .pcmf_getRealSwingObj();
187:                            if (xConstraint == IUnBox.BOX_CONSTRAINT_FLEXFILLX) {
188:                                l_comp.setPreferredSize(new Dimension(
189:                                        Short.MAX_VALUE, l_comp
190:                                                .getPreferredSize().height));
191:
192:                                if (this .pem_hvbox == IUnBox.VBOX)
193:                                    l_comp
194:                                            .setMaximumSize(new Dimension(
195:                                                    Short.MAX_VALUE,
196:                                                    l_comp.getPreferredSize().height));
197:                            } else if (xConstraint == IUnBox.BOX_CONSTRAINT_FLEXFILLY) {
198:                                l_comp.setPreferredSize(new Dimension(l_comp
199:                                        .getPreferredSize().width,
200:                                        Short.MAX_VALUE));
201:
202:                                if (this .pem_hvbox == IUnBox.HBOX)
203:                                    l_comp.setMaximumSize(new Dimension(l_comp
204:                                            .getPreferredSize().width,
205:                                            Short.MAX_VALUE));
206:                            } else if (xConstraint == IUnBox.BOX_CONSTRAINT_FLEXFILLXY) {
207:                                if (this .pem_hvbox == IUnBox.HBOX)
208:                                    l_comp.setMaximumSize(new Dimension(l_comp
209:                                            .getPreferredSize().width,
210:                                            Short.MAX_VALUE));
211:                                else
212:                                    l_comp
213:                                            .setMaximumSize(new Dimension(
214:                                                    Short.MAX_VALUE,
215:                                                    l_comp.getPreferredSize().height));
216:
217:                                l_comp.setPreferredSize(new Dimension(
218:                                        Short.MAX_VALUE, Short.MAX_VALUE));
219:                            } else if (xConstraint == IUnBox.BOX_CONSTRAINT_FLEX) {
220:                                int l_idx = Arrays.asList(this .getComponents())
221:                                        .indexOf(l_comp);
222:                                JLabel l_l1 = new JLabel();
223:                                JLabel l_l2 = new JLabel();
224:                                if (this .pem_hvbox == IUnBox.HBOX) {
225:                                    l_l1
226:                                            .setPreferredSize(new Dimension(
227:                                                    Short.MAX_VALUE,
228:                                                    l_l1.getPreferredSize().height));
229:                                    l_l1
230:                                            .setMaximumSize(new Dimension(
231:                                                    Short.MAX_VALUE,
232:                                                    l_l1.getPreferredSize().height));
233:
234:                                    l_l2
235:                                            .setPreferredSize(new Dimension(
236:                                                    Short.MAX_VALUE,
237:                                                    l_l2.getPreferredSize().height));
238:                                    l_l2
239:                                            .setMaximumSize(new Dimension(
240:                                                    Short.MAX_VALUE,
241:                                                    l_l2.getPreferredSize().height));
242:
243:                                    this .add(l_l1, l_idx);
244:                                    this .add(l_l2, l_idx + 2);
245:                                } else if (this .pem_hvbox == IUnBox.VBOX) {
246:                                    l_l1.setPreferredSize(new Dimension(l_l1
247:                                            .getPreferredSize().width,
248:                                            Short.MAX_VALUE));
249:                                    l_l1.setMaximumSize(new Dimension(l_l1
250:                                            .getPreferredSize().width,
251:                                            Short.MAX_VALUE));
252:
253:                                    l_l2.setPreferredSize(new Dimension(l_l2
254:                                            .getPreferredSize().width,
255:                                            Short.MAX_VALUE));
256:                                    l_l2.setMaximumSize(new Dimension(l_l2
257:                                            .getPreferredSize().width,
258:                                            Short.MAX_VALUE));
259:
260:                                    this .add(l_l1, l_idx);
261:                                    this .add(l_l2, l_idx + 2);
262:                                }
263:                            }
264:                        } else
265:                            KeLog
266:                                    .pcmf_log(
267:                                            "ug2t",
268:                                            "can not set constraint, component not found",
269:                                            this , KeLog.MESSAGE);
270:                    } else {
271:                        if (HoSwingBox.this .pcmf_contains(xObj))
272:                            this .pem_constraints.put(xObj, new Integer(
273:                                    xConstraint));
274:                        else
275:                            KeLog
276:                                    .pcmf_log(
277:                                            "ug2t",
278:                                            "can not set constraint, component not found",
279:                                            this , KeLog.MESSAGE);
280:                    }
281:                };
282:
283:                public int pcmf_getConstaint(UnComponent xObj) {
284:                    if (this .pem_constraints == null)
285:                        return (IUnBox.BOX_CONSTRAINT_NONE);
286:
287:                    Object l_obj = this .pem_constraints.get(xObj);
288:                    if (l_obj == null)
289:                        return (IUnBox.BOX_CONSTRAINT_NONE);
290:                    else
291:                        return (((Integer) l_obj).intValue());
292:                }
293:
294:                public void pcmf_checkConstraints() {
295:                    if (this .pem_constraints == null)
296:                        return;
297:
298:                    Iterator l_it = HoSwingBox.this .pcmf_getSubIterator();
299:                    HashMap l_newConstraints = new HashMap();
300:                    while (l_it.hasNext()) {
301:                        Object l_obj = l_it.next();
302:                        Object l_constraint = this .pem_constraints.get(l_obj);
303:                        if (l_constraint != null)
304:                            l_newConstraints.put(l_obj, l_constraint);
305:                    }
306:                    this .pem_constraints = l_newConstraints;
307:                }
308:
309:                public void pcmf_setGap(int xGap) {
310:                    this .pem_gap = xGap;
311:                }
312:
313:                public void pcmf_setBoxHVType(int xType) {
314:                    this .pem_hvbox = xType;
315:                }
316:
317:                public void pcmf_setBoxType(int xType) {
318:                    this .pem_type = xType;
319:                    if (this .pem_type == IUnBox.SIMPLE)
320:                        this 
321:                                .setLayout(this .pem_hvbox == IUnBox.HBOX ? new BoxLayout(
322:                                        this , BoxLayout.X_AXIS)
323:                                        : new BoxLayout(this , BoxLayout.Y_AXIS));
324:                    else if (this .pem_type == IUnBox.LAYOUTED)
325:                        this .setLayout(new BoxGridBag());
326:                    else
327:                        this .setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0));
328:                }
329:
330:                public Insets getInsets() {
331:                    int l_lo = this .pem_box.pcm_marginLeft
332:                            + this .pem_box.pcm_paddingLeft
333:                            + (this .pem_box.pcm_bLeft != null ? this .pem_box.pcm_bLeft.pcm_width
334:                                    : 0);
335:                    int l_ro = this .pem_box.pcm_marginRight
336:                            + this .pem_box.pcm_paddingRight
337:                            + (this .pem_box.pcm_bRight != null ? this .pem_box.pcm_bRight.pcm_width
338:                                    : 0);
339:                    int l_bo = this .pem_box.pcm_marginBottom
340:                            + this .pem_box.pcm_paddingBottom
341:                            + (this .pem_box.pcm_bBottom != null ? this .pem_box.pcm_bBottom.pcm_width
342:                                    : 0);
343:                    int l_to = this .pem_box.pcm_marginTop
344:                            + this .pem_box.pcm_paddingTop
345:                            + (this .pem_box.pcm_bTop != null ? this .pem_box.pcm_bTop.pcm_width
346:                                    : 0);
347:
348:                    if (l_lo == 0 && l_ro == 0 && l_bo == 0 && l_to == 0)
349:                        return (super .getInsets());
350:                    else
351:                        return new Insets(l_to, l_lo, l_bo, l_ro);
352:                }
353:
354:                public void pcmf_setBorder(int xDir, String xCol, int xWidth,
355:                        int xStyle) {
356:                    this .pem_box.pcmf_setBorder(xDir, xCol, xWidth, xStyle);
357:                }
358:
359:                public void pcmf_setPadding(int xDir, int xWidth) {
360:                    this .pem_box.pcmf_setPadding(xDir, xWidth);
361:                }
362:
363:                public void pcmf_setMargin(int xDir, int xWidth) {
364:                    this .pem_box.pcmf_setMargin(xDir, xWidth);
365:                }
366:
367:                public void pcmf_setBgImage(IUnImage xImg) {
368:                    this .pem_bg = (ImageIcon) ((HoSwingImage) xImg)
369:                            .pcmf_getIcon();
370:                }
371:
372:                public void pcmf_setAlign(String xAlign) {
373:                    this .pem_box.pcmf_setAlign(xAlign);
374:                    if (this .pem_type == IUnBox.SINGLE) {
375:                        if (xAlign.toUpperCase().endsWith("WEST"))
376:                            this 
377:                                    .setLayout(new FlowLayout(FlowLayout.LEFT,
378:                                            0, 0));
379:                        else if (xAlign.toUpperCase().endsWith("EAST"))
380:                            this .setLayout(new FlowLayout(FlowLayout.RIGHT, 0,
381:                                    0));
382:                        else
383:                            this .setLayout(new FlowLayout(FlowLayout.CENTER, 0,
384:                                    0));
385:                    }
386:                }
387:
388:                protected void paintComponent(Graphics g) {
389:                    if (this .pem_bg != null) {
390:                        int hi = this .getHeight();
391:                        int wi = this .getWidth();
392:                        if (hi != 0 && wi != 0) {
393:                            Image l_img = this .pem_bg.getImage()
394:                                    .getScaledInstance(wi, hi,
395:                                            Image.SCALE_DEFAULT);
396:                            new ImageIcon(l_img).paintIcon(this , g, 0, 0);
397:                        }
398:                    } else
399:                        super .paintComponent(g);
400:                }
401:
402:                public void paint(Graphics g) {
403:                    super .paintComponent(g);
404:                    Graphics l_og = g;
405:
406:                    try {
407:                        g = g.create(this .pem_box.pcm_marginLeft,
408:                                this .pem_box.pcm_marginTop, this .getWidth()
409:                                        - this .pem_box.pcm_marginRight
410:                                        - this .pem_box.pcm_marginLeft, this 
411:                                        .getHeight()
412:                                        - this .pem_box.pcm_marginTop
413:                                        - this .pem_box.pcm_marginBottom);
414:
415:                        int l_x = this .getWidth()
416:                                - this .pem_box.pcm_marginRight
417:                                - this .pem_box.pcm_marginLeft - 1;
418:                        int l_y = this .getHeight()
419:                                - this .pem_box.pcm_marginBottom
420:                                - this .pem_box.pcm_marginTop - 1;
421:
422:                        if (this .pem_box.pcm_bBottom != null) {
423:                            int l_red1 = 0;
424:                            int l_red2 = 0;
425:                            g
426:                                    .setColor(HoSwingComponent
427:                                            .pcmf_createColor(this .pem_box.pcm_bBottom.pcm_color));
428:                            for (int i = 0; i < this .pem_box.pcm_bBottom.pcm_width; i++) {
429:                                if (this .pem_box.pcm_bBottom.pcm_style == IUnBox.BORDER_DOUBLE) {
430:                                    int l_th = this .pem_box.pcm_bBottom.pcm_width / 3;
431:                                    if (i >= l_th && i < l_th * 2)
432:                                        g.setColor(this .getBackground());
433:                                }
434:
435:                                g
436:                                        .drawLine(
437:                                                this .pem_box.pcm_bLeft != null ? l_red1++
438:                                                        : 0,
439:                                                l_y - i,
440:                                                this .pem_box.pcm_bRight != null ? l_x
441:                                                        - l_red2++
442:                                                        : l_x, l_y - i);
443:                                g
444:                                        .setColor(HoSwingComponent
445:                                                .pcmf_createColor(this .pem_box.pcm_bBottom.pcm_color));
446:                            }
447:                            switch (this .pem_box.pcm_bBottom.pcm_style) {
448:                            case IUnBox.BORDER_DOTTED:
449:                                g.setColor(this .getBackground());
450:                                for (int dot = l_red1 << 1; dot < l_x
451:                                        - (l_red2 << 1); dot += this .pem_box.pcm_bBottom.pcm_width * 2)
452:                                    g
453:                                            .fillRect(
454:                                                    dot,
455:                                                    l_y
456:                                                            - this .pem_box.pcm_bBottom.pcm_width
457:                                                            + 1,
458:                                                    this .pem_box.pcm_bBottom.pcm_width,
459:                                                    this .pem_box.pcm_bBottom.pcm_width);
460:                                break;
461:                            case IUnBox.BORDER_DASHED:
462:                                g.setColor(this .getBackground());
463:                                for (int dot = l_red1 << 1; dot < l_x
464:                                        - (l_red2 << 1); dot += this .pem_box.pcm_bBottom.pcm_width * 3)
465:                                    g
466:                                            .fillRect(
467:                                                    dot,
468:                                                    l_y
469:                                                            - this .pem_box.pcm_bBottom.pcm_width
470:                                                            + 1,
471:                                                    this .pem_box.pcm_bBottom.pcm_width,
472:                                                    this .pem_box.pcm_bBottom.pcm_width);
473:                            }
474:                        }
475:                        if (this .pem_box.pcm_bTop != null) {
476:                            int l_red1 = 0;
477:                            int l_red2 = 0;
478:                            g
479:                                    .setColor(HoSwingComponent
480:                                            .pcmf_createColor(this .pem_box.pcm_bTop.pcm_color));
481:                            for (int i = 0; i < this .pem_box.pcm_bTop.pcm_width; i++) {
482:                                if (this .pem_box.pcm_bTop.pcm_style == IUnBox.BORDER_DOUBLE) {
483:                                    int l_th = this .pem_box.pcm_bTop.pcm_width / 3;
484:                                    if (i >= l_th && i < l_th * 2)
485:                                        g.setColor(this .getBackground());
486:                                }
487:                                g
488:                                        .drawLine(
489:                                                this .pem_box.pcm_bLeft != null ? l_red1++
490:                                                        : 0,
491:                                                i,
492:                                                this .pem_box.pcm_bRight != null ? l_x
493:                                                        - l_red2++
494:                                                        : l_x, i);
495:                                g
496:                                        .setColor(HoSwingComponent
497:                                                .pcmf_createColor(this .pem_box.pcm_bTop.pcm_color));
498:                            }
499:                            switch (this .pem_box.pcm_bTop.pcm_style) {
500:                            case IUnBox.BORDER_DOTTED:
501:                                g.setColor(this .getBackground());
502:                                for (int dot = l_red1 << 1; dot < l_x
503:                                        - (l_red2 << 1); dot += this .pem_box.pcm_bTop.pcm_width * 2)
504:                                    g.fillRect(dot, 0,
505:                                            this .pem_box.pcm_bTop.pcm_width,
506:                                            this .pem_box.pcm_bTop.pcm_width);
507:                                break;
508:                            case IUnBox.BORDER_DASHED:
509:                                g.setColor(this .getBackground());
510:                                for (int dot = l_red1 << 1; dot < l_x
511:                                        - (l_red2 << 1); dot += this .pem_box.pcm_bTop.pcm_width * 3)
512:                                    g.fillRect(dot, 0,
513:                                            this .pem_box.pcm_bTop.pcm_width,
514:                                            this .pem_box.pcm_bTop.pcm_width);
515:                            }
516:                        }
517:                        if (this .pem_box.pcm_bLeft != null) {
518:                            g
519:                                    .setColor(HoSwingComponent
520:                                            .pcmf_createColor(this .pem_box.pcm_bLeft.pcm_color));
521:                            int l_red1 = 0;
522:                            int l_red2 = 0;
523:                            for (int i = 0; i < this .pem_box.pcm_bLeft.pcm_width; i++) {
524:                                if (this .pem_box.pcm_bLeft.pcm_style == IUnBox.BORDER_DOUBLE) {
525:                                    int l_th = this .pem_box.pcm_bLeft.pcm_width / 3;
526:                                    if (i >= l_th && i < l_th * 2)
527:                                        g.setColor(this .getBackground());
528:                                }
529:                                g
530:                                        .drawLine(
531:                                                i,
532:                                                this .pem_box.pcm_bTop != null ? l_red1++
533:                                                        : 0,
534:                                                i,
535:                                                this .pem_box.pcm_bBottom != null ? l_y
536:                                                        - l_red2++
537:                                                        : l_y);
538:                                g
539:                                        .setColor(HoSwingComponent
540:                                                .pcmf_createColor(this .pem_box.pcm_bLeft.pcm_color));
541:                            }
542:                            switch (this .pem_box.pcm_bLeft.pcm_style) {
543:                            case IUnBox.BORDER_DOTTED:
544:                                g.setColor(this .getBackground());
545:                                for (int dot = l_red1 << 1; dot < l_y
546:                                        - (l_red2 << 1); dot += this .pem_box.pcm_bLeft.pcm_width * 2)
547:                                    g.fillRect(0, dot,
548:                                            this .pem_box.pcm_bLeft.pcm_width,
549:                                            this .pem_box.pcm_bLeft.pcm_width);
550:                                break;
551:                            case IUnBox.BORDER_DASHED:
552:                                g.setColor(this .getBackground());
553:                                for (int dot = l_red1 << 1; dot < l_y
554:                                        - (l_red2 << 1); dot += this .pem_box.pcm_bLeft.pcm_width * 3)
555:                                    g.fillRect(0, dot,
556:                                            this .pem_box.pcm_bLeft.pcm_width,
557:                                            this .pem_box.pcm_bLeft.pcm_width);
558:                            }
559:                        }
560:                        if (this .pem_box.pcm_bRight != null) {
561:                            int l_red1 = 0;
562:                            int l_red2 = 0;
563:                            g
564:                                    .setColor(HoSwingComponent
565:                                            .pcmf_createColor(this .pem_box.pcm_bRight.pcm_color));
566:                            for (int i = 0; i < this .pem_box.pcm_bRight.pcm_width; i++) {
567:                                if (this .pem_box.pcm_bRight.pcm_style == IUnBox.BORDER_DOUBLE) {
568:                                    int l_th = this .pem_box.pcm_bRight.pcm_width / 3;
569:                                    if (i >= l_th && i < l_th * 2)
570:                                        g.setColor(this .getBackground());
571:                                }
572:                                g
573:                                        .drawLine(
574:                                                l_x - i,
575:                                                this .pem_box.pcm_bTop != null ? l_red1++
576:                                                        : 0,
577:                                                l_x - i,
578:                                                this .pem_box.pcm_bBottom != null ? l_y
579:                                                        - l_red2++
580:                                                        : l_y);
581:                                g
582:                                        .setColor(HoSwingComponent
583:                                                .pcmf_createColor(this .pem_box.pcm_bRight.pcm_color));
584:                            }
585:                            switch (this .pem_box.pcm_bRight.pcm_style) {
586:                            case IUnBox.BORDER_DOTTED:
587:                                g.setColor(this .getBackground());
588:                                for (int dot = l_red1 << 1; dot < l_y
589:                                        - (l_red2 << 1); dot += this .pem_box.pcm_bRight.pcm_width * 2)
590:                                    g.fillRect(l_x
591:                                            - this .pem_box.pcm_bRight.pcm_width
592:                                            + 1, dot,
593:                                            this .pem_box.pcm_bRight.pcm_width,
594:                                            this .pem_box.pcm_bRight.pcm_width);
595:                                break;
596:                            case IUnBox.BORDER_DASHED:
597:                                g.setColor(this .getBackground());
598:                                for (int dot = l_red1 << 1; dot < l_y
599:                                        - (l_red2 << 1); dot += this .pem_box.pcm_bRight.pcm_width * 3)
600:                                    g.fillRect(l_x
601:                                            - this .pem_box.pcm_bRight.pcm_width
602:                                            + 1, dot,
603:                                            this .pem_box.pcm_bRight.pcm_width,
604:                                            this .pem_box.pcm_bRight.pcm_width);
605:                            }
606:                        }
607:                    } catch (Exception e) {
608:                        KeLog.pcmf_log("ug2t", "error painting box", this ,
609:                                KeLog.ERROR);
610:                    }
611:
612:                    super .paintChildren(l_og);
613:                    super .paintBorder(g);
614:
615:                    // @@
616:
617:                }
618:
619:                public Component add(Component xComp) {
620:                    if (this .pem_type == IUnBox.SIMPLE) {
621:                        int l_align = this .pem_box.pcmf_getIAlign();
622:                        switch (l_align) {
623:                        case GridBagConstraints.CENTER:
624:                            ((JComponent) xComp)
625:                                    .setAlignmentX(JComponent.CENTER_ALIGNMENT);
626:                            ((JComponent) xComp)
627:                                    .setAlignmentY(JComponent.CENTER_ALIGNMENT);
628:                            break;
629:                        case GridBagConstraints.WEST:
630:                            ((JComponent) xComp)
631:                                    .setAlignmentX(JComponent.LEFT_ALIGNMENT);
632:                            ((JComponent) xComp)
633:                                    .setAlignmentY(JComponent.CENTER_ALIGNMENT);
634:                            break;
635:                        case GridBagConstraints.EAST:
636:                            ((JComponent) xComp)
637:                                    .setAlignmentX(JComponent.RIGHT_ALIGNMENT);
638:                            ((JComponent) xComp)
639:                                    .setAlignmentY(JComponent.CENTER_ALIGNMENT);
640:                            break;
641:                        case GridBagConstraints.NORTH:
642:                            ((JComponent) xComp)
643:                                    .setAlignmentY(JComponent.TOP_ALIGNMENT);
644:                            ((JComponent) xComp)
645:                                    .setAlignmentX(JComponent.CENTER_ALIGNMENT);
646:                            break;
647:                        case GridBagConstraints.SOUTH:
648:                            ((JComponent) xComp)
649:                                    .setAlignmentY(JComponent.BOTTOM_ALIGNMENT);
650:                            ((JComponent) xComp)
651:                                    .setAlignmentX(JComponent.CENTER_ALIGNMENT);
652:                            break;
653:                        case GridBagConstraints.NORTHEAST:
654:                            ((JComponent) xComp)
655:                                    .setAlignmentY(JComponent.TOP_ALIGNMENT);
656:                            ((JComponent) xComp)
657:                                    .setAlignmentX(JComponent.RIGHT_ALIGNMENT);
658:                            break;
659:                        case GridBagConstraints.NORTHWEST:
660:                            ((JComponent) xComp)
661:                                    .setAlignmentY(JComponent.TOP_ALIGNMENT);
662:                            ((JComponent) xComp)
663:                                    .setAlignmentX(JComponent.LEFT_ALIGNMENT);
664:                            break;
665:                        case GridBagConstraints.SOUTHEAST:
666:                            ((JComponent) xComp)
667:                                    .setAlignmentX(JComponent.RIGHT_ALIGNMENT);
668:                            ((JComponent) xComp)
669:                                    .setAlignmentY(JComponent.BOTTOM_ALIGNMENT);
670:                            break;
671:                        case GridBagConstraints.SOUTHWEST:
672:                            ((JComponent) xComp)
673:                                    .setAlignmentX(JComponent.LEFT_ALIGNMENT);
674:                            ((JComponent) xComp)
675:                                    .setAlignmentY(JComponent.BOTTOM_ALIGNMENT);
676:                        }
677:                        super .add(xComp);
678:                        if (this .pem_hvbox == IUnBox.HBOX)
679:                            super .add(Box.createRigidArea(new Dimension(
680:                                    pem_gap, 1)));
681:                        else
682:                            super .add(Box.createRigidArea(new Dimension(1,
683:                                    pem_gap)));
684:                    } else
685:                        super .add(xComp);
686:
687:                    return (xComp);
688:                }
689:
690:                public void remove(Component comp) {
691:                    int l_idx = Arrays.asList(this .getComponents()).indexOf(
692:                            comp);
693:                    if (l_idx != -1) {
694:                        super .remove(l_idx);
695:                        if (this .pem_type == IUnBox.SIMPLE)
696:                            super .remove(l_idx);
697:                    }
698:
699:                    super .remove(comp);
700:                }
701:            }
702:
703:            private SwingBox pem_swingObj = new SwingBox();
704:
705:            public HoSwingBox(String xName, IUnApplication xAppl,
706:                    IHoSession xSess) throws Exception {
707:                super (xName, xAppl, xSess);
708:                this .pdm_realSwingCmp = this .pem_swingObj;
709:            }
710:
711:            public HoSwingBox(String xName, IUnApplication xAppl)
712:                    throws Exception {
713:                super (xName, xAppl);
714:                this .pdm_realSwingCmp = this .pem_swingObj;
715:            }
716:
717:            public void pcmf_setBorder(int xDir, String xCol, int xWidth,
718:                    int xStyle) {
719:                this .pem_swingObj.pcmf_setBorder(xDir, xCol, xWidth, xStyle);
720:            }
721:
722:            public void pcmf_setBoxAlign(String xAlign) {
723:                this .pem_swingObj.pcmf_setAlign(xAlign);
724:            }
725:
726:            public void pcmf_setPadding(int xDir, int xWidth) {
727:                this .pem_swingObj.pcmf_setPadding(xDir, xWidth);
728:            }
729:
730:            public void pcmf_setMargin(int xDir, int xWidth) {
731:                this .pem_swingObj.pcmf_setMargin(xDir, xWidth);
732:            }
733:
734:            public void pcmf_setBgImage(IUnImage xImg) {
735:                this .pem_swingObj.pcmf_setBgImage(xImg);
736:            }
737:
738:            public void pcmf_setGap(int xGap) {
739:                this .pem_swingObj.pcmf_setGap(xGap);
740:            }
741:
742:            public void pcmf_setBoxHVType(int xType) {
743:                this .pem_swingObj.pcmf_setBoxHVType(xType);
744:            }
745:
746:            public void pcmf_setBoxType(int xType) {
747:                this .pem_swingObj.pcmf_setBoxType(xType);
748:            }
749:
750:            public void pcmf_addWidget(String xName, UnComponent xObj) {
751:                this .pcmf_addNode(xName, xObj);
752:            };
753:
754:            public UnComponent pcmf_removeWidget(String xName) {
755:                return ((UnComponent) this .pcmf_removeNode(xName));
756:            };
757:
758:            public UnComponent pcmf_removeWidget(UnComponent xObj) {
759:                return ((UnComponent) this .pcmf_removeNode(xObj));
760:            };
761:
762:            public UnComponent pcmf_getWidget(String xName) {
763:                return ((UnComponent) this .pcmf_getSubNode(xName));
764:            };
765:
766:            public boolean pcmf_contains(UnComponent xObj) {
767:                return (super .pcmf_contains(xObj));
768:            };
769:
770:            // New methods (delegates only) due to interface harmonisation
771:            public void pcmf_addWidget(String xName, IUnComponent xObj) {
772:                this .pcmf_addWidget(xName, (UnComponent) xObj);
773:            }
774:
775:            public boolean pcmf_contains(IUnComponent xObj) {
776:                return (super .pcmf_contains((UnComponent) xObj));
777:            }
778:
779:            public IUnComponent pcmf_getWidgetbyName(String xName) {
780:                return (this .pcmf_getWidget(xName));
781:            }
782:
783:            public IUnComponent pcmf_removeWidget(IUnComponent xObj) {
784:                return (this .pcmf_removeWidget((UnComponent) xObj));
785:            }
786:
787:            public void pcmf_setContraint(UnComponent xObj, int xConstraint) {
788:                this .pem_swingObj.pcmf_setContraint(xObj, xConstraint);
789:            };
790:
791:            public int pcmf_getConstaint(UnComponent xObj) {
792:                return (this .pem_swingObj.pcmf_getConstaint(xObj));
793:            }
794:
795:            public void pcmf_checkConstraints() {
796:                this .pem_swingObj.pcmf_checkConstraints();
797:            }
798:
799:            public KeTreeNode pcmf_addNode(String xName, KeTreeNode xNode) {
800:                if (xNode instanceof  HoSwingMenu)
801:                    this .pem_swingObj
802:                            .add(((HoSwingComponent) xNode).pdm_realSwingCmp);
803:
804:                return (super .pcmf_addNode(xName, xNode));
805:            };
806:
807:            public KeTreeNode pcmf_addNode(String xName, KeTreeNode xNode,
808:                    int xIdx) {
809:                if (xNode instanceof  HoSwingMenu)
810:                    this .pem_swingObj.add(
811:                            ((HoSwingComponent) xNode).pdm_realSwingCmp, xIdx);
812:
813:                return (super .pcmf_addNode(xName, xNode, xIdx));
814:            };
815:
816:            public KeTreeElement pcmf_addElement(String xName,
817:                    KeTreeElement xNode) {
818:                if (xNode instanceof  HoSwingMenu)
819:                    this .pem_swingObj
820:                            .add(((HoSwingComponent) xNode).pdm_realSwingCmp);
821:
822:                return (super.pcmf_addElement(xName, xNode));
823:            };
824:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.