Source Code Cross Referenced for HtmlLayer.java in  » J2EE » Sofia » com » salmonllc » html » 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 » Sofia » com.salmonllc.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        //** Copyright Statement ***************************************************
002:        //The Salmon Open Framework for Internet Applications (SOFIA)
003:        // Copyright (C) 1999 - 2002, Salmon LLC
004:        //
005:        // This program is free software; you can redistribute it and/or
006:        // modify it under the terms of the GNU General Public License version 2
007:        // as published by the Free Software Foundation;
008:        // 
009:        // This program is distributed in the hope that it will be useful,
010:        // but WITHOUT ANY WARRANTY; without even the implied warranty of
011:        // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
012:        // GNU General Public License for more details.
013:        // 
014:        // You should have received a copy of the GNU General Public License
015:        // along with this program; if not, write to the Free Software
016:        // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
017:        // 
018:        // For more information please visit http://www.salmonllc.com
019:        //** End Copyright Statement ***************************************************
020:        package com.salmonllc.html;
021:
022:        /**
023:         * Implements a div tag or layer tag in Html.
024:         */
025:        public class HtmlLayer extends HtmlContainer {
026:            private int _containerWidth = -1;
027:            private int _containerHeight = -1;
028:            private int _containerTop = -9999;
029:            private int _containerLeft = -9999;
030:            private int _browserType;
031:            private int _browserVersion;
032:            private HtmlStyle _style;
033:            private boolean _useLayerTag = false, _enableClip = false;
034:            private String _position = "absolute";
035:            private boolean _useBuffer = false;
036:
037:            /**
038:             * HtmlLayer constructor.
039:             * @param name java.lang.String
040:             * @param p com.salmonllc.html.HtmlPage
041:             */
042:            public HtmlLayer(String name, HtmlPage p) {
043:                super (name, p);
044:                _browserType = p.getBrowserType();
045:                _browserVersion = p.getBrowserVersion();
046:
047:            }
048:
049:            /**
050:             * HtmlLayer constructor.
051:             * @param name java.lang.String
052:             * @param style com.salmonllc.html.HtmlStyle
053:             * @param p com.salmonllc.html.HtmlPage
054:             */
055:            public HtmlLayer(String name, HtmlStyle style, HtmlPage p) {
056:                super (style != null ? style.getStyleName() : name, p);
057:                _style = style;
058:                _browserType = p.getBrowserType();
059:                _browserVersion = p.getBrowserVersion();
060:                String sStyle = _style.getStyle();
061:                int topIndex = sStyle.toUpperCase().indexOf("TOP");
062:                int leftIndex = sStyle.toUpperCase().indexOf("LEFT");
063:                int widthIndex = sStyle.toUpperCase().indexOf("WIDTH");
064:                int heightIndex = sStyle.toUpperCase().indexOf("HEIGHT");
065:                int positionIndex = sStyle.toUpperCase().indexOf("POSITION");
066:                if (topIndex >= 0) {
067:                    String sTop = sStyle.substring(topIndex);
068:                    int colonIndex = sTop.indexOf(":");
069:                    int semicolonIndex = sTop.indexOf(";");
070:                    String sValue = sTop.substring(colonIndex + 1,
071:                            semicolonIndex).trim();
072:                    try {
073:                        _containerTop = Integer.parseInt(sValue);
074:                    } catch (Exception e) {
075:                        ;
076:                    }
077:                }
078:                if (leftIndex >= 0) {
079:                    String sLeft = sStyle.substring(leftIndex);
080:                    int colonIndex = sLeft.indexOf(":");
081:                    int semicolonIndex = sLeft.indexOf(";");
082:                    String sValue = sLeft.substring(colonIndex + 1,
083:                            semicolonIndex).trim();
084:                    try {
085:                        _containerLeft = Integer.parseInt(sValue);
086:                    } catch (Exception e) {
087:                        ;
088:                    }
089:                }
090:                if (widthIndex >= 0) {
091:                    String sWidth = sStyle.substring(widthIndex);
092:                    int colonIndex = sWidth.indexOf(":");
093:                    int semicolonIndex = sWidth.indexOf(";");
094:                    String sValue = sWidth.substring(colonIndex + 1,
095:                            semicolonIndex).trim();
096:                    try {
097:                        _containerWidth = Integer.parseInt(sValue);
098:                    } catch (Exception e) {
099:                        ;
100:                    }
101:                }
102:                if (heightIndex >= 0) {
103:                    String sHeight = sStyle.substring(heightIndex);
104:                    int colonIndex = sHeight.indexOf(":");
105:                    int semicolonIndex = sHeight.indexOf(";");
106:                    String sValue = sHeight.substring(colonIndex + 1,
107:                            semicolonIndex).trim();
108:                    try {
109:                        _containerHeight = Integer.parseInt(sValue);
110:                    } catch (Exception e) {
111:                        ;
112:                    }
113:                }
114:                if (positionIndex >= 0) {
115:                    String sPosition = sStyle.substring(positionIndex);
116:                    int colonIndex = sPosition.indexOf(":");
117:                    int semicolonIndex = sPosition.indexOf(";");
118:                    _position = sPosition.substring(colonIndex + 1,
119:                            semicolonIndex).trim();
120:                }
121:
122:            }
123:
124:            public void generateHTML(java.io.PrintWriter p, int rowNo)
125:                    throws Exception {
126:                if (_browserType != HtmlPageBase.BROWSER_MICROSOFT
127:                        && _browserType != HtmlPageBase.BROWSER_NETSCAPE)
128:                    return;
129:                if (_browserVersion < 4)
130:                    return;
131:
132:                if (!getVisible())
133:                    return;
134:                if (_center)
135:                    p.print("<CENTER>");
136:
137:                String layerHeading = "";
138:                String attributes = "";
139:                String sName = getFullName();
140:                if (_browserType == HtmlPage.BROWSER_MICROSOFT && _useBuffer) {
141:                    p.println("<IFRAME STYLE=\"display:none\" NAME=\"" + sName
142:                            + "BUFFER\"></IFRAME>");
143:                }
144:                boolean styleProvided = false;
145:                if (_style != null && _style.getStyleName() != null
146:                        && !_style.getStyleName().trim().equals("")) {
147:                    styleProvided = true;
148:                }
149:                layerHeading = "<DIV id=\"" + sName + "\"";
150:                if (!styleProvided)
151:                    attributes = " STYLE=\"position:" + _position + ";";
152:
153:                if (_useLayerTag && _browserType == HtmlPage.BROWSER_NETSCAPE) {
154:                    layerHeading = "<LAYER NAME=\"" + sName + "\"";
155:                    attributes = "";
156:                }
157:                if (_containerWidth > -1) {
158:                    if (!_useLayerTag && !styleProvided)
159:                        attributes += "width:" + _containerWidth + "px;";
160:                    else if (_useLayerTag)
161:                        attributes += " WIDTH=\"" + _containerWidth + "\"";
162:                    //		if (_sizeOption == SIZE_PERCENT)
163:                    //		{
164:                    //			tableHeading += "%";
165:                    //		}
166:                    //		tableHeading += "\"";
167:                }
168:                if (_containerHeight > -1) {
169:                    if (!_useLayerTag && !styleProvided)
170:                        attributes += "height:" + _containerHeight + "px;";
171:                    else if (_useLayerTag
172:                            && _browserType == HtmlPage.BROWSER_NETSCAPE)
173:                        attributes += " HEIGHT=\"" + _containerHeight + "\"";
174:                }
175:                if (_containerTop > -9999) {
176:                    if (!_useLayerTag && !styleProvided)
177:                        attributes += "top:" + _containerTop + "px;";
178:                    else if (_useLayerTag
179:                            && _browserType == HtmlPage.BROWSER_NETSCAPE)
180:                        attributes += " TOP=\"" + _containerTop + "\"";
181:                }
182:                if (_containerLeft > -9999) {
183:                    if (!_useLayerTag && !styleProvided)
184:                        attributes += "left:" + _containerLeft + "px;";
185:                    else if (_useLayerTag
186:                            && _browserType == HtmlPage.BROWSER_NETSCAPE)
187:                        attributes += " LEFT=\"" + _containerLeft + "\"";
188:                }
189:                if (_enableClip && _containerHeight > -1
190:                        && _containerWidth > -1) {
191:                    if (!_useLayerTag && !styleProvided)
192:                        attributes += "clip:rect(0px," + _containerWidth
193:                                + "px," + _containerHeight + "px,0px);";
194:                }
195:                if (!_useLayerTag && !styleProvided)
196:                    attributes += "\"";
197:                layerHeading += attributes;
198:
199:                /*	if (_bgColor != null)
200:                 {
201:                 if (!_bgColor.equals(""))
202:                 {
203:                 tableHeading += " BGCOLOR=\"" + _bgColor + "\"";
204:                 }
205:                 }*/
206:                /*	if (_align != null)
207:                 {
208:                 if (_align.equals(ALIGN_LEFT) || _align.equals(ALIGN_RIGHT) || _align.equals(ALIGN_CENTER))
209:                 tableHeading += " align=\"" + _align + "\"";
210:                 }*/
211:                layerHeading += ">";
212:                p.println(layerHeading);
213:                super .generateHTML(p, rowNo);
214:
215:                if (_browserType == HtmlPageBase.BROWSER_MICROSOFT
216:                        || !_useLayerTag)
217:                    p.print("</DIV>");
218:                else
219:                    p.print("</LAYER>");
220:
221:                /*	if (_containerHeight>-1 || _containerWidth>-1 || _containerLeft>-9999 || _containerTop>-1) {
222:                 p.print("<SCRIPT LANGUAGE=\"JavaScript1.2\">");
223:                 p.print("function "+getName()+"Draw() {");
224:                 if (_containerHeight>-1)
225:                 p.print("document."+getName()+".height="+_containerHeight+";");
226:                 if (_containerWidth>-1)
227:                 p.print("document."+getName()+".width="+_containerWidth+";");
228:                 if (_containerTop>-9999)
229:                 p.print("document."+getName()+".top="+_containerTop+";");
230:                 if (_containerLeft>-9999)
231:                 p.print("document."+getName()+".left="+_containerLeft+";");
232:                 p.print("};");
233:                 //p.print("setTimeout(\""+getName()+"Draw();\",100);");
234:                 p.print("</SCRIPT>");
235:                 }*/
236:                if (_center)
237:                    p.print("</CENTER>");
238:                p.println("");
239:            }
240:
241:            public void generateHTML(java.io.PrintWriter p, int rowStart,
242:                    int rowEnd) throws Exception {
243:                if (_browserType != HtmlPageBase.BROWSER_MICROSOFT
244:                        && _browserType != HtmlPageBase.BROWSER_NETSCAPE)
245:                    return;
246:                if (_browserVersion < 4)
247:                    return;
248:
249:                if (!getVisible())
250:                    return;
251:                if (_center)
252:                    p.print("<CENTER>");
253:
254:                String layerHeading = "";
255:                String attributes = "";
256:                String sName = getFullName();
257:                if (_browserType == HtmlPage.BROWSER_MICROSOFT && _useBuffer) {
258:                    p.println("<IFRAME STYLE=\"display:none\" NAME=\"" + sName
259:                            + "BUFFER\"></IFRAME>");
260:                }
261:                boolean styleProvided = false;
262:                if (_style != null && _style.getStyleName() != null
263:                        && !_style.getStyleName().trim().equals("")) {
264:                    styleProvided = true;
265:                }
266:                layerHeading = "<DIV id=\"" + sName + "\"";
267:                if (!styleProvided)
268:                    attributes = " STYLE=\"position:" + _position + ";";
269:
270:                if (_useLayerTag && _browserType == HtmlPage.BROWSER_NETSCAPE) {
271:                    layerHeading = "<LAYER NAME=\"" + sName + "\"";
272:                    attributes = "";
273:                }
274:                if (_containerWidth > -1) {
275:                    if (!_useLayerTag && !styleProvided)
276:                        attributes += "width:" + _containerWidth + "px;";
277:                    else if (_useLayerTag)
278:                        attributes += " WIDTH=\"" + _containerWidth + "\"";
279:                    //		if (_sizeOption == SIZE_PERCENT)
280:                    //		{
281:                    //			tableHeading += "%";
282:                    //		}
283:                    //		tableHeading += "\"";
284:                }
285:                if (_containerHeight > -1) {
286:                    if (!_useLayerTag && !styleProvided)
287:                        attributes += "height:" + _containerHeight + "px;";
288:                    else if (_useLayerTag
289:                            && _browserType == HtmlPage.BROWSER_NETSCAPE)
290:                        attributes += " HEIGHT=\"" + _containerHeight + "\"";
291:                }
292:                if (_containerTop > -9999) {
293:                    if (!_useLayerTag && !styleProvided)
294:                        attributes += "top:" + _containerTop + "px;";
295:                    else if (_useLayerTag
296:                            && _browserType == HtmlPage.BROWSER_NETSCAPE)
297:                        attributes += " TOP=\"" + _containerTop + "\"";
298:                }
299:                if (_containerLeft > -9999) {
300:                    if (!_useLayerTag && !styleProvided)
301:                        attributes += "left:" + _containerLeft + "px;";
302:                    else if (_useLayerTag
303:                            && _browserType == HtmlPage.BROWSER_NETSCAPE)
304:                        attributes += " LEFT=\"" + _containerLeft + "\"";
305:                }
306:                if (_enableClip && _containerHeight > -1
307:                        && _containerWidth > -1) {
308:                    if (!_useLayerTag && !styleProvided)
309:                        attributes += "clip:rect(0px," + _containerWidth
310:                                + "px," + _containerHeight + "px,0px);";
311:                }
312:                if (!_useLayerTag && !styleProvided)
313:                    attributes += "\"";
314:                layerHeading += attributes;
315:                /*	if (_style != null && _style.getStyleName()!=null && !_style.getStyleName().trim().equals(""))
316:                 layerHeading += " CLASS=\"" + _style.getStyleName() + "\"";*/
317:
318:                /*	if (_bgColor != null)
319:                 {
320:                 if (!_bgColor.equals(""))
321:                 {
322:                 tableHeading += " BGCOLOR=\"" + _bgColor + "\"";
323:                 }
324:                 }*/
325:                /*	if (_align != null)
326:                 {
327:                 if (_align.equals(ALIGN_LEFT) || _align.equals(ALIGN_RIGHT) || _align.equals(ALIGN_CENTER))
328:                 tableHeading += " align=\"" + _align + "\"";
329:                 }*/
330:                layerHeading += ">";
331:                p.println(layerHeading);
332:                super .generateHTML(p, rowStart, rowEnd);
333:
334:                if (_browserType == HtmlPageBase.BROWSER_MICROSOFT
335:                        || !_useLayerTag)
336:                    p.print("</DIV>");
337:                else
338:                    p.print("</LAYER>");
339:                /*	if (_containerHeight>-1 || _containerWidth>-1 || _containerLeft>-9999 || _containerTop>-1) {
340:                 p.print("<SCRIPT LANGUAGE=\"JavaScript1.2\">");
341:                 p.print("function "+getName()+"Draw() {");
342:                 if (_containerHeight>-1)
343:                 p.print("document."+getName()+".height="+_containerHeight+";");
344:                 if (_containerWidth>-1)
345:                 p.print("document."+getName()+".width="+_containerWidth+";");
346:                 if (_containerTop>-9999)
347:                 p.print("document."+getName()+".top="+_containerTop+";");
348:                 if (_containerLeft>-9999)
349:                 p.print("document."+getName()+".left="+_containerLeft+";");
350:                 p.print("};");
351:                 //p.print("setTimeout(\""+getName()+"Draw();\",100);");
352:                 p.print("</SCRIPT>");
353:                 }*/
354:
355:                if (_center)
356:                    p.print("</CENTER>");
357:                p.println("");
358:            }
359:
360:            /**
361:             * Returns the I-Frame Buffer name. Only valid if buffer being used.
362:             * @return java.lang.String The name of the I-Frame buffer.
363:             */
364:            public String getBufferName() {
365:                return getFullName() + "BUFFER";
366:            }
367:
368:            /**
369:             * Returns whether a clip:rect description is to be used to describe the div/layer.
370:             * @return boolean Indicates if clip:rect description is to be used in Html Generation.
371:             */
372:            public boolean getEnableClip() {
373:                return _enableClip;
374:            }
375:
376:            /**
377:             * Returns the full name of the component for scripting purposes.
378:             * @return java.lang.String The fullname of the component
379:             */
380:            public String getFullName() {
381:                if (_style != null)
382:                    return _style.getStyleName();
383:                else if (_useLayerTag
384:                        || _browserType == HtmlPage.BROWSER_NETSCAPE)
385:                    return super .getName();
386:                else
387:                    return super .getFullName();
388:            }
389:
390:            /**
391:             * This method gets the minimum height of the table in pixels.
392:             */
393:            public int getHeight() {
394:                return _containerHeight;
395:            }
396:
397:            /**
398:             * This method gets the left position of the layer in pixels.
399:             * @return int The number of pixels from the Left of the window the Layer is.
400:             */
401:            public int getLeft() {
402:                return _containerLeft;
403:            }
404:
405:            /**
406:             * This method gets a position attribute of the layer.
407:             * @return java.lang.String Position Attribute of the layer.
408:             */
409:            public String getPosition() {
410:                return _position;
411:            }
412:
413:            /**
414:             * This method gets the top position of the layer in pixels.
415:             * @return int The number of pixels from the Top of the window the Layer is.
416:             */
417:            public int getTop() {
418:                return _containerTop;
419:            }
420:
421:            /**
422:             * This method returns whether a Buffer is to be used.
423:             * @return boolean Indicates if a buffer is being used by the layer.
424:             */
425:            public boolean getUseBuffer() {
426:                return _useBuffer;
427:            }
428:
429:            /**
430:             * This method returns the width of the table.
431:             */
432:            public int getWidth() {
433:                return _containerWidth;
434:            }
435:
436:            /**
437:             * Specifies whether to use the clip:rect syntax in the Html Generation.
438:             * @param enableClip boolean Indicates whether to use the clip:rect syntax or not.
439:             */
440:            public void setEnableClip(boolean enableClip) {
441:                _enableClip = enableClip;
442:            }
443:
444:            /**
445:             * This method sets the minimum height of the table in pixels.
446:             */
447:            public void setHeight(int height) {
448:                _containerHeight = height;
449:                if (_style != null && _style.getStyleName() != null
450:                        && !_style.getStyleName().trim().equals("")) {
451:                    String sStyle = _style.getStyle();
452:                    int heightIndex = sStyle.toUpperCase().indexOf("HEIGHT");
453:                    if (heightIndex >= 0) {
454:                        String sHeight = sStyle.substring(heightIndex);
455:                        int colonIndex = heightIndex + sHeight.indexOf(":");
456:                        int semicolonIndex = heightIndex + sHeight.indexOf(";");
457:                        sStyle = sStyle.substring(0, colonIndex + 1) + height
458:                                + sStyle.substring(semicolonIndex);
459:                        _style.setStyle(sStyle);
460:                    } else {
461:                        if (sStyle.endsWith(";"))
462:                            sStyle = sStyle + "height:" + height + ";";
463:                        else
464:                            sStyle = sStyle + ";height:" + height + ";";
465:                        _style.setStyle(sStyle);
466:                    }
467:                }
468:            }
469:
470:            /**
471:             * Sets the Left position of the layer in pixels.
472:             * @param left int The left position in pixels.
473:             */
474:            public void setLeft(int left) {
475:                _containerLeft = left;
476:                if (_style != null && _style.getStyleName() != null
477:                        && !_style.getStyleName().trim().equals("")) {
478:                    String sStyle = _style.getStyle();
479:                    int leftIndex = sStyle.toUpperCase().indexOf("LEFT");
480:                    if (leftIndex >= 0) {
481:                        String sLeft = sStyle.substring(leftIndex);
482:                        int colonIndex = leftIndex + sLeft.indexOf(":");
483:                        int semicolonIndex = leftIndex + sLeft.indexOf(";");
484:                        sStyle = sStyle.substring(0, colonIndex + 1) + left
485:                                + sStyle.substring(semicolonIndex);
486:                        _style.setStyle(sStyle);
487:                    } else {
488:                        if (sStyle.endsWith(";"))
489:                            sStyle = sStyle + "left:" + left + ";";
490:                        else
491:                            sStyle = sStyle + ";left:" + left + ";";
492:                        _style.setStyle(sStyle);
493:                    }
494:                }
495:            }
496:
497:            /**
498:             * Sets the position attribute of the layer.
499:             * @param position java.lang.String The position of the layer.
500:             */
501:            public void setPosition(String position) {
502:                _position = position;
503:                if (_style != null && _style.getStyleName() != null
504:                        && !_style.getStyleName().trim().equals("")) {
505:                    String sStyle = _style.getStyle();
506:                    int positionIndex = sStyle.toUpperCase()
507:                            .indexOf("POSITION");
508:                    if (positionIndex >= 0) {
509:                        String sPosition = sStyle.substring(positionIndex);
510:                        int colonIndex = positionIndex + sPosition.indexOf(":");
511:                        int semicolonIndex = positionIndex
512:                                + sPosition.indexOf(";");
513:                        sStyle = sStyle.substring(0, colonIndex + 1) + position
514:                                + sStyle.substring(semicolonIndex);
515:                        _style.setStyle(sStyle);
516:                    } else {
517:                        if (sStyle.endsWith(";"))
518:                            sStyle = sStyle + "position:" + position + ";";
519:                        else
520:                            sStyle = sStyle + ";position:" + position + ";";
521:                        _style.setStyle(sStyle);
522:                    }
523:                }
524:            }
525:
526:            /**
527:             * Specifies the layer should used the passed style to indicate the layer's properties.
528:             * @param style com.salmonllc.html.HtmlStyle
529:             */
530:            public void setStyle(HtmlStyle style) {
531:                _style = style;
532:                if (_style == null)
533:                    return;
534:                setName(style.getStyleName());
535:                String sStyle = _style.getStyle();
536:                int topIndex = sStyle.toUpperCase().indexOf("TOP");
537:                int leftIndex = sStyle.toUpperCase().indexOf("LEFT");
538:                int widthIndex = sStyle.toUpperCase().indexOf("WIDTH");
539:                int heightIndex = sStyle.toUpperCase().indexOf("HEIGHT");
540:                int positionIndex = sStyle.toUpperCase().indexOf("POSITION");
541:                if (topIndex >= 0) {
542:                    String sTop = sStyle.substring(topIndex);
543:                    int colonIndex = sTop.indexOf(":");
544:                    int semicolonIndex = sTop.indexOf(";");
545:                    String sValue = sTop.substring(colonIndex + 1,
546:                            semicolonIndex).trim();
547:                    try {
548:                        _containerTop = Integer.parseInt(sValue);
549:                    } catch (Exception e) {
550:                        ;
551:                    }
552:                }
553:                if (leftIndex >= 0) {
554:                    String sLeft = sStyle.substring(leftIndex);
555:                    int colonIndex = sLeft.indexOf(":");
556:                    int semicolonIndex = sLeft.indexOf(";");
557:                    String sValue = sLeft.substring(colonIndex + 1,
558:                            semicolonIndex).trim();
559:                    try {
560:                        _containerLeft = Integer.parseInt(sValue);
561:                    } catch (Exception e) {
562:                        ;
563:                    }
564:                }
565:                if (widthIndex >= 0) {
566:                    String sWidth = sStyle.substring(widthIndex);
567:                    int colonIndex = sWidth.indexOf(":");
568:                    int semicolonIndex = sWidth.indexOf(";");
569:                    String sValue = sWidth.substring(colonIndex + 1,
570:                            semicolonIndex).trim();
571:                    try {
572:                        _containerWidth = Integer.parseInt(sValue);
573:                    } catch (Exception e) {
574:                        ;
575:                    }
576:                }
577:                if (heightIndex >= 0) {
578:                    String sHeight = sStyle.substring(heightIndex);
579:                    int colonIndex = sHeight.indexOf(":");
580:                    int semicolonIndex = sHeight.indexOf(";");
581:                    String sValue = sHeight.substring(colonIndex + 1,
582:                            semicolonIndex).trim();
583:                    try {
584:                        _containerHeight = Integer.parseInt(sValue);
585:                    } catch (Exception e) {
586:                        ;
587:                    }
588:                }
589:                if (positionIndex >= 0) {
590:                    String sPosition = sStyle.substring(positionIndex);
591:                    int colonIndex = sPosition.indexOf(":");
592:                    int semicolonIndex = sPosition.indexOf(";");
593:                    _position = sPosition.substring(colonIndex + 1,
594:                            semicolonIndex).trim();
595:                }
596:            }
597:
598:            /**
599:             * Sets the Top position of the layer in pixels.
600:             * @param left int The top position in pixels.
601:             */
602:            public void setTop(int top) {
603:                _containerTop = top;
604:                if (_style != null && _style.getStyleName() != null
605:                        && !_style.getStyleName().trim().equals("")) {
606:                    String sStyle = _style.getStyle();
607:                    int topIndex = sStyle.toUpperCase().indexOf("TOP");
608:                    if (topIndex >= 0) {
609:                        String sTop = sStyle.substring(topIndex);
610:                        int colonIndex = topIndex + sTop.indexOf(":");
611:                        int semicolonIndex = topIndex + sTop.indexOf(";");
612:                        sStyle = sStyle.substring(0, colonIndex + 1) + top
613:                                + sStyle.substring(semicolonIndex);
614:                        _style.setStyle(sStyle);
615:                    } else {
616:                        if (sStyle.endsWith(";"))
617:                            sStyle = sStyle + "top:" + top + ";";
618:                        else
619:                            sStyle = sStyle + ";top:" + top + ";";
620:                        _style.setStyle(sStyle);
621:                    }
622:                }
623:            }
624:
625:            /**
626:             * Specifies whether to use a buffer with the layer.
627:             * @param useBuffer boolean Indicates whether to use a buffer or not.
628:             */
629:            public void setUseBuffer(boolean useBuffer) {
630:                _useBuffer = useBuffer;
631:            }
632:
633:            /**
634:             * Specifies whether to use the layer tag instead of div.
635:             * @param useLayerTag boolean Indicates whether to use a the layer tag or not.
636:             */
637:            public void setUseLayerTag(boolean useLayerTag) {
638:                _useLayerTag = useLayerTag;
639:
640:            }
641:
642:            /**
643:             * This method sets the minimum width of the table in either pixels or percent depending on size option.
644:             */
645:            public void setWidth(int width) {
646:                _containerWidth = width;
647:                if (_style != null && _style.getStyleName() != null
648:                        && !_style.getStyleName().trim().equals("")) {
649:                    String sStyle = _style.getStyle();
650:                    int widthIndex = sStyle.toUpperCase().indexOf("WIDTH");
651:                    if (widthIndex >= 0) {
652:                        String sWidth = sStyle.substring(widthIndex);
653:                        int colonIndex = widthIndex + sWidth.indexOf(":");
654:                        int semicolonIndex = widthIndex + sWidth.indexOf(";");
655:                        sStyle = sStyle.substring(0, colonIndex + 1) + width
656:                                + sStyle.substring(semicolonIndex);
657:                        _style.setStyle(sStyle);
658:                    } else {
659:                        if (sStyle.endsWith(";"))
660:                            sStyle = sStyle + "width:" + width + ";";
661:                        else
662:                            sStyle = sStyle + ";width:" + width + ";";
663:                        _style.setStyle(sStyle);
664:                    }
665:                }
666:            }
667:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.