KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > wings > plaf > css > BorderLayoutCG


1 /*
2  * $Id: BorderLayoutCG.java,v 1.7 2005/06/03 13:16:16 blueshift Exp $
3  * Copyright 2000,2005 wingS development team.
4  *
5  * This file is part of wingS (http://www.j-wings.org).
6  *
7  * wingS is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU Lesser General Public License
9  * as published by the Free Software Foundation; either version 2.1
10  * of the License, or (at your option) any later version.
11  *
12  * Please see COPYING for the complete licence.
13  */

14 package org.wings.plaf.css;
15
16 import org.wings.SBorderLayout;
17 import org.wings.SComponent;
18 import org.wings.SLayoutManager;
19 import org.wings.io.Device;
20
21 import java.io.IOException JavaDoc;
22
23 public class BorderLayoutCG extends AbstractLayoutCG {
24
25     public void write(Device d, SLayoutManager l)
26             throws IOException JavaDoc {
27         final SBorderLayout layout = (SBorderLayout) l;
28         final SComponent north = (SComponent) layout.getComponents().get(SBorderLayout.NORTH);
29         final SComponent east = (SComponent) layout.getComponents().get(SBorderLayout.EAST);
30         final SComponent center = (SComponent) layout.getComponents().get(SBorderLayout.CENTER);
31         final SComponent west = (SComponent) layout.getComponents().get(SBorderLayout.WEST);
32         final SComponent south = (SComponent) layout.getComponents().get(SBorderLayout.SOUTH);
33
34         int cols = 0;
35         if (west != null) cols++;
36         if (center != null) cols++;
37         if (east != null) cols++;
38
39         printLayouterTableHeader(d, "SBorderLayout",layout.getHgap(), layout.getVgap(), layout.getBorder(),layout);
40
41         if (north != null) {
42             d.print("<tr style=\"height: 0%\">");
43             Utils.printNewline(d, north);
44             d.print("<td colspan=\"").print(cols).print("\"");
45             Utils.printTableCellAlignment(d, north);
46             d.print(">");
47             north.write(d);
48             d.print("</td>");
49             Utils.printNewline(d, layout.getContainer());
50             d.print("</tr>");
51             Utils.printNewline(d, layout.getContainer());
52         }
53
54         d.print("<tr style=\"height: 100%\">");
55
56         if (west != null) {
57             Utils.printNewline(d, west);
58             d.print("<td");
59             Utils.printTableCellAlignment(d, west);
60             d.print(">");
61             west.write(d);
62             d.print("</td>");
63         }
64
65         if (center != null) {
66             Utils.printNewline(d, center);
67             d.print("<td");
68             Utils.printTableCellAlignment(d, center);
69             d.print(">");
70             center.write(d);
71             d.print("</td>");
72         }
73
74         if (east != null) {
75             Utils.printNewline(d, east);
76             d.print("<td");
77             Utils.printTableCellAlignment(d, east);
78             d.print(">");
79             east.write(d);
80             d.print("</td>");
81         }
82
83         Utils.printNewline(d, layout.getContainer());
84         d.print("</tr>");
85
86         if (south != null) {
87             Utils.printNewline(d, layout.getContainer());
88             d.print("<tr style=\"height: 0%\">");
89             Utils.printNewline(d, south);
90             d.print("<td colspan=\"").print(cols).print("\"");
91             Utils.printTableCellAlignment(d, south);
92             south.write(d);
93             d.print("</td>");
94             Utils.printNewline(d, layout.getContainer());
95             d.print("</tr>");
96         }
97
98         printLayouterTableFooter(d, "SBorderLayout", layout);
99     }
100
101 }
102
103
104
Popular Tags