use of com.github.bordertech.wcomponents.layout.BorderLayout.BorderLayoutConstraint in project wcomponents by BorderTech.
the class BorderLayoutRenderer method paintChildrenWithConstraint.
/**
* Paints all the child components with the given constraint.
*
* @param children the list of potential children to paint.
* @param renderContext the RenderContext to paint to.
* @param constraint the target constraint.
*/
private void paintChildrenWithConstraint(final List<Duplet<WComponent, BorderLayoutConstraint>> children, final WebXmlRenderContext renderContext, final BorderLayoutConstraint constraint) {
String containingTag = null;
XmlStringBuilder xml = renderContext.getWriter();
final int size = children.size();
for (int i = 0; i < size; i++) {
Duplet<WComponent, BorderLayoutConstraint> child = children.get(i);
if (constraint.equals(child.getSecond())) {
if (containingTag == null) {
containingTag = getTag(constraint);
xml.appendTag(containingTag);
}
child.getFirst().paint(renderContext);
}
}
if (containingTag != null) {
xml.appendEndTag(containingTag);
}
}
use of com.github.bordertech.wcomponents.layout.BorderLayout.BorderLayoutConstraint 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");
}
Aggregations