public ElementStyle background(String background) { setBackground(background); return this; }
public ElementStyle(String tag, Integer width, Integer height, String background, String color, Integer fontSize, Shape shape) { this.tag = tag; this.width = width; this.height = height; setBackground(background); setColor(color); this.fontSize = fontSize; this.shape = shape; }
@Test(expected = IllegalArgumentException.class) public void test_setBackground_ThrowsAnException_WhenAnInvalidHexColorCodeIsSpecified() { ElementStyle style = new ElementStyle(); style.setBackground("white"); }
@Test public void test_setBackground_SetsTheBackgroundProperty_WhenAValidHexColorCodeIsSpecified() { ElementStyle style = new ElementStyle(); style.setBackground("#ffffff"); assertEquals("#ffffff", style.getBackground()); style.setBackground("#FFFFFF"); assertEquals("#ffffff", style.getBackground()); style.setBackground("#123456"); assertEquals("#123456", style.getBackground()); }
public ElementStyle findElementStyle(Element element) { ElementStyle style = new ElementStyle("").background("#dddddd").color("#000000").shape(Shape.Box); if (element != null) { for (String tag : element.getTagsAsSet()) { ElementStyle elementStyle = findElementStyle(tag); if (elementStyle != null) { if (elementStyle.getBackground() != null && elementStyle.getBackground().trim().length() > 0) { style.setBackground(elementStyle.getBackground()); } if (elementStyle.getColor() != null && elementStyle.getColor().trim().length() > 0) { style.setColor(elementStyle.getColor()); } if (elementStyle.getShape() != null) { style.setShape(elementStyle.getShape()); } } } } return style; }