use of com.github.bordertech.wcomponents.util.Duplet in project wcomponents by BorderTech.
the class UIManager method getRenderer.
/**
* Retrieves a renderer which can renderer the given component to the context.
*
* @param component the component to retrieve the renderer for.
* @param context the render context.
* @return an appropriate renderer for the component and context, or null if a suitable renderer could not be found.
*/
public static Renderer getRenderer(final WComponent component, final RenderContext context) {
Class<? extends WComponent> clazz = component.getClass();
Duplet<String, Class<?>> key = new Duplet<String, Class<?>>(context.getRenderPackage(), clazz);
Renderer renderer = INSTANCE.renderers.get(key);
if (renderer == null) {
renderer = INSTANCE.findRenderer(component, key);
} else if (renderer == NULL_RENDERER) {
return null;
}
return renderer;
}
use of com.github.bordertech.wcomponents.util.Duplet 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