old_contents: """
  Node item may represent a node or a device UML metamodel classes.
  
  Grouping
  ========
  Node item can group following items
  
  - other nodes, which are represented with Node.nestedNode on UML metamodel
    level
  - deployed artifacts using deployment
  - components, which are parts of a node acting as structured classifier
    (nodes may have internal structures)
  
  Node item grouping logic is implemented in `gaphor.adapters.grouping`
  module.
  """
  
  from gaphor import UML
  from gaphor.diagram.classifier import ClassifierItem
  from gaphor.diagram.support import represents
  
  
  @represents(UML.Node)
  @represents(UML.Device)
  class NodeItem(ClassifierItem):
      """
      Representation of node or device from UML Deployment package.
      """
  
      __stereotype__ = {"device": UML.Device}
  
      DEPTH = 10
  
      def __init__(self, id=None, model=None):
          super().__init__(id, model)
          self.drawing_style = self.DRAW_COMPARTMENT
          self.height = 50
          self.width = 120
  
      def draw_compartment(self, context):
          cr = context.cairo
          cr.save()
          super().draw_compartment(context)
          cr.restore()
  
          d = self.DEPTH
          w = self.width
          h = self.height
  
          cr.move_to(0, 0)
          cr.line_to(d, -d)
          cr.line_to(w + d, -d)
          cr.line_to(w + d, h - d)
          cr.line_to(w, h)
          cr.move_to(w, 0)
          cr.line_to(w + d, -d)
  
          cr.stroke()
  
new_contents: """
  Node item may represent a node or a device UML metamodel classes.
  
  Grouping
  ========
  Node item can group following items
  
  - other nodes, which are represented with Node.nestedNode on UML metamodel
    level
  - deployed artifacts using deployment
  - components, which are parts of a node acting as structured classifier
    (nodes may have internal structures)
  
  Node item grouping logic is implemented in `gaphor.adapters.grouping`
  module.
  """
  
  from gaphor import UML
  from gaphor.diagram.profiles.stereotype import stereotype_compartments
  from gaphor.diagram.presentation import ElementPresentation, Classified
  from gaphor.diagram.shapes import Box, EditableText, Text, draw_border
  from gaphor.diagram.text import VerticalAlign
  from gaphor.diagram.support import represents
  
  
  @represents(UML.Node)
  @represents(UML.Device)
  class NodeItem(ElementPresentation, Classified):
      """
      Representation of node or device from UML Deployment package.
      """
  
      def __init__(self, id=None, model=None):
          super().__init__(id, model)
  
          self.update_shapes()
  
          self.watch("show_stereotypes_attrs", self.update_shapes)
          self.watch("subject<NamedElement>.name")
          self.watch("subject.appliedStereotype", self.update_shapes)
          self.watch("subject.appliedStereotype.classifier.name")
          self.watch("subject.appliedStereotype.slot", self.update_shapes)
          self.watch("subject.appliedStereotype.slot.definingFeature.name")
          self.watch("subject.appliedStereotype.slot.value", self.update_shapes)
  
      show_stereotypes_attrs = UML.properties.attribute("show_stereotypes_attrs", int)
  
      def update_shapes(self, event=None):
          self.shape = Box(
              Box(
                  Text(
                      text=lambda: UML.model.stereotypes_str(
                          self.subject,
                          ("device",) if isinstance(self.subject, UML.Device) else (),
                      ),
                      style={"min-width": 0, "min-height": 0},
                  ),
                  EditableText(text=lambda: self.subject.name or ""),
                  style={"padding": (4, 4, 4, 4)},
              ),
              *(
                  self.show_stereotypes_attrs
                  and stereotype_compartments(self.subject)
                  or []
              ),
              style={"min-width": 100, "min-height": 50},
              draw=draw_node
          )
          self.request_update()
  
      def postload(self):
          super().postload()
          self.update_shapes()
  
  
  def draw_node(box, context, bounding_box):
      cr = context.cairo
  
      d = 10
      w = bounding_box.width
      h = bounding_box.height
  
      cr.rectangle(0, 0, w, h)
  
      cr.move_to(0, 0)
      cr.line_to(d, -d)
      cr.line_to(w + d, -d)
      cr.line_to(w + d, h - d)
      cr.line_to(w, h)
      cr.move_to(w, 0)
      cr.line_to(w + d, -d)
  
      cr.stroke()
  
subject: Convert node to new style