Class: CTioga2::Graphics::Styles::MarkerStringStyle

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

Overview

The style for a string marker. Hmmm, this is somewhat redundant with TiogaPrimitiveCall::MarkerOptions and I don’t like that.

Constant Summary collapse

MarkerOptions =
{
  'color' => 'color',
  'stroke_color' => 'color',
  'fill_color' => 'color',
  'scale' => 'float',
  'horizontal_scale' => 'float',
  'vertical_scale' => 'float',
  'angle' => 'float',
  'justification' => 'justification',
  'alignment' => 'alignment',
}

Constants inherited from BasicStyle

BasicStyle::OldAttrAccessor

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from BasicStyle

attr_accessor, attributes, from_hash, #instance_variable_defined?, #set_from_hash, #to_hash, #update_from_other

Constructor Details

#initializeMarkerStringStyle

Returns a new instance of MarkerStringStyle.



216
217
218
219
220
221
# File 'lib/ctioga2/graphics/styles/texts.rb', line 216

def initialize
  # It make sense to use both by default, as it would be
  # confusing to provide both fill_ and stroke_color that
  # don't have effects by default...
  @mode = Tioga::FigureConstants::FILL_AND_STROKE
end

Instance Attribute Details

#alignementObject

The vertical alignment



200
201
202
# File 'lib/ctioga2/graphics/styles/texts.rb', line 200

def alignement
  @alignement
end

#angleObject

The angle of the text



188
189
190
# File 'lib/ctioga2/graphics/styles/texts.rb', line 188

def angle
  @angle
end

#colorObject

Colors



206
207
208
# File 'lib/ctioga2/graphics/styles/texts.rb', line 206

def color
  @color
end

#fill_colorObject

Returns the value of attribute fill_color.



208
209
210
# File 'lib/ctioga2/graphics/styles/texts.rb', line 208

def fill_color
  @fill_color
end

#fontObject

A number between 1 to 14 – a PDF font



211
212
213
# File 'lib/ctioga2/graphics/styles/texts.rb', line 211

def font
  @font
end

#horizontal_scaleObject

The horizontal scale of the text



194
195
196
# File 'lib/ctioga2/graphics/styles/texts.rb', line 194

def horizontal_scale
  @horizontal_scale
end

#justificationObject

The horizontal alignment



203
204
205
# File 'lib/ctioga2/graphics/styles/texts.rb', line 203

def justification
  @justification
end

#modeObject

The rendering mode.



214
215
216
# File 'lib/ctioga2/graphics/styles/texts.rb', line 214

def mode
  @mode
end

#scaleObject

The scale of the text



191
192
193
# File 'lib/ctioga2/graphics/styles/texts.rb', line 191

def scale
  @scale
end

#stroke_colorObject

Returns the value of attribute stroke_color.



207
208
209
# File 'lib/ctioga2/graphics/styles/texts.rb', line 207

def stroke_color
  @stroke_color
end

#vertical_scaleObject

The vertical scale of the text



197
198
199
# File 'lib/ctioga2/graphics/styles/texts.rb', line 197

def vertical_scale
  @vertical_scale
end

Instance Method Details

#draw_string_marker(t, text, x, y) ⇒ Object

Draws the string marker at the given location



225
226
227
228
229
230
231
232
# File 'lib/ctioga2/graphics/styles/texts.rb', line 225

def draw_string_marker(t, text, x, y)
  dict = self.to_hash
  dict['text'] = text
  dict['at'] = [x, y]
  # TODO !
  dict['mode'] = 
  t.show_marker(dict)
end

#real_vertical_scaleObject

Returns the true vertical scale of the marker



235
236
237
# File 'lib/ctioga2/graphics/styles/texts.rb', line 235

def real_vertical_scale
  return (@vertical_scale || 1.0) * (@scale || 1.0)
end