Class: GraphicObject

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
CoreBase
Defined in:
app/models/graphic_object.rb

Overview

Attributes:

Associations:

Direct Known Subclasses

Group, Shape, Text, TextContent

Instance Method Summary (collapse)

Instance Method Details

- (Object) get_all_descendants



35
36
37
# File 'app/models/graphic_object.rb', line 35

def get_all_descendants
  GraphicObject.all(:conditions => "address like '#{address}%' and id != #{id}", :order => "parent_id, \"order\"")
end

- (Object) get_display_attributes_svg



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
# File 'app/models/graphic_object.rb', line 55

def get_display_attributes_svg
  da = ""
  if !display_attributes.nil? && display_attributes.length > 0
    da = " style=\""
    display_attributes.each do |key,value|
      if key == "stroke"
        da << "stroke:black;"
      elsif key == "color"
        da << "stroke:black;fill:##{'%06x' % value}"
      else
        da << " #{key}: #{value}; "
      end
    end
    da += "\""
  end

  transforms = graphic_transformations
  if transforms.size > 0
    da << " transform=\""
    transforms.each do |t|
      da << " #{t.type.downcase}(#{t.sx}, #{t.sy})"
    end
    da += "\""
  end

  da
end

- (Object) get_display_attributes_xml



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'app/models/graphic_object.rb', line 39

def get_display_attributes_xml
  da = ""

  begin
    if display_attributes.present?
      display_attributes.each{|key,value|
          da << " #{key}='#{value}'"
      } unless display_attributes.nil?
    end
  rescue
    da = ""
  end

  da
end