<commit_before>###
  @depend ../namespace.js
###
class grumble.Link extends Spine.Model
  @configure "Link", "sourceId", "targetId", "segments", "strokeColor", "strokeStyle"
  @extend Spine.Model.Local
  
  # TODO duplication with grumble.Node
  constructor: (attributes) ->
    super
    @k = v for k,v of attributes
    @moveTo(attributes.segments)
    @bind "save", @addToNodes
    @bind "destroy", @removeFromNodes
  
  # extract the information needed to reconstruct
  # the path used to draw this link (and nothing more)
  moveTo: (segments) =>
    @segments = (for s in segments
      point: {x: s.point.x, y: s.point.y}
      handleIn: {x: s.handleIn.x, y: s.handleIn.y}
      handleOut: {x: s.handleOut.x, y: s.handleOut.y})
      
  addToNodes: =>
    @source().addLink(@id)
    @target().addLink(@id)
    
  removeFromNodes: =><commit_msg>Updated comment.<commit_after>###
  @depend ../namespace.js
###
class grumble.Link extends Spine.Model
  @configure "Link", "sourceId", "targetId", "segments", "strokeColor", "strokeStyle"
  @extend Spine.Model.Local
  
  # TODO duplication with grumble.Node
  constructor: (attributes) ->
    super
    @k = v for k,v of attributes
    @moveTo(attributes.segments)
    @bind "save", @addToNodes
    @bind "destroy", @removeFromNodes
  
  # Spine.Model.Local uses JSON for seralisation and hence
  # cannot contain cyclic structures. Paper.js's paths 
  # are sometimes cyclic, so we filter the Paper.js structure
  # to the bare essentials (which will be acyclic)
  moveTo: (segments) =>
    @segments = (for s in segments
      point: {x: s.point.x, y: s.point.y}
      handleIn: {x: s.handleIn.x, y: s.handleIn.y}
      handleOut: {x: s.handleOut.x, y: s.handleOut.y})
      
  addToNodes: =>
    @source().addLink(@id)
    @target().addLink(@id)
    
  removeFromNodes: =>
{'fraction_non_alphanumeric': 0.14129244249726178, 'fraction_numerical': 0.0, 'mean_word_length': 3.2587412587412588, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '524688', 'n_tokens_mistral': 630, 'n_tokens_neox': 619, 'n_words': 172}