/** * Returns string representation of horizontal alignment. * * @return horizontal alignment as CSS value */ public String getHorizontalAlignment() { if (isRight()) { return "right"; } else if (isCenter()) { return "center"; } return "left"; }
/** * Writes the alignment to the given child element attributes. * * @since 7.6.4 * @param childElement * the child element * @param alignment * the component alignment */ public static void writeAlignment(Element childElement, Alignment alignment) { if (alignment.isMiddle()) { childElement.attr(":middle", true); } else if (alignment.isBottom()) { childElement.attr(":bottom", true); } if (alignment.isCenter()) { childElement.attr(":center", true); } else if (alignment.isRight()) { childElement.attr(":right", true); } }
} else if (alignment.isRight()) { childElement.attr(":right", true);
public void recalculateExpandRatios() { for (Iterator<Component> it = getComponentIterator(); it.hasNext(); ) { setExpandRatio(it.next(), 0.0f); } if (getComponentCount() > 0) { if (alignment.isLeft()) { setExpandRatio(getComponent(getComponentCount() - 1), 1.0f); } else if (alignment.isRight()) { setExpandRatio(getComponent(0), 1.0f); } } } }
public static HorizontalLayout horizontalLayout(Alignment alignment, com.vaadin.ui.Component... components) { HorizontalLayout hl = new HorizontalLayout(); hl.setWidth(100, Sizeable.UNITS_PERCENTAGE); hl.setSpacing(true); if (components != null && components.length > 0) { for (com.vaadin.ui.Component c : components) { hl.addComponent(c); hl.setComponentAlignment(c, alignment); } if (alignment.isRight()) { hl.setExpandRatio(hl.getComponent(0), 1.0f); } else if (alignment.isLeft()) { hl.setExpandRatio(hl.getComponent(hl.getComponentCount() - 1), 1.0f); } } return hl; }