<commit_before>/*
 * Copyright (c) 2015 <NAME> and contributors. All rights reserved.
 * The use and distribution terms for this software are covered by the
 * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
 * which can be found in the file LICENSE at the root of this distribution.
 * By using this software in any fashion, you are agreeing to be bound by
 * the terms of this license.
 * You must not remove this notice, or any other, from this software.
 */

var referenceFont = '12px Tahoma';
var canvas = document.getElementById("hostCanvas");
var ctx = canvas.getContext("2d");
function initCanvas()
{
    ctx.lineWidth = 1;
    ctx.font = referenceFont;
}
initCanvas();

function adjustCanvasSize()
{
    console.log("Window size: " + window.innerWidth + " -- " + window.innerHeight);
    canvas.width  = window.innerWidth;
    canvas.height = window.innerHeight;
    initCanvas();
}

function handleResize(evt)
{
    adjustCanvasSize();
    sendEventToServer(getEncodedHostResizeEvent());
}

window.onresize = handleResize;


var currentTransform = [[1, 0, 0],
                        [0, 1, 1],
                        [0, 0, 1]];
var currentClip = {x: 0, y: 0, w: Infinity, h: Infinity};
var clipRectStack = [];


/*
 * Image cache
 */

var uriToImage = {}

// TODO handle loading delay properly
function getImage(uri)
{
    var img = uriToImage[uri];
    if (img)
    {
        return img;<commit_msg>Ability to draw image on component surface #30 - bugs: image change within same component was not reflected; image loading time was not taken into account<commit_after>/*
 * Copyright (c) 2015 <NAME> and contributors. All rights reserved.
 * The use and distribution terms for this software are covered by the
 * Eclipse Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
 * which can be found in the file LICENSE at the root of this distribution.
 * By using this software in any fashion, you are agreeing to be bound by
 * the terms of this license.
 * You must not remove this notice, or any other, from this software.
 */

var referenceFont = '12px Tahoma';
var canvas = document.getElementById("hostCanvas");
var ctx = canvas.getContext("2d");
function initCanvas()
{
    ctx.lineWidth = 1;
    ctx.font = referenceFont;
}
initCanvas();

function adjustCanvasSize()
{
    console.log("Window size: " + window.innerWidth + " -- " + window.innerHeight);
    canvas.width  = window.innerWidth;
    canvas.height = window.innerHeight;
    initCanvas();
}

function handleResize(evt)
{
    adjustCanvasSize();
    sendEventToServer(getEncodedHostResizeEvent());
}

window.onresize = handleResize;


var currentTransform = [[1, 0, 0],
                        [0, 1, 1],
                        [0, 0, 1]];
var currentClip = {x: 0, y: 0, w: Infinity, h: Infinity};
var clipRectStack = [];


/*
 * Image cache
 */

var uriToImage = {}

function getImage(uri)
{
    var img = uriToImage[uri];
    if (img)
    {
        return img;
{'fraction_non_alphanumeric': 0.11390284757118928, 'fraction_numerical': 0.016080402010050253, 'mean_word_length': 3.2354609929078015, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7217773', 'n_tokens_mistral': 906, 'n_tokens_neox': 869, 'n_words': 312}