     updateCanvasSize()
     if found > 0
       @navigator.navigateToResult 0
-    
+      
+  importData: (data)->
+    try
+      console.log "importing #{data}"
+      @cells = importField parseFieldData data
+      console.log "Imported #{@cells.count} cells"
+    catch e
+      alert "Faield to import data: #{e}"
+      @cells = new NodeHashMap
+
 
 updateCanvasSize = ->
   return if canvasSizeUpdateBlocked

{Animator} = require "./animator.coffee"
{MouseToolCombo} = require "./mousetool.coffee"
{GenericTransitionFunc, BinaryTransitionFunc,DayNightTransitionFunc,binaryTransitionFunc2GenericCode, dayNightBinaryTransitionFunc2GenericCode, parseGenericTransitionFunction, parseTransitionFunction} = require "./rule.coffee"
M = require "./matrix3.coffee"

MIN_WIDTH = 100

  getGroup: -> @tessellation.group
  getTransitionFunc: -> @transitionFunc

  initialize: (config = new DefaultConfig)->
    [n,m] = config.getGrid()
    @tessellation = new Tessellation n, m
    console.log "Running knuth-bendix algorithm...."
    rewriteRuleset = knuthBendix vdRule @getGroup().n, @getGroup().m
    console.log "Finished"    
    @appendRewrite = makeAppendRewrite rewriteRuleset
    @getNeighbors = mooreNeighborhood @getGroup().n, @getGroup().m, @appendRewrite

    cellData = config.getCellData()
    if cellData
      console.log "import: #{cellData}"
      @importData cellData
    else
      @cells = new NodeHashMap
      @cells.put unity, 1
    
    @observer = new @ObserverClass @tessellation, @appendRewrite, minVisibleSize
    @observer.onFinish = -> redraw()
