KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > info > magnolia > cms > gui > misc > Spacer


1 /**
2  *
3  * Magnolia and its source-code is licensed under the LGPL.
4  * You may copy, adapt, and redistribute this file for commercial or non-commercial use.
5  * When copying, adapting, or redistributing this document in keeping with the guidelines above,
6  * you are required to provide proper attribution to obinary.
7  * If you reproduce or distribute the document without making any substantive modifications to its content,
8  * please use the following attribution line:
9  *
10  * Copyright 1993-2006 obinary Ltd. (http://www.obinary.com) All rights reserved.
11  *
12  */

13 package info.magnolia.cms.gui.misc;
14
15 /**
16  * Utility class. Draw a simple spacer div.
17  * @author Vinzenz Wyser
18  * @version 2.0
19  */

20 public final class Spacer {
21
22     /**
23      * utility class, don't instantiate.
24      */

25     private Spacer() {
26     }
27
28     /**
29      * Draw a spacer div with the specified width and height.
30      * @param height div height
31      * @param width div width
32      * @return html for the spacer
33      */

34     public static String JavaDoc getHtml(int height, int width) {
35
36         StringBuffer JavaDoc buffer = new StringBuffer JavaDoc(120);
37         buffer.append("<div class=\""); //$NON-NLS-1$
38
buffer.append(CssConstants.CSSCLASS_TINYVSPACE);
39         buffer.append("\" "); //$NON-NLS-1$
40

41         if (height != 0 || width != 0) {
42             buffer.append("style=\""); //$NON-NLS-1$
43
if (height != 0) {
44                 buffer.append("height:" + height + "px;"); //$NON-NLS-1$ //$NON-NLS-2$
45
}
46             if (width != 0) {
47                 buffer.append("width:" + width + "px;"); //$NON-NLS-1$ //$NON-NLS-2$
48
}
49             buffer.append("\" "); //$NON-NLS-1$
50
}
51
52         buffer.append("><!-- ie --></div>"); //$NON-NLS-1$
53

54         return buffer.toString();
55     }
56 }
57
Popular Tags