Class: CTioga2::Graphics::Styles::MarkerStyle

Inherits:
BasicStyle
  • Object
show all
Defined in:
lib/ctioga2/graphics/styles/drawable.rb

Overview

This class represents all the stylistic information to draw a Marker.

todo many things are still missing here…

  • in particular, angles could be handled here, and they could be handled directly in the marker specification…

Constant Summary

Constants inherited from BasicStyle

BasicStyle::AllStyles, BasicStyle::OldAttrAccessor

Instance Method Summary collapse

Methods inherited from BasicStyle

alias_for, aliases, attr_accessor, attribute_type, attribute_types, attributes, convert_string_hash, defined_aliases, deprecated_attribute, from_hash, inherited, #instance_variable_defined?, normalize_hash, normalize_in, normalize_out, options_hash, #set_from_hash, sub_style, sub_styles, #to_hash, typed_attribute, #update_from_other, #use_defaults_from

Instance Method Details

#draw_markers_at(t, x, y, override = nil) ⇒ Object

Shows the marker at a given location/set of locations.

p override is a hash that can override part of the dictionnary specification.



101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/ctioga2/graphics/styles/drawable.rb', line 101

def draw_markers_at(t, x, y, override = nil)
  return if (! @marker || @marker == 'None')

  dict = { 
    'marker' => @marker
  }
  if @line_width
    dict['stroke_width'] = @line_width
  end
  if !(@fill_color.nil?) || !(@line_color.nil?)
    dict['fill_color'] = @fill_color.nil? ? @color : @fill_color
    dict['stroke_color'] = @line_color.nil? ? @color : @line_color
    dict['rendering_mode'] = 
      if dict['fill_color']
        if dict['stroke_color']
          Tioga::FigureConstants::FILL_AND_STROKE
        else
          Tioga::FigureConstants::FILL
        end
      else
        Tioga::FigureConstants::STROKE
      end
    dict.strip_if_false!(%w{fill_color stroke_color})
  else
    dict['color'] = @color
    if ! @color
      return            # Nothing to do !
    end
  end
  if @angle
    dict['angle'] = @angle
  end
  
  if x.is_a? Numeric
    dict['x'] = x
    dict['y'] = y
  else
    dict['Xs'] = x
    dict['Ys'] = y
  end

  if @scale
    dict['scale'] = @scale
  end
  if override
    dict.merge!(override)
  end
  t.context do
    ## \todo allow custom line types for markers ?
    t.line_type = LineStyles::Solid
    t.show_marker(dict)
  end
end