1 14 package org.wings.border; 15 16 import org.wings.style.CSSAttributeSet; 17 import org.wings.style.CSSStyleSheet; 18 import org.wings.style.CSSProperty; 19 20 import java.awt.*; 21 22 29 public abstract class SAbstractBorder 30 implements SBorder { 31 34 private Insets insets; 35 36 39 private Color color; 40 41 44 private int thickness; 45 46 protected CSSAttributeSet attributes = new CSSAttributeSet(); 47 48 public SAbstractBorder() { 49 this(Color.black, 2, new Insets(0, 0, 0, 0)); 50 } 51 52 public SAbstractBorder(Color c, int thickness, Insets insets) { 53 setInsets(insets); 54 setColor(c); 55 setThickness(thickness); 56 } 57 58 public SAbstractBorder(Insets insets) { 59 this(null, 0, insets); 60 } 61 62 public SAbstractBorder(Color c) { 63 this(c, 2, new Insets(0, 0, 0, 0)); 64 } 65 66 public SAbstractBorder(int thickness) { 67 this(Color.black, thickness, new Insets(0, 0, 0, 0)); 68 } 69 70 73 public void setInsets(Insets insets) { 74 this.insets = insets; 75 if (insets != null) { 76 attributes.put(CSSProperty.PADDING_TOP, insets.top + "px"); 77 attributes.put(CSSProperty.PADDING_LEFT, insets.left + "px"); 78 attributes.put(CSSProperty.PADDING_RIGHT, insets.right + "px"); 79 attributes.put(CSSProperty.PADDING_BOTTOM, insets.bottom + "px"); 80 } 81 else { 82 attributes.remove(CSSProperty.PADDING_TOP); 83 attributes.remove(CSSProperty.PADDING_LEFT); 84 attributes.remove(CSSProperty.PADDING_RIGHT); 85 attributes.remove(CSSProperty.PADDING_BOTTOM); 86 } 87 } 88 89 92 public final Insets getInsets() { 93 return insets; 94 } 95 96 99 public Color getColor() { 100 return color; 101 } 102 103 106 public void setColor(Color color) { 107 this.color = color; 108 attributes.put(CSSProperty.BORDER_COLOR, CSSStyleSheet.getAttribute(color)); 109 } 110 111 115 public void setThickness(int thickness) { 116 this.thickness = thickness; 117 attributes.put(CSSProperty.BORDER_WIDTH, thickness + "px"); 118 } 119 120 public CSSAttributeSet getAttributes() { 121 return attributes; 122 } 123 124 127 public final int getThickness() { 128 return thickness; 129 } 130 131 } 132 | Popular Tags |