<commit_before>/**
 * @fileoverview Main Renderer Class
 *
 */
goog.provide('chem.render.Renderer');

chem.render.Renderer = function(context){
    this.context = context;
    context.mol.renderer = this;
    context.renderParams.atomFont.size = 18 * context.renderParams.zoomFactor;
    this.transform = chem.render.Geometry.createTransform(context);
    this.graphics = goog.graphics.createGraphics(context.width, context.height);
    this.graphics.render(context.targetElement);
    this.mouseFocusEvents = [goog.events.EventType.MOUSEOVER, goog.events.EventType.MOUSEOUT]
  	this.renderBonds();
   	this.renderAtoms();
};


chem.render.Renderer.prototype.renderBonds = function(){
	var context=this.context;
	var transform=this.transform;
	var graphics=this.graphics;
    for (var i = 0, il = context.mol.countBonds(); i < il; i++) {
        var bond = context.mol.getBond(i);
        var ptSource = transform.transformPoint(bond.source.x, bond.source.y);
        var ptTarget = transform.transformPoint(bond.target.x, bond.target.y);
        
        var bondPath = new goog.graphics.Path();
        
        var result = chem.render.Geometry.distanceCalculator(bond, context.renderParams.bondDistance / transform.getScaleX())
        var ptLine0_source = transform.transformPoint(result.source[0].x, result.source[0].y);
        var ptLine0_target = transform.transformPoint(result.target[0].x, result.target[0].y);
        var ptLine1_source = transform.transformPoint(result.source[1].x, result.source[1].y);
        var ptLine1_target = transform.transformPoint(result.target[1].x, result.target[1].y);
        
        switch (bond.bondType) {
            case chem.core.Bond.BondType.Single:
                bondPath.moveTo(ptSource.x, ptSource.y);
                bondPath.lineTo(ptTarget.x, ptTarget.y);
                break;
            case chem.core.Bond.BondType.Double:
                bondPath.moveTo(ptLine0_source.x, ptLine0_source.y);
                bondPath.lineTo(ptLine0_target.x, ptLine0_target.y);
                bondPath.moveTo(ptLine1_source.x, ptLine1_source.y);
                bondPath.lineTo(ptLine1_target.x, ptLine1_target.y);
                break;
            case chem.core.Bond.BondType.Triple:
                bondPath.moveTo(ptSource.x, ptSource.y);
                bondPath.lineTo(ptTarget.x, ptTarget.y);
                bondPath.moveTo(ptLine0_source.x, ptLine0_source.y);
                bondPath.lineTo(ptLine0_target.x, ptLine0_target.y);
                bondPath.moveTo(ptLine1_source.x, ptLine1_source.y);
                bondPath.lineTo(ptLine1_target.x, ptLine1_target.y);
                break;
        }
        bondPath.close();
        
        var group = graphics.createGroup();
        
        bondBoxPath = new goog.graphics.Path();
        bondBoxPath.moveTo(ptLine0_source.x, ptLine0_source.y);
        bondBoxPath.lineTo(ptLine0_target.x, ptLine0_target.y);
        bondBoxPath.lineTo(ptLine1_target.x, ptLine1_target.y);
        bondBoxPath.lineTo(ptLine1_source.x, ptLine1_source.y);
        bondBoxPath.close();
        
        group.bondPath = graphics.drawPath(bondPath, context.renderParams.bondStroke, null, group);<commit_msg>background support and more responsive bond capture<commit_after>/**
 * @fileoverview Main Renderer Class
 *
 */
goog.provide('chem.render.Renderer');

chem.render.Renderer = function(context){
    this.context = context;
    context.mol.renderer = this;
    context.renderParams.atomFont.size = 18 * context.renderParams.zoomFactor;
    this.transform = chem.render.Geometry.createTransform(context);
    this.graphics = goog.graphics.createGraphics(context.width, context.height);
    this.graphics.render(context.targetElement);
    this.mouseFocusEvents = [goog.events.EventType.MOUSEOVER, goog.events.EventType.MOUSEOUT]
	this.graphics.drawRect(0,0,context.width, context.height,null,context.renderParams.backgroundFill);
  	this.renderBonds();
   	this.renderAtoms();
};


chem.render.Renderer.prototype.renderBonds = function(){
	var context=this.context;
	var transform=this.transform;
	var graphics=this.graphics;
    for (var i = 0, il = context.mol.countBonds(); i < il; i++) {
        var bond = context.mol.getBond(i);
        var ptSource = transform.transformPoint(bond.source.x, bond.source.y);
        var ptTarget = transform.transformPoint(bond.target.x, bond.target.y);
        
        var bondPath = new goog.graphics.Path();
        
        var result = chem.render.Geometry.distanceCalculator(bond, context.renderParams.bondDistance / transform.getScaleX())
        var ptLine0_source = transform.transformPoint(result.source[0].x, result.source[0].y);
        var ptLine0_target = transform.transformPoint(result.target[0].x, result.target[0].y);
        var ptLine1_source = transform.transformPoint(result.source[1].x, result.source[1].y);
        var ptLine1_target = transform.transformPoint(result.target[1].x, result.target[1].y);
        
        switch (bond.bondType) {
            case chem.core.Bond.BondType.Single:
                bondPath.moveTo(ptSource.x, ptSource.y);
                bondPath.lineTo(ptTarget.x, ptTarget.y);
                break;
            case chem.core.Bond.BondType.Double:
                bondPath.moveTo(ptLine0_source.x, ptLine0_source.y);
                bondPath.lineTo(ptLine0_target.x, ptLine0_target.y);
                bondPath.moveTo(ptLine1_source.x, ptLine1_source.y);
                bondPath.lineTo(ptLine1_target.x, ptLine1_target.y);
                break;
            case chem.core.Bond.BondType.Triple:
                bondPath.moveTo(ptSource.x, ptSource.y);
                bondPath.lineTo(ptTarget.x, ptTarget.y);
                bondPath.moveTo(ptLine0_source.x, ptLine0_source.y);
                bondPath.lineTo(ptLine0_target.x, ptLine0_target.y);
                bondPath.moveTo(ptLine1_source.x, ptLine1_source.y);
                bondPath.lineTo(ptLine1_target.x, ptLine1_target.y);
                break;
        }
        bondPath.close();
        
        var group = graphics.createGroup();
        
		result = chem.render.Geometry.distanceCalculator(bond, context.renderParams.atomTransparentCircleSize/transform.getScaleX())
        ptLine0_source = transform.transformPoint(result.source[0].x, result.source[0].y);
        ptLine0_target = transform.transformPoint(result.target[0].x, result.target[0].y);
        ptLine1_source = transform.transformPoint(result.source[1].x, result.source[1].y);
        ptLine1_target = transform.transformPoint(result.target[1].x, result.target[1].y);

        bondBoxPath = new goog.graphics.Path();
        bondBoxPath.moveTo(ptLine0_source.x, ptLine0_source.y);
        bondBoxPath.lineTo(ptLine0_target.x, ptLine0_target.y);
        bondBoxPath.lineTo(ptLine1_target.x, ptLine1_target.y);
        bondBoxPath.lineTo(ptLine1_source.x, ptLine1_source.y);
        bondBoxPath.close();
        
        group.bondPath = graphics.drawPath(bondPath, context.renderParams.bondStroke, null, group);
{'fraction_non_alphanumeric': 0.12071662164083606, 'fraction_numerical': 0.013081188681928053, 'mean_word_length': 2.869086908690869, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7424932', 'n_tokens_mistral': 2261, 'n_tokens_neox': 2187, 'n_words': 292}