1 29 30 package nextapp.echo2.webcontainer.propertyrender; 31 32 import nextapp.echo2.app.Extent; 33 import nextapp.echo2.app.Insets; 34 import nextapp.echo2.webrender.output.CssStyle; 35 36 40 public class InsetsRender { 41 42 50 public static void renderToStyle(CssStyle cssStyle, String cssAttribute, Insets insets) { 51 if (insets == null) { 52 return; 53 } 54 cssStyle.setAttribute(cssAttribute, renderCssAttributeValue(insets)); 55 } 56 57 63 public static String renderCssAttributeValue(Insets insets) { 64 Extent top = insets.getTop(); 65 if (top != null && top.equals(insets.getLeft()) && top.equals(insets.getRight()) 66 && top.equals(insets.getBottom())) { 67 return ExtentRender.renderCssAttributeValue(top); 68 } else { 69 StringBuffer out = new StringBuffer (); 70 if (top == null) { 71 out.append("0px"); 72 } else { 73 out.append(ExtentRender.renderCssAttributeValue(top)); 74 } 75 out.append(" "); 76 if (insets.getRight() == null) { 77 out.append("0px"); 78 } else { 79 out.append(ExtentRender.renderCssAttributeValue(insets.getRight())); 80 } 81 out.append(" "); 82 if (insets.getBottom() == null) { 83 out.append("0px"); 84 } else { 85 out.append(ExtentRender.renderCssAttributeValue(insets.getBottom())); 86 } 87 out.append(" "); 88 if (insets.getLeft() == null) { 89 out.append("0px"); 90 } else { 91 out.append(ExtentRender.renderCssAttributeValue(insets.getLeft())); 92 } 93 return out.toString(); 94 } 95 } 96 97 98 private InsetsRender() { } 99 } 100 | Popular Tags |