Class: CTioga::Region
- Inherits:
-
Container
- Object
- TiogaElement
- Container
- CTioga::Region
- Defined in:
- lib/CTioga/elements/containers.rb
Overview
The Region class handles the cases where the user wants some parts between curves to be coloured. In this case, all the curves which are included between the –region and –end options will
Instance Attribute Summary collapse
-
#dont_display ⇒ Object
Some general options.
-
#fill_twice ⇒ Object
Filling rules:.
-
#invert_rule ⇒ Object
Filling rules:.
-
#region_color ⇒ Object
Style attributes.
-
#region_debug ⇒ Object
Some general options.
-
#region_transparency ⇒ Object
Style attributes.
Attributes inherited from Container
#accept_legend, #disable_legend, #elements, #force_position, #funcalls, #layout, #layout_preferences, #rescale, #root_frame, #show_legend
Attributes inherited from TiogaElement
Instance Method Summary collapse
- #do(t) ⇒ Object
-
#fill_region(t, i) ⇒ Object
Fills the regions using the index to choose the closing path for the first curve and opposed ones for next curves.
-
#get_boundaries ⇒ Object
Region must return its true boundaries.
-
#initialize(parent = nil) ⇒ Region
constructor
A new instance of Region.
Methods inherited from Container
#add_elem, #add_funcall, #add_legend_info, #convert_layout, #display_legend?, #has_plots?, #internal_get_boundaries, #make_funcalls, #method_missing
Methods inherited from TiogaElement
Methods included from Log
#identify, #init_logger, #logger, #logger_options, #spawn
Methods included from Debug
#debug_figmaker, #debug_patterns, #debug_puts, #figmaker_options, #test_pattern, #test_pattern_right
Constructor Details
#initialize(parent = nil) ⇒ Region
Returns a new instance of Region.
508 509 510 511 512 513 |
# File 'lib/CTioga/elements/containers.rb', line 508 def initialize(parent = nil) super @region_color = [0.9,0.9,0.9] # Very light gray. @region_transparency = 0 @dont_display = false end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class CTioga::Container
Instance Attribute Details
#dont_display ⇒ Object
Some general options
498 499 500 |
# File 'lib/CTioga/elements/containers.rb', line 498 def dont_display @dont_display end |
#fill_twice ⇒ Object
Filling rules:
501 502 503 |
# File 'lib/CTioga/elements/containers.rb', line 501 def fill_twice @fill_twice end |
#invert_rule ⇒ Object
Filling rules:
501 502 503 |
# File 'lib/CTioga/elements/containers.rb', line 501 def invert_rule @invert_rule end |
#region_color ⇒ Object
Style attributes
494 495 496 |
# File 'lib/CTioga/elements/containers.rb', line 494 def region_color @region_color end |
#region_debug ⇒ Object
Some general options
498 499 500 |
# File 'lib/CTioga/elements/containers.rb', line 498 def region_debug @region_debug end |
#region_transparency ⇒ Object
Style attributes
494 495 496 |
# File 'lib/CTioga/elements/containers.rb', line 494 def region_transparency @region_transparency end |
Instance Method Details
#do(t) ⇒ Object
556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 |
# File 'lib/CTioga/elements/containers.rb', line 556 def do(t) debug "Region: plotting elements" make_funcalls(t) # We fill first, as it looks way better if @fill_twice or (! @invert_rule) fill_region(t,0) end if @fill_twice or @invert_rule fill_region(t,1) end # Then, we plot the elements, unless we were told not to # by --region-dont-display unless @dont_display @elements.each do |e| e.do(t) end end end |
#fill_region(t, i) ⇒ Object
Fills the regions using the index to choose the closing path for the first curve and opposed ones for next curves.
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
# File 'lib/CTioga/elements/containers.rb', line 517 def fill_region(t,i) # We need to wrap in a context, else the clipping path screws up # everyting t.context do debug "Filling with parameter #{i}" bound = internal_get_boundaries for el in @elements if el.respond_to?(:make_path) el.make_path(t) # We close the path with a line coming back alternatively to # the top and the bottom close_to = bound[i % 2 + 2] el.close_path(t, close_to) i += 1 # If the debugging flag is set, we heavily tamper with the # style of the elements to force the fill where # we would clip. if @region_debug el.style.fill_type = close_to el.style.fill_transparency = 0.8 el.style.fill_color = el.style.color || el.style.marker_color end end t.clip end t.fill_color = @region_color t.fill_transparency = @region_transparency t.fill_rect(bound[0], bound[3], bound[1] - bound[0], bound[2] - bound[3]) end end |
#get_boundaries ⇒ Object
Region must return its true boundaries.
552 553 554 |
# File 'lib/CTioga/elements/containers.rb', line 552 def get_boundaries internal_get_boundaries end |