<commit_before>//
//  SonarViewCenteredLayout.swift
//  Pods
//
//  Created by <NAME> on 15/01/16.
//
//

import Foundation

public protocol SonarViewCenteredLayoutDelegate: class {
    func sizeForItem(sonarView: SonarView, inWave waveIndex: Int, atIndex index: Int) -> CGSize
}

public class SonarViewCenteredLayout {
    public weak var delegate: SonarViewCenteredLayoutDelegate?
    public var itemSize: CGSize = CGSizeMake(50, 50)
    public var segmentPadding: Double = 0.0
    public var edgeItemsShift: Double = 6.0
}

extension SonarViewCenteredLayout: SonarViewLayout {
    
    public func sizeForItem(sonarView: SonarView, inWave waveIndex: Int, atIndex index: Int) -> CGSize {
        if let delegate = delegate {
            return delegate.sizeForItem(sonarView, inWave: waveIndex, atIndex: index)
        } else {
            return itemSize
        }
    }
    
    public func positionForItem(sonarView: SonarView, inWave waveIndex: Int, atIndex index: Int) -> Double {
        guard let numberOfItemsInWave = sonarView.dataSource?.sonarView(sonarView, numberOfItemForWaveIndex: waveIndex) else {
            assertionFailure("*** SonarViewCenteredLayout: Missing DataSource!")
            return 0.0
        }
        
        if numberOfItemsInWave % 2 == 0 {
            
            let fullSegmentSize: Double = 100.0 // Just a value that represents 100%
            let segmentSize = (fullSegmentSize / Double(numberOfItemsInWave + 1)) + segmentPadding
            let padding: Double = segmentSize - edgeItemsShift
            
            if index % 2 == 0 {
                let size = (padding + (Double(index / 2) * segmentSize))
                return size / fullSegmentSize
            } else {
                let size = fullSegmentSize - (padding + (Double((index / 2)) * segmentSize))
                return size / fullSegmentSize
            }
        }
        
        return (Double(index + 1) / Double(numberOfItemsInWave + 1))
    }
  
    public func positionForWaveLabel(sonarView: SonarView, inWave waveIndex: Int) -> Double {
        return 0.5
    }
    
    public func waveRadiusOffset(sonarView: SonarView) -> Double {
        return 0.1
    }
}<commit_msg>Exposes wave radius offset property<commit_after>//
//  SonarViewCenteredLayout.swift
//  Pods
//
//  Created by <NAME> on 15/01/16.
//
//

import Foundation

public protocol SonarViewCenteredLayoutDelegate: class {
    func sizeForItem(sonarView: SonarView, inWave waveIndex: Int, atIndex index: Int) -> CGSize
}

public class SonarViewCenteredLayout {
    public weak var delegate: SonarViewCenteredLayoutDelegate?
    public var itemSize: CGSize = CGSizeMake(50, 50)
    public var segmentPadding: Double = 0.0
    public var edgeItemsShift: Double = 6.0
    public var waveRadiusOffset: Double = 0.0
}

extension SonarViewCenteredLayout: SonarViewLayout {
    
    public func sizeForItem(sonarView: SonarView, inWave waveIndex: Int, atIndex index: Int) -> CGSize {
        if let delegate = delegate {
            return delegate.sizeForItem(sonarView, inWave: waveIndex, atIndex: index)
        } else {
            return itemSize
        }
    }
    
    public func positionForItem(sonarView: SonarView, inWave waveIndex: Int, atIndex index: Int) -> Double {
        guard let numberOfItemsInWave = sonarView.dataSource?.sonarView(sonarView, numberOfItemForWaveIndex: waveIndex) else {
            assertionFailure("*** SonarViewCenteredLayout: Missing DataSource!")
            return 0.0
        }
        
        if numberOfItemsInWave % 2 == 0 {
            
            let fullSegmentSize: Double = 100.0 // Just a value that represents 100%
            let segmentSize = (fullSegmentSize / Double(numberOfItemsInWave + 1)) + segmentPadding
            let padding: Double = segmentSize - edgeItemsShift
            
            if index % 2 == 0 {
                let size = (padding + (Double(index / 2) * segmentSize))
                return size / fullSegmentSize
            } else {
                let size = fullSegmentSize - (padding + (Double((index / 2)) * segmentSize))
                return size / fullSegmentSize
            }
        }
        
        return (Double(index + 1) / Double(numberOfItemsInWave + 1))
    }
  
    public func positionForWaveLabel(sonarView: SonarView, inWave waveIndex: Int) -> Double {
        return 0.5
    }
    
    public func waveRadiusOffset(sonarView: SonarView) -> Double {
        return waveRadiusOffset
    }
}
{'fraction_non_alphanumeric': 0.08420583648919581, 'fraction_numerical': 0.01603920695032301, 'mean_word_length': 2.3432613551749815, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '1446297', 'n_tokens_mistral': 1345, 'n_tokens_neox': 1247, 'n_words': 349}