<commit_before>//
//  RMTEditRatingView.swift
//  RateMyTalkAtMobOS
//
//  Created by <NAME> on 10/11/14.
//  Copyright (c) 2014 Grigaci. All rights reserved.
//

import UIKit

class RMTEditRatingView: RMTDisplayRatingView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addTapGestures()
    }

    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    func handleTapGesture(tapGesture:UITapGestureRecognizer) {
        let tappedImageView = tapGesture.view
        let index = self.imageViews.find {$0 == tappedImageView}
        if index != nil {
            let highlightValue = Float(index! + 1)
            self.highlightStars(highlightValue)
        }
    }

    private func addTapGestures() {
        for imageView in self.imageViews {
            self.addTapGestureImageView(imageView)
        }
    }

    private func addTapGestureImageView(imageView: UIImageView) {
        let tapGesture = UITapGestureRecognizer(target: self, action: "handleTapGesture:")
        imageView.addGestureRecognizer(tapGesture)
    }

}<commit_msg>Add pan gesture to edit rating view.<commit_after>//
//  RMTEditRatingView.swift
//  RateMyTalkAtMobOS
//
//  Created by <NAME> on 10/11/14.
//  Copyright (c) 2014 Grigaci. All rights reserved.
//

import UIKit

class RMTEditRatingView: RMTDisplayRatingView {

    override init(frame: CGRect) {
        super.init(frame: frame)
        self.addTapGestures()
        self.addPanGesture()
    }

    required init(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }

    func handleTapGesture(tapGesture:UITapGestureRecognizer) {
        let tappedImageView = tapGesture.view as? UIImageView
        self.tapOnImageView(tappedImageView)
    }

    func handlePanGesture(panGesture: UIPanGestureRecognizer) {
        switch panGesture.state {
        case .Began, .Changed, .Ended:
            self.handlePanGestureHighlight(panGesture)
        default: ()
        }
    }

    private func handlePanGestureHighlight(panGesture: UIPanGestureRecognizer) {
        let point = panGesture.locationInView(self)
        var touchedImageView: UIImageView? = nil
        for imageView in self.imageViews {
            let pointInView = imageView.convertPoint(point, fromView: self)
            if imageView.pointInside(pointInView, withEvent: nil) {
                touchedImageView = imageView
                break
            }
        }
        if touchedImageView != nil {
            self.tapOnImageView(touchedImageView)
        }
    }

    private func tapOnImageView(imageView: UIImageView?) {
        let index = self.imageViews.find {$0 == imageView}
        if index != nil {
            let highlightValue = Float(index! + 1)
            self.highlightStars(highlightValue)
        }
    }

    private func addTapGestures() {
        for imageView in self.imageViews {
            self.addTapGestureImageView(imageView)
        }
    }

    private func addTapGestureImageView(imageView: UIImageView) {
        let tapGesture = UITapGestureRecognizer(target: self, action: "handleTapGesture:")
        imageView.addGestureRecognizer(tapGesture)
    }

    private func addPanGesture() {
        let panGesture = UIPanGestureRecognizer(target: self, action: "handlePanGesture:")
        self.addGestureRecognizer(panGesture)
    }
}
{'fraction_non_alphanumeric': 0.08851113716295428, 'fraction_numerical': 0.007033997655334115, 'mean_word_length': 2.5813221406086044, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7322373', 'n_tokens_mistral': 1153, 'n_tokens_neox': 1007, 'n_words': 210}