Module: CTioga2::Graphics
- Defined in:
- lib/ctioga2/graphics/root.rb,
lib/ctioga2/graphics/types.rb,
lib/ctioga2/graphics/legends.rb,
lib/ctioga2/graphics/elements.rb,
lib/ctioga2/graphics/geometry.rb,
lib/ctioga2/graphics/generator.rb,
lib/ctioga2/graphics/styles/box.rb,
lib/ctioga2/graphics/types/fill.rb,
lib/ctioga2/graphics/types/grid.rb,
lib/ctioga2/graphics/coordinates.rb,
lib/ctioga2/graphics/styles/axes.rb,
lib/ctioga2/graphics/styles/base.rb,
lib/ctioga2/graphics/styles/fill.rb,
lib/ctioga2/graphics/styles/plot.rb,
lib/ctioga2/graphics/styles/sets.rb,
lib/ctioga2/graphics/types/boxes.rb,
lib/ctioga2/graphics/types/point.rb,
lib/ctioga2/graphics/legends/area.rb,
lib/ctioga2/graphics/styles/curve.rb,
lib/ctioga2/graphics/styles/image.rb,
lib/ctioga2/graphics/styles/scope.rb,
lib/ctioga2/graphics/styles/texts.rb,
lib/ctioga2/graphics/styles/ticks.rb,
lib/ctioga2/graphics/legends/items.rb,
lib/ctioga2/graphics/styles/arrows.rb,
lib/ctioga2/graphics/styles/legend.rb,
lib/ctioga2/graphics/styles/styles.rb,
lib/ctioga2/graphics/styles/carrays.rb,
lib/ctioga2/graphics/styles/contour.rb,
lib/ctioga2/graphics/styles/factory.rb,
lib/ctioga2/graphics/types/location.rb,
lib/ctioga2/graphics/elements/region.rb,
lib/ctioga2/graphics/legends/storage.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/types/bijection.rb,
lib/ctioga2/graphics/elements/contour.rb,
lib/ctioga2/graphics/elements/curve2d.rb,
lib/ctioga2/graphics/elements/element.rb,
lib/ctioga2/graphics/elements/subplot.rb,
lib/ctioga2/graphics/elements/tangent.rb,
lib/ctioga2/graphics/elements/xyz-map.rb,
lib/ctioga2/graphics/legends/provider.rb,
lib/ctioga2/graphics/styles/gradients.rb,
lib/ctioga2/graphics/subplot-commands.rb,
lib/ctioga2/graphics/types/boundaries.rb,
lib/ctioga2/graphics/types/dimensions.rb,
lib/ctioga2/graphics/legends/multicols.rb,
lib/ctioga2/graphics/styles/background.rb,
lib/ctioga2/graphics/styles/plot-types.rb,
lib/ctioga2/graphics/styles/stylesheet.rb,
lib/ctioga2/graphics/elements/histogram.rb,
lib/ctioga2/graphics/elements/primitive.rb,
lib/ctioga2/graphics/styles/colorbrewer.rb,
lib/ctioga2/graphics/elements/containers.rb,
lib/ctioga2/graphics/elements/style-lists.rb,
lib/ctioga2/graphics/elements/xyz-contour.rb,
lib/ctioga2/graphics/elements/parametric2d.rb,
lib/ctioga2/graphics/elements/plot-elements.rb,
lib/ctioga2/graphics/elements/gradient-region.rb,
lib/ctioga2/graphics/elements/redirecting-container.rb
Overview
This module contains all graphical elements of CTioga2
Defined Under Namespace
Modules: Elements, Legends, LineStyles, Styles, Types Classes: CoordinateTransforms, CurveGenerator, Line, RootObject, Segment
Constant Summary collapse
- NoRE =
/no(ne)?|off|false/i- ColorType =
CmdType.new('color', { :type => :tioga_color, :namespace => Tioga::ColorConstants, }, "A color. It can take three forms:\n * a named color, see \n{url: http://tioga.rubyforge.org/doc/classes/Tioga/ColorConstants.html}\nfor the list of color names.\n * an HTML color: for instance, @#f00@ or @#ff0000@ is red;\n * a list of three numbers between 0 and 1: @1,0,0@ is red too.\n")
- ColorOrFalseType =
CmdType.new('color-or-false', { :type => :tioga_color, :namespace => Tioga::ColorConstants, :shortcuts => { NoRE => false } }, "A {type: color}, or none to say that nothing should be drawn.\n")
- RegionSideType =
CmdType.new('region-side', { :type => :list, :list => {}, :shortcuts => { 'above' => :above, 'below' => :below, 'ignore' => false, } }, "Within a {command: region}, designates the position of the curve with\nrespect to the region:\n * @above@\n * @below@\n * @ignore@ if this curve is not to be taken into account\n")
- LineStyleType =
CmdType.new('line-style', { :type => :tioga_line_style, :namespace => LineStyles, :shortcuts => { NoRE => false, } }, "A line style, which is one of @solid@, @dots@, @dashes@, @small_dots@,\na series of comma-separated numbers which are the length of the\nstrokes and gaps, or @no@, @none@ or @off@ to mean no line.\n")
- MarkerType =
CmdType.new('marker', { :type => :tioga_marker, :namespace => Tioga::MarkerConstants, :shortcuts => { NoRE => false } }, "A Tioga Marker, ie either a name from the list at {url:\nhttp://tioga.rubyforge.org/doc/Tioga/MarkerConstants.html}, such as\n@Box@, @Star@, @Spade@ or two or three comma-separated numbers,\n_font_, _number_ and _width_. _font_ defines the font (standard PDF\nfonts, from 1 to 14), _number_ the number of the character within the\nfont (between 0 and 255), and if _width_ is specified, the marker is\nstroked and not filled, and the number is the line width for the\nstroke.\n")
- PointType =
CmdType.new('point', :point, "A given point on a figure.\n")
- LevelType =
We need a very specific type for that as we want to have a reference to the level too !
CmdType.new('level', :level, "A level on a XYZ map (that is, just a Z value).\n")
- JustificationRE =
{ /l(eft)?/i => Tioga::FigureConstants::LEFT_JUSTIFIED, /c(enter)?/i => Tioga::FigureConstants::CENTERED, /r(ight)?/i => Tioga::FigureConstants::RIGHT_JUSTIFIED }
- JustificationType =
CmdType.new('justification', {:type => :re_list, :list => JustificationRE}, "Horizontal aligment of the (with respect to its location). Can be one of:\n * @l@ or @left@\n * @c@, @center@\n * @r@, @right@\n")
- TextAlignType =
CmdType.new('text-align', {:type => :re_list, :list => JustificationRE, :shortcut => { NoRE => :no } }, "Horizontal aligment for text within its box. Only of use\nfor texts with a given text width.\nCan be one of:\n * @l@ or @left@\n * @c@, @center@\n * @r@, @right@\n * @no@ or @none@ to not issue aligning commands, in which case you get \nfull LaTeX-justified paragraphs (probably with a lot of hyphens).\n")
- AlignmentRE =
Regular expression for vertical alignment
{ /t(op)?/i => Tioga::FigureConstants::ALIGNED_AT_TOP, /c(enter)|m(idheight)/i => Tioga::FigureConstants::ALIGNED_AT_MIDHEIGHT, /B|Baseline|baseline/ => Tioga::FigureConstants::ALIGNED_AT_BASELINE, /b(ottom)?/ => Tioga::FigureConstants::ALIGNED_AT_BOTTOM }
- AlignmentType =
CmdType.new('alignment', {:type => :re_list, :list => AlignmentRE}, "Vertical aligment for text. Can be one of:\n * @t@ or @top@\n * @c@, @center@, @m@ or @midheight@ (vertically centered)\n * @B@, @Baseline@ or @baseline@ to align at the baseline\n * @b@ or @bottom@\n")
- PDFFont =
CmdType.new('pdf-font', :integer, "A number between 1 and 14 that designates one of the 14 standard \nPDF fonts. (see for instance\n{url: http://tioga.rubyforge.org/doc/classes/Tioga/MarkerConstants.html}\nfor more information).\n")
- AlignedPointType =
CmdType.new('aligned-point', {:type => :aligned_point, :default => :frame}, "A point together with alignment specifications, used to place some \nelements such as legends for instance, that require alignment information. \n\nThe first two letters represent the alignment:\n\n * @t@ for top\n * @b@ for bottom\n * @c@ for center\n * @l@ for left and\n * @r@ for right\n\nThese letters can optionally be followed by the exact location of the\npoint in frame coordinates. If not provided, a reasonable default\nvalue is chosen.\n\nExamples:\n\n * @tl@ is a point at the top left of the frame aligned to the top\n and left;\n * @cl:0.1,0.6@ is vertically centered and aligned to the left, and\n positioned 10% from the left and 60% from the bottom.\n")
- FrameMarginsType =
CmdType.new('frame-margins', {:type => :frame_margins, :shortcuts => { /^\s*auto\s*$/i => nil}}, "Margins around a plot, ie the distance from the side of the plot to\nthe corresponding side of the container (most likely the whole\nPDF). It can take three forms:\n * @dimension@ (applies to all sides)\n * @left_right, top_bottom@\n * @left, right, top, bottom@\n\nEach of these elements is a valid {type: dimension}.\n\nIt can also be @auto@, in which case the position of the margins is\ncomputed automatically to accomodate the various labels/ticks.\n")
- AxisDecorationType =
Now, axes stuff:
CmdType.new('axis-decoration', :tioga_axis_type, "Kinds of decoration on a axis line, such as nothing, lines, ticks, \ntick labels. Possible values:\n * @hidden@, @off@, @no@, @none@: no axis at all\n * @line@: only a line\n * @ticks@: only ticks\n * @major@: only major ticks\n * @major-num@: major ticks along with their labels\n * @full@: major ticks and labels + minor ticks\n")
- TicksSideRE =
{ /i(nside)?/i => {'ticks_inside' => true, 'ticks_outside' => false}, /o(utside)?/i => {'ticks_outside' => true, 'ticks_inside' => false}, /b(oth)?/i => {'ticks_outside' => true, 'ticks_inside' => true} }
- TicksSideType =
CmdType.new('ticks-side', {:type => :re_list, :list => TicksSideRE}, "On what side of an axis line are the ticks positioned:\n * @inside@: on the inside\n * @outside@: on the outside\n * @both@: on both the inside and the outside\n")
- DimensionType =
Dimensions
CmdType.new('dimension', { :type => :dimension, :default => :dy }, "\nA dimension, in absolute units, or in units of text height, figure,\nframe or page coordinates. It is in the form \n@value unit@\nwhere @value@ is a number and unit can be one of @pt@,\n@bp@, @in@, @cm@ (absolute units, same meaning as in TeX), \n@dy@ (@1.0 dy@ is the height of a text\nline), @figure@ or @f@ (for figure coordinates, i.e. the coordinates of the\nplot), @frame@ or @F@ (@1.0 frame@ is the full size of the current subplot) and\n@page@ or @p@ (@1.0 page@ is the whole height/width of the output file).\n\nIt can also be @auto@, which is 1.0 in frame units (ie the width or\nthe height of the current plot).\n")
- DimensionOrNoType =
CmdType.new('dimension-or-no', { :type => :dimension, :default => :dy, :shortcuts => { NoRE => false } }, "A {type: dimension}, or @no@ or @none@.\n")
- BoxType =
Boxes
CmdType.new('box', :box, "The specification for a box, such as an inset. It can be a grid\nspecification, such as @grid:0,1@. For this to work, a grid must have\nbeen setup beforehand using {command: setup-grid}.\n\nIt can also be an {type: aligned-point} together with a width and\noptionally a height in frame coordinates, such as:\n\n * @cc:0.3@: a box in the center of size 30% width and 30% height;\n * @bl:0.1,0.2:0.7,0.2@ a box starting from the point at 10% from the left\n and 20% from the bottom, with a width of 70% and a height of 20%.\n")
- BijectionType =
Coordinate transformations
CmdType.new('bijection', :bijection, "A pair of functions of x specifying a bidirectional coordinate\ntransformation separated by a double colon (@::@), in the order\n@from::to@.\n\nEach of the functions must be valid Ruby code - it is not exactly\nmathematical functions, in particular Ruby does not like floats which\nare missing digits on either side of the dot : for instance, @.3@ and\n@1.@ are not valid. Sorry.\n\nIn most of the usual cases, the coordinate transform is an involution,\nthat is from and to is the same function (this is the case for\na/x). In this case, you can omit the second function.\n")
- LegendGroup =
Now, various commands pertaining to legends
CmdGroup.new('legends', "Legends", "Commands to specify legends and tweak their look.\n", 1)
- NextLegendCommand =
Cmd.new("legend",'-l',"--legend", [ CmdArg.new('text') ]) do |plotmaker, legend| plotmaker.curve_generator.legend_provider.current_legend = legend end
- LegendLineCommand =
Cmd.new("legend-line",nil,"--legend-line", [ CmdArg.new('text') ], Styles::FullTextStyleOptions) do |plotmaker, legend, opts| l = Legends::LegendLine.new(legend, opts) plotmaker.root_object.current_plot.add_legend_item(l) end
- AutoLegendCommand =
Cmd.new("auto-legend",nil,"--auto-legend", [ CmdArg.new('boolean') ]) do |plotmaker, value| plotmaker.curve_generator.legend_provider.auto_legend = value end
- LegendStyleOptions =
Styles::LegendStorageStyle.()
- LegendStyleCommand =
Cmd.new("legend-style",nil,"--legend-style", [], LegendStyleOptions) do |plotmaker, | plotmaker.root_object.current_legend_area. legend_style.set_from_hash() end
- LegendInsideCommand =
Cmd.new("legend-inside", nil, "--legend-inside", [ CmdArg.new('aligned-point')], opts) do |plotmaker, point, | l = Legends::LegendArea.new(:inside, plotmaker.root_object.current_plot, ) l.legend_position = point plotmaker.root_object.current_plot.legend_area = l l.legend_style.set_from_hash() end
- LegendMulticolOptions =
Styles::MultiColumnLegendStyle.()
- LegendMultiColCommand =
Cmd.new("legend-multicol", nil, "--legend-multicol", [], LegendMulticolOptions) do |plotmaker, | multicol = Legends::MultiColumnLegend.new multicol.style.set_from_hash() plotmaker.root_object.current_plot. enter_legend_subcontainer(multicol) end
- LegendMultiColEndCommand =
Cmd.new("legend-multicol-end", nil, "--legend-multicol-end", [], {}) do |plotmaker, | plotmaker.root_object.current_plot. enter_legend_subcontainer(nil) end
- PlotCoordinatesGroup =
Now, various commands pertaining to various drawables
CmdGroup.new('coordinates', "Plot coordinates", "Plot coordinates", 2)
- PlotMarginCommand =
Cmd.new("margin",nil,"--margin", [ CmdArg.new('float') ]) do |plotmaker, margin| plotmaker.root_object.current_plot.style.plot_margin = margin end
- CoordinateRelatedCommands =
TODO:
All these commands should be axis-dependent, and not
Various coordinate-related commands:
plot-dependent.
[]
- PlotTypesGroup =
The group for chosing plot types.
CmdGroup.new('plot-types', "Switch between different kinds of plots", "How to switch between different kinds of plot types", 01)
- XYParametricPlotCommand =
Cmd.new("xy-parametric",nil,"--xy-parametric", [], Styles::ParametricPlotStyle.) do |plotmaker, opts| plotmaker.curve_generator.current_curves = :xy_parametric plotmaker.curve_generator. xy_parametric_parameters.set_from_hash(opts) end
- HistogramPlotCommand =
Cmd.new("histogram",nil,"--histogram", [], Styles::HistogramStyle.) do |plotmaker, opts| plotmaker.curve_generator.current_curves = :histogram plotmaker.curve_generator. histogram_parameters.set_from_hash(opts) end
- ContourPlotCommand =
Cmd.new("contour",nil,"--contour") do |plotmaker| plotmaker.curve_generator.current_curves = :xyz_contour end
- XYPlotCommand =
Cmd.new("xy-plot",nil,"--xy-plot") do |plotmaker| plotmaker.curve_generator.current_curves = :xy_plot end
- XYZMapCommand =
Cmd.new("xyz-map",nil,"--xyz-map") do |plotmaker| plotmaker.curve_generator.current_curves = :xyz_map end
- SubplotsGroup =
The group containing all commands linked to subplots and other insets, frame margin selections…
CmdGroup.new('subplots', "Subplots and assimilated", "Subplots and assimilated", 31)
- SFMOpts =
{}
- SetFrameMarginsCommand =
Cmd.new("frame-margins",nil,"--frame-margins", [ CmdArg.new('frame-margins'), ], SFMOpts) do |plotmaker, margins, opts| if margins for w in SFMOpts.keys if opts.key? w dim = margins.send(w) dim.copy_from(opts[w]) end end end plotmaker.root_object.current_plot.subframe = margins end
- PaddingCommand =
Cmd.new("padding",nil,"--padding", [ CmdArg.new('dimension'), ]) do |plotmaker, dim| Styles::PlotStyle.current_plot_style(plotmaker).padding = dim end
- TARE =
{ /^\s*old/i => :old, /^\s*both/i => :both, /^\s*measure/i => :measure, }
- TEType =
CmdType.new('text-adjust-mode', {:type => :re_list, :list => TARE}, "Mode for text size adjustment\n * @old@ for the old style heuristics\n * @both@ for both the old style heuristics and the measures, taking\n whichever of those is the biggest\n * @measure@ for only measured text size (but watch out for axis ticks !)\n")
- TAACommand =
Cmd.new("text-adjust-mode",nil,"--text-adjust-mode", [ CmdArg.new('text-adjust-mode'), ]) do |plotmaker, tf| Styles::PlotStyle.current_plot_style(plotmaker).text_auto_adjust = tf end
- RootPlotCommand =
Cmd.new("root-plot",nil,"--root-plot", [ ], Elements::TiogaElement::StyleBaseOptions) do |plotmaker, opts| Log::debug { "Explicitly starting the root plot, options #{opts.inspect}" } opts['id'] ||= 'root' plotmaker.root_object. enter_subobject(Elements::Subplot.new(nil,plotmaker.root_object, opts)) end
- InsetCommand =
Cmd.new("inset",nil,"--inset", [ CmdArg.new('box'), ], Elements::TiogaElement::StyleBaseOptions) do |plotmaker, box, opts| Log::debug { "Starting a subplot with specs #{box.inspect}" } subplot = plotmaker.root_object.subplot(opts) subplot.subframe = box end
- NextInsetCommand =
Cmd.new("next-inset",nil,"--next-inset", [ CmdArg.new('box'), ], Elements::TiogaElement::StyleBaseOptions) do |plotmaker, box,opts| plotmaker.root_object.leave_subobject subplot = plotmaker.root_object.subplot(opts) subplot.subframe = box end
- EndCommand =
Cmd.new("end",nil,"--end", []) do |plotmaker| plotmaker.root_object.leave_subobject end
- RegionOptions =
{ 'color' => CmdArg.new('color'), 'pattern' => CmdArg.new('fill-pattern'), 'reversed_pattern' => CmdArg.new('fill-pattern'), 'transparency' => CmdArg.new('float'), 'reversed_color' => CmdArg.new('color'), 'reversed_transparency' => CmdArg.new('float'), }
- RegionCommand =
Cmd.new("region",nil,"--region", [ ], RegionOptions) do |plotmaker, | r = plotmaker.root_object.enter_region() r.set_from_hash() end
- GradientCommand =
Cmd.new("gradient",nil,"--gradient", [CmdArg.new('color'), CmdArg.new('color') ], Elements::TiogaElement::StyleBaseOptions) do |plotmaker, s, e, | r = plotmaker.root_object.enter_gradient() r.start_color = s r.end_color = e r.set_from_hash() end
- RescaleCommand =
Cmd.new("plot-scale",nil,"--plot-scale", [CmdArg.new('float')], {'what' => CmdArg.new('text')}) do |plotmaker, scale, | what = ['what'] || 'text' case what when /text/i Styles::PlotStyle.current_plot_style(plotmaker).text_scale = scale when /lines/i Styles::PlotStyle.current_plot_style(plotmaker).lines_scale = scale when /both/i Styles::PlotStyle.current_plot_style(plotmaker).text_scale = scale Styles::PlotStyle.current_plot_style(plotmaker).lines_scale = scale else CTioga2::Log::error { "Unkown 'what' option for plot-scale: #{what}" } end end
- SetupGridOptions =
Options for the SetupGrid command:
{}
- SetupGridCommand =
Cmd.new('setup-grid', nil, '--setup-grid', [ CmdArg.new('text') ], SetupGridOptions ) do |plotmaker, nup, | grd = Types::GridLayout.new(nup) for f in %w(left right top bottom) if .key? f grd.outer_margins[f] = [f] end end grd.delta_x = ['dx'] if ['dx'] grd.delta_y = ['dy'] if ['dy'] Types::GridLayout.current_grid = grd end
- ReopenCommand =
Cmd.new("reopen",nil,"--reopen", [CmdArg.new('object')], {}) do |plotmaker, obj, | plotmaker.root_object.enter_subobject(obj, false) end
- HideCommand =
Cmd.new("hide",nil,"--hide", [CmdArg.new('objects')], { 'show' => CmdArg.new('boolean') }) do |plotmaker, objs, opts| hidden = if opts.key? 'show' ! opts['show'] else true end for o in objs o.hidden = hidden end end