stateIconElement.setAttribute("id", elementId + "_stateicon");
}
int entityCount = (textNode == null ? 0 : 1) + (iconElement == null ? 0 : 1) + (stateIconElement == null ? 0 : 1);
Extent iconTextMargin;
Alignment textPosition;
Element tableElement;
switch (entityCount) {
case 1:
if (textNode != null) {
contentNode = textNode;
} else if (iconElement != null) {
contentNode = iconElement;
} else { // stateIconElement must not be null.
contentNode = stateIconElement;
}
break;
case 2:
iconTextMargin = (Extent) button.getRenderProperty(AbstractButton.PROPERTY_ICON_TEXT_MARGIN,
DEFAULT_ICON_TEXT_MARGIN);
TriCellTable tct;
textPosition = (Alignment) button.getRenderProperty(AbstractButton.PROPERTY_TEXT_POSITION,
DEFAULT_TEXT_POSITION);
if (stateIconElement == null) {
// Not rendering a ToggleButton.
int orientation = TriCellTableConfigurator.convertIconTextPositionToOrientation(textPosition, button);
tct = new TriCellTable(rc, document, elementId, orientation, iconTextMargin);
renderCellText(tct, textNode, button);
renderCellIcon(tct, iconElement, 1, button);
} else {
// Rendering a ToggleButton.
Extent stateMargin = (Extent) button.getRenderProperty(ToggleButton.PROPERTY_STATE_MARGIN,
DEFAULT_ICON_TEXT_MARGIN);
Alignment statePosition = (Alignment) button.getRenderProperty(ToggleButton.PROPERTY_STATE_POSITION,
DEFAULT_STATE_POSITION);
int orientation = TriCellTableConfigurator.convertStatePositionToOrientation(statePosition, button);
tct = new TriCellTable(rc, document, elementId, orientation, stateMargin);
if (textNode == null) {
renderCellIcon(tct, iconElement, 0, button);
} else {
renderCellText(tct, textNode, button);
}
renderCellState(tct, stateIconElement, 1, button);
}
tct.addCellCssText("padding:0px;");
tableElement = tct.getTableElement();
tableElement.setAttribute("id", elementId + "_table");
tableElement.setAttribute("style", getContainerTableCssText(button));
contentNode = tableElement;
break;
case 3:
iconTextMargin = (Extent) button.getRenderProperty(AbstractButton.PROPERTY_ICON_TEXT_MARGIN,
DEFAULT_ICON_TEXT_MARGIN);
textPosition = (Alignment) button.getRenderProperty(AbstractButton.PROPERTY_TEXT_POSITION,
DEFAULT_TEXT_POSITION);
Extent stateMargin = (Extent) button.getRenderProperty(ToggleButton.PROPERTY_STATE_MARGIN,
DEFAULT_ICON_TEXT_MARGIN);
Alignment statePosition = (Alignment) button.getRenderProperty(ToggleButton.PROPERTY_STATE_POSITION,
DEFAULT_STATE_POSITION);
int stateOrientation = TriCellTableConfigurator.convertStatePositionToOrientation(statePosition, button);
int orientation = TriCellTableConfigurator.convertIconTextPositionToOrientation(textPosition, button);