Module: Xumlidot::Diagram::Xmi::Klass
- Includes:
- Shared::Naming, ID
- Defined in:
- lib/xumlidot/diagram/xmi/klass.rb
Overview
Draw the klass
Defined Under Namespace
Modules: Name Classes: Diagram, Model
Instance Method Summary collapse
-
#draw_diagram(options) ⇒ Object
Draws a diagram element i.e.
- #draw_diagram_composition(composee) ⇒ Object
- #draw_diagram_generalisation ⇒ Object
- #draw_klass(options) ⇒ Object
- #draw_model_composition(composee) ⇒ Object
-
#draw_model_inheritance ⇒ Object
Inheritance has to be drawn both as part of the model and as a part of the diagram.
-
#extend_and_draw(collection) ⇒ Object
Im not happy with this - xmi should not have to know about types and it should be a method.
Methods included from Shared::Naming
#draw_ancestor, #draw_identifier, #draw_name
Methods included from ID
#association_end_id, #association_id, #force_id, #gen_id, #id
Instance Method Details
#draw_diagram(options) ⇒ Object
Draws a diagram element i.e. the part which is rendered
44 45 46 47 48 49 50 51 52 |
# File 'lib/xumlidot/diagram/xmi/klass.rb', line 44 def draw_diagram() xml = %(<uml:DiagramElement preferredShapeType="Class" subject="#{id}" xmi:id="#{id}de"> </uml:DiagramElement>) return xml if @definition.superklass.empty? && @definition.inherited_modules.empty? return xml unless .inheritance xml += draw_diagram_generalisation end |
#draw_diagram_composition(composee) ⇒ Object
112 113 114 115 |
# File 'lib/xumlidot/diagram/xmi/klass.rb', line 112 def draw_diagram_composition(composee) %(<uml:DiagramElement fromDiagramElement="#{id}de" preferredShapeType="Association" subject="#{association_id}" toDiagramElement="#{composee.id}de"> </uml:DiagramElement>) end |
#draw_diagram_generalisation ⇒ Object
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/xumlidot/diagram/xmi/klass.rb', line 54 def draw_diagram_generalisation xml = '' if ! @definition.superklass.empty? xml += %(<uml:DiagramElement fromDiagramElement="#{@definition.superklass.id}de" preferredShapeType="Generalization" subject="#{gen_id}" toDiagramElement="#{id}de"> </uml:DiagramElement>) end return xml if @definition.inherited_modules.empty? @definition.inherited_modules.each do |m| next if m.empty? xml += %(<uml:DiagramElement fromDiagramElement="#{m.id}de" preferredShapeType="Generalization" subject="#{gen_id}" toDiagramElement="#{id}de"> </uml:DiagramElement>) end xml end |
#draw_klass(options) ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/xumlidot/diagram/xmi/klass.rb', line 33 def draw_klass() definition.name.extend(Name) xmi = "<ownedMember isAbstract=\"false\" isActive=\"false\" isLeaf=\"false\" name=\"#{definition.name.to_xmi}\" visibility=\"public\" xmi:id=\"#{id}\" xmi:type=\"uml:Class\">" xmi += draw_model_inheritance if .inheritance xmi += extend_and_draw(attributes) xmi += extend_and_draw(class_methods) xmi += extend_and_draw(instance_methods) xmi += "</ownedMember>" end |
#draw_model_composition(composee) ⇒ Object
101 102 103 104 105 106 107 108 109 110 |
# File 'lib/xumlidot/diagram/xmi/klass.rb', line 101 def draw_model_composition(composee) %(<ownedMember isAbstract="false" isDerived="false" isLeaf="false" xmi:id="#{association_id}" xmi:type="uml:Association"> <memberEnd xmi:idref="#{association_end_id}"/> <ownedEnd aggregation="none" association="#{association_id}" isDerived="false" isDerivedUnion="false" isLeaf="false" isNavigable="true" isReadOnly="false" isStatic="false" type="#{id}" xmi:id="9JMZlYaD.AACASCI" xmi:type="uml:Property"> </ownedEnd> <memberEnd xmi:idref="#{composee.association_end_id}"/> <ownedEnd aggregation="composite" association="#{association_id}" isDerived="false" isDerivedUnion="false" isLeaf="false" isNavigable="true" isReadOnly="false" isStatic="false" type="#{composee.id}" xmi:id="9JMZlYaD.AACASCK" xmi:type="uml:Property"> </ownedEnd> </ownedMember>) end |
#draw_model_inheritance ⇒ Object
Inheritance has to be drawn both as part of the model and as a part of the diagram
general = id = IMPORTANT; will be used to draw the lines in the diagram
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/xumlidot/diagram/xmi/klass.rb', line 80 def draw_model_inheritance return '' if @definition.superklass.empty? && @definition.inherited_modules.empty? xml = '' if ! @definition.superklass.empty? xml += %(<generalization general="#{@definition.superklass.id}" xmi:id="#{gen_id}" xmi:type="uml:Generalization"> </generalization>) end return xml if @definition.inherited_modules.empty? @definition.inherited_modules.each do |m| next if m.empty? xml += %(<generalization general="#{m.id}" xmi:id="#{gen_id}" xmi:type="uml:Generalization"> </generalization>) end xml end |
#extend_and_draw(collection) ⇒ Object
Im not happy with this - xmi should not have to know about types and it should be a method
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/xumlidot/diagram/xmi/klass.rb', line 119 def extend_and_draw(collection) collection.map do |member| case member when ::Xumlidot::Types::MethodSignature member.extend(::Xumlidot::Diagram::Xmi::MethodSignature) when ::Xumlidot::Types::Attribute member.extend(::Xumlidot::Diagram::Xmi::Attribute) end member.draw end.join(' ') end |