<commit_before>//
//  SymbolPathProviders.swift
//  RingGraph
//
//  Created by <NAME> on 18.04.15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit

protocol SymbolPathProvider {
    func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath
}

class DefaultPathProvider {
    let animationHelper: RangeAnimationHelper = RangeAnimationHelper(animationStart: 0.3, animationEnd: 0.6)
    let margin :CGFloat = 2
    
    func defaultPath() -> UIBezierPath {
        let path = UIBezierPath()
        
        path.lineCapStyle = kCGLineCapRound
        path.lineJoinStyle = kCGLineJoinRound
        path.lineWidth = 3
        
        return path
    }
    
    func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath {
        return UIBezierPath()
    }
    
    func normalizedProgress(progress :Float) -> CGFloat {
        return CGFloat(animationHelper.normalizedProgress(absoluteProgress: progress))
    }
}

class RightArrowPathProvider : DefaultPathProvider, SymbolPathProvider {
    
    override func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath {
        let progress = normalizedProgress(animationProgress)
        
        if (progress == 0.0) {
            return super.path(inRect: rect, forAnimationProgress: animationProgress)
        }
        
        var points = [CGPoint]()
        
        let middleEndPoint = CGPoint(x: CGRectGetMaxX(rect), y: CGRectGetMidY(rect))
        
        var intermediatePoint1 = middleEndPoint
        intermediatePoint1.x = middleEndPoint.x * progress
        
        var intermediatePoint2 = middleEndPoint
        intermediatePoint2.x = CGRectGetMidX(rect) + middleEndPoint.x * progress / 2
        
        points.append(intermediatePoint1)
        points.append(CGPoint(x: CGRectGetMinX(rect), y: CGRectGetMidY(rect)))
        
        points.append(intermediatePoint2)
        points.append(CGPoint(x: CGRectGetMidX(rect), y: CGRectGetMinY(rect)))
        points.append(CGPoint(x: CGRectGetMidX(rect), y: CGRectGetMaxY(rect)))
        
        let path = defaultPath()
        
        path.moveToPoint(points[0])
        path.addLineToPoint(points[1])
        path.moveToPoint(points[2])
        path.addLineToPoint(points[3])
        path.moveToPoint(points[2])
        path.addLineToPoint(points[4])
        path.closePath()
        
        return path
    }
    
}

class DoubleRightArrowPathProvider : DefaultPathProvider, SymbolPathProvider {
    
    override func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath {
        var points = [CGPoint]()
        
        let arrowSpacing :CGFloat = 6
        
        points.append(CGPoint(x: CGRectGetMaxX(rect) - arrowSpacing, y: CGRectGetMidY(rect)))
        points.append(CGPoint(x: CGRectGetMinX(rect), y: CGRectGetMidY(rect)))
        points.append(CGPoint(x: CGRectGetMidX(rect) - arrowSpacing, y: CGRectGetMinY(rect)))
        points.append(CGPoint(x: CGRectGetMidX(rect) - arrowSpacing, y: CGRectGetMaxY(rect)))
        
        points.append(CGPoint(x: CGRectGetMaxX(rect), y: CGRectGetMidY(rect)))
        points.append(CGPoint(x: CGRectGetMidX(rect), y: CGRectGetMinY(rect)))
        points.append(CGPoint(x: CGRectGetMidX(rect), y: CGRectGetMaxY(rect)))
        
        let path = defaultPath()
        
        path.moveToPoint(points[0])
        path.addLineToPoint(points[1])
        path.moveToPoint(points[0])
        path.addLineToPoint(points[2])
        path.moveToPoint(points[0])
        path.addLineToPoint(points[3])
        
        path.moveToPoint(points[4])
        path.addLineToPoint(points[5])
        path.moveToPoint(points[4])
        path.addLineToPoint(points[6])
        
        path.closePath()
        
        return path
    }
    
}

class UpArrowPathProvider : RightArrowPathProvider, SymbolPathProvider {
    
    override func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath {
        var path = super.path(inRect: rect, forAnimationProgress: animationProgress)
        
        let center = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect))
        let radians = CGFloat(-90 * M_PI / 180)
        
        var transform = CGAffineTransformIdentity
        transform = CGAffineTransformTranslate(transform, center.x, center.y)
        transform = CGAffineTransformRotate(transform, radians)
        transform = CGAffineTransformTranslate(transform, -center.x, -center.y)
        
        path.applyTransform(transform)
        
        return path
    }
    
}

internal class NilPathProvider : SymbolPathProvider {
    func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath {
        return UIBezierPath()
    }
}<commit_msg>add double right arrow animation<commit_after>//
//  SymbolPathProviders.swift
//  RingGraph
//
//  Created by <NAME> on 18.04.15.
//  Copyright (c) 2015 <NAME>. All rights reserved.
//

import UIKit

let DefaultSymbolAnimationStart :Float = 0.3
let DefaultSymbolAnimationEnd :Float = 0.6

protocol SymbolPathProvider {
    func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath
}

class DefaultPathProvider {
    let animationHelper: RangeAnimationHelper = RangeAnimationHelper(animationStart: DefaultSymbolAnimationStart, animationEnd: DefaultSymbolAnimationEnd)
    let margin :CGFloat = 2
    
    func defaultPath() -> UIBezierPath {
        let path = UIBezierPath()
        
        path.lineCapStyle = kCGLineCapRound
        path.lineJoinStyle = kCGLineJoinRound
        path.lineWidth = 3
        
        return path
    }
    
    func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath {
        return UIBezierPath()
    }
    
    func normalizedProgress(progress :Float) -> CGFloat {
        return CGFloat(animationHelper.normalizedProgress(absoluteProgress: progress))
    }
}

class RightArrowPathProvider : DefaultPathProvider, SymbolPathProvider {
    
    override func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath {
        let progress = normalizedProgress(animationProgress)
        
        if (progress == 0.0) {
            return super.path(inRect: rect, forAnimationProgress: animationProgress)
        }
        
        var points = [CGPoint]()
        
        let middleEndPoint = CGPoint(x: CGRectGetMaxX(rect), y: CGRectGetMidY(rect))
        
        var intermediatePoint1 = middleEndPoint
        intermediatePoint1.x = middleEndPoint.x * progress
        
        var intermediatePoint2 = middleEndPoint
        intermediatePoint2.x = CGRectGetMidX(rect) + middleEndPoint.x * progress / 2
        
        points.append(intermediatePoint1)
        points.append(CGPoint(x: CGRectGetMinX(rect), y: CGRectGetMidY(rect)))
        
        points.append(intermediatePoint2)
        points.append(CGPoint(x: CGRectGetMidX(rect), y: CGRectGetMinY(rect)))
        points.append(CGPoint(x: CGRectGetMidX(rect), y: CGRectGetMaxY(rect)))
        
        let path = defaultPath()
        
        path.moveToPoint(points[0])
        path.addLineToPoint(points[1])
        path.moveToPoint(points[2])
        path.addLineToPoint(points[3])
        path.moveToPoint(points[2])
        path.addLineToPoint(points[4])
        path.closePath()
        
        return path
    }
    
}

class UpArrowPathProvider : RightArrowPathProvider, SymbolPathProvider {
    
    override func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath {
        var path = super.path(inRect: rect, forAnimationProgress: animationProgress)
        
        let center = CGPointMake(CGRectGetMidX(rect), CGRectGetMidY(rect))
        let radians = CGFloat(-90 * M_PI / 180)
        
        var transform = CGAffineTransformIdentity
        transform = CGAffineTransformTranslate(transform, center.x, center.y)
        transform = CGAffineTransformRotate(transform, radians)
        transform = CGAffineTransformTranslate(transform, -center.x, -center.y)
        
        path.applyTransform(transform)
        
        return path
    }
    
}

private let intermediateAnimationPoint :Float = DefaultSymbolAnimationEnd - 0.1

class DoubleRightArrowPathProvider : DefaultPathProvider, SymbolPathProvider {
    
    let leftAnimationHelper: RangeAnimationHelper = RangeAnimationHelper(animationStart: DefaultSymbolAnimationStart, animationEnd: intermediateAnimationPoint)
    let rightAnimationHelper: RangeAnimationHelper = RangeAnimationHelper(animationStart: intermediateAnimationPoint, animationEnd: DefaultSymbolAnimationEnd)
    let arrowSpacing :CGFloat = 6
    
    override func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath {
        let progress = normalizedProgress(animationProgress)
        
        if (progress == 0.0) {
            return super.path(inRect: rect, forAnimationProgress: animationProgress)
        }
        
        let leftProgress = CGFloat(leftAnimationHelper.normalizedProgress(absoluteProgress: animationProgress))
        let rightProgress = CGFloat(rightAnimationHelper.normalizedProgress(absoluteProgress: animationProgress))
        
        var points = [CGPoint]()
        
        let middleEndPoint = CGPoint(x: CGRectGetMaxX(rect) - arrowSpacing, y: CGRectGetMidY(rect))
        let rightEndPoint = CGPoint(x: CGRectGetMaxX(rect), y: CGRectGetMidY(rect))
        
        var intermediatePoint1 = middleEndPoint
        intermediatePoint1.x = middleEndPoint.x * leftProgress
        
        points.append(intermediatePoint1)
        points.append(CGPoint(x: CGRectGetMinX(rect), y: CGRectGetMidY(rect)))
        points.append(CGPoint(x: CGRectGetMidX(rect) - arrowSpacing, y: CGRectGetMinY(rect)))
        points.append(CGPoint(x: CGRectGetMidX(rect) - arrowSpacing, y: CGRectGetMaxY(rect)))
        
        if (rightProgress > 0) {
            let delta = arrowSpacing * (1 - rightProgress)
            var intermediateEndPoint2 = rightEndPoint
            intermediateEndPoint2.x -= delta
            
            points.append(intermediateEndPoint2)
            points.append(CGPoint(x: CGRectGetMidX(rect) - delta, y: CGRectGetMinY(rect)))
            points.append(CGPoint(x: CGRectGetMidX(rect) - delta, y: CGRectGetMaxY(rect)))
        }
        
        return pathFromPoints(points)
    }
    
    func pathFromPoints(points :[CGPoint]) -> UIBezierPath {
        let path = defaultPath()
        
        path.moveToPoint(points[0])
        path.addLineToPoint(points[1])
        path.moveToPoint(points[0])
        path.addLineToPoint(points[2])
        path.moveToPoint(points[0])
        path.addLineToPoint(points[3])
        
        if (count(points) > 4) {
            path.moveToPoint(points[4])
            path.addLineToPoint(points[5])
            path.moveToPoint(points[4])
            path.addLineToPoint(points[6])
        }
        
        path.closePath()
        
        return path
    }
    
}

internal class NilPathProvider : SymbolPathProvider {
    func path(inRect rect: CGRect, forAnimationProgress animationProgress: Float) -> UIBezierPath {
        return UIBezierPath()
    }
}
{'fraction_non_alphanumeric': 0.0896801555045061, 'fraction_numerical': 0.00945396713200212, 'mean_word_length': 2.8265720081135903, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 26, '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': '6065943', 'n_tokens_mistral': 3377, 'n_tokens_neox': 3236, 'n_words': 627}