Class: Tabula::ZoneEntity
- Inherits:
-
Tabula.javajava.awtjava.awt.geomjava.awt.geom.Rectangle2Djava.awt.geom.Rectangle2D::Float
- Object
- Tabula.javajava.awtjava.awt.geomjava.awt.geom.Rectangle2Djava.awt.geom.Rectangle2D::Float
- Tabula::ZoneEntity
- Defined in:
- lib/tabula/entities/zone_entity.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#texts ⇒ Object
TODO used? remove if not.
Instance Method Summary collapse
-
#<=>(other) ⇒ Object
default sorting order for ZoneEntity objects is lexicographical (left to right, top to bottom).
-
#initialize(top, left, width, height) ⇒ ZoneEntity
constructor
A new instance of ZoneEntity.
- #inspect ⇒ Object
- #merge!(other) ⇒ Object
- #points ⇒ Object
- #tlbr ⇒ Object
- #tlwh ⇒ Object
- #to_json(options = {}) ⇒ Object
Constructor Details
#initialize(top, left, width, height) ⇒ ZoneEntity
Returns a new instance of ZoneEntity.
10 11 12 13 14 15 16 17 |
# File 'lib/tabula/entities/zone_entity.rb', line 10 def initialize(top, left, width, height) super() if left && top && width && height self.java_send :setRect, [Java::float, Java::float, Java::float, Java::float,], left, top, width, height end # TODO used? remove if not. self.texts = [] end |
Instance Attribute Details
#texts ⇒ Object
TODO used? remove if not.
8 9 10 |
# File 'lib/tabula/entities/zone_entity.rb', line 8 def texts @texts end |
Instance Method Details
#<=>(other) ⇒ Object
default sorting order for ZoneEntity objects is lexicographical (left to right, top to bottom)
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/tabula/entities/zone_entity.rb', line 32 def <=>(other) yDifference = (self.bottom - other.bottom).abs if yDifference < 0.1 || (other.bottom >= self.top && other.bottom <= self.bottom) || (self.bottom >= other.top && self.bottom <= other.bottom) self.left <=> other.left else self.bottom <=> other.bottom end end |
#inspect ⇒ Object
47 48 49 |
# File 'lib/tabula/entities/zone_entity.rb', line 47 def inspect "#<#{self.class} dims: #{self.dims(:top, :left, :width, :height)}>" end |
#merge!(other) ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/tabula/entities/zone_entity.rb', line 19 def merge!(other) self.top = [self.top, other.top].min self.left = [self.left, other.left].min self.width = [self.right, other.right].max - left self.height = [self.bottom, other.bottom].max - top self.java_send :setRect, [Java::float, Java::float, Java::float, Java::float,], self.left, self.top, self.width, self.height self end |
#points ⇒ Object
59 60 61 62 63 64 |
# File 'lib/tabula/entities/zone_entity.rb', line 59 def points [ Point2D::Float.new(left, top), Point2D::Float.new(right, top), Point2D::Float.new(right, bottom), Point2D::Float.new(left, bottom) ] end |
#tlbr ⇒ Object
51 52 53 |
# File 'lib/tabula/entities/zone_entity.rb', line 51 def tlbr [top, left, bottom, right] end |
#tlwh ⇒ Object
55 56 57 |
# File 'lib/tabula/entities/zone_entity.rb', line 55 def tlwh [top, left, width, height] end |
#to_json(options = {}) ⇒ Object
43 44 45 |
# File 'lib/tabula/entities/zone_entity.rb', line 43 def to_json(={}) self.to_h.to_json end |