1
4
5 import org.aswing.geom.*;
6
7
14 class org.aswing.Insets{
15 public var bottom:Number;
16 public var top:Number;
17 public var left:Number;
18 public var right:Number;
19
20
24 public function Insets(top:Number, left:Number, bottom:Number, right:Number){
25 if(top == undefined) top = 0;
26 if(left == undefined) left = 0;
27 if(bottom == undefined) bottom = 0;
28 if(right == undefined) right = 0;
29
30 this.top = top;
31 this.left = left;
32 this.bottom = bottom;
33 this.right = right;
34 }
35
36
39 public function addInsets(insets:Insets):Insets{
40 this.top += insets.top;
41 this.left += insets.left;
42 this.bottom += insets.bottom;
43 this.right += insets.right;
44 return this;
45 }
46
47 public function getInsideBounds(bounds:Rectangle):Rectangle{
48 var r:Rectangle = new Rectangle(bounds);
49 r.x += left;
50 r.y += top;
51 r.width -= (left + right);
52 r.height -= (top + bottom);
53 return r;
54 }
55
56 public function getRoundBounds(bounds:Rectangle):Rectangle{
57 var r:Rectangle = new Rectangle(bounds);
58 r.x -= left;
59 r.y -= top;
60 r.width += (left + right);
61 r.height += (top + bottom);
62 return r;
63 }
64
65 public function roundsSize(size:Dimension):Dimension{
66 var s:Dimension = new Dimension(size);
67 s.width += (left + right);
68 s.height += (top + bottom);
69 return s;
70 }
71
72 public function inroundsSize(size:Dimension):Dimension{
73 var s:Dimension = new Dimension(size);
74 s.width -= (left + right);
75 s.height -= (top + bottom);
76 return s;
77 }
78
79 public function equals(o:Object):Boolean{
80 var i:Insets = Insets(o);
81 if(i == null){
82 return false;
83 }else{
84 return i.bottom == bottom && i.left == left && i.right == right && i.top == top;
85 }
86 }
87
88 public function toString():String{
89 return "Insets(top:"+top+", left:"+left+", bottom:"+bottom+", right"+right+")";
90 }
91 }
92