Class: CTioga2::Graphics::Styles::CurveStyle
- Inherits:
-
BasicStyle
- Object
- BasicStyle
- 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 ?
Constant Summary
Constants inherited from BasicStyle
BasicStyle::AllStyles, BasicStyle::OldAttrAccessor
Instance Attribute Summary collapse
-
#target ⇒ Object
The object attached to this style.
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.
-
#initialize ⇒ CurveStyle
constructor
A new instance of CurveStyle.
Methods inherited from BasicStyle
alias_for, attr_accessor, attribute_type, attribute_types, attributes, deprecated_attribute, from_hash, inherited, #instance_variable_defined?, options_hash, #set_from_hash, sub_style, sub_styles, #to_hash, typed_attribute, #update_from_other
Constructor Details
#initialize ⇒ CurveStyle
Returns a new instance of CurveStyle.
104 105 106 107 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 104 def initialize() @clipped = true @depth = 50 end |
Instance Attribute Details
#target ⇒ Object
The object attached to this style. It is set by Generator#curve_from_dataset
102 103 104 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 102 def target @target end |
Instance Method Details
#draw_legend_pictogram(t) ⇒ Object
Most probably the legend pictogram should be done by
Draws a legend pictogram that fills up the whole current frame.
todo add more elements to the pictogram in case of more complex things.
the curve directly rather than by the style.
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 132 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? ⇒ Boolean
True if there is one legend to be drawn for this object.
120 121 122 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 120 def has_legend? return @legend end |
#has_line? ⇒ Boolean
True if a line should be drawn.
110 111 112 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 110 def has_line? return @line && @line.style end |
#has_marker? ⇒ Boolean
True if markers should be drawn
115 116 117 |
# File 'lib/ctioga2/graphics/styles/curve.rb', line 115 def has_marker? return @marker && @marker.marker end |