public void initializeFromStyle(final ElementStyleSheet styleSheet) { final ElementAlignment halign = (ElementAlignment) styleSheet.getStyleProperty(ElementStyleKeys.ALIGNMENT); if (ElementAlignment.LEFT.equals(halign)) { leftAlignButton.setSelected(true); } else if (ElementAlignment.CENTER.equals(halign)) { centerAlignButton.setSelected(true); } else { rightAlignButton.setSelected(true); } final ElementAlignment valign = (ElementAlignment) styleSheet.getStyleProperty(ElementStyleKeys.VALIGNMENT); if (ElementAlignment.BOTTOM.equals(valign)) { bottomAlignButton.setSelected(true); } else if (ElementAlignment.MIDDLE.equals(valign)) { middleAlignButton.setSelected(true); } else { topAlignButton.setSelected(true); } wrapTextCheckbox.setSelected( TextWrap.WRAP.equals(styleSheet.getStyleProperty(TextStyleKeys.TEXT_WRAP))); lineHeightField.setText( BorderPropertiesPane.printLength( (Number) styleSheet.getStyleProperty(TextStyleKeys.LINEHEIGHT))); textAlignModel.setSelectedKey( styleSheet.getStyleProperty(TextStyleKeys.VERTICAL_TEXT_ALIGNMENT)); whitespaceModel.setSelectedKey(styleSheet.getStyleProperty(TextStyleKeys.WHITE_SPACE_COLLAPSE)); }
private void computeCellStyle(final RenderBox content, final Cell cell) { final ElementAlignment verticalAlign = content.getNodeLayoutProperties().getVerticalAlignment(); if (ElementAlignment.BOTTOM.equals(verticalAlign)) { cell.setVerticalAlignment(Element.ALIGN_BOTTOM); } else if (ElementAlignment.MIDDLE.equals(verticalAlign)) { cell.setVerticalAlignment(Element.ALIGN_MIDDLE); } else { cell.setVerticalAlignment(Element.ALIGN_TOP); } final ElementAlignment textAlign = (ElementAlignment) content.getStyleSheet().getStyleProperty(ElementStyleKeys.ALIGNMENT); if (ElementAlignment.RIGHT.equals(textAlign)) { cell.setHorizontalAlignment(Element.ALIGN_RIGHT); } else if (ElementAlignment.JUSTIFY.equals(textAlign)) { cell.setHorizontalAlignment(Element.ALIGN_JUSTIFIED); } else if (ElementAlignment.CENTER.equals(textAlign)) { cell.setHorizontalAlignment(Element.ALIGN_CENTER); } else { cell.setHorizontalAlignment(Element.ALIGN_LEFT); } }