Class: Xsdvi::SVG::Symbols::Any

Inherits:
Xsdvi::SVG::Symbol show all
Defined in:
lib/xsdvi/svg/symbols/any.rb

Overview

Symbol for XSD any wildcard

Constant Summary

Constants inherited from Xsdvi::SVG::Symbol

Xsdvi::SVG::Symbol::MAX_HEIGHT, Xsdvi::SVG::Symbol::MID_HEIGHT, Xsdvi::SVG::Symbol::MIN_HEIGHT, Xsdvi::SVG::Symbol::MIN_WIDTH, Xsdvi::SVG::Symbol::PC_LAX, Xsdvi::SVG::Symbol::PC_SKIP, Xsdvi::SVG::Symbol::PC_STRICT, Xsdvi::SVG::Symbol::X_INDENT, Xsdvi::SVG::Symbol::Y_INDENT

Instance Attribute Summary collapse

Attributes inherited from Xsdvi::SVG::Symbol

#additional_height, #description, #description_string_array, #height, #start_y_position, #svg, #width, #x_position, #y_position, #y_shift

Attributes inherited from Tree::Element

#children, #parent

Instance Method Summary collapse

Methods inherited from Xsdvi::SVG::Symbol

#prepare_box, reset_class_variables, #x_end, #y_end

Methods inherited from Tree::Element

#add_child, #children?, #code, #first_child?, #index, #last_child, #last_child?, #parent?

Constructor Details

#initializeAny

Returns a new instance of Any.



12
13
14
15
16
17
# File 'lib/xsdvi/svg/symbols/any.rb', line 12

def initialize
  super
  @namespace = nil
  @process_contents = PC_STRICT
  @cardinality = nil
end

Instance Attribute Details

#cardinalityObject

Returns the value of attribute cardinality.



10
11
12
# File 'lib/xsdvi/svg/symbols/any.rb', line 10

def cardinality
  @cardinality
end

#namespaceObject

Returns the value of attribute namespace.



10
11
12
# File 'lib/xsdvi/svg/symbols/any.rb', line 10

def namespace
  @namespace
end

#process_contentsObject

Returns the value of attribute process_contents.



10
11
12
# File 'lib/xsdvi/svg/symbols/any.rb', line 10

def process_contents
  @process_contents
end

Instance Method Details

#calculate_heightObject



53
54
55
# File 'lib/xsdvi/svg/symbols/any.rb', line 53

def calculate_height
  MAX_HEIGHT
end

#calculate_widthObject



46
47
48
49
50
51
# File 'lib/xsdvi/svg/symbols/any.rb', line 46

def calculate_width
  calc = Utils::WidthCalculator.new(MIN_WIDTH)
  calc.new_width(15, namespace)
  calc.new_width(15, cardinality)
  calc.width
end

#drawObject



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
# File 'lib/xsdvi/svg/symbols/any.rb', line 19

def draw
  process_description
  draw_g_start
  print("<rect class='shadow' x='3' y='3' width='#{width}' height='#{height}'/>")
  print("<rect class='boxany' x='0' y='0' width='#{width}' height='#{height}'/>")

  # Draw process contents boxes
  pc_class = case process_contents
             when PC_STRICT then "strict"
             when PC_SKIP then "skip"
             when PC_LAX then "lax"
             else "strict"
             end
  print("<rect class='#{pc_class}' x='6' y='34' width='6' height='6'/>")
  print("<rect class='#{pc_class}' x='16' y='34' width='6' height='6'/>")
  print("<rect class='#{pc_class}' x='26' y='34' width='6' height='6'/>")

  print("<text x='5' y='13'>#{namespace}</text>") if namespace
  # Java shows just angle brackets <> not <any>
  print("<text class='strong' x='5' y='27'>&lt;&gt;</text>")
  print("<text x='5' y='59'>#{cardinality}</text>") if cardinality
  draw_description(59)
  draw_connection
  draw_use
  draw_g_end
end