Class: CTioga2::Graphics::Styles::CurveStyle
- Inherits:
-
Object
- Object
- CTioga2::Graphics::Styles::CurveStyle
- Defined in:
- lib/ctioga2/graphics/styles/curve.rb
Overview
A class holding all the styles for a curve.
todo maybe for objects different than Curve2D, a subclass of CurveStyle could be used ? This way, we could have clearly separated legends and the like ?
Instance Attribute Summary collapse
-
#color_map ⇒ Object
A colormap for strokes (only for XYZ data).
-
#error_bar ⇒ Object
The style of the error bars when needed, as a ErrorBarStyle.
-
#fill ⇒ Object
Filling of the curve, if applicable.
-
#legend ⇒ Object
The text of the legend, if there is one.
-
#line ⇒ Object
The style of the line that is drawn, as a StrokeStyle.
-
#location ⇒ Object
Details of the location of the curve, a LocationStyle object.
-
#marker ⇒ Object
The style of markers that should be drawn, as a MarkerStyle.
-
#marker_color_map ⇒ Object
A colormap for markers (only for XYZ data).
-
#path_style ⇒ Object
A path style.
-
#region_position ⇒ Object
Whether in a region plot, the curve should be above or below the filled region.
-
#split_on_nan ⇒ Object
Whether the XY display should split on NaN values (wherever).
-
#zaxis ⇒ Object
The name of an axis to create to use for the display of the Z scale.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates a CurveStyle object straight from a hash description.
Instance Method Summary collapse
-
#draw_legend_pictogram(t) ⇒ Object
Draws a legend pictogram that fills up the whole current frame.
-
#has_legend? ⇒ Boolean
True if there is one legend to be drawn for this object.
-
#has_line? ⇒ Boolean
True if a line should be drawn.
-
#has_marker? ⇒ Boolean
True if markers should be drawn.
-
#set_from_hash(hash) ⇒ Object
Sets the values of the different sub-objects from a ‘flat’ hash.
Instance Attribute Details
#color_map ⇒ Object
There should be a very clear way to mark curve style
A colormap for strokes (only for XYZ data)
elements which are specific to certain kinds of plots (and warn the user about misuses ?)
69 70 71 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 69 def color_map @color_map end |
#error_bar ⇒ Object
The style of the error bars when needed, as a ErrorBarStyle.
43 44 45 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 43 def @error_bar end |
#fill ⇒ Object
Filling of the curve, if applicable
46 47 48 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 46 def fill @fill end |
#legend ⇒ Object
The text of the legend, if there is one.
40 41 42 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 40 def legend @legend end |
#line ⇒ Object
The style of the line that is drawn, as a StrokeStyle.
34 35 36 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 34 def line @line end |
#location ⇒ Object
Details of the location of the curve, a LocationStyle object.
49 50 51 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 49 def location @location end |
#marker ⇒ Object
The style of markers that should be drawn, as a MarkerStyle.
37 38 39 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 37 def marker @marker end |
#marker_color_map ⇒ Object
A colormap for markers (only for XYZ data)
78 79 80 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 78 def marker_color_map @marker_color_map end |
#path_style ⇒ Object
Ideas for a path tyle include
A path style.
-
plain lines
-
impulses ?
-
splines
See gnuplot help for “plot with” for inspiration.
62 63 64 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 62 def path_style @path_style end |
#region_position ⇒ Object
Whether in a region plot, the curve should be above or below the filled region.
53 54 55 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 53 def region_position @region_position end |
#split_on_nan ⇒ Object
Whether the XY display should split on NaN values (wherever)
81 82 83 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 81 def split_on_nan @split_on_nan end |
#zaxis ⇒ Object
specify the behaviour when the axis exists.
The name of an axis to create to use for the display of the Z scale.
75 76 77 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 75 def zaxis @zaxis end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates a CurveStyle object straight from a hash description. See #set_from_hash for more information.
132 133 134 135 136 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 132 def self.from_hash(hash) a = CurveStyle.new a.set_from_hash(hash) return a end |
Instance Method Details
#draw_legend_pictogram(t) ⇒ Object
Draws a legend pictogram that fills up the whole current frame.
todo add more elements to the pictogram in case of more complex things.
144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 144 def draw_legend_pictogram(t) t.context do if has_line? @line.set_stroke_style(t) t.stroke_line(0.0, 0.5, 1.0, 0.5) end if has_marker? @marker.draw_markers_at(t, [0.5], [0.5]) end end end |
#has_legend? ⇒ Boolean
True if there is one legend to be drawn for this object.
95 96 97 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 95 def has_legend? return @legend end |
#has_line? ⇒ Boolean
True if a line should be drawn.
85 86 87 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 85 def has_line? return @line && @line.style end |
#has_marker? ⇒ Boolean
True if markers should be drawn
90 91 92 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 90 def has_marker? return @marker && @marker.marker end |
#set_from_hash(hash) ⇒ Object
Sets the values of the different sub-objects from a ‘flat’ hash. Keys have the following meaning:
-
‘line_…’: a StrokeStyle for the drawing the line
-
‘marker_…’: a MarkerStyle for the drawing of markers
-
‘legend’: the legend of the curve
-
‘[xy]axis’: the name of the axis the curve should be
plotted onto
todo make #legend another object derived from BasicStyle ?
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 108 def set_from_hash(hash) @line = StrokeStyle.from_hash(hash, 'line_%s') @marker = MarkerStyle.from_hash(hash, 'marker_%s') @error_bar = ErrorBarStyle.from_hash(hash, 'error_bar_%s') @location = LocationStyle.from_hash(hash, 'location_%s') @fill = CurveFillStyle.from_hash(hash, 'fill_%s') @region_position = hash['region_position'] @legend = hash['legend'] @path_style = hash['style'] @color_map = hash['color_map'] @marker_color_map = hash['marker_color_map'] @split_on_nan = hash['split_on_nan'] @zaxis = hash['zaxis'] end |