1 29 30 package nextapp.echo2.webcontainer.propertyrender; 31 32 import nextapp.echo2.app.Border; 33 import nextapp.echo2.webrender.output.CssStyle; 34 35 39 public class BorderRender { 40 41 48 public static final String getStyleValue(int style) { 49 switch (style) { 50 case Border.STYLE_NONE: 51 return "none"; 52 case Border.STYLE_INSET: 53 return "inset"; 54 case Border.STYLE_OUTSET: 55 return "outset"; 56 case Border.STYLE_SOLID: 57 return "solid"; 58 case Border.STYLE_DOTTED: 59 return "dotted"; 60 case Border.STYLE_DASHED: 61 return "dashed"; 62 case Border.STYLE_GROOVE: 63 return "groove"; 64 case Border.STYLE_RIDGE: 65 return "ridge"; 66 case Border.STYLE_DOUBLE: 67 return "double"; 68 default: 69 return "none"; 70 } 71 } 72 73 80 public static String renderCssAttributeValue(Border border) { 81 StringBuffer out = new StringBuffer (); 82 if (border.getSize() != null) { 83 out.append(ExtentRender.renderCssAttributeValue(border.getSize())); 84 out.append(" "); 85 } 86 out.append(getStyleValue(border.getStyle())); 87 if (border.getColor() != null) { 88 out.append(" "); 89 out.append(ColorRender.renderCssAttributeValue(border.getColor())); 90 } 91 return out.toString(); 92 } 93 94 101 public static void renderToStyle(CssStyle cssStyle, Border border) { 102 if (border == null) { 103 return; 104 } 105 cssStyle.setAttribute("border", renderCssAttributeValue(border)); 106 } 107 108 109 private BorderRender() { } 110 } 111 | Popular Tags |