<commit_before>//
//  CircleGraphView.swift
//  CounterAnimations
//
//  Created by <NAME> on 05.10.15.
//  Derived w/ full Copyright attribution from: 
//  http://makeapppie.com/2015/03/10/swift-swift-basic-core-graphics-for-the-ring-graph/

import UIKit



@IBDesignable
class CircleGraphView: UIControl {

  @IBInspectable var endArc: CGFloat = 0.5 { // up to 1.0
    didSet {
      // print("End arc set. Value: \(endArc)")
      setNeedsDisplay()
    }
  }
  // TODO should be based on the surrounding bounds
  // TODO from external in setup
  @IBInspectable var arcWidth: CGFloat =  10.0
  @IBInspectable var arcColor: UIColor = UIColor(hue:0.113, saturation:0.9598, brightness:0.9717, alpha:1.0)
  @IBInspectable var arcBackgroundColor: UIColor = UIColor(hue:0.4167, saturation:0.036, brightness:0.2124, alpha:1.0)
  @IBInspectable var minutes: NSString = "Whereof we cannot speak, thereof we must remain silent."
  
  // Labels
  @IBInspectable var labelFontColor: UIColor { return UIColor.white }
  @IBInspectable var labelFont: UIFont? = UIFont(name: "Helvetica Neue", size: 18)
  @IBInspectable var labelFontParagraphStyle: NSMutableParagraphStyle = NSMutableParagraphStyle()
  @IBInspectable var labelFontObliqueness = 0.1
  
 
  var lastInterval = TimeInterval()
  var timer = Timer()
  var totalTime = TimeInterval()
  let maxTime: Double = 12.0
  var isRunning = false
  var wasStopped = false
  var counterTimeValues = (minutes: "00", seconds: "00", milliseconds: "00")


  
    override func draw(_ rect: CGRect) {
      // print("arcWidth: \(arcWidth)")
      // circle defs
      let fullCircle = 2.0 * π
      let start: CGFloat = -0.25 * fullCircle
      let end: CGFloat = endArc * fullCircle + start
      // "We need a center point, an angle on the circle to start and an angle on the circle to end."
      let centerPoint = CGPoint(x: rect.midX, y: rect.midY)
      var radius: CGFloat = 0.0
      
      if rect.width > rect.height {
        radius = (rect.width - arcWidth) / 2.0
      } else {
        radius = (rect.height - arcWidth) / 2.0
      }
      
      let context = UIGraphicsGetCurrentContext()
      // let colorspace = CGColorSpaceCreateDeviceRGB()
      context!.setLineWidth(arcWidth)
      context!.setLineCap(.round)
      context!.setStrokeColor(arcColor.cgColor)
      
      // CGContextAddArc(context, centerPoint.x, centerPoint.y, radius, start, end, 0)
      context?.addArc(center: centerPoint, radius: radius, startAngle: start, endAngle: end, clockwise: true)
      context!.strokePath()
      
      
      let labelFontAttributes: NSDictionary = [ NSForegroundColorAttributeName: labelFontColor,
        NSParagraphStyleAttributeName: labelFontParagraphStyle,
        NSObliquenessAttributeName: labelFontObliqueness,
        NSFontAttributeName: labelFont!
      ]
      
      let delimiter = "\t:\t"
      let timeLabel: NSString = counterTimeValues.minutes + delimiter + counterTimeValues.seconds + delimiter + counterTimeValues.milliseconds as NSString
      let center = CGPoint(x:bounds.width/2, y: bounds.height/2)
      let size = timeLabel.size(attributes: (labelFontAttributes as! [String : AnyObject]))

      timeLabel.draw(in: CGRect(x: center.x - size.width/2, y: center.y - size.height/2, width: size.width,height: size.height), withAttributes: (labelFontAttributes as! [String : AnyObject]))<commit_msg>trying to change the custom view label font weirdly difficult<commit_after>//
//  CircleGraphView.swift
//  CounterAnimations
//
//  Created by <NAME> on 05.10.15.
//  Derived w/ full Copyright attribution from: 
//  http://makeapppie.com/2015/03/10/swift-swift-basic-core-graphics-for-the-ring-graph/

import UIKit



@IBDesignable
class CircleGraphView: UIControl {

  @IBInspectable var endArc: CGFloat = 0.5 { // up to 1.0
    didSet {
      // print("End arc set. Value: \(endArc)")
      setNeedsDisplay()
    }
  }
  // TODO should be based on the surrounding bounds
  // TODO from external in setup
  @IBInspectable var arcWidth: CGFloat =  10.0
  @IBInspectable var arcColor: UIColor = UIColor(hue:0.113, saturation:0.9598, brightness:0.9717, alpha:1.0)
  @IBInspectable var arcBackgroundColor: UIColor = UIColor(hue:0.4167, saturation:0.036, brightness:0.2124, alpha:1.0)
  @IBInspectable var minutes: NSString = "Whereof we cannot speak, thereof we must remain silent."
  
  // Labels
  @IBInspectable var labelFontColor: UIColor { return UIColor.white }
  @IBInspectable var labelFont: UIFont? = UIFont(name: "Avenir Next", size: 18)
  @IBInspectable var labelFontParagraphStyle: NSMutableParagraphStyle = NSMutableParagraphStyle()
  @IBInspectable var labelFontObliqueness = 0.1
  
 
  var lastInterval = TimeInterval()
  var timer = Timer()
  var totalTime = TimeInterval()
  let maxTime: Double = 12.0
  var isRunning = false
  var wasStopped = false
  var counterTimeValues = (minutes: "00", seconds: "00", milliseconds: "00")


  
    override func draw(_ rect: CGRect) {
      // print("arcWidth: \(arcWidth)")
      // circle defs
      let fullCircle = 2.0 * π
      let start: CGFloat = -0.25 * fullCircle
      let end: CGFloat = endArc * fullCircle + start
      // "We need a center point, an angle on the circle to start and an angle on the circle to end."
      let centerPoint = CGPoint(x: rect.midX, y: rect.midY)
      var radius: CGFloat = 0.0
      
      if rect.width > rect.height {
        radius = (rect.width - arcWidth) / 2.0
      } else {
        radius = (rect.height - arcWidth) / 2.0
      }
      
      let context = UIGraphicsGetCurrentContext()
      // let colorspace = CGColorSpaceCreateDeviceRGB()
      context!.setLineWidth(arcWidth)
      context!.setLineCap(.round)
      context!.setStrokeColor(arcColor.cgColor)
      
      // CGContextAddArc(context, centerPoint.x, centerPoint.y, radius, start, end, 0)
      context?.addArc(center: centerPoint, radius: radius, startAngle: start, endAngle: end, clockwise: true)
      context!.strokePath()
      
      
      let labelFontAttributes: NSDictionary = [ NSForegroundColorAttributeName: labelFontColor,
        NSParagraphStyleAttributeName: labelFontParagraphStyle,
        NSObliquenessAttributeName: labelFontObliqueness,
        NSFontAttributeName: labelFont!
      ]
      
      let delimiter = "\t:\t"
      let timeLabel: NSString = counterTimeValues.minutes + delimiter + counterTimeValues.seconds + delimiter + counterTimeValues.milliseconds as NSString
      let center = CGPoint(x:bounds.width/2, y: bounds.height/2)
      let size = timeLabel.size(attributes: (labelFontAttributes as! [String : AnyObject]))

      timeLabel.draw(in: CGRect(x: center.x - size.width/2, y: center.y - size.height/2, width: size.width*1.2,height: size.height*1.2), withAttributes: (labelFontAttributes as! [String : AnyObject]))
      
      let dummyLabel = UILabel()
      dummyLabel.text = "Harr harr, Dingo"
      dummyLabel.font = UIFont.systemFont(ofSize: 22)
      
      
      self.inputView?.addSubview(dummyLabel)
{'fraction_non_alphanumeric': 0.107810938169356, 'fraction_numerical': 0.024275310581179495, 'mean_word_length': 3.169047619047619, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2388667', 'n_tokens_mistral': 2360, 'n_tokens_neox': 2204, 'n_words': 579}