Module: CTioga2::Graphics::Styles

Defined in:
lib/ctioga2/graphics/styles/box.rb,
lib/ctioga2/graphics/styles/axes.rb,
lib/ctioga2/graphics/styles/base.rb,
lib/ctioga2/graphics/styles/plot.rb,
lib/ctioga2/graphics/styles/sets.rb,
lib/ctioga2/graphics/styles/curve.rb,
lib/ctioga2/graphics/styles/image.rb,
lib/ctioga2/graphics/styles/sheet.rb,
lib/ctioga2/graphics/styles/texts.rb,
lib/ctioga2/graphics/styles/ticks.rb,
lib/ctioga2/graphics/styles/arrows.rb,
lib/ctioga2/graphics/styles/legend.rb,
lib/ctioga2/graphics/styles/carrays.rb,
lib/ctioga2/graphics/styles/contour.rb,
lib/ctioga2/graphics/styles/factory.rb,
lib/ctioga2/graphics/styles/colormap.rb,
lib/ctioga2/graphics/styles/drawable.rb,
lib/ctioga2/graphics/styles/errorbar.rb,
lib/ctioga2/graphics/styles/location.rb,
lib/ctioga2/graphics/styles/map-axes.rb,
lib/ctioga2/graphics/styles/gradients.rb,
lib/ctioga2/graphics/styles/background.rb,
lib/ctioga2/graphics/styles/plot-types.rb,
lib/ctioga2/graphics/styles/colorbrewer.rb

Overview

All the styles

Defined Under Namespace

Modules: Sets Classes: ArrowStyle, AxisStyle, AxisTicks, BackgroundStyle, BaseContourStyle, BaseTextStyle, BasicStyle, BoxStyle, CircularArray, ColorMap, ContoursStyle, CurveFillStyle, CurveStyle, CurveStyleFactory, ErrorBarStyle, FillStyle, FullLatexFont, FullTextStyle, HistogramStyle, ImageStyle, LaTeXFont, LegendStorageStyle, LineStyle, LocationStyle, MapAxisStyle, MarkerStringStyle, MarkerStyle, MultiColumnLegendStyle, ParametricPlotStyle, PlotStyle, StrokeStyle, StyleSheet, TextLabel, TwoPointGradient

Constant Summary collapse

BoxShapeRE =
{
  /^square$/i => :square,
  /^round(ed)?$/i => :round,
}
BoxShape =
CmdType.new('box-shape', {:type => :re_list,
                      :list => BoxShapeRE}, <<EOD)
The shape of a box. It can be:
 * @square@ for a plain square box
 * @round@ for a rounded box
EOD
AxisStyleOptions =
AxisStyle.options_hash()
PartialAxisStyle =
AxisStyleOptions.without('decoration')
AxisGroup =
CmdGroup.new('axes-labels',
"Axes and labels", "Axes and labels", 40)
AxisTypeCommands =
[]
AxisStyleCommand =
Cmd.new("axis-style",nil,"--axis-style", 
            [
             CmdArg.new('axis'),
            ], asco) do |plotmaker, which, opts|
  axes = [which]
  if opts['also-axes']
    axes += opts['also-axes'].split(/\s*,\s*/)
  end

  for w in axes
    begin
      style = AxisStyle.current_axis_style(plotmaker, w)
      style.set_from_hash(opts)
    rescue Exception => e
      error {"Error while setting style of axis: #{w} -- #{e}"}
    end
  end
end
ClearAxesCommand =
Cmd.new("clear-axes",nil,"--clear-axes"
            ) do |plotmaker, opts|
  PlotStyle.current_plot_style(plotmaker).clear_axes
end
DrawingFrameCommand =
Cmd.new("drawing-frame",nil,"--drawing-frame", [],
          { 'units' => CmdArg.new('text') 
          }) do |plotmaker, opts|
  style = PlotStyle.current_plot_style(plotmaker)
  style.clear_axes
  style.padding = nil
  u = opts['units'] || 'cm'
  if u =~ /([\d.]+)?\s*(cm|in|bp|pt|mm)/
    nb = $1 ? $1.to_f : 1.0
    un = $2
    style.frame_real_size = 10 * nb * 
      Types::Dimension::DimensionConversion.fetch(un)
  else
    raise 'Invalid unit'
  end
end
TicksCommand =
Cmd.new("ticks",nil,"--ticks", 
            [
             CmdArg.new('axis'),
            ], Styles::AxisTicks.options_hash) do |plotmaker, which, opts|
  style = AxisStyle.current_axis_style(plotmaker, which)
  style.ticks.set_from_hash(opts)
end
BackgroundLinesCommand =
Cmd.new('background-lines', nil, '--background-lines',
          [
           CmdArg.new('axis'), 
           CmdArg.new('color-or-false')
          ],
          StrokeStyle.options_hash().without('color')
          ) 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
TitleLabelCommand =
Cmd.new('title', '-t', '--title', 
          [ CmdArg.new('text') ],
          TextLabel.options_hash().without('text')
          ) do |plotmaker, label, options|
  PlotStyle.current_plot_style(plotmaker).
    set_label_style('title', options, label)
end
NoTitleLabelCommand =
Cmd.new('no-title', nil, '--no-title', []) do |plotmaker|
  PlotStyle.current_plot_style(plotmaker).
    set_label_style('title', {}, false)
end
X2Command =
Cmd.new('x2', nil, '--x2', []) do |plotmaker|
  plotmaker.interpreter.
    run_commands("xaxis top\naxis-style top /decoration=full")
end
Y2Command =
Cmd.new('y2', nil, '--y2', []) do |plotmaker|
  plotmaker.interpreter.
    run_commands("yaxis right\naxis-style right /decoration=full")
end
NewZAxisCommand =
Cmd.new('new-zaxis', nil, '--new-zaxis',
          [
           CmdArg.new('text')
          ],ZAxisStyle) do |plotmaker, name, options|
  axis = Styles::MapAxisStyle.new
  PlotStyle.current_plot_style(plotmaker).
    set_axis_style(name, axis)
  axis.set_from_hash(options)
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
AspectRatioRE =
{
  /ignore/i => :ignore,
  /expand/i => :expand,
  /contract/i => :contract,
}
AspectRatioType =
CmdType.new('aspect-ratio', 
                    {:type => :re_list,
                      :list => AspectRatioRE}, <<EOD)
How the {command: draw-image} command respects the original image
aspect ratio:
 * @ignore@ (the default) ignores the original aspect ratio
 * @expand@ expand the original box to respect aspect ratio
 * @contract@ contract the original box to respect aspect ratio
EOD
StyleSheetGroup =
CmdGroup.new('style-sheets',
                                     "Default styles", 
                                     <<EOD, 40)
Commands for defining default styles.

All commands take the name of the style to redefine. Different styles
live in a different name space, so there is no risk naming an @axis@ and
a @text@ style with the same name. All styles for a given type inherit from 
the style name @base@.

ctioga2 does not support changing a style after its use. It may
affect only the following objects or all the ones that were created
from the beginning, depending on the context. For safety, only define
style before issueing any graphics command.

ctioga2 may support at a later time loading style files, but that is
not the case for now.

EOD
StyleSheetCommands =
{}
StyleSheetPredefinedNames =
{}
FullTextStyleOptions =

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

FullTextStyle.options_hash()
FullTextLabelOptions =
TextLabel.options_hash()
ZAxisStyle =
TODO:

This naming doesn’t look that good, honestly

MapAxisStyle.options_hash()
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') ], 
          MarkerStringStyle.options_hash) do |plotmaker, text, opts|
  bg = PlotStyle.current_plot_style(plotmaker).
    background
  bg.watermark = text
  bg.watermark_style.set_from_hash(opts)
end
StyleAspectRE =
{
  /^marker[_-]color$/i => :marker_color,
  /^marker[_-](size|scale)$/i => :marker_scale,
}
StyleAspect =
CmdType.new('style-aspect',  {:type => :re_list,
                      :list => StyleAspectRE}, <<EOD)

This type designs which aspect of the style of a 
{command: xy-parametric} plot is controlled by a certain Z value.
It can take the following values:
 * @marker_color@: the color for the markers
 * @marker_size@/@marker_scale@: the size of the markers
EOD
CumulativeHistogramsType =
CmdType.new('cumulative-histograms',
                    {
                      :type => :integer,
                      :shortcuts => {
                        /next/i => :next,
                        /no|false/i => false
                      }
                    }, <<EOD)
How to specify that histograms should be stacked. Can be:
 * a positive number, in which case the following histograms
   will be added to the numbered one (0 is the first)
 * no/false, in which case the following histograms are not stacked
 * next, in which case the following histograms get stacked on a new slot
EOD