Class: Wx::SF::OpenArrow

Inherits:
LineArrow show all
Defined in:
lib/wx/shapes/arrows/open_arrow.rb

Overview

Class extends the Wx::LineArrow class and encapsulates arrow shape consisting of single two lines leading from the end of the parent line shape.

Direct Known Subclasses

ProngArrow

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from LineArrow

#get_pen, #get_pen_width, #set_parent_shape, #set_pen

Methods inherited from ArrowBase

#get_parent_shape, #set_parent_shape, #translate_arrow

Constructor Details

#initialize(parent = nil) ⇒ OpenArrow

Constructor

Parameters:



22
23
24
25
# File 'lib/wx/shapes/arrows/open_arrow.rb', line 22

def initialize(parent=nil)
  super(parent)
  scale
end

Class Method Details

.arrow(ratio) ⇒ Object



14
15
16
17
# File 'lib/wx/shapes/arrows/open_arrow.rb', line 14

def arrow(ratio)
  x = ratio*11; y = ratio*5
  [Wx::RealPoint.new(0,0), Wx::RealPoint.new(x, y), Wx::RealPoint.new(x,-y), Wx::RealPoint.new(x, 0)]
end

Instance Method Details

#draw(from, to, dc) ⇒ Wx::Point

Returns translated connection point for arrow.

Returns:

  • (Wx::Point)

    translated connection point for arrow



43
44
45
46
47
48
49
50
51
# File 'lib/wx/shapes/arrows/open_arrow.rb', line 43

def draw(from, to, dc)
  tip, wing1, wing2, cp = translate_arrow(vertices, from, to)
  dc.with_pen(pen) do |dc|
    dc.draw_line(tip, wing1)
    dc.draw_line(tip, wing2)
    dc.draw_line(tip, cp)
  end
  cp
end

#scaleObject (protected)



32
33
34
35
# File 'lib/wx/shapes/arrows/open_arrow.rb', line 32

def scale
  @vertices = nil
  @ratio = 1 + (pen_width / 2) * 0.5
end