01: /*
02: * Copyright Javelin Software, All rights reserved.
03: */
04:
05: package com.javelin.swinglets.plaf.wml;
06:
07: import java.awt.*;
08: import java.util.*;
09: import java.io.*;
10:
11: import com.javelin.swinglets.*;
12: import com.javelin.swinglets.plaf.*;
13:
14: /**
15: * WMLGridLayoutUI defines a look and feel for default WML.
16: *
17: * @author Robin Sharp
18: */
19:
20: public class WMLGridLayoutUI extends WMLLayoutUI {
21: /**
22: * Lays out the container in the specified manner.
23: */
24: public void layoutContainer(SContainer parent, PrintWriter out) {
25: if (parent.getComponentCount() == 0)
26: return;
27:
28: SGridLayout gridLayout = (SGridLayout) parent
29: .getLayoutManager();
30:
31: int columns = gridLayout.getColumns();
32: int rows = gridLayout.getRows();
33:
34: if (columns == 0 && rows == 0) {
35: columns = 2;
36: rows = (parent.getComponentCount() + 1) / columns;
37: } else if (columns == 0 && rows > 0) {
38: columns = (parent.getComponentCount() + 1) / rows;
39: } else if (columns > 0 && rows == 0) {
40: rows = (parent.getComponentCount() + 1) / columns;
41: }
42:
43: int count = 0;
44: for (int row = 0; count < parent.getComponentCount()
45: && row < rows; row++) {
46: out.print(WMLCharacterUI
47: .getSpecialCharacter(SCharacter.BREAK));
48:
49: for (int column = 0; count < parent.getComponentCount()
50: && column < columns; column++) {
51: if (column > 0) {
52: out.print(WMLCharacterUI
53: .getSpecialCharacter(SCharacter.SPACE));
54: }
55:
56: parent.getComponent(count++).paint(out);
57: }
58:
59: }
60:
61: }
62:
63: }
|