Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required constructors added to Drawing Layers. #157

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Classes/Drawing/BarDrawingLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ internal class BarDrawingLayer: ScrollableGraphViewDrawingLayer {
private var barWidth: CGFloat = 4
private var shouldRoundCorners = false

override init(layer: Any) {
super.init(layer: layer)
}

init(frame: CGRect, barWidth: CGFloat, barColor: UIColor, barLineWidth: CGFloat, barLineColor: UIColor, shouldRoundCorners: Bool) {
super.init(viewportWidth: frame.size.width, viewportHeight: frame.size.height)

Expand Down
4 changes: 4 additions & 0 deletions Classes/Drawing/DotDrawingLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ internal class DotDrawingLayer: ScrollableGraphViewDrawingLayer {

private var customDataPointPath: ((_ centre: CGPoint) -> UIBezierPath)?

override init(layer: Any) {
super.init(layer: layer)
}

init(frame: CGRect, fillColor: UIColor, dataPointType: ScrollableGraphViewDataPointType, dataPointSize: CGFloat, customDataPointPath: ((_ centre: CGPoint) -> UIBezierPath)? = nil) {

self.dataPointType = dataPointType
Expand Down
6 changes: 5 additions & 1 deletion Classes/Drawing/FillDrawingLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ internal class FillDrawingLayer : ScrollableGraphViewDrawingLayer {

// Fills are only used with lineplots and we need
// to know what the line looks like.
private var lineDrawingLayer: LineDrawingLayer
private var lineDrawingLayer: LineDrawingLayer!

override init(layer: Any) {
super.init(layer: layer)
}

init(frame: CGRect, fillColor: UIColor, lineDrawingLayer: LineDrawingLayer) {

Expand Down
18 changes: 12 additions & 6 deletions Classes/Drawing/GradientDrawingLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import UIKit

internal class GradientDrawingLayer : ScrollableGraphViewDrawingLayer {

private var startColor: UIColor
private var endColor: UIColor
private var gradientType: ScrollableGraphViewGradientType
private var startColor: UIColor!
private var endColor: UIColor!
private var gradientType: ScrollableGraphViewGradientType!

// Gradient fills are only used with lineplots and we need
// to know what the line looks like.
private var lineDrawingLayer: LineDrawingLayer
private var lineDrawingLayer: LineDrawingLayer!

lazy private var gradientMask: CAShapeLayer = ({
let mask = CAShapeLayer()
Expand All @@ -20,6 +20,10 @@ internal class GradientDrawingLayer : ScrollableGraphViewDrawingLayer {

return mask
})()

override init(layer: Any) {
super.init(layer: layer)
}

init(frame: CGRect, startColor: UIColor, endColor: UIColor, gradientType: ScrollableGraphViewGradientType, lineJoin: String = convertFromCAShapeLayerLineJoin(CAShapeLayerLineJoin.round), lineDrawingLayer: LineDrawingLayer) {
self.startColor = startColor
Expand Down Expand Up @@ -61,10 +65,12 @@ internal class GradientDrawingLayer : ScrollableGraphViewDrawingLayer {
let endRadius: CGFloat = self.bounds.width

switch(gradientType) {
case .linear:
case .linear?:
ctx.drawLinearGradient(gradient!, start: topCentre, end: bottomCentre, options: .drawsAfterEndLocation)
case .radial:
case .radial?:
ctx.drawRadialGradient(gradient!, startCenter: topCentre, startRadius: startRadius, endCenter: topCentre, endRadius: endRadius, options: .drawsAfterEndLocation)
default:
fatalError("Unknown type of gradient.")
}
}
}
Expand Down
10 changes: 7 additions & 3 deletions Classes/Drawing/LineDrawingLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,13 @@ internal class LineDrawingLayer : ScrollableGraphViewDrawingLayer {

private var currentLinePath = UIBezierPath()

private var lineStyle: ScrollableGraphViewLineStyle
private var shouldFill: Bool
private var lineCurviness: CGFloat
private var lineStyle: ScrollableGraphViewLineStyle!
private var shouldFill: Bool!
private var lineCurviness: CGFloat!

override init(layer: Any) {
super.init(layer: layer)
}

init(frame: CGRect, lineWidth: CGFloat, lineColor: UIColor, lineStyle: ScrollableGraphViewLineStyle, lineJoin: String, lineCap: String, shouldFill: Bool, lineCurviness: CGFloat) {

Expand Down
4 changes: 4 additions & 0 deletions Classes/Drawing/ScrollableGraphViewDrawingLayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ internal class ScrollableGraphViewDrawingLayer : CAShapeLayer {

var active = true

override init(layer: Any) {
super.init()
}

init(viewportWidth: CGFloat, viewportHeight: CGFloat, offset: CGFloat = 0) {
super.init()

Expand Down