|
@@ -142,8 +142,8 @@ import Foundation
|
|
|
}
|
|
|
context?.setLineWidth(annotationModel.lineWidth())
|
|
|
|
|
|
- startPoint = self._drawLineExEnding(style: annotationModel.startLineStyle(), point: startPoint, cpoint: endPoint, inContext: context!, model: annotationModel)
|
|
|
- endPoint = self._drawLineExEnding(style: annotationModel.endLineStyle(), point: endPoint, cpoint: startPoint, inContext: context!, model: annotationModel)
|
|
|
+ startPoint = self._drawLineExEnding(style: annotationModel.startLineStyle(), point: startPoint, cpoint: endPoint, inContext: context, model: annotationModel)
|
|
|
+ endPoint = self._drawLineExEnding(style: annotationModel.endLineStyle(), point: endPoint, cpoint: startPoint, inContext: context, model: annotationModel)
|
|
|
if (annotationModel.style() == .dashed) {
|
|
|
if let dashPattern = annotationModel.dashPattern(), dashPattern.count > 0 {
|
|
|
let count = annotationModel.dashPattern().count
|
|
@@ -170,47 +170,47 @@ import Foundation
|
|
|
// MARK: - Private Methods
|
|
|
|
|
|
extension CPDFLineAnnotation {
|
|
|
- private class func _drawLineExEnding(style: CPDFLineStyle, point: CGPoint, cpoint: CGPoint, inContext context: CGContext, model annotationModel: CPDFAnnotationModel) -> CGPoint {
|
|
|
+ private class func _drawLineExEnding(style: CPDFLineStyle, point: CGPoint, cpoint: CGPoint, inContext context: CGContext?, model annotationModel: CPDFAnnotationModel) -> CGPoint {
|
|
|
var rpoint = point
|
|
|
switch style {
|
|
|
case .openArrow:
|
|
|
var points: [CGPoint] = [CGPoint](repeating: CGPointZero, count: 3)
|
|
|
self._openArrowExPoints(&points, point: point, cpoint: cpoint, borderWidth: annotationModel.lineWidth())
|
|
|
- context.beginPath()
|
|
|
- context.addLines(between: points)
|
|
|
- context.drawPath(using: .stroke)
|
|
|
+ context?.beginPath()
|
|
|
+ context?.addLines(between: points)
|
|
|
+ context?.drawPath(using: .stroke)
|
|
|
break
|
|
|
case .closedArrow:
|
|
|
var points: [CGPoint] = [CGPoint](repeating: CGPointZero, count: 3)
|
|
|
rpoint = self._closedArrowExPoints(&points, point: point, cpoint: cpoint)
|
|
|
- context.beginPath()
|
|
|
- context.addLines(between: points)
|
|
|
- context.closePath()
|
|
|
- context.drawPath(using: .fillStroke)
|
|
|
+ context?.beginPath()
|
|
|
+ context?.addLines(between: points)
|
|
|
+ context?.closePath()
|
|
|
+ context?.drawPath(using: .fillStroke)
|
|
|
break
|
|
|
case .square:
|
|
|
var points: [CGPoint] = [CGPoint](repeating: CGPointZero, count: 4)
|
|
|
rpoint = self._squareExPoints(&points, point: point, cpoint: cpoint, borderWidth: annotationModel.lineWidth())
|
|
|
- context.beginPath()
|
|
|
- context.addLines(between: points)
|
|
|
- context.closePath()
|
|
|
- context.drawPath(using: .fillStroke)
|
|
|
+ context?.beginPath()
|
|
|
+ context?.addLines(between: points)
|
|
|
+ context?.closePath()
|
|
|
+ context?.drawPath(using: .fillStroke)
|
|
|
break
|
|
|
case .circle:
|
|
|
var points: [CGPoint] = [CGPoint](repeating: CGPointZero, count: 1)
|
|
|
rpoint = self._circleExPoints(&points, point: point, cpoint: cpoint, borderWidth: annotationModel.lineWidth())
|
|
|
let radius = sqrt((rpoint.x - points[0].x) * (rpoint.x - points[0].x) + (rpoint.y - points[0].y) * (rpoint.y - points[0].y))
|
|
|
- context.beginPath()
|
|
|
- context.addArc(center: points[0], radius: radius, startAngle: 0, endAngle: 2 * Double.pi, clockwise: false)
|
|
|
- context.closePath()
|
|
|
- context.drawPath(using: .fillStroke)
|
|
|
+ context?.beginPath()
|
|
|
+ context?.addArc(center: points[0], radius: radius, startAngle: 0, endAngle: 2 * Double.pi, clockwise: false)
|
|
|
+ context?.closePath()
|
|
|
+ context?.drawPath(using: .fillStroke)
|
|
|
case .diamond:
|
|
|
var points: [CGPoint] = [CGPoint](repeating: CGPointZero, count: 4)
|
|
|
rpoint = self._diamondExPoints(&points, point: point, cpoint: cpoint, borderWidth: annotationModel.lineWidth())
|
|
|
- context.beginPath()
|
|
|
- context.addLines(between: points)
|
|
|
- context.closePath()
|
|
|
- context.drawPath(using: .fillStroke)
|
|
|
+ context?.beginPath()
|
|
|
+ context?.addLines(between: points)
|
|
|
+ context?.closePath()
|
|
|
+ context?.drawPath(using: .fillStroke)
|
|
|
break
|
|
|
default:
|
|
|
break
|