001: /*
002: * Copyright Javelin Software, All rights reserved.
003: */
004:
005: package com.javelin.swinglets.plaf.html;
006:
007: import java.awt.*;
008: import java.util.*;
009: import java.io.*;
010:
011: import com.javelin.swinglets.*;
012: import com.javelin.swinglets.plaf.*;
013:
014: /**
015: * HTMLBorderLayoutUI defines a look and feel for default HTML.
016: *
017: * @author Robin Sharp
018: */
019:
020: public class HTMLBorderLayoutUI extends HTMLLayoutUI {
021: /**
022: * Lays out the container in the specified manner.
023: */
024: public void layoutContainer(SContainer parent, PrintWriter out) {
025: if (parent.getComponentCount() == 0)
026: return;
027:
028: SBorderLayout borderLayout = (SBorderLayout) parent
029: .getLayoutManager();
030: SComponent component = null;
031:
032: out.print("<TABLE BORDER=0 CELLSPACING=");
033: out.print(borderLayout.getGap());
034: out.println(" CELLPADDING=0 >");
035:
036: //NORTH
037: if (borderLayout.getComponent(SBorderLayout.NORTH) != null) {
038: out.print("<TR>");
039: out.print("<TD COLSPAN=3 WIDTH=\"100%\"");
040:
041: HTMLUtility.updateHorizontalAlignment(out, component,
042: SConstants.CENTER);
043: HTMLUtility.updateVerticalAlignment(out, component,
044: SConstants.BOTTOM);
045:
046: paintCell(parent, borderLayout
047: .getComponent(SBorderLayout.NORTH), out);
048:
049: out.println("</TR>");
050: }
051:
052: out.print("<TR>");
053:
054: //WEST
055: if (borderLayout.getComponent(SBorderLayout.WEST) != null) {
056: out.print("<TD");
057:
058: HTMLUtility.updateHorizontalAlignment(out, component,
059: SConstants.LEFT);
060:
061: paintCell(parent, borderLayout
062: .getComponent(SBorderLayout.WEST), out);
063: }
064:
065: //CENTER
066: if (borderLayout.getComponent(SBorderLayout.CENTER) != null) {
067: out.print("<TD");
068:
069: HTMLUtility.updateHorizontalAlignment(out, component,
070: SConstants.CENTER);
071:
072: paintCell(parent, borderLayout
073: .getComponent(SBorderLayout.CENTER), out);
074: }
075:
076: //EAST
077: if (borderLayout.getComponent(SBorderLayout.EAST) != null) {
078: out.print("<TD");
079:
080: HTMLUtility.updateHorizontalAlignment(out, component,
081: SConstants.RIGHT);
082:
083: paintCell(parent, borderLayout
084: .getComponent(SBorderLayout.EAST), out);
085: }
086:
087: out.println("</TR>");
088:
089: //SOUTH
090: if (borderLayout.getComponent(SBorderLayout.SOUTH) != null) {
091: out.print("<TR>");
092: out.print("<TD COLSPAN=3 WIDTH=\"100%\"");
093:
094: HTMLUtility.updateHorizontalAlignment(out, component,
095: SConstants.CENTER);
096: HTMLUtility.updateVerticalAlignment(out, component,
097: SConstants.TOP);
098:
099: paintCell(parent, borderLayout
100: .getComponent(SBorderLayout.SOUTH), out);
101: out.println("</TR>");
102: }
103:
104: out.print("</TABLE>");
105: }
106:
107: protected void paintCell(SContainer parent, SComponent component,
108: PrintWriter out) {
109:
110: if (!(component instanceof SIcon) && !component.isOpaque()) {
111: } else if (!(component instanceof SIcon)
112: && component.getBackground() != null) {
113: out.print(" BGCOLOR=\"#"
114: + SColor.toHexString(component.getBackground())
115: + "\"");
116: } else if (!(component instanceof SIcon)
117: && parent.getBackground() != null) {
118: out
119: .print(" BGCOLOR=\"#"
120: + SColor
121: .toHexString(parent.getBackground())
122: + "\"");
123: }
124:
125: out.print(" >");
126: component.paint(out);
127: out.print("</TD>");
128: }
129: }
|