 
   TWO_PI:          2*Math.PI
   HALF_PI:         Math.PI*0.5
+  SIXTH_PI:        Math.PI/6
   LABEL_MAX_WIDTH: 130
   context:         null
   quadtree:        null


  drawNodeLabel: (d) =>
    ypos = null
    @context.fillStyle = d.fontColor
    @context.font      = '300 '+d.fontSize+'px Montserrat'
    if (@parameters.showNodesLabelComplete or @node_hovered or @node_active) and d.long_label
      d.long_label.forEach (line, i) =>
        ypos = (d.y+d.size+(i*d.fontSize))|0
        @context.strokeText line, d.x|0, ypos+1
        @context.fillText   line, d.x|0, ypos
    else
      ypos = (d.y+d.size)|0
      @context.strokeText d.short_label, d.x|0, ypos+1
      @context.fillText   d.short_label, d.x|0, ypos

  drawRelations: ->
    # make stroke color dynamic based on nodes state !!!


  drawNodes: ->
    @data_nodes.forEach (d) =>
      x = d.x|0
      y = d.y|0
      size = d.size|0
      # set styles
      @context.fillStyle = d.fill
      # draw node
      @context.beginPath()
      @context.moveTo x, y
      @context.arc x, y, size, 0, @TWO_PI, true
      @context.fill()
      @context.closePath()
      # draw image
      if d.img
        @drawNodeImage d.imgObj, x-size, y-size, 2*size

  drawNodesActive: ->
    @data_nodes.forEach (d) =>
      x = d.x|0
      y = d.y|0
      size = d.size|0
      # set styles
      @context.lineWidth = d.strokeWidth
      @context.strokeStyle = d.stroke
      @context.fillStyle = d.fill
      # draw node
      @context.beginPath()
      @context.moveTo x, y
      @context.arc x, y, size, 0, @TWO_PI, true
      @context.fill()
      @context.stroke()
      @context.closePath()
      # draw image
      if d.img
        @drawNodeImage d.imgObj, x-size, y-size, 2*size

  drawNodeImage: (img, x, y, size) ->
    @context.save()
    @context.clip()
    @context.drawImage img, x, y, size, size
    @context.restore()

  drawNodesLabels: ->
    # set styles
