     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')
   }
 ]
 



  mousedown: (pos, idx, t) ->
    for n in @nodes
      if n.isHit(pos)
        if @merging?
          if n isnt @merging.node
            @mergeNodes(@merging.node, n)
            @merging = null

            return true

    if @merging?
      @merging = null

    # try moving nodes
    for n in @nodes
      hit = n.tryAll( (node) ->

  constructor: (@shape) ->
    @nodes = []
    @animations = []

  copyNodesFrom: (nc) ->
    @nodes = nc.nodes

  addLeaves: (dict, pos) ->
    length = 0
