class CTioga2::Graphics::Styles::CurveStyle
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 ?
Attributes
target[RW]
The object attached to this style. It is set by Generator#curve_from_dataset
Public Class Methods
new()
click to toggle source
# File lib/ctioga2/graphics/styles/curve.rb, line 118 def initialize() @clipped = true @depth = 50 end
Public Instance Methods
draw_legend_pictogram(t)
click to toggle source
Draws a legend pictogram that fills up the whole current frame.
todo add more elements to the pictogram in case of more complex things.
@todo Most probably the legend pictogram should be done by the curve directly rather than by the style.
# File lib/ctioga2/graphics/styles/curve.rb, line 146 def draw_legend_pictogram(t) t.context do case @target when Elements::Curve2D 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 when Elements::Parametric2D if has_marker? && @marker_color_map colors = @marker_color_map.colors.uniq i = 1 total = colors.size + 1.0 for c in colors @marker.draw_markers_at(t, [i/total], [0.5], {'color' => c} ) i += 1 end end end end end
has_legend?()
click to toggle source
True if there is one legend to be drawn for this object.
# File lib/ctioga2/graphics/styles/curve.rb, line 134 def has_legend? return @legend end
has_line?()
click to toggle source
True if a line should be drawn.
# File lib/ctioga2/graphics/styles/curve.rb, line 124 def has_line? return @line && @line.style end
has_marker?()
click to toggle source
True if markers should be drawn
# File lib/ctioga2/graphics/styles/curve.rb, line 129 def has_marker? return @marker && @marker.marker end