19
19
# This module contains all the classes used by ctioga
22
Version::register_svn_info('$Revision: 202 $', '$Date: 2010-11-30 22:21:17 +0100 (Tue, 30 Nov 2010) $')
22
Version::register_svn_info('$Revision: 370 $', '$Date: 2012-12-28 17:40:18 +0100 (Fri, 28 Dec 2012) $')
34
34
# * background (uniform fill + watermark if applicable + possibly
37
# This class is way too complex and needs too much flexibility
38
# to be handled by a subclass of BasicStyle. However, all
39
# substyles should be.
38
42
include Tioga::FigureConstants
76
82
# Default style for the plots.
78
@axes[:left] = AxisStyle.new(:left,
79
AXIS_WITH_TICKS_AND_NUMERIC_LABELS,
81
@axes[:bottom] = AxisStyle.new(:bottom,
82
AXIS_WITH_TICKS_AND_NUMERIC_LABELS,
85
StyleSheet.style_for(AxisStyle, 'left', :left,
86
AXIS_WITH_TICKS_AND_NUMERIC_LABELS,
89
StyleSheet.style_for(AxisStyle, 'bottom', :bottom,
90
AXIS_WITH_TICKS_AND_NUMERIC_LABELS,
85
@axes[:right] = AxisStyle.new(:right, AXIS_WITH_TICKS_ONLY)
86
@axes[:top] = AxisStyle.new(:top, AXIS_WITH_TICKS_ONLY)
94
StyleSheet.style_for(AxisStyle, 'right', :right,
97
StyleSheet.style_for(AxisStyle, 'top', :top,
88
100
@xaxis_location = :bottom
89
101
@yaxis_location = :left
91
@title = TextLabel.new
92
@title.loc = Types::PlotLocation.new(:top)
104
StyleSheet.style_for(TextLabel, 'title',
106
Types::PlotLocation.new(:top))
94
108
@plot_margin = nil
96
110
@transforms = CoordinateTransforms.new
98
@background = BackgroundStyle.new
113
StyleSheet.style_for(BackgroundStyle, 'background')
100
115
# A padding of 4bp ? Why ?? Why not ?
101
116
@padding = Types::Dimension.new(:bp, 4)
119
# Apply (destructively) the current transformations to the
121
def apply_transforms!(dataset)
122
@transforms.transform_2d!(dataset)
104
126
# Whether to use log scale for the given axis.
106
128
# Now the question is: how should that affect user-defined
310
332
"Axes and labels", "Axes and labels", 40)
314
335
AxisTypeCommands = []
315
336
[:left, :right, :top, :bottom].each do |loc|
316
337
AxisTypeCommands <<
317
338
Cmd.new("#{loc}",nil,"--#{loc}",
319
CmdArg.new('axis-decoration'),
340
AxisStyleOptions['decoration'],
320
341
], PartialAxisStyle) do |plotmaker, dec, opts|
321
342
style = AxisStyle.current_axis_style(plotmaker, loc)
322
343
style.decoration = dec
327
348
describe("Sets the type of the #{loc} axis",
328
349
<<"EOH", AxisGroup)
329
350
Sets the type of the #{loc} axis.
352
The options have the same meaning as for {command: define-axis-style},
353
see that command for more information.
333
358
AxisStyleCommand =
334
359
Cmd.new("axis-style",nil,"--axis-style",
336
361
CmdArg.new('axis'),
337
], FullAxisStyle) do |plotmaker, which, opts|
362
], AxisStyleOptions) do |plotmaker, which, opts|
338
363
style = AxisStyle.current_axis_style(plotmaker, which)
339
364
style.set_from_hash(opts)
342
367
describe("Sets the style of the given axis",
343
368
<<"EOH", AxisGroup)
344
369
This command can be used to set various aspects of the style of the
345
given axis, through its various options:
370
given axis, through its various options, which are documented in more details
371
in the {command: define-axis-style} command.
349
374
BackgroundLinesCommand =
352
377
CmdArg.new('axis'),
353
378
CmdArg.new('color-or-false')
355
'style' => CmdArg.new('line-style'),
356
'width' => CmdArg.new('float')
357
}) do |plotmaker, which, color, options|
380
StrokeStyle.options_hash().without('color')
381
) do |plotmaker, which, color, options|
358
382
axis = AxisStyle.current_axis_style(plotmaker, which)
360
384
style = {'color' => color}
379
403
%w{x y}.each do |axis|
380
404
labelcmd = Cmd.new("#{axis}label", "-#{axis}",
381
405
"--#{axis}label", [ CmdArg.new('text') ],
382
FullTextStyleOptions) do |plotmaker, label, options|
406
TextLabel.options_hash().without('text')
407
) do |plotmaker, label, options|
383
408
PlotStyle.current_plot_style(plotmaker).
384
409
set_label_style("#{axis}_label", options, label)
387
412
<<"EOH", AxisGroup)
388
413
Sets the #{axis.upcase} label of the current plot.
416
Commands::make_alias_for_option "#{axis}label", 'alignment', 'align', true
391
418
nolabelcmd = Cmd.new("no-#{axis}label", nil,
392
419
"--no-#{axis}label", []) do |plotmaker|
417
444
TitleLabelCommand =
418
Cmd.new('title', '-t', '--title', [ CmdArg.new('text') ],
419
FullTextStyleOptions) do |plotmaker, label, options|
445
Cmd.new('title', '-t', '--title',
446
[ CmdArg.new('text') ],
447
TextLabel.options_hash().without('text')
448
) do |plotmaker, label, options|
420
449
PlotStyle.current_plot_style(plotmaker).
421
450
set_label_style('title', options, label)
426
455
Sets the title of the current plot.
458
Commands::make_alias_for_option 'title', 'alignment', 'align', true
429
460
NoTitleLabelCommand =
430
461
Cmd.new('no-title', nil, '--no-title', []) do |plotmaker|
431
462
PlotStyle.current_plot_style(plotmaker).
492
523
PlotStyle.current_plot_style(plotmaker).
493
524
set_label_style(which, options)
527
Commands::make_alias_for_option 'label-style', 'alignment', 'align', true
496
529
LabelStyleCommand.describe("Sets the style of the given label",
497
530
<<"EOH", AxisGroup)