Class: Gliffynator::Arrow

Inherits:
Hash
  • Object
show all
Defined in:
lib/gliffynator/arrow.rb

Class Method Summary collapse

Class Method Details

.create(id, x, y, length, direction, text = false) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/gliffynator/arrow.rb', line 7

def self.create(id, x, y, length, direction, text=false)

  arrow = {
    x: x.to_f,
    y: y.to_f,
    rotation: 0.0,
    id: id,
    width: 143.5644622626777,
    height: 100.0,
    uid: "com.gliffy.shape.uml.uml_v1.default.message",
    order: id,
    lockAspectRatio: false,
    lockShape: false,
    graphic: {
      type: "Line",
      Line: {
        strokeWidth: 1.0,
        strokeColor: "#000000",
        fillColor: "none",
        dashStyle: nil,
        startArrow: if direction == :left then 2 else 0 end,
        endArrow: if direction == :right then 2 else 0 end,
        startArrowRotation: "auto",
        endArrowRotation: "auto",
        interpolationType: "linear",
        cornerRadius: nil,
        controlPath: [
          [
            0.0,
            0.0
          ],
          [
            length,
            0.0
          ]
        ],
        lockSegments: [],
        ortho: false
      }
    },
    linkMap: [],
    children: [],
    hidden: false,
    layerId: "C3WysuhtocNA"
  }

  if text
    arrow[:children] << {
      x: 0.0,
      y: 0.0,
      rotation: 0.0,
      id: id+1,
      width: 6.4 * text.length,
      height: 14,
      uid: nil,
      order: "auto",
      lockAspectRatio: false,
      lockShape: false,
      graphic: {
        type: "Text",
        Text: {
          overflow: "both",
          paddingTop: 2,
          paddingright: 2,
          paddingBottom: 2,
          paddingLeft: 2,
          outerPaddingTop: 6,
          outerPaddingRight: 6,
          outerPaddingBottom: 2,
          outerPaddingLeft: 6,
          type: "fixed",
          lineTValue: 0.48267771584556685,
          linePerpValue: 0.0,
          cardinalityType: nil,
          html: "<p style=\"text-align:center;\"><span style=\"font-family:Arial;font-size:12px;\"><span style=\"\">"+text+"</span></p>",
          tid: nil,
          valign: "middle",
          vposition: "none",
          hposition: "none"
        }
      },
      children: [],
      hidden: false,
      layerId: "C3WysuhtocNA"
    }
  end

  arrow
end

.id_usageObject



3
4
5
# File 'lib/gliffynator/arrow.rb', line 3

def self.id_usage
  3
end