<commit_before>import UIKit

class VDrawProjectCanvasNode:VDrawProjectCanvasView
{
    private weak var timer:Timer?
    private weak var viewEffect:VDrawProjectCanvasNodeEffect!
    private let kTimerInterval:TimeInterval = 0.05
    
    required init(
        controller:CDrawProject,
        model:DDrawable)
    {
        super.init(
            controller:controller,
            model:model)
        
        let viewEffect:VDrawProjectCanvasNodeEffect = VDrawProjectCanvasNodeEffect(
            viewCanvas:self,
            model:model)
        self.viewEffect = viewEffect
        
        addSubview(viewEffect)
        
        NSLayoutConstraint.equals(
            view:viewEffect,
            toView:self)
        
        NotificationCenter.default.addObserver(
            self,
            selector:#selector(self.notifiedNodeDraw(sender:)),
            name:Notification.nodeDraw,
            object:nil)
    }
    
    required init?(coder:NSCoder)
    {
        return nil
    }
    
    deinit
    {
        timer?.invalidate()
    }
    
    override func positionCenter()
    {
        guard
            
            let model:DNode = viewSpatial.model as? DNode
            
        else
        {
            return
        }
        
        let zoom:CGFloat = controller.modelZoom.currentZoom()
        let originalX:CGFloat = CGFloat(model.centerX)
        let originalY:CGFloat = CGFloat(model.centerY)
        let widthOriginal:CGFloat = CGFloat(model.width)
        let heightOriginal:CGFloat = CGFloat(model.height)
        let maxSize:CGFloat = max(widthOriginal, heightOriginal)
        let widthOriginal_2:CGFloat = widthOriginal / 2.0
        let heightOriginal_2:CGFloat = heightOriginal / 2.0
        let positionedOriginalX:CGFloat = originalX - widthOriginal_2
        let positionedOriginalY:CGFloat = originalY - heightOriginal_2
        let zoomedX:CGFloat = positionedOriginalX * zoom
        let zoomedY:CGFloat = positionedOriginalY * zoom
        let zoomedWidth:CGFloat = widthOriginal * zoom
        let zoomedHeight:CGFloat = heightOriginal * zoom
        let positionedX:CGFloat = zoomedX - kMargin
        let positionedY:CGFloat = zoomedY - kMargin
        let widthExpanded:CGFloat = zoomedWidth + margin2
        let heightExpanded:CGFloat = zoomedHeight + margin2
        
        frame = CGRect(
            x:positionedX,
            y:positionedY,<commit_msg>using max size avoiding clipping<commit_after>import UIKit

class VDrawProjectCanvasNode:VDrawProjectCanvasView
{
    private weak var timer:Timer?
    private weak var viewEffect:VDrawProjectCanvasNodeEffect!
    private let kTimerInterval:TimeInterval = 0.05
    
    required init(
        controller:CDrawProject,
        model:DDrawable)
    {
        super.init(
            controller:controller,
            model:model)
        
        let viewEffect:VDrawProjectCanvasNodeEffect = VDrawProjectCanvasNodeEffect(
            viewCanvas:self,
            model:model)
        self.viewEffect = viewEffect
        
        addSubview(viewEffect)
        
        NSLayoutConstraint.equals(
            view:viewEffect,
            toView:self)
        
        NotificationCenter.default.addObserver(
            self,
            selector:#selector(self.notifiedNodeDraw(sender:)),
            name:Notification.nodeDraw,
            object:nil)
    }
    
    required init?(coder:NSCoder)
    {
        return nil
    }
    
    deinit
    {
        timer?.invalidate()
    }
    
    override func positionCenter()
    {
        guard
            
            let model:DNode = viewSpatial.model as? DNode
            
        else
        {
            return
        }
        
        let zoom:CGFloat = controller.modelZoom.currentZoom()
        let originalX:CGFloat = CGFloat(model.centerX)
        let originalY:CGFloat = CGFloat(model.centerY)
        let widthOriginal:CGFloat = CGFloat(model.width)
        let heightOriginal:CGFloat = CGFloat(model.height)
        let maxSize:CGFloat = max(widthOriginal, heightOriginal)
        let size_2:CGFloat = maxSize / 2.0
        let positionedOriginalX:CGFloat = originalX - size_2
        let positionedOriginalY:CGFloat = originalY - size_2
        let zoomedX:CGFloat = positionedOriginalX * zoom
        let zoomedY:CGFloat = positionedOriginalY * zoom
        let zoomedWidth:CGFloat = maxSize * zoom
        let zoomedHeight:CGFloat = maxSize * zoom
        let positionedX:CGFloat = zoomedX - kMargin
        let positionedY:CGFloat = zoomedY - kMargin
        let widthExpanded:CGFloat = zoomedWidth + margin2
        let heightExpanded:CGFloat = zoomedHeight + margin2
        
        frame = CGRect(
            x:positionedX,
            y:positionedY,
{'fraction_non_alphanumeric': 0.06486941870261162, 'fraction_numerical': 0.004844144903117102, 'mean_word_length': 2.05009633911368, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '3107914', 'n_tokens_mistral': 1293, 'n_tokens_neox': 1322, 'n_words': 253}