Location: Holmes 2006 @ 43e456c10f5e / holmes_2006.xul

Author:
Hanne <Hanne@hanne-nielsens-macbook.local>
Date:
2010-08-05 15:46:31+12:00
Desc:
Added xul and session file
Permanent Source URI:
https://models.cellml.org/workspace/holmes_2006/rawfile/43e456c10f5e1b6fb40323f4c4a90e2d7dfbc2d1/holmes_2006.xul

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="layout-diagram" xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" style="overflow: auto" onload="setupDocument()">
<hbox>
	<scale id="zoom_scale" value="10" min="7" max="14" flex="4"/>
	<label value="Zoom" control="zoom_scale" flex="1"/>
	<button id="reset_button" label="Reset View" flex="1"/>
	<spacer flex="34"/>
</hbox>
<script>
<![CDATA[
window.model_entities =
  {

			
	L_se: {
		id: "L_se",
		y: "contraction/L_se",
		x: "environment/time",
		graph: "Traces: Clickable Elements Against Time (s)",
		colour: "#ff9900",
		linestyle: "none"
	},

	L_ce: {
		id: "L_ce",
		y: "contraction/L_ce",
		x: "environment/time",
		graph: "Traces: Clickable Elements Against Time (s)",
		colour: "#ff00cc",
		linestyle: "none"
	}
				
 // Repeat the above section for each controllable graph trace.
 // Remember to add a comma to each repeat after the final },
 // except for the final one!
 
};

function flushVisibilityInformation(entity_id, entity_colour)
{
	var message = "";
	var entity;

	if (typeof pcenv != "undefined")
	{
		for (var i in window.model_entities)
		{
			entity = window.model_entities[i];
			if (typeof entity_id == "undefined" || entity_id == window.model_entities[i].id)
			{
				pcenv.selectTrace
				(
					entity.graph,
					entity.x,
					entity.y,
					typeof entity_colour == "undefined" ? "" : entity_colour,
					entity.linestyle
				);
			}
			if (entity.linestyle != "none")
				message += i + ", ";
		}
		pcenv.status(message == "" ? "No fluxes displayed" : "Displaying flux of " + message.slice(0, -2));
	}
}

function processSelectEntity(event)
{
	if (typeof pcenv != "undefined")
		pcenv.status("In processSelectEntity");

	var entity = window.model_entities[window.svgIdToName[event.currentTarget.id]];

	switch(entity.linestyle)
	{
	case "none":
		entity.linestyle = "lines";
		highlightEntity(event.currentTarget.id);
		break;
	case "lines":
		entity.linestyle = "none";
		unlightEntity(event.currentTarget.id);
		break;
	}

	flushVisibilityInformation(entity.id);
}

function processContext(event)
{
	// if (event.button != 2)
	//   return true;

	var entity = window.model_entities[window.svgIdToName[event.currentTarget.id]];

	if (entity.context == null)
		return true;

	var menu = document.getElementById("entityContextMenu");

	for (var c = menu.firstChild, x = null; c != null; c = x)
	{
		x = c.nextSibling;
		menu.removeChild(c);
	}

	for (var i in entity.context)
	{
		var item = entity.context[i];

		var mitem = document.createElementNS
		(
			"http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul",
			"menuitem"
		);

		mitem.setAttribute("label", item.label);
		mitem.setAttribute("url", item.url);
		mitem.addEventListener("command", processShowEntityURL, false);
		menu.appendChild(mitem);
	}

	menu.showPopup(window.diagram, event.screenX, event.screenY, "context");

	event.stopPropagation;
	return false;
}

function processShowEntityURL(event)
{
	url = event.target.getAttribute("url");

	window.open(url);

	var hl = document.getElementById("hidden-link");
	hl.href = url;

	// This is ugly, but it is one way to force everything through the proper
	// external handler...
	var evt = document.createEvent("HTMLEvents");
	evt.initEvent("click", true, true);
	hl.dispatchEvent(evt);
}

function highlightEntity(id)
{
	for (var path = document.getElementById(id + "_path1"), i = 1; path != null; path = document.getElementById(id + "_path" + ++i))
	{
		if (!(i in window.model_entities[window.svgIdToName[id]].path_colours))
			window.model_entities[window.svgIdToName[id]].path_colours[i] = path.attributes.getNamedItem("stroke").value;
		path.attributes.getNamedItem("stroke").value = "#ff0000";
	}
}

function highlightEntityOnRollover(event) {
	if (window.model_entities[window.svgIdToName[event.currentTarget.id]].colour)
		flushVisibilityInformation(event.currentTarget.id, "#ffffff");

	if (window.model_entities[window.svgIdToName[event.currentTarget.id]].linestyle == "none")
		highlightEntity(event.currentTarget.id);
}

function unlightEntity(id)
{
	for (var path = document.getElementById(id + "_path1"), i = 1; path != null; path = document.getElementById(id + "_path" + ++i))
		path.attributes.getNamedItem("stroke").value = window.model_entities[window.svgIdToName[id]].path_colours[i];
}

function unlightEntityOnRollover(event) {
	if (window.model_entities[window.svgIdToName[event.currentTarget.id]].colour)
		flushVisibilityInformation(event.currentTarget.id, window.model_entities[window.svgIdToName[event.currentTarget.id]].colour);

	if (window.model_entities[window.svgIdToName[event.currentTarget.id]].linestyle == "none")
		unlightEntity(event.currentTarget.id);
}

var mouseDown = false;
var initial_x;
var initial_y;
var viewBox;

function startDrag(event)
{
	if (event.button)
		return true;

	mouseDown = true;

	initial_x = parseInt(currentZoom * event.pageX + parseInt(viewBox.value.match(/^-?\d+/)[0]));
	initial_y = parseInt(currentZoom * event.pageY + parseInt(viewBox.value.match(/^-?\d+\s+(-?(\d+))/)[1]));
}

function stopDrag(event)
{
	if (!event.button)
		mouseDown = false;
}

function moveDrag(event)
{
	if (mouseDown == true)
		viewBox.value = viewBox.value.replace(/^-?\d+\s+-?\d+/, parseInt(initial_x - currentZoom * event.pageX) + " " + parseInt(initial_y - currentZoom * event.pageY));
}

function reset()
{
	var zoom_scale = document.getElementById("zoom_scale")
	zoom_scale.value = zoom_scale.originalValue;
	viewBox.value = viewBox.originalValue;
}

var initialZoom;
var currentZoom = 1;
var initialHeight;
var initialWidth;

function zoomDiagram(event)
{
	currentZoom = initialZoom / event.currentTarget.value;
	viewBox.value = viewBox.value.replace(/\d+\s+\d+$/, parseInt(initialHeight * currentZoom) + " " + parseInt(initialWidth * currentZoom));
}

function setupDocument()
{
	flushVisibilityInformation();

	window.diagram = document.getElementById("sachse");

	window.svgIdToName = {};

	for (var name in window.model_entities)
	{
		var id = window.model_entities[name].id;
		window.model_entities[name].path_colours = [];

		var svg = document.getElementById(id);
		window.svgIdToName[id] = name;

		svg.addEventListener("click", processSelectEntity, false);
		svg.addEventListener("contextmenu", processContext, false);
		svg.addEventListener("mouseover", highlightEntityOnRollover ,false);
		svg.addEventListener("mouseout", unlightEntityOnRollover, false);
	}

	document.getElementsByTagName("svg")[0].addEventListener("mousedown", startDrag, false);
	document.addEventListener("mouseup", stopDrag, false);
	document.addEventListener("mousemove", moveDrag, false);
	document.getElementById("reset_button").addEventListener("click", reset, false);

	document.getElementById("zoom_scale").addEventListener("change", zoomDiagram, false);
	document.getElementById("zoom_scale").originalValue = document.getElementById("zoom_scale").value;

	viewBox = document.getElementsByTagName("svg")[0].attributes.getNamedItem("viewBox");
	viewBox.originalValue = viewBox.value;

	initialZoom = document.getElementById("zoom_scale").value;
	initialHeight = parseInt(viewBox.value.match(/(\d+)\s+\d+$/)[1]);
	initialWidth = parseInt(viewBox.value.match(/\d+$/)[0]);
}

]]>
</script>

<popupset>
  <menupopup id="entityContextMenu" />
</popupset>

<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
	 width="423px" height="486px" viewBox="0 0 423 486" enable-background="new 0 0 423 486" xml:space="preserve">
<polyline fill="none" stroke="#010101" points="301.987,136.523 310.987,127.522 320.32,136.355 329.32,127.689 338.153,136.523 
	346.987,127.522 356.153,136.523 365.153,127.522 374.153,136.523 382.987,127.355 "/>
<g>
	<g>
		<line fill="none" stroke="#010101" x1="26.597" y1="41.537" x2="228.89" y2="41.537"/>
		<polygon fill="#010101" points="226.082,45.24 227.654,41.537 226.082,37.833 234.859,41.537 		"/>
		<polygon fill="#010101" points="29.406,37.834 27.833,41.537 29.406,45.241 20.628,41.537 		"/>
	</g>
</g>
<g>
	<g>
		<line fill="none" stroke="#010101" x1="26.597" y1="275.866" x2="443.634" y2="275.866"/>
		<polygon fill="#010101" points="440.825,279.568 442.398,275.866 440.825,272.162 449.603,275.866 		"/>
		<polygon fill="#010101" points="29.406,272.163 27.833,275.866 29.406,279.57 20.628,275.866 		"/>
	</g>
</g>
<g>
	<g>
		<line fill="none" stroke="#010101" x1="241.341" y1="41.537" x2="443.634" y2="41.537"/>
		<polygon fill="#010101" points="440.825,45.24 442.398,41.537 440.825,37.833 449.603,41.537 		"/>
		<polygon fill="#010101" points="244.149,37.834 242.577,41.537 244.149,45.241 235.372,41.537 		"/>
	</g>
</g>
<line fill="none" stroke="#010101" x1="21.597" y1="22.134" x2="21.597" y2="60.94"/>
<line fill="none" stroke="#010101" x1="451.447" y1="22.134" x2="451.447" y2="60.94"/>
<line fill="none" stroke="#010101" x1="233.89" y1="22.134" x2="233.89" y2="60.94"/>
<line fill="none" stroke="#010101" x1="21.597" y1="254.93" x2="21.597" y2="293.734"/>
<line fill="none" stroke="#010101" x1="451.447" y1="254.93" x2="451.447" y2="293.734"/>
<g>
	<rect x="94.88" y="126.422" fill="none" stroke="#010101" width="79.104" height="35.866"/>
	<g>
		<path d="M134.549,147.625c-0.372,0.192-1.15,0.384-2.135,0.384c-2.279,0-3.981-1.439-3.981-4.102c0-2.542,1.715-4.246,4.222-4.246
			c0.996,0,1.643,0.216,1.919,0.36l-0.264,0.851c-0.385-0.191-0.948-0.335-1.619-0.335c-1.896,0-3.154,1.211-3.154,3.334
			c0,1.991,1.139,3.25,3.094,3.25c0.648,0,1.295-0.132,1.716-0.336L134.549,147.625z"/>
		<path d="M140.045,144.087h-3.13v2.915h3.502v0.875h-4.558v-8.083h4.378v0.875h-3.322v2.555h3.13V144.087z"/>
	</g>
</g>
<g>
	<line fill="none" stroke="#010101" x1="19.693" y1="90.584" x2="19.693" y2="199.018"/>
	<line fill="none" stroke="#010101" x1="19.693" y1="90.584" x2="8.275" y2="111.916"/>
	<line fill="none" stroke="#010101" x1="19.694" y1="179.298" x2="8.275" y2="200.63"/>
	<line fill="none" stroke="#010101" x1="19.694" y1="199.018" x2="8.275" y2="220.35"/>
	<line fill="none" stroke="#010101" x1="19.694" y1="157.967" x2="8.275" y2="179.298"/>
	<line fill="none" stroke="#010101" x1="19.694" y1="136.635" x2="8.275" y2="157.967"/>
	<line fill="none" stroke="#010101" x1="19.694" y1="112.66" x2="8.275" y2="133.992"/>
</g>
<g>
	<line fill="none" stroke="#010101" x1="451.447" y1="220.35" x2="451.447" y2="111.916"/>
	<line fill="none" stroke="#010101" x1="451.447" y1="220.35" x2="462.865" y2="199.018"/>
	<line fill="none" stroke="#010101" x1="451.447" y1="131.635" x2="462.865" y2="110.304"/>
	<line fill="none" stroke="#010101" x1="451.447" y1="111.916" x2="462.865" y2="90.584"/>
	<line fill="none" stroke="#010101" x1="451.447" y1="152.967" x2="462.865" y2="131.635"/>
	<line fill="none" stroke="#010101" x1="451.447" y1="174.299" x2="462.865" y2="152.967"/>
	<line fill="none" stroke="#010101" x1="451.447" y1="198.273" x2="462.865" y2="176.941"/>
</g>
<line fill="none" stroke="#010101" x1="19.694" y1="136.635" x2="94.88" y2="136.635"/>
<line fill="none" stroke="#010101" x1="173.985" y1="136.635" x2="301.987" y2="136.635"/>
<line fill="none" stroke="#010101" x1="393" y1="137.833" x2="451.447" y2="137.833"/>
<line fill="none" stroke="#010101" x1="382.987" y1="127.355" x2="393" y2="137.833"/>
<g>
	<path d="M220.899,246.845h1.056v7.208h3.454v0.875h-4.51V246.845z"/>
	<path d="M231.079,256.436c-0.042-0.789-0.093-1.748-0.093-2.445h-0.018c-0.201,0.656-0.429,1.369-0.715,2.152l-1,2.748h-0.555
		l-0.925-2.699c-0.27-0.807-0.488-1.529-0.647-2.202h-0.017c-0.018,0.706-0.06,1.646-0.109,2.505l-0.15,2.43h-0.698l0.395-5.667
		h0.934l0.967,2.741c0.236,0.697,0.42,1.32,0.572,1.909h0.017c0.151-0.572,0.354-1.194,0.605-1.909l1.009-2.741h0.933l0.354,5.667
		h-0.724L231.079,256.436z"/>
</g>
<g id="L_ce">
	<path id="L_ce_path1" fill="#FFFFFF" stroke="#000000" stroke-width="2" d="M136.169,25.251c0,6.627-5.373,12-12,12H97.031
		c-6.627,0-12-5.373-12-12v-1.333c0-6.627,5.373-12,12-12h27.138c6.627,0,12,5.373,12,12V25.251z"/>
	<g>
		<path d="M103.868,18.499h1.056v7.208h3.454v0.875h-4.51V18.499z"/>
		<path d="M113.223,30.401c-0.26,0.135-0.807,0.269-1.497,0.269c-1.597,0-2.791-1.009-2.791-2.875c0-1.783,1.202-2.977,2.959-2.977
			c0.698,0,1.152,0.151,1.346,0.252l-0.186,0.597c-0.269-0.134-0.664-0.235-1.135-0.235c-1.329,0-2.211,0.849-2.211,2.337
			c0,1.396,0.799,2.278,2.169,2.278c0.454,0,0.908-0.092,1.203-0.235L113.223,30.401z"/>
		<path d="M117.071,27.921h-2.194v2.043h2.455v0.614h-3.195v-5.666h3.069v0.614h-2.329v1.791h2.194V27.921z"/>
	</g>
</g>
<g id="L_se">
	<path id="L_se_path1" fill="#FFFFFF" stroke="#000000" stroke-width="2" d="M375.834,24.669c0,6.628-5.373,12-12,12h-27.139
		c-6.627,0-12-5.372-12-12v-1.333c0-6.627,5.373-12,12-12h27.139c6.627,0,12,5.373,12,12V24.669z"/>
	<g>
		<path d="M343.899,17.917h1.056v7.208h3.454V26h-4.51V17.917z"/>
		<path d="M349.211,29.105c0.327,0.21,0.799,0.37,1.303,0.37c0.748,0,1.187-0.395,1.187-0.967c0-0.521-0.303-0.832-1.067-1.118
			c-0.925-0.336-1.497-0.824-1.497-1.614c0-0.883,0.731-1.539,1.833-1.539c0.571,0,1,0.135,1.244,0.277l-0.201,0.597
			c-0.177-0.109-0.556-0.269-1.067-0.269c-0.773,0-1.067,0.462-1.067,0.849c0,0.53,0.345,0.791,1.126,1.093
			c0.959,0.37,1.438,0.833,1.438,1.665c0,0.874-0.641,1.639-1.978,1.639c-0.546,0-1.143-0.168-1.444-0.37L349.211,29.105z"/>
		<path d="M356.369,27.339h-2.194v2.043h2.455v0.614h-3.194V24.33h3.068v0.614h-2.329v1.791h2.194V27.339L356.369,27.339z"/>
	</g>
</g>
</svg>
</window>