     dy = pos.y - default_node_radius*(2 + 3 * idx)
 
     return dx*dx + dy*dy < default_node_radius*default_node_radius
+
+  collection_dropdown_menu: collection_dropdown_menu
 
   mousemove: (pos) ->
     if @dropdown_menu?


      s.node.move(newx, newy)

    if @merging?
      @merging.x = pos.x
      @merging.y = pos.y

    return

  mouseup: (pos, t) ->
    if @dropdown_menu?
      if @dropdown_menu.selected >= 0
        @dropdown_menu.options[@dropdown_menu.selected].action(this, t)
      @dropdown_menu = null
      return

    if @selected?
      if t - @selected.t < 200

    name: 'Huffman',
    action: (c, t) ->
      console.log('Huffman')
      c.reconstruct_as = HuffmanNodeCollection
  }
]

huffman_collection_dropdown_menu = [
  {
    name: 'sort by weight',
    action: (c, t) ->
      console.log('sort by weight')
      c.sortNodes( ((n1, n2) -> n2.value - n1.value), t)
  },
  {
    name: 'automatic Huffman step',
    action: (c, t) ->
      console.log('automatic Huffman step')
  },
  {
    name: 'finish Huffman'
    action: (c, t) ->
      console.log('finish Huffman')
      # TODO: maybe first this should automatically finish the construction?
      c.reconstruct_as = NodeCollection
  }
]

shannon_fano_dropdown_menu = [
  {
    name: 'sort by weight',
    action: (c, t) ->
      console.log('sort by weight')
      c.sortNodes( ((n1, n2) -> n2.value - n1.value), t)
  },
  {
    name: 'sort alpha',
    action: (c, t) ->
      console.log('sort alpha')
  },
  {
    name: 'automatic Shannon-Fano step',
    action: (c, t) ->
      console.log('automatic Shannon-Fano step')
  },
  {
    name: 'finish Shannon-Fano',
    action: (c, t) ->
      console.log('finish Shannon-Fano')
  }
]

