use of com.github.bordertech.wcomponents.Size in project wcomponents by BorderTech.
the class WListRenderer method doRender.
/**
* Paints the given WList.
*
* @param component the WList to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WList list = (WList) component;
XmlStringBuilder xml = renderContext.getWriter();
WList.Type type = list.getType();
WList.Separator separator = list.getSeparator();
Size gap = list.getSpace();
String gapString = gap == null ? null : gap.toString();
xml.appendTagOpen("ui:panel");
xml.appendAttribute("id", component.getId());
xml.appendOptionalAttribute("class", component.getHtmlClass());
xml.appendOptionalAttribute("track", component.isTracking(), "true");
xml.appendOptionalAttribute("type", list.isRenderBorder(), "box");
xml.appendClose();
// Render margin
MarginRendererUtil.renderMargin(list, renderContext);
xml.appendTagOpen("ui:listlayout");
xml.appendOptionalAttribute("gap", gapString);
if (type != null) {
switch(type) {
case FLAT:
xml.appendAttribute("type", "flat");
break;
case STACKED:
xml.appendAttribute("type", "stacked");
break;
case STRIPED:
xml.appendAttribute("type", "striped");
break;
default:
throw new SystemException("Unknown list type: " + type);
}
}
if (separator != null) {
switch(separator) {
case BAR:
xml.appendAttribute("separator", "bar");
break;
case DOT:
xml.appendAttribute("separator", "dot");
break;
case NONE:
break;
default:
throw new SystemException("Unknown list type: " + type);
}
}
xml.appendClose();
paintRows(list, renderContext);
xml.appendEndTag("ui:listlayout");
xml.appendEndTag("ui:panel");
}
use of com.github.bordertech.wcomponents.Size in project wcomponents by BorderTech.
the class ColumnLayoutRenderer method doRender.
/**
* Paints the given WPanel's children.
*
* @param component the container to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPanel panel = (WPanel) component;
XmlStringBuilder xml = renderContext.getWriter();
ColumnLayout layout = (ColumnLayout) panel.getLayout();
int childCount = panel.getChildCount();
Size hgap = layout.getHorizontalGap();
String hgapString = hgap == null ? null : hgap.toString();
Size vgap = layout.getVerticalGap();
String vgapString = vgap == null ? null : vgap.toString();
int cols = layout.getColumnCount();
xml.appendTagOpen("ui:columnlayout");
xml.appendOptionalAttribute("hgap", hgapString);
xml.appendOptionalAttribute("vgap", vgapString);
xml.appendClose();
// Column Definitions
for (int col = 0; col < cols; col++) {
xml.appendTagOpen("ui:column");
int width = layout.getColumnWidth(col);
xml.appendOptionalAttribute("width", width > 0, width);
switch(layout.getColumnAlignment(col)) {
case LEFT:
// left is assumed if omitted
break;
case RIGHT:
xml.appendAttribute("align", "right");
break;
case CENTER:
xml.appendAttribute("align", "center");
break;
default:
throw new IllegalArgumentException("Invalid alignment: " + layout.getColumnAlignment(col));
}
xml.appendEnd();
}
for (int i = 0; i < childCount; i++) {
xml.appendTag("ui:cell");
WComponent child = panel.getChildAt(i);
child.paint(renderContext);
xml.appendEndTag("ui:cell");
}
xml.appendEndTag("ui:columnlayout");
}
use of com.github.bordertech.wcomponents.Size in project wcomponents by BorderTech.
the class BorderLayoutRenderer method doRender.
/**
* Paints the given WPanel's children.
*
* @param component the container to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPanel panel = (WPanel) component;
XmlStringBuilder xml = renderContext.getWriter();
BorderLayout layout = (BorderLayout) panel.getLayout();
Size hgap = layout.getHorizontalGap();
String hgapString = hgap == null ? null : hgap.toString();
Size vgap = layout.getVerticalGap();
String vgapString = vgap == null ? null : vgap.toString();
xml.appendTagOpen("ui:borderlayout");
xml.appendOptionalAttribute("hgap", hgapString);
xml.appendOptionalAttribute("vgap", vgapString);
xml.appendClose();
// Fetch the children and their constraints.
final int childCount = panel.getChildCount();
List<Duplet<WComponent, BorderLayoutConstraint>> children = new ArrayList<>(childCount);
for (int i = 0; i < childCount; i++) {
WComponent child = panel.getChildAt(i);
children.add(new Duplet<>(child, getConstraints(panel, child)));
}
// Now paint them
paintChildrenWithConstraint(children, renderContext, BorderLayout.NORTH);
paintChildrenWithConstraint(children, renderContext, BorderLayout.EAST);
paintChildrenWithConstraint(children, renderContext, BorderLayout.SOUTH);
paintChildrenWithConstraint(children, renderContext, BorderLayout.WEST);
paintChildrenWithConstraint(children, renderContext, BorderLayout.CENTER);
xml.appendEndTag("ui:borderlayout");
}
use of com.github.bordertech.wcomponents.Size in project wcomponents by BorderTech.
the class FlowLayoutRenderer method doRender.
/**
* Paints the given WPanel's children.
*
* @param component the container to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPanel panel = (WPanel) component;
XmlStringBuilder xml = renderContext.getWriter();
FlowLayout layout = (FlowLayout) panel.getLayout();
Size gap = layout.getSpace();
String gapString = gap != null ? gap.toString() : null;
FlowLayout.Alignment align = layout.getAlignment();
xml.appendTagOpen("ui:flowlayout");
switch(align) {
case RIGHT:
{
xml.appendAttribute("align", "right");
break;
}
case CENTER:
{
xml.appendAttribute("align", "center");
break;
}
case LEFT:
{
xml.appendAttribute("align", "left");
break;
}
case VERTICAL:
xml.appendAttribute("align", "vertical");
break;
default:
throw new IllegalStateException("Unknown layout type: " + layout.getAlignment());
}
if (layout.getContentAlignment() != null) {
switch(layout.getContentAlignment()) {
case TOP:
{
xml.appendAttribute("valign", "top");
break;
}
case MIDDLE:
{
xml.appendAttribute("valign", "middle");
break;
}
case BASELINE:
{
xml.appendAttribute("valign", "baseline");
break;
}
case BOTTOM:
xml.appendAttribute("valign", "bottom");
break;
default:
throw new IllegalStateException("Unknown content alignment type: " + layout.getContentAlignment());
}
}
xml.appendOptionalAttribute("gap", gapString);
xml.appendClose();
int size = panel.getChildCount();
for (int i = 0; i < size; i++) {
xml.appendTag("ui:cell");
WComponent child = panel.getChildAt(i);
child.paint(renderContext);
xml.appendEndTag("ui:cell");
}
xml.appendEndTag("ui:flowlayout");
}
use of com.github.bordertech.wcomponents.Size in project wcomponents by BorderTech.
the class GridLayoutRenderer method doRender.
/**
* Paints the given WPanel's children.
*
* @param component the container to paint.
* @param renderContext the RenderContext to paint to.
*/
@Override
public void doRender(final WComponent component, final WebXmlRenderContext renderContext) {
WPanel panel = (WPanel) component;
XmlStringBuilder xml = renderContext.getWriter();
GridLayout layout = (GridLayout) panel.getLayout();
Size hgap = layout.getHorizontalGap();
String hgapString = hgap == null ? null : hgap.toString();
Size vgap = layout.getVerticalGap();
String vgapString = vgap == null ? null : vgap.toString();
int rows = layout.getRows();
int cols = layout.getCols();
xml.appendTagOpen("ui:gridlayout");
xml.appendAttribute("rows", rows > 0 ? String.valueOf(rows) : "0");
xml.appendAttribute("cols", cols > 0 ? String.valueOf(cols) : "0");
xml.appendOptionalAttribute("hgap", hgapString);
xml.appendOptionalAttribute("vgap", vgapString);
xml.appendClose();
int size = panel.getChildCount();
for (int i = 0; i < size; i++) {
xml.appendTag("ui:cell");
WComponent child = panel.getChildAt(i);
child.paint(renderContext);
xml.appendEndTag("ui:cell");
}
xml.appendEndTag("ui:gridlayout");
}
Aggregations