Class: CTioga::FixedLayout

Inherits:
SimpleLayout show all
Defined in:
lib/CTioga/layout.rb

Overview

This class implements a layout for objects that only need to report extension information to the parent but don’t need to really take this into consideration for themselves. A good example is the ‘alternative axes’ things.

Instance Attribute Summary collapse

Attributes inherited from SimpleLayout

#bounding_box

Attributes inherited from Layout

#child_layouts, #object, #parent

Instance Method Summary collapse

Methods inherited from SimpleLayout

#extension

Methods inherited from Layout

#add_child, #compute_padding, #convert_layout, #extension, #legend_extension, #legend_only_specs, #update_extension_with_object, #update_extensions

Methods included from Log

#identify, #init_logger, #logger, #logger_options, #spawn

Constructor Details

#initialize(ro, ch = [], children = []) ⇒ FixedLayout

Creates a Fixed layout for the given object.



354
355
356
357
# File 'lib/CTioga/layout.rb', line 354

def initialize(ro, ch = [], children = [])
  super
  @position = [0, 0, 0, 0]
end

Instance Attribute Details

#positionObject

The margins of the given object, either an array or a hash with plot_%s_margin



351
352
353
# File 'lib/CTioga/layout.rb', line 351

def position
  @position
end

Instance Method Details

#legend_specs(object, t = nil) ⇒ Object

Return default plot specifications: we don’t take the legend into consideration, for instance.



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/CTioga/layout.rb', line 361

def legend_specs(object, t = nil)

  # First, the position of the layout:
  if @position.is_a? Hash
    specs = @position.dup
  else
    specs = @position.to_frame("plot_%s_margin")
  end


  # Then handling of the legends if applicable:
  # TODO: this will fail for normal legends....
  if @object.display_legend?
    case @object.layout_preferences.legend_position
    when :inside
      a = @object.layout_preferences.legend_spec
      
      legend = Utils::frame_to_array(a, "legend_%s_margin")
      frame = Utils::frame_to_array(specs, "plot_%s_margin")
      
      target = Utils::compose_margins(frame, legend)
      a = target.to_frame("legend_%s_margin")
    else
      warn "Legend position #{@object.layout_preferences.legend_position.inspect} not implemented for FixedLayout"
      a = {}
    end
    return specs.merge(a)
  else
    return specs
  end
end