001: // (c) copyright 2006 by eXXcellent solutions, Ulm. Author: bschmid
002:
003: package org.wings.plaf.css;
004:
005: import org.wings.style.CSSAttributeSet;
006: import org.wings.SConstants;
007:
008: import java.awt.*;
009: import java.io.Serializable;
010:
011: /**
012: * A class holding styling attributes for one or more cells of (layout) tables.
013: */
014: public final class TableCellStyle implements Serializable, Cloneable {
015:
016: /**
017: * desired insets for this table cell.
018: * Use {@link #getInsets()}
019: */
020: private Insets insets = null;
021:
022: /**
023: * render cells of first line as <code>TH</code> element
024: */
025: public boolean renderAsTH = false;
026:
027: /**
028: * Optional CSS class for this <code>TD</code> or <code>TH</code> cell
029: */
030: public String optionalStyleClass = null;
031:
032: /**
033: * A set holding additional CSS property values that should be appliied to the cell.
034: * Use {@link #getAdditionalCellStyles()}.
035: */
036: private CSSAttributeSet additionalCellStyles = null;
037:
038: /**
039: * Optional <code>TD</code> cell width
040: */
041: public String width = null;
042:
043: /**
044: * colspan attribute for this <code>TD</code> or <code>TH</code> cell
045: */
046: public int colspan = -1;
047:
048: /**
049: * rowspan attribute for this <code>TD</code> or <code>TH</code> cell
050: */
051: public int rowspan = -1;
052:
053: /**
054: * default in-cell <b>horizontal</b> alignment of inner component if component does not wear a orientation
055: */
056: public int defaultLayoutCellHAlignment = SConstants.NO_ALIGN;
057:
058: /**
059: * default in-cell <b>vertical</b> alignment of inner component if component does not wear a orientation
060: */
061: public int defaultLayoutCellVAlignment = SConstants.NO_ALIGN;
062:
063: public TableCellStyle() {
064: }
065:
066: public TableCellStyle makeACopy() {
067: try {
068: return (TableCellStyle) super .clone();
069: } catch (CloneNotSupportedException e) {
070: return null;
071: }
072: }
073:
074: public boolean hasAdditionalCellStyles() {
075: return additionalCellStyles != null
076: && !additionalCellStyles.isEmpty();
077: }
078:
079: public CSSAttributeSet getAdditionalCellStyles() {
080: if (additionalCellStyles == null)
081: additionalCellStyles = new CSSAttributeSet();
082: return additionalCellStyles;
083: }
084:
085: public void setAdditionalCellStyles(
086: CSSAttributeSet additionalCellStyles) {
087: this .additionalCellStyles = additionalCellStyles;
088: }
089:
090: public Insets getInsets() {
091: if (insets == null)
092: insets = new Insets(0, 0, 0, 0);
093: return insets;
094: }
095:
096: public void setInsets(Insets insets) {
097: this .insets = insets;
098: }
099:
100: public boolean hasInsets() {
101: return insets != null
102: && (insets.top > 0 || insets.left > 0
103: || insets.right > 0 || insets.bottom > 0);
104: }
105: }
|