Last active
September 6, 2022 01:05
-
-
Save kenwebb/8289853 to your computer and use it in GitHub Desktop.
The Lord of the Rings (with Chap Links timeline)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Mon Nov 24 2014 04:49:17 GMT-0500 (EST)--> | |
<XholonWorkbook> | |
<Notes><![CDATA[ | |
Xholon | |
------ | |
Title: The Lord of the Rings (with Chap Links timeline) | |
Description: Exploring the structure of Tolkien's Lord of the Rings | |
Url: http://www.primordion.com/Xholon/gwt/ | |
InternalName: 0c8ede44-f063-463f-9045-a4916dc75b15 4f1cfe89-65b2-40c8-8da7-63b440ee0710 | |
Keywords: | |
My Notes | |
======== | |
January 6, 2014 LOTR (with Chap Links timeline) | |
This XholonWorkbook extends the earlier "The Lord of the Rings ((with character movements on line chart)" workbook, which was saved as gist 8260014. | |
My goal is to explore the Chap Links timeline library, described at and available from: | |
http://almende.github.io/chap-links-library/timeline.html | |
I've added several new Java classes to Xholon, added them to the GWT build so they'll be converted to JavaScript, | |
and tested them. It's all available as an optional Xholon service called "TimelineService-ChapJSON". | |
I've elected to use the pure JSON (non-Google data tables) approach offered by Chap Links timeline. | |
Notes from the earlier workbooks | |
================================ | |
January 4, 2014 LOTR (with character movements on line chart) | |
This XholonWorkbook extends the earlier "The Lord of the Rings (with canvas JPEG map)" workbook, which was saved as gist 8242658. | |
My goal in this workbook is to display a line chart showing the movement of characters (hobbits, wizards, men, dark lords, etc.) between various places in Middle Earth, during the years 3018 and 3019 of the Third Age. The Xholon library supports this type of capability, with a Google Charts line chart. The X axis will show the date in YYMMDD (ex: 181025) format. The Y axis is the ID of the character or place. Each character has a base y value (it's ID), and will move to a different y value (the ID of the place) when he/she/it moves to a new place. When two characters have the same y value, they are in the same place. When Frodo and Aragorn are both in Bree, then the Frodo and Aragorn lines on the line chart both have a y value of 79. This makes it easy to see which characters are together in a place at a particular date. | |
To make this possible, I've done the following: | |
- added Class Details | |
- created a line chart in LotrSystembehavior | |
- added some new attributes and code in Eventsbehavior | |
I've decided not to add horizontal lines on the chart for each place. This would clutter it too much. The places are only on the chart implicitly. When the mouse hovers over any character's line, you can see the name of the character, the date, and the ID of the place where the character is on that date. | |
It's possible to customize the tooltips in Google Charts line chart. Instead of showing the internal ID of the place (ex: 79), it would show the full name of the place (ex: Bree). I don't have time to do that right now, but for future reference, here's a URL: | |
https://developers.google.com/chart/interactive/docs/customizing_tooltip_content | |
January 2, 2014 LOTR (with canvas JPEG map) | |
This XholonWorkbook extends the earlier "The Lord of the Rings" workbook, which was saved as gist 8203728. | |
It displays a map of Middle Earth as the background on a HTML5 canvas. | |
I'll use the map at | |
http://lotr.wikia.com/wiki/File:Middle-earth.jpg | |
which doesn't state that it's copyrighted or licensed. | |
The next step is to add x, y coordinates to places. | |
When an event occurs, the map will be updated to show each character's current location. | |
I've added a JavaScript method that shows the map x and y coordinates as the user moves the mouse over the map. | |
I'll read off the coordinates from the map, and add them to each place. | |
December 30, 2013 | |
In this Xholon Workbook, I explore the structure of The Lord of the Rings (LOTR), J.R.R. Tolkien's three-volume fantasy novel. More generally, I'll be working out how to capture the structure of any novel, film, or other story. As an editor, at least initially, I'm using the online Xholon Workbook editor. | |
As much as possible, I'll use the exact spellings used in wikipedia. This will allow users to directly search wikipedia for more information. The names of characters and places will be in English alphabetical order. | |
Initially, I'm interested in identifying the main characters, places, and events, and how these interact with each other. I'll consider the main characters to be those identified in the wikipedia LOTR template. There is no short list of main places in wikipedia, so I'll take these from the LOTR article(s) as I see fit. | |
To bring those characters into this workbook, all I need to do is copy the text from the wikipedia page, and paste it into the CSH Characters tag. It appears automatically formatted as a vertical list. The only editing I need to do is to convert spaces and dashes to underlines, because Xholon will later need to convert these names into XML tags. | |
I've added a behavior (LotrSystembehavior) that generates the Xholon structure from the various lists. | |
Events, Timeline | |
---------------- | |
I want to add some events, that together will make up a timeline. Querying for "lotr timeline" reveals that there's a lot of material available online. An event should include the following information: | |
date: 81006 = October 6 in the year 3018 of the Third Age | |
place: a town, region, river, or other geographical location | |
characters: main character, plus optional additional characters | |
annotation: a short semi-structured description | |
events are from http://en.wikipedia.org/wiki/Timeline_of_Arda | |
December 31, 2013 | |
Events read the timeStep, keep track of which event is the current event, and print matching events in the out tab. | |
This completes the simple first version of my LOTR app. | |
TODO | |
---- | |
- | |
References and Sources | |
---------------------- | |
http://en.wikipedia.org/wiki/The_Lord_of_the_Rings | |
http://en.wikipedia.org/wiki/Template:The_Lord_of_the_Rings | |
http://en.wikipedia.org/wiki/Category:The_Lord_of_the_Rings | |
http://en.wikipedia.org/wiki/Category:Middle-earth_locations | |
http://lotro-wiki.com/index.php/Landmark_coordinates | |
http://lotr.wikia.com/wiki/File:Middle-earth.jpg | |
http://www.primordion.com/Xholon/gwt/wb/editwb.html | |
google: lotr timeline | |
http://lotrproject.com/timeline/ | |
http://en.wikipedia.org/wiki/Timeline_of_Arda | |
http://lotr.wikia.com/wiki/Timeline_of_Arda | |
http://xkcd.com/657/ | |
]]></Notes> | |
<_-.XholonClass> | |
<LotrSystem/> | |
<Lord_of_the_Rings/> | |
<!-- Character | |
hobbit, man, wizard, elf, dwarf, troll, orc, ent, etc. | |
these are active objects | |
--> | |
<Character/> | |
<!-- Place | |
anything that can have geographical coordinates | |
these are passive objects, or containers | |
--> | |
<Place superClass="Attribute_String"/> | |
<!-- Event | |
something that happens at a specific time, in a specific place, involving specific characters | |
events are deterministic, and always happen at the same time | |
these are passive objects | |
--> | |
<Event superClass="Attribute_String"/> | |
<!-- Thing | |
ring | |
these are typically passive objects, but the one ring may be an active object (it wants to get back to Sauron) | |
--> | |
<Thing/> | |
<!-- collections --> | |
<Characters/> | |
<Placess superClass="XholonMap"/> | |
<Events/> | |
<Things/> | |
<!-- control and initialization --> | |
<CharactersControl/> | |
<PlacessControl/> | |
<EventsControl/> | |
<ThingsControl/> | |
</_-.XholonClass> | |
<xholonClassDetails> | |
<!-- control which nodes are included in the line-chart; passive yes, container no --> | |
<Character xhType="XhtypePurePassiveObject"/> | |
<Place xhType="XhtypePureContainer"/> | |
<Event xhType="XhtypePureContainer"/> | |
<Thing xhType="XhtypePureContainer"/> | |
</xholonClassDetails> | |
<LotrSystem> | |
<CharactersControl> | |
<Attribute_String> | |
Aragorn | |
Arwen | |
Bilbo | |
Boromir | |
Celeborn | |
Denethor | |
Elrond | |
Éomer | |
Éowyn | |
Faramir | |
Frodo | |
Galadriel | |
Gandalf | |
Gimli | |
Gollum | |
Legolas | |
Merry | |
Mouth_of_Sauron | |
Old_Man_Willow | |
Pippin | |
Radagast | |
Sam | |
Saruman | |
Sauron | |
Shelob | |
Théoden | |
Tom_Bombadil | |
Treebeard | |
Witch_king | |
Wormtongue | |
</Attribute_String> | |
</CharactersControl> | |
<PlacessControl> | |
<Attribute_String> | |
Bag_End,196,158 | |
Barad-dûr,580,392 | |
Bree,248,158 | |
Bruinen,368,154 | |
Cirith_Ungol,539,417 | |
Cracks_of_Doom,564,398 | |
Dead_Marshes,506,358 | |
Edoras,388,365 | |
Fangorn_Forest,382,297 | |
Henneth_Annûn,521,394 | |
Hornburg,343,345 | |
Isengard,340,322 | |
Khazad-dûm,373,212 | |
Lórien,407,244 | |
Lothlórien,407,244 | |
Minas_Morgul,527,419 | |
Minas_Tirith,505,418 | |
Mirkwood,465,143 | |
Misty_Mountains,388,84 | |
Mordor,555,390 | |
Morgai,533,384 | |
Moria,372,212 | |
Mount_Doom,564,398 | |
Old_Forest,225,161 | |
Orthanc,340,322 | |
Osgiliath,521,419 | |
Parth_Galen,464,362 | |
Paths_of_the_Dead,389,370 | |
Pelargir,485,477 | |
Rivendell,369,154 | |
Shelob_lair,537,418 | |
Shire,196,158 | |
Slag_hills,529,364 | |
Weathertop,285,154 | |
</Attribute_String> | |
</PlacessControl> | |
<ThingsControl> | |
<Attribute_String> | |
One_Ring | |
</Attribute_String> | |
</ThingsControl> | |
<EventsControl> | |
<!-- the years are 3018 and 3019 of the Third Age; the dates are in YYMMDD format --> | |
<Attribute_String> | |
180411,Shire,Gandalf[Frodo],"Gandalf returns to the Shire, telling Frodo Baggins he must take the Ring away" | |
180620,Osgiliath,Sauron,"Sauron attacks Osgiliath" | |
180704,Minas_Tirith,Boromir,"Boromir leaves Minas Tirith" | |
180710,Orthanc,Saruman[Gandalf],"Saruman imprisons Gandalf in Orthanc" | |
180918,Orthanc,Gandalf,"Gandalf escapes from Orthanc" | |
180919,Edoras,Gandalf,"Gandalf reaches Edoras and is given Shadowfax the horse" | |
180923,Bag_End,Frodo,"Frodo leaves Bag End" | |
180930,Bree,Aragorn,"Aragorn meets Frodo Baggins in the Inn of the Prancing Pony in Bree" | |
181006,Weathertop,Frodo,"Frodo wounded at Weathertop" | |
181020,Bruinen,Frodo,"Frodo crosses the ford of Bruinen" | |
181025,Rivendell,Council of Elrond,"Council of Elrond at Rivendell" | |
181225,Rivendell,Fellowship,"The Fellowship of the Ring sets out in the evening from Rivendell" | |
190115,Khazad-dûm,Gandalf,"Gandalf falls in Khazad-dûm while fighting a Balrog" | |
190225,Parth_Galen,Fellowship,"The Fellowship passes the Argonath and camp at Parth Galen. First Battle of Fords of Isen; Théodred son of Théoden is slain" | |
190226,Parth_Galen,Fellowship,"The breaking of the Fellowship; Boromir is killed" | |
190229,Parth_Galen,Merry[Pippin],"Merry and Pippin escape the orcs and meet Treebeard" | |
190301,Fangorn_Forest,Aragorn[Legolas Gimli Gandalf],"Aragorn, Legolas and Gimli meet the resurrected Gandalf the White in Fangorn Forest while looking for Merry and Pippin, and they head off for Edoras." | |
190301,Dead_Marshes,Frodo[Sam],"Frodo and Sam begin travelling through the Dead Marshes" | |
190303,Hornburg,,"Battle of the Hornburg" | |
190305,Isengard,,"Rohan's army reaches Isengard" | |
190307,Henneth_Annûn,Faramir[Frodo Sam],"Faramir takes Frodo and Sam to Henneth Annûn" | |
190308,Paths_of_the_Dead,Aragorn[Legolas Gimli],"Aragorn, Legolas and Gimli enter the Paths of the Dead" | |
190309,Minas_Tirith,Gandalf[Pippin],"Gandalf and Pippin arrive in Minas Tirith" | |
190310,Minas_Morgul,Frodo[Sam],"Frodo and Sam see the Morgul host led by the Witch-king leave Minas Morgul. An army from Morannon takes Cair Andros and marches in Anórien" | |
190311,Lórien,,"First assault on Lórien by Dol Guldur" | |
190312,Shelob_lair,Gollum[Frodo],"Gollum leads Frodo into Shelob's lair" | |
190313,Cirith_Ungol,Frodo,"Frodo captured by Cirith Ungol orcs" | |
190313,Pelargir,Aragorn,"Aragorn captures the Umbar fleet at Pelargir" | |
190315,Minas_Tirith,,"Witch-king breaks the gate of Minas Tirith in the early hours. Denethor burns himself on a pyre. Confrontation between Gandalf and the Witch-king at the gate; Horns of the Rohirrim are heard at a cockcrow. Battle of the Pelennor Fields. Théoden King of Rohan is killed by the Witch-king; Éomer succeeds him as the eighteenth king of Rohan. Éowyn and Merry kill the Witch-king. Aragorn, Rangers, sons of Elrond and men from the southern fiefdoms of Gondor arrive in the black ships and turn the tide of battle." | |
190315,Morgai,Frodo[Sam],"Sam and Frodo escape and journey along the Morgai." | |
190315,Mirkwood,,"Battle under the trees in Mirkwood; second assault on Lórien" | |
190316,,,"Debate of the Captains of the West" | |
190317,,,"Battle of Dale. King Brand and Dáin Ironfoot fall in battle against invading Easterlings. Many Men and Dwarves take refuge in Erebor" | |
190318,Minas_Tirith,,"Armies leave Minas Tirith." | |
190318,,Frodo[Sam],"Frodo and Sam join the orc company" | |
190325,Slag_hills,,"The Host is surrounded on the Slag-hills." | |
190325,Cracks_of_Doom,Frodo[Sam Gollum],"Frodo and Sam reach the Sammath Naur. Gollum (Sméagol) seizes the One Ring and falls into the Cracks of Doom." | |
190325,Barad-dûr,Sauron,"Downfall of Barad-dûr and the passing of the Dark Lord Sauron" | |
</Attribute_String> | |
</EventsControl> | |
<Lord_of_the_Rings/> | |
</LotrSystem> | |
<LotrSystembehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[ | |
var lotrsys, app, $this; | |
var beh = { | |
postConfigure: function() { | |
$this = this; | |
lotrsys = this.cnode.parent(); | |
app = $wnd.xh.app(); | |
$wnd.xh.param("MaxPorts", "10"); | |
$wnd.xh.param("TimeStep", "180410"); | |
$wnd.xh.param("MaxProcessLoops", "190410"); | |
$wnd.xh.param("TimeStepInterval", "200"); | |
$wnd.xh.param("InformationFile","http://en.wikipedia.org/wiki/The_Lord_of_the_Rings"); | |
// get xhRoot | |
//console.log(lotrsys.toString()); | |
var xhRoot = $wnd.xh.xpath("./Lord_of_the_Rings", lotrsys); | |
//console.log(xhRoot.toString()); | |
// get xhcRoot | |
var xhcRoot = lotrsys.xhc().parent(); | |
var node = lotrsys.first(); | |
this.makeAll("Character", "s", node.first().text(), xhRoot, xhcRoot); | |
node = node.next(); | |
this.makeAll("Place", "ss", node.first().text(), xhRoot, xhcRoot); | |
node = node.next(); | |
this.makeAll("Thing", "s", node.first().text(), xhRoot, xhcRoot); | |
// create a line chart that plots the characters moving between the place lines | |
var dpp = "Lord of the Rings,Time (YYMMDD),Characters moving between places,./statistics/,stats,1,WRITE_AS_INT"; | |
var mode = "new"; | |
var dp = "google2"; // gnuplot google2 | |
var plotStr = '<Plot mode="' + mode + '" dataPlotter="' + dp + '" dataPlotterParams="' + dpp + '"></Plot>'; | |
xhRoot.append(plotStr); | |
// add a LOTR-specific search engine | |
var seName = "lotr.wikia"; | |
var seUrl = "http://lotr.wikia.com/wiki/"; | |
var sesMap = $wnd.xh.service('SearchEngineService').first(); | |
var xmlStr = '<Attribute_String roleName="' + seName + '">' + seUrl + '</Attribute_String>'; | |
sesMap.append(xmlStr); | |
// Display a map of Middle Earth | |
this.displayMap(); | |
}, | |
makeAll: function(tagName, pluralizer, text, xhRoot, xhcRoot) { | |
// ih | |
xhcRoot.append(this.makeIhStr(tagName, text)); | |
// csh | |
xhRoot.append(this.makeCshStr(tagName + pluralizer, text)); | |
}, | |
// Make an Inheritance Hierarchy XML string | |
makeIhStr: function(tagName, text) { | |
//console.log("ih: " + tagName); | |
var classXml = "<_-.XholonClass><" + tagName + ">\n"; | |
var arr = text.split("\n"); | |
for (var i = 0; i < arr.length; i++) { | |
var str = arr[i]; | |
if (str) { | |
var items = str.split(","); | |
classXml += " <" + items[0].trim() + "/>\n"; | |
} | |
} | |
classXml += "</" + tagName + "></_-.XholonClass>\n"; | |
return classXml; | |
}, | |
// Make a Composite Structure Hierarchy XML string | |
makeCshStr: function(tagName, text) { | |
//console.log("csh: " + tagName); | |
var xml = "<" + tagName + ">\n"; | |
var arr = text.split("\n"); | |
for (var i = 0; i < arr.length; i++) { | |
var str = arr[i]; | |
if (str) { | |
var items = str.split(","); | |
if (items.length == 1) { | |
xml += " <" + items[0].trim() + "/>\n"; | |
} | |
else { | |
var item0 = items[0].trim(); | |
xml += " <" + item0 + ">"; | |
items.shift(); // remove first item | |
xml += items.join(); | |
xml += " </" + item0 + ">\n"; | |
} | |
} | |
} | |
xml += "</" + tagName + ">\n"; | |
return xml; | |
}, | |
// Display a map of Middle Earth | |
displayMap: function() { | |
var xhcanvas = $doc.getElementById("xhcanvas"); | |
var canvas = $doc.createElement("canvas"); | |
canvas.id = "lotrmap"; | |
canvas.width = 800; | |
canvas.height = 562; | |
xhcanvas.appendChild(canvas); | |
var ctx = canvas.getContext("2d"); | |
var img = new Image(); | |
img.onload = function() { | |
ctx.drawImage(img, 0, 0); | |
$this.showMapCoords(); | |
}; | |
//img.src = "http://static2.wikia.nocookie.net/__cb20060726004752/lotr/images/5/59/Middle-earth.jpg"; | |
img.src = "http://www.primordion.com/Xholon/gwtimages/Middle-earth.jpg"; | |
}, | |
// Show the map x and y coordinates as the user moves the mouse | |
showMapCoords: function() { | |
var xhcanvas = $doc.getElementById("xhcanvas"); | |
var coords = $doc.createElement("div"); | |
xhcanvas.appendChild(coords); | |
var canvas = $doc.getElementById("lotrmap"); | |
var imgPos = [ | |
canvas.offsetLeft, | |
canvas.offsetTop | |
]; | |
canvas.addEventListener("mousemove", function(e) { | |
coords.innerHTML = (e.pageX-imgPos[0]) + ", " + (e.pageY-imgPos[1]); | |
}); | |
} | |
} | |
]]></LotrSystembehavior> | |
<EventsControlbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[ | |
var events, xhRoot; | |
var beh = { | |
postConfigure: function() { | |
events = this.cnode.parent(); | |
xhRoot = $wnd.xh.xpath("Lord_of_the_Rings", $wnd.xh.root().first()); | |
var node = events.first(); | |
xhRoot.append(this.makeCshStr("Events", node.text())); | |
}, | |
// Make a Composite Structure Hierarchy XML string | |
makeCshStr: function(tagName, text) { | |
var xml = "<" + tagName + ">\n"; | |
var arr = text.split("\n"); | |
for (var i = 0; i < arr.length; i++) { | |
var str = arr[i]; | |
if (str) { | |
xml += " <Event>" + str + "</Event>\n"; | |
} | |
} | |
xml += "</" + tagName + ">\n"; | |
return xml; | |
} | |
} | |
]]></EventsControlbehavior> | |
<Eventsbehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[ | |
var events, nextEvent, nextEventArr, nextTimeStep, state, placess, characters, placeArr, ctx, tlSrvc; | |
var beh = { | |
postConfigure: function() { | |
events = this.cnode.parent(); | |
state = 0; | |
nextEvent = null; | |
nextEventArr = null; | |
nextTimeStep = "0"; | |
placess = events.xpath("../Placess"); | |
characters = events.xpath("../Characters"); | |
//console.log(placess.toString()); | |
placeArr = placess.obj(); | |
// initialize TimelineService | |
tlSrvc = $wnd.xh.service("TimelineService-ChapJSON"); | |
tlSrvc.call(-3898, [null, $wnd.xh.param("ModelName"), events], events); | |
// set the val of each place, to the value of its id, as required by the line-chart plotter | |
// BUT Attribute_String can't have an integer value in addition to its string value, | |
// and besides, this would add too much clutter to the line-chart | |
//var node = placess.first(); | |
//while(node) { | |
// node.val(node.id()); | |
// node = node.next(); | |
//} | |
// set the val of each character, to the value of its id, as required by the line-chart plotter | |
node = characters.first(); | |
while(node) { | |
node.val(node.id()); | |
node = node.next(); | |
} | |
ctx = null; | |
this.findNextEvent(); | |
}, | |
act: function() { | |
var ts = $wnd.xh.param("TimeStep"); | |
while (nextTimeStep == ts) { | |
events.println(nextEventArr); | |
this.processThisEvent(); | |
this.findNextEvent(); | |
} | |
// adjust the time step to correspond with years months and days YYMMDD | |
// YYMM31 becomes YYMM99 | |
if ((ts.charAt(4) == "3") && (ts.charAt(5) == "1")) { | |
$wnd.xh.param("TimeStep", ts.substr(0, 4) + "99"); | |
} | |
if (ts == "181231") { | |
$wnd.xh.param("TimeStep", "190101"); | |
} | |
if (ts == "190401") { | |
// pause, display Google chart timeline, display Chap Links timeline | |
tlSrvc.call(-3895, null, events); | |
} | |
}, | |
processThisEvent: function() { | |
if (!placeArr) {return;} | |
var placeName = nextEventArr[1]; | |
if (placeName) { | |
var place = placeArr[placeName]; | |
if (place) { | |
var coords = place.split(","); // "123,456" | |
if (coords && coords.length == 2) { | |
var x = coords[0]; | |
var y = coords[1]; | |
//console.log("x=" + x + " y=" + y); | |
this.showOnMap(x, y); | |
} | |
// update the 1+ characters' val, for the optional line-chart plotter | |
var characterName = nextEventArr[2]; | |
if (characterName) { | |
// TODO for now just update the main character | |
characterName = characterName.split("[")[0]; | |
var c = characters.xpath("./" + characterName); | |
var p = placess.xpath("./" + placeName); | |
if (c && p) { | |
c.val(p.id()); | |
} | |
} | |
// capture an event for the TimelineService | |
// service.call(-3896, ["3018,0,6", "One"], root); | |
// ex dateRaw 180411 becomes date "3018,04,11" | |
var dateRaw = nextEventArr[0]; | |
//console.log(dateRaw); | |
var year = '30' + dateRaw.substring(0,2); | |
// months must be 0-based (ex: January is month 0), so subtract 1 | |
var month = dateRaw.substring(2,4) - 1; | |
var day = dateRaw.substring(4,6); | |
var startDate = year + ',' + month + ',' + day; | |
var content = nextEventArr[3]; | |
if (content.length > 100) { | |
content = content.substring(0, 100); | |
} | |
//console.log(startDate); | |
tlSrvc.call(-3896, [startDate, content], events); | |
} | |
} | |
}, | |
showOnMap: function(x, y) { | |
if (!ctx) { | |
var canvas = $doc.getElementById("lotrmap"); | |
ctx = canvas.getContext("2d"); | |
} | |
ctx.beginPath(); | |
ctx.arc(x, y, 5, 0, 2 * Math.PI, false); | |
ctx.fillStyle = "red"; | |
ctx.fill(); | |
}, | |
findNextEvent: function() { | |
if (state == 0) { | |
nextEvent = events.first(); | |
state = 1; | |
} | |
else if (nextEvent == null) { | |
nextTimeStep = "0"; | |
return; | |
} | |
else { | |
nextEvent = nextEvent.next(); | |
} | |
if (nextEvent.xhc().name() != "Event") { | |
// nextEvent must be an Eventsbehavior object | |
nextEvent = null; | |
nextTimeStep = "0"; | |
return; | |
} | |
var text = nextEvent.text(); | |
// the quoted annotation may include commas, so limit the size of the array to 3 | |
nextEventArr = nextEvent.text().split(",", 3); | |
// now add the annotation to the array | |
var start = text.indexOf('"') + 1; | |
var end = text.indexOf('"', start); | |
nextEventArr.push(text.substring(start, end)); | |
nextTimeStep = nextEventArr[0]; | |
} | |
} | |
]]></Eventsbehavior> | |
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml, | |
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg"> | |
<g> | |
<title>Lord of the Rings</title> | |
<rect id="LotrSystem" fill="#98FB98" height="50" width="50" x="25" y="0"/> | |
</g> | |
</svg> | |
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient> | |
</XholonWorkbook> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment