Module: CTioga2::Graphics::Styles

Defined in:
lib/ctioga2/graphics/styles/base.rb,
lib/ctioga2/graphics/styles/axes.rb,
lib/ctioga2/graphics/styles/plot.rb,
lib/ctioga2/graphics/styles/sets.rb,
lib/ctioga2/graphics/styles/curve.rb,
lib/ctioga2/graphics/styles/texts.rb,
lib/ctioga2/graphics/styles/legend.rb,
lib/ctioga2/graphics/styles/carrays.rb,
lib/ctioga2/graphics/styles/factory.rb,
lib/ctioga2/graphics/styles/drawable.rb,
lib/ctioga2/graphics/styles/background.rb

Overview

All the styles

Defined Under Namespace

Modules: Sets Classes: AxisStyle, BackgroundStyle, BaseTextStyle, BasicStyle, CircularArray, CurveStyle, CurveStyleFactory, FullTextStyle, LegendStorageStyle, MarkerStringStyle, MarkerStyle, PlotStyle, StrokeStyle, TextLabel

Constant Summary collapse

PartialAxisStyle =
{
  'transform' => CmdArg.new('bijection'),
  'stroke_color' => CmdArg.new('color')
}
FullAxisStyle =
PartialAxisStyle.dup
AxisGroup =
CmdGroup.new('axes-labels',
"Axes and labels", "Axes and labels", 40)
AxisTypeCommands =
[]
AxisStyleCommand =
Cmd.new("axis-style",nil,"--axis-style", 
            [
             CmdArg.new('axis'),
            ], FullAxisStyle) do |plotmaker, which, opts|
  style = AxisStyle.current_axis_style(plotmaker, which)
  style.set_from_hash(opts)
end
BackgroundLinesCommands =
Cmd.new('background-lines', nil, '--background-lines',
          [
           CmdArg.new('axis'), 
           CmdArg.new('color-or-false')
          ],{
            'style' => CmdArg.new('line-style'),
            'width' => CmdArg.new('float')
          }) do |plotmaker, which, color, options|
  axis = AxisStyle.current_axis_style(plotmaker, which)
  if color
    style = {'color' => color}
    style.merge!(options)
    if axis.background_lines
      axis.background_lines.set_from_hash(style)
    else
      axis.background_lines = StrokeStyle.from_hash(style)
    end
  else
    axis.background_lines = false
  end
end
XAxisLabelCommand =
Cmd.new('xlabel', '-x', '--xlabel', [ CmdArg.new('text') ],
          FullTextStyleOptions) do |plotmaker, label, options|
  PlotStyle.current_plot_style(plotmaker).
    set_label_style('x_label', options, label)
end
NoXAxisLabelCommand =
Cmd.new('no-xlabel', nil, '--no-xlabel', []) do |plotmaker|
  PlotStyle.current_plot_style(plotmaker).
    set_label_style('x_label', {}, false)
end
YAxisLabelCommand =
Cmd.new('ylabel', '-y', '--ylabel', [ CmdArg.new('text') ],
          FullTextStyleOptions) do |plotmaker, label, options|
  PlotStyle.current_plot_style(plotmaker).
    set_label_style('y_label', options, label)
end
NoYAxisLabelCommand =
Cmd.new('no-ylabel', nil, '--no-ylabel', []) do |plotmaker|
  PlotStyle.current_plot_style(plotmaker).
    set_label_style('y_label', {}, false)
end
TitleLabelCommand =
Cmd.new('title', '-t', '--title', [ CmdArg.new('text') ],
          FullTextStyleOptions) do |plotmaker, label, options|
  PlotStyle.current_plot_style(plotmaker).
    set_label_style('title', options, label)
end
LabelStyleCommand =
Cmd.new('label-style', nil, '--label-style',
          [ CmdArg.new('label') ], # Here: change the label too... 
          FullTextLabelOptions) do |plotmaker, which, options|
  PlotStyle.current_plot_style(plotmaker).
    set_label_style(which, options)
end
LocationToTiogaLocation =

Conversion between the #location attribute and the real constant used for Tioga

{
  :left => Tioga::FigureConstants::LEFT,
  :right => Tioga::FigureConstants::RIGHT,
  :bottom => Tioga::FigureConstants::BOTTOM,
  :top => Tioga::FigureConstants::TOP,
  :at_x_origin => Tioga::FigureConstants::AT_X_ORIGIN,
  :at_y_origin => Tioga::FigureConstants::AT_Y_ORIGIN
}
LocationVertical =

Horizontal or vertical

{
  :left => true,
  :right => true,
  :bottom => false,
  :top => false,
  :at_x_origin => true,
  :at_y_origin => false
}
FullTextStyleOptions =

A hash that can be used as a base for optional arguments to things that take texts.

{
  'angle' => CmdArg.new('float'),
  'shift' => CmdArg.new('float'),
  'scale' => CmdArg.new('float'),
  'justification' => CmdArg.new('justification'),
  'color' => CmdArg.new('color'),
  'align' => CmdArg.new('alignment'),
}
FullTextLabelOptions =

Same thing as FullTextStyleOptions, but also permits to override the #text part of the whole stuff..

FullTextStyleOptions.dup
StringMarkerOptions =
{
  'color' => CmdArg.new('color'),
  'stroke_color' => CmdArg.new('color'),
  'fill_color' => CmdArg.new('color'),
  'scale' => CmdArg.new('float'),
  'horizontal_scale' => CmdArg.new('float'),
  'vertical_scale' => CmdArg.new('float'),
  'angle' => CmdArg.new('float'),
  'justification' => CmdArg.new('justification'),
  'alignment' => CmdArg.new('alignment'),
  'font' => CmdArg.new('pdf-font')
}
BackgroundGroup =
CmdGroup.new('background',
                     "Background", <<EOD, 40)
Commands dealing with the aspect of the background of a plot (excluding
background lines, which are linked to axes).
EOD
BackgroundColorCmd =
Cmd.new('background', nil, '--background', 
          [ CmdArg.new('color-or-false') ]) do |plotmaker, color|
  PlotStyle.current_plot_style(plotmaker).
    background.background_color = color
end
WatermarkCmd =
Cmd.new('watermark', nil, '--watermark', 
          [ CmdArg.new('text') ], 
          StringMarkerOptions) do |plotmaker, text, opts|
  bg = PlotStyle.current_plot_style(plotmaker).
    background
  bg.watermark_text = text
  bg.watermark_style.set_from_hash(opts)
end