<commit_before>class ADF.GMap.Views.Polygon extends ADF.MVC.Views.Base
  
  label: false
  content: false 
  withLabel: false
  initialized: false
  
  initialize: () ->
    @mapView = @options.mapView
    @zone = @options.model
    @polygon = @zone.mapObject
    @label = @options.label if @options.label?
    @content = @options.content if @options.content?
    @withLabel = @options.withLabel if @options.withLabel?
    @_initCallbacksFromOptions()

  initZone: (allowDraw) -> 
    @initialized = true
    @map = @mapView.getMap().getGMap()
    if @zone.isNew() && allowDraw
      @startDrawing()
    else 
      @setPolygonMap( @map )
      @setPolygonHandlers()
      @_initLabelView() if @withLabel
      @onPolygonDrawCompleted() if allowDraw

    @mapView.getMap().addOverlay(@)
    @onZoneInitialized()
      
  _initCallbacksFromOptions: () ->
    @onShapeClicked = @options.onShapeClicked if typeof @options.onShapeClicked == 'function'
    @onPolygonDrawCompleted =  @options.onPolygonDrawCompleted if typeof @options.onPolygonDrawCompleted == 'function'
    @onPolygonDrawStarted = @options.onPolygonDrawStarted if typeof @options.onPolygonDrawStarted == 'function'
    @onPathChanged = @options.pathChanged if typeof @options.pathChanged == 'function'

  _initLabelView: () ->
    @labelView = new ADF.Map.Views.PolygonLabel
      point: @getCenter()
      map : @mapView.getMap()
      model: @zone
      label: if @label && @label.length > 0 then @label else null
      content: @content
      clickable: false
      hidden: true
      template: @zonePopupTemplate
            
  isClustering: () ->
    false
    
  removeFromMap: () -> # Depricated
    @zone.removeFromMap()
    @labelView.remove() if @labelView
    
  remove: () ->
    @polygon.getPolygon().setMap(null)
    @labelView.remove() if @labelView
  
  addContextMenu: () ->
    @contextMenu = new ADF.GMap.Views.ContextMenu({gElement : @polygon.getPolygon(), mapModel: @mapView.getMap()})
    @contextMenu.render()

# HELPERS
  setContent: ( content ) ->
    return unless @labelView
    @content = content
    @labelView.setContent( content )
    @labelView.render()
    
  setLabel: ( label) ->
    return unless @labelView
    @label = label
    @labelView.setLabel @label

  setLabelPosition: () ->
    point = @getCenter()
    @labelView.overlay.setPosition point
  
  getZone: ->
    @zone
  
  clearSelection: => 
    @setUnEditable( ) 

  setMap: (map) ->
    @setPolygonMap( map )
      
  getCenter: () ->
    bounds = new google.maps.LatLngBounds()
    i = 0
    while i < @polygon.getPolygon().getPath().length
     bounds.extend(@polygon.getPolygon().getPath().getAt(i))
     i++
    bounds.getCenter()

  setFirstCoordinate: (latLng) ->
    @first_coordinate = latLng

  getFirstCoordinate: ->
    if @first_coordinate? then @first_coordinate else false 
        
# HANDLERS
  setPolygonHandlers: () ->
    google.maps.event.addListener @polygon.getPolygon(), 'click', @newShapeClickHandler if @isEditable()
    google.maps.event.addListener @polygon.getPolygon(), 'mouseout', @onMouseOut
    google.maps.event.addListener @polygon.getPolygon(), 'mouseover', @onMouseOver
    google.maps.event.addListener @polygon.getPolygon(), 'mousemove', @onMouseMove
    google.maps.event.addListener @map, 'click', @clearSelection
    google.maps.event.addListener @polygon.getPolygon().getPath(), 'set_at', @onPathChanged
    google.maps.event.addListener @polygon.getPolygon().getPath(), 'insert_at', @onPathChanged
    google.maps.event.addListener @polygon.getPolygon().getPath(), 'remove_at', @onPathChanged
    @setEditable()
  
  onMouseOut: (e) =>
    @labelView.hideOverlayAfterTime() if @labelView
      
  onMouseOver: (e) =>
    @labelView.openOverlayOnHover() if @labelView && !@isEditable() && @content
  
  onMouseMove: (e) =>
    @labelView.hide() if @isEditable() && @labelView && @labelView.opened
<commit_msg>hide overlay<commit_after>class ADF.GMap.Views.Polygon extends ADF.MVC.Views.Base
  
  label: false
  content: false 
  withLabel: false
  initialized: false
  
  initialize: () ->
    @mapView = @options.mapView
    @zone = @options.model
    @polygon = @zone.mapObject
    @label = @options.label if @options.label?
    @content = @options.content if @options.content?
    @withLabel = @options.withLabel if @options.withLabel?
    @_initCallbacksFromOptions()

  initZone: (allowDraw) -> 
    @initialized = true
    @map = @mapView.getMap().getGMap()
    if @zone.isNew() && allowDraw
      @startDrawing()
    else 
      @setPolygonMap( @map )
      @setPolygonHandlers()
      @_initLabelView() if @withLabel
      @onPolygonDrawCompleted() if allowDraw

    @mapView.getMap().addOverlay(@)
    @onZoneInitialized()
      
  _initCallbacksFromOptions: () ->
    @onShapeClicked = @options.onShapeClicked if typeof @options.onShapeClicked == 'function'
    @onPolygonDrawCompleted =  @options.onPolygonDrawCompleted if typeof @options.onPolygonDrawCompleted == 'function'
    @onPolygonDrawStarted = @options.onPolygonDrawStarted if typeof @options.onPolygonDrawStarted == 'function'
    @onPathChanged = @options.pathChanged if typeof @options.pathChanged == 'function'

  _initLabelView: () ->
    @labelView = new ADF.Map.Views.PolygonLabel
      point: @getCenter()
      map : @mapView.getMap()
      model: @zone
      label: if @label && @label.length > 0 then @label else null
      content: @content
      clickable: false
      hidden: true
      template: @zonePopupTemplate
            
  isClustering: () ->
    false
    
  removeFromMap: () -> # Depricated
    @zone.removeFromMap()
    @labelView.remove() if @labelView
    
  remove: () ->
    @polygon.getPolygon().setMap(null)
    @labelView.remove() if @labelView
  
  addContextMenu: () ->
    @contextMenu = new ADF.GMap.Views.ContextMenu({gElement : @polygon.getPolygon(), mapModel: @mapView.getMap()})
    @contextMenu.render()

# HELPERS
  setContent: ( content ) ->
    return unless @labelView
    @content = content
    @labelView.setContent( content )
    @labelView.render()
    
  setLabel: ( label) ->
    return unless @labelView
    @label = label
    @labelView.setLabel @label

  setLabelPosition: () ->
    point = @getCenter()
    @labelView.overlay.setPosition point
  
  getZone: ->
    @zone
  
  clearSelection: => 
    @setUnEditable( ) 

  setMap: (map) ->
    @setPolygonMap( map )
      
  getCenter: () ->
    bounds = new google.maps.LatLngBounds()
    i = 0
    while i < @polygon.getPolygon().getPath().length
     bounds.extend(@polygon.getPolygon().getPath().getAt(i))
     i++
    bounds.getCenter()

  setFirstCoordinate: (latLng) ->
    @first_coordinate = latLng

  getFirstCoordinate: ->
    if @first_coordinate? then @first_coordinate else false 
        
# HANDLERS
  setPolygonHandlers: () ->
    google.maps.event.addListener @polygon.getPolygon(), 'click', @newShapeClickHandler if @isEditable()
    google.maps.event.addListener @polygon.getPolygon(), 'mouseout', @onMouseOut
    google.maps.event.addListener @polygon.getPolygon(), 'mouseover', @onMouseOver
    google.maps.event.addListener @polygon.getPolygon(), 'mousemove', @onMouseMove
    google.maps.event.addListener @map, 'click', @clearSelection
    google.maps.event.addListener @polygon.getPolygon().getPath(), 'set_at', @onPathChanged
    google.maps.event.addListener @polygon.getPolygon().getPath(), 'insert_at', @onPathChanged
    google.maps.event.addListener @polygon.getPolygon().getPath(), 'remove_at', @onPathChanged
    @setEditable()
  
  onMouseOut: (e) =>
    @labelView.hideOverlayAfterTime() if @labelView
      
  onMouseOver: (e) =>
    @labelView.openOverlayOnHover() if @labelView && !@isEditable() && @content && @content.length > 0
  
  onMouseMove: (e) =>
    @labelView.hide() if @isEditable() && @labelView && @labelView.opened

{'fraction_non_alphanumeric': 0.1334097859327217, 'fraction_numerical': 0.0006371049949031601, 'mean_word_length': 3.44199207696661, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 48, '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': '2770659', 'n_tokens_mistral': 2567, 'n_tokens_neox': 2534, 'n_words': 481}