Class: Ea::Qea::Models::EaDiagramObject

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/ea/qea/models/ea_diagram_object.rb

Overview

Represents a diagram object from the t_diagramobjects table

This model represents the placement of UML elements (classes, packages, etc.) on specific diagrams, including their position and styling.

Constant Summary collapse

COLUMN_MAP =
{
  "Object_ID" => :ea_object_id,
}.freeze

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

from_db_row, #primary_key, #sort_position

Class Method Details

.column_mapObject



34
35
36
# File 'lib/ea/qea/models/ea_diagram_object.rb', line 34

def self.column_map
  COLUMN_MAP
end

.primary_key_columnObject



21
22
23
# File 'lib/ea/qea/models/ea_diagram_object.rb', line 21

def self.primary_key_column
  :instance_id
end

.table_nameObject



25
26
27
# File 'lib/ea/qea/models/ea_diagram_object.rb', line 25

def self.table_name
  "t_diagramobjects"
end

Instance Method Details

#bounding_boxHash

Get the bounding box of the diagram object

Returns:

  • (Hash)

    Hash with :top, :left, :right, :bottom, :width, :height



40
41
42
43
44
45
46
47
48
49
# File 'lib/ea/qea/models/ea_diagram_object.rb', line 40

def bounding_box
  {
    top: recttop,
    left: rectleft,
    right: rectright,
    bottom: rectbottom,
    width: rectright - rectleft,
    height: rectbottom - recttop,
  }
end

#center_pointHash

Get the center point of the diagram object

Returns:

  • (Hash)

    Hash with :x, :y coordinates



53
54
55
56
57
58
# File 'lib/ea/qea/models/ea_diagram_object.rb', line 53

def center_point
  {
    x: (rectleft + rectright) / 2,
    y: (recttop + rectbottom) / 2,
  }
end

#parsed_styleHash

Parse ObjectStyle string into a hash

Returns:

  • (Hash)

    Parsed style attributes



62
63
64
65
66
67
68
69
# File 'lib/ea/qea/models/ea_diagram_object.rb', line 62

def parsed_style
  return {} unless objectstyle

  objectstyle.split(";").each_with_object({}) do |pair, hash|
    key, value = pair.split("=", 2)
    hash[key] = value if key && value
  end
end