     
     // Returns whether it changed size
     func displayValue(value: Double?) -> Bool {
-        self.sizeThatFits(CGSizeZero)
         if let value = value {
             if isPercent {
-                self.text = String(format: "%.1f%%", value * 100)
+                self.valueLabel.text = String(format: "%.1f%%", value * 100)
             }
             else
             {
                 if abs(value) < 3 {
-                    self.text = String(format: "%.2f", value)
+                    self.valueLabel.text = String(format: "%.2f", value)
                 } else if abs(value) < 100 {
-                    self.text = String(format: "%.1f", value)
+                    self.valueLabel.text = String(format: "%.1f", value)
                 } else {
-                    self.text = String(format: "%.f", value)
+                    self.valueLabel.text = String(format: "%.f", value)
                 }
             }
         } else {
-            self.text = "?"
-        }
-        
+            self.valueLabel.text = "?"
+        }
+        
+        return resizeAndLayout()
+    }
+    
+    func resizeAndLayout() -> Bool {
         let center = self.center
         let size = self.bounds.size
-        self.sizeToFit()
+        sizeToFit()
         if !CGSizeEqualToSize(size, self.bounds.size) {
             self.center = center
             return true


import UIKit
import DigitRecognizerSDK

// Views that contain and draw Connector, Adder, or Multiplier. Their center stays the same, but otherwise they can rotate and resize to fit

class ConnectorLabel: UILabel {
    var scale: Double = 1
    let connector: Connector
    var isDependent: Bool = false
    var isPercent: Bool = false

    init(connector: Connector) {
        self.connector = connector

        return false
    }
    
    override func sizeToFit() {
        self.valueLabel.sizeToFit()
        let valueLabelSize = self.valueLabel.frame.size
        var newSize = valueLabelSize
        
        let verticalMargin: CGFloat = 7.0 + borderWidth
        let horizontalMargin: CGFloat = 7.0 + borderWidth
        let equationSpace: CGFloat = 2.0
        
        if let equationView = self.equationView {
            if let equationSize = self.equationViewSize {
                equationView.frame.size = equationSize
                
                newSize.width = max(newSize.width, equationSize.width)
                newSize.height += equationSpace + equationSize.height
            }
        }

        newSize.width += horizontalMargin * 2
        newSize.height += verticalMargin * 2
        
        self.valueLabel.center = CGPointMake(newSize.width / 2, verticalMargin + valueLabelSize.height / 2)
        if let equationView = self.equationView {
            equationView.center = CGPointMake(newSize.width / 2,
                verticalMargin + valueLabelSize.height + equationSpace + equationView.frame.size.height / 2)
        }
        
        self.frame.size = newSize
    }
}

