Class: CTioga2::Graphics::Types::Box
- Inherits:
-
Object
- Object
- CTioga2::Graphics::Types::Box
- Defined in:
- lib/ctioga2/graphics/types/boxes.rb
Overview
The base class for different kind of boxes
Direct Known Subclasses
Instance Method Summary collapse
-
#classes ⇒ Object
The classes enumerated here get added to the class list of the subwindow.
-
#initialize ⇒ Box
constructor
A new instance of Box.
-
#to_frame_coordinates(t) ⇒ Object
This function returns the frame coordinates of the box, in the form: [ xl, yt, xr, yb ] This function must be reimplemented in children.
-
#to_frame_margins(t) ⇒ Object
Converts this object into an array suitable for use with FigureMaker#set_sub_frame.
-
#within_frames(t, frame_coords = true) ⇒ Object
Runs the block within the context of the box.
Constructor Details
#initialize ⇒ Box
Returns a new instance of Box.
29 30 31 |
# File 'lib/ctioga2/graphics/types/boxes.rb', line 29 def initialize raise "Use a derived class !" end |
Instance Method Details
#classes ⇒ Object
The classes enumerated here get added to the class list of the subwindow
62 63 64 |
# File 'lib/ctioga2/graphics/types/boxes.rb', line 62 def classes return [] end |
#to_frame_coordinates(t) ⇒ Object
This function returns the frame coordinates of the box, in the form:
[ xl, yt, xr, yb ]
This function must be reimplemented in children.
37 38 39 |
# File 'lib/ctioga2/graphics/types/boxes.rb', line 37 def to_frame_coordinates(t) raise "Reimplement this in children !" end |
#to_frame_margins(t) ⇒ Object
Converts this object into an array suitable for use with FigureMaker#set_sub_frame.
43 44 45 46 |
# File 'lib/ctioga2/graphics/types/boxes.rb', line 43 def to_frame_margins(t) xl, yt, xr, yb = self.to_frame_coordinates(t) return [xl, 1 - xr, 1 - yt, yb] end |
#within_frames(t, frame_coords = true) ⇒ Object
Runs the block within the context of the box.
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/ctioga2/graphics/types/boxes.rb', line 49 def within_frames(t, frame_coords = true) t.context do t.subfigure(self.to_frame_margins(t)) do if frame_coords t.set_bounds([0, 1, 1, 0]) end yield end end end |