Added label objects
[erd-marker.git] / lib / erd_handler / box.rb
index 7389955d4b58d2927efc70703e9b3e966f799ded..75543eb22674b1dcc92f5734dcc6ea6366a929e3 100644 (file)
@@ -8,7 +8,7 @@ module ErdHandler
     
     def read(box_element)
       self.id = box_element.attributes["id"].to_i
-      self.name = box_element.attributes["name"]
+      self.name = Label.new box_element.attributes["name"]
       self.mark = box_element.attributes["mark"].to_f
       
       self.x = box_element.elements["location"].attributes["x"].to_f
@@ -19,5 +19,14 @@ module ErdHandler
       self
     end
     
+    def contains?(other)
+      self.x < other.x and self.x + self.width > other.x + other.width and 
+          self.y < other.y and self.y + self.height > other.y + other.height
+    end
+
+    def within?(other)
+      other.contains?(self)
+    end
+    
   end
 end