<commit_before>var canvas;
var ctx;

var states = new Array();
var chain;

var paper = null;

function dragStart(x, y, event) {
	this.xs = this.attr("cx");
	this.ys = this.attr("cy");
}

function dragMove(dx, dy, x, y, event) {
	//alert("toto");
	//this.attr({cx: this.attr("cx") + dx});
	this.attr({
		cx : this.xs + dx
	});
	this.attr({
		cy : this.ys + dy
	});
}

function dragEnd(event) {

}

function drawDebug()
{
	canvas = document.getElementById("cnMain");
	ctx = canvas.getContext("2d");

	ctx.fillStyle = "rgb(200,0,0)";
	ctx.fillRect(10, 10, 55, 50);

	ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
	ctx.fillRect(30, 30, 55, 50);

	ctx.strokeText('Hello world!', 0, 50);
}

function drawInit() {
	paper = new Raphael("raph", 1600, 600);
	
	var circle = paper.circle(200, 200, 50);
	circle.attr("fill", "#f00");
	circle.attr({
		fill : 'firebrick',
		stroke : 'darkorchid',
		'stroke-width' : 5
	});
	//circle.animate({"fill": "#f00", "transform": 't100,100'}, 2000, 'linear', function() {});
	circle.animate({
		cx : 10,
		cy : 10
	}, 2000, 'linear');

	circle.drag(dragMove, dragStart, dragEnd);
}

function errorCallback(httpStatus, httpStatusText) {
	alert('error ' + httpStatusText);
}

function successCallback(responseObject) {
	//alert(responseObject.getReturn());
	$("#greetings").html(responseObject.getReturn() + " - " + uuid.v4());
}

function getChainOK(responseObject) {
	chain = responseObject.getReturn();

	var ss = chain.getStates().getDTOState();

	for(var i = 0; i < ss.length; i++) {
		addState(ss[i]);
	}
}

function addState(DTOState) {
	states.push(DTOState);
	var circle = paper.circle(DTOState._x, DTOState._y, 50);
	circle.attr({
		fill : 'firebrick',
		stroke : 'darkorchid',
		'stroke-width' : 2
	});
	circle.drag(dragMove, dragStart, dragEnd);
}

function getChainKO(responseObject) {
	alert("oooops");
}

function loadChain() {
	var p = new internalapi_chronix_oxymores_org__IServiceClientPortType();
	p.getChain(getChainOK, getChainKO);
}

function pingServer() {
	var p = new internalapi_chronix_oxymores_org__IServiceClientPortType();
	p.sayHello(successCallback, errorCallback, "marsu", 12);
}
<commit_msg>Dragging states now updates underlying model object<commit_after>var canvas;
var ctx;

var states = new Array();
var chain;

var paper = null;

function dragStateStart(x, y, event) {
	this.xs = this.attr("cx");
	this.ys = this.attr("cy");
}

function dragStateMove(dx, dy, x, y, event) {
	this.attr({
		cx : this.xs + dx
	});
	this.attr({
		cy : this.ys + dy
	});
	this.modeldata._x = this.xs + dx;
	this.modeldata._y = this.ys + dy;
}

function dragStateEnd(event) {

}

function drawDebug() {
	canvas = document.getElementById("cnMain");
	ctx = canvas.getContext("2d");

	ctx.fillStyle = "rgb(200,0,0)";
	ctx.fillRect(10, 10, 55, 50);

	ctx.fillStyle = "rgba(0, 0, 200, 0.5)";
	ctx.fillRect(30, 30, 55, 50);

	ctx.strokeText('Hello world!', 0, 50);
}

function drawInit() {
	paper = new Raphael("raph", 1600, 600);

	// Debug animation - don't remove till GUI nearing completion
	var circle = paper.circle(200, 200, 50);
	circle.attr("fill", "#f00");
	circle.attr({
		fill : 'firebrick',
		stroke : 'darkorchid',
		'stroke-width' : 5
	});
	//circle.animate({"fill": "#f00", "transform": 't100,100'}, 2000, 'linear', function() {});
	circle.animate({
		cx : 10,
		cy : 10
	}, 2000, 'linear');
}

function errorCallback(httpStatus, httpStatusText) {
	alert('error ' + httpStatusText);
}

function successCallback(responseObject) {
	//alert(responseObject.getReturn());
	$("#greetings").html(responseObject.getReturn() + " - " + uuid.v4());
}

function getChainOK(responseObject) {
	chain = responseObject.getReturn();

	// add chain states to the list and draw them
	var ss = chain.getStates().getDTOState();
	for(var i = 0; i < ss.length; i++) {
		addState(ss[i]);
	}
}

function addState(DTOState) {
	// Add state to list
	states.push(DTOState);

	// Draw state as a circle
	var circle = paper.circle(DTOState._x, DTOState._y, 50);
	circle.attr({
		fill : 'firebrick',
		stroke : 'darkorchid',
		'stroke-width' : 2
	});

	// Set reference between business model object and representation object
	DTOState._drawing = circle;
	circle.modeldata = DTOState;

	// Allow dragging with callback taking connections and business objects into account
	circle.drag(dragStateMove, dragStateStart, dragStateEnd);
}

function getChainKO(responseObject) {
	alert("oooops");
}

function loadChain() {
	var p = new internalapi_chronix_oxymores_org__IServiceClientPortType();
	p.getChain(getChainOK, getChainKO);
}

function pingServer() {
	var p = new internalapi_chronix_oxymores_org__IServiceClientPortType();
	p.sayHello(successCallback, errorCallback, "marsu", 12);
}

{'fraction_non_alphanumeric': 0.1709910676307954, 'fraction_numerical': 0.0327520204168439, 'mean_word_length': 4.632335329341317, 'pattern_counts': {'":': 4, '<': 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': '5951006', 'n_tokens_mistral': 1871, 'n_tokens_neox': 1704, 'n_words': 389}