| 1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" |
| 2 | "http://www.w3.org/TR/html4/strict.dtd"> |
| 3 | <html> |
| 4 | <head> |
| 5 | <title>Annotator/Figure Testing</title> |
| 6 | <style type="text/css"> |
| 7 | @import "../../../dojo/resources/dojo.css"; |
| 8 | @Import "../../../dijit/themes/tundra/tundra.css"; |
| 9 | </style> |
| 10 | <link href="../resources/sketch.css" type="text/css" rel="stylesheet"> |
| 11 | <style type="text/css"> |
| 12 | body { |
| 13 | background:#fff url("images/testsBodyBg.gif") repeat-x top left; |
| 14 | padding:1em 3em; |
| 15 | } |
| 16 | table { margin:0; width:100%;} |
| 17 | table tr td { padding:0; } |
| 18 | table tr td table { border:0; width:auto;} |
| 19 | |
| 20 | #container{ width:600px; } |
| 21 | #toolbar{ width:100%; } |
| 22 | #canvasContainer{ outline:none; width:600px; height:600px; background-color:#fff;border:1px solid #ccc; overflow:auto;position:relative;} |
| 23 | </style> |
| 24 | <script>var djConfig={ isDebug: false };</script> |
| 25 | <script src="../../../dojo/dojo.js"></script> |
| 26 | <script> |
| 27 | dojo.require("dijit.robot"); |
| 28 | dojo.require("dojox.sketch"); |
| 29 | dojo.require("dojox.sketch.Slider"); |
| 30 | dojo.require("dojox.sketch.LeadAnnotation"); |
| 31 | dojo.require("dojox.sketch.UnderlineAnnotation"); |
| 32 | dojo.require("dojox.sketch.SingleArrowAnnotation"); |
| 33 | dojo.require("dojox.sketch.DoubleArrowAnnotation"); |
| 34 | dojo.require("dojox.sketch.PreexistingAnnotation"); |
| 35 | var f, a, t; |
| 36 | function init(){ |
| 37 | var ta=dojox.sketch; |
| 38 | f=new ta.Figure({gridSize:10}); |
| 39 | dojo.connect(f, "_mu", function(){ dojo.byId("output").value=f.serialize(); }); |
| 40 | |
| 41 | t=ta.makeToolbar(dojo.byId("toolbar"), f); |
| 42 | |
| 43 | // test loading from an SVG file |
| 44 | dojo.xhrGet({ |
| 45 | url:"annotation.svg", |
| 46 | preventCache:true, |
| 47 | load:function(data, ioArgs){ |
| 48 | var svg=dojox.xml.DomParser.parse(data); |
| 49 | f.load(svg, dojo.byId("canvas")); |
| 50 | dojo.byId("output").value=f.serialize(); |
| 51 | } |
| 52 | }); |
| 53 | |
| 54 | setTimeout(function(){ |
| 55 | doh.robot.startRobot(); |
| 56 | setTimeout(function(){ |
| 57 | rundoh(); |
| 58 | },1000); |
| 59 | },1000); |
| 60 | } |
| 61 | dojo.addOnLoad(init); |
| 62 | |
| 63 | function rundoh(){ |
| 64 | dojo.require("dojox.sketch.tests.FTHelper"); |
| 65 | var helper=new dojox.sketch.tests.FTHelper; |
| 66 | doh.register("placeLeadShape",{ |
| 67 | timeout: 1500, |
| 68 | runTest:function(t){ |
| 69 | var d = new doh.Deferred(); |
| 70 | helper.drawShape({x:100,y:100},{x:200,y:200}); |
| 71 | doh.robot.sequence(d.getTestCallback(function(){ |
| 72 | t.is('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dojoxsketch="http://dojotoolkit.org/dojox/sketch" width="1000" height="855"><g><image xlink:href="images/figure2.gif" x="0" y="0" width="1000" height="855" /><g id="ann-1" dojoxsketch:type="Lead" transform="translate(437,169)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M0,0 Q100,-50 200,0" /><text style="fill:blue;text-anchor:start" font-weight="bold" x="204" y="-2">1</text></g><g id="ann-2" dojoxsketch:type="Preexisting" transform="translate(526,408)"><rect style="stroke:blue;stroke-width:1;fill:none;" x="0" width="104" y="0" height="210" rx="8" ry="8" /><text style="fill:blue;text-anchor:end" font-weight="bold" x="100" y="206">2</text></g><g id="ann-3" dojoxsketch:type="SingleArrow" transform="translate(537,804)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M-44,13 Q-137,38 -162,-23" /><g transform="translate(-44,13) rotate(164.9536)"><path style="fill:blue;" d="M0,0 l20,-5, -3,5, 3,5 Z" /></g><text style="fill:blue;text-anchor:middle" font-weight="bold" x="-160.36065573770492" y="-27">3</text></g><g id="ann-4" dojoxsketch:type="DoubleArrow" transform="translate(329,-7)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M249,306 Q505,242 426,389" /><g transform="translate(249,306) rotate(-14.0362)"><path style="fill:blue;" d="M0,0 l20,-5, -3,5, 3,5 Z" /></g><g transform="rotate(118.2542, 426, 389)"><path style="fill:blue;" d="M426,389 l-20,-5, 3,5, -3,5 Z" /></g><text style="fill:blue;text-anchor:middle" font-weight="bold" x="421.25" y="288.75">4</text></g><g id="ann-5" dojoxsketch:type="Underline" transform="translate(821,517)"><text style="fill:blue;" font-weight="bold" text-decoration="underline" x="0" y="0">5</text></g><g id="annotation-6" dojoxsketch:type="Lead" transform="translate(170,170)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M0,0 Q80,80 170,170" /><text style="fill:blue;text-anchor:middle" font-weight="bold" x="174" y="184"></text></g></g></svg>', f.getValue()); |
| 73 | }), 500); |
| 74 | return d; |
| 75 | } |
| 76 | }); |
| 77 | doh.register("removeLeadShape",{ |
| 78 | timeout: 1500, |
| 79 | runTest:function(t){ |
| 80 | var d = new doh.Deferred(); |
| 81 | helper.click({left:true,x:100,y:100},100); |
| 82 | doh.robot.keyPress(dojo.keys.DELETE,100); |
| 83 | doh.robot.sequence(d.getTestCallback(function(){ |
| 84 | t.is('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dojoxsketch="http://dojotoolkit.org/dojox/sketch" width="1000" height="855"><g><image xlink:href="images/figure2.gif" x="0" y="0" width="1000" height="855" /><g id="ann-1" dojoxsketch:type="Lead" transform="translate(437,169)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M0,0 Q100,-50 200,0" /><text style="fill:blue;text-anchor:start" font-weight="bold" x="204" y="-2">1</text></g><g id="ann-2" dojoxsketch:type="Preexisting" transform="translate(526,408)"><rect style="stroke:blue;stroke-width:1;fill:none;" x="0" width="104" y="0" height="210" rx="8" ry="8" /><text style="fill:blue;text-anchor:end" font-weight="bold" x="100" y="206">2</text></g><g id="ann-3" dojoxsketch:type="SingleArrow" transform="translate(537,804)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M-44,13 Q-137,38 -162,-23" /><g transform="translate(-44,13) rotate(164.9536)"><path style="fill:blue;" d="M0,0 l20,-5, -3,5, 3,5 Z" /></g><text style="fill:blue;text-anchor:middle" font-weight="bold" x="-160.36065573770492" y="-27">3</text></g><g id="ann-4" dojoxsketch:type="DoubleArrow" transform="translate(329,-7)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M249,306 Q505,242 426,389" /><g transform="translate(249,306) rotate(-14.0362)"><path style="fill:blue;" d="M0,0 l20,-5, -3,5, 3,5 Z" /></g><g transform="rotate(118.2542, 426, 389)"><path style="fill:blue;" d="M426,389 l-20,-5, 3,5, -3,5 Z" /></g><text style="fill:blue;text-anchor:middle" font-weight="bold" x="421.25" y="288.75">4</text></g><g id="ann-5" dojoxsketch:type="Underline" transform="translate(821,517)"><text style="fill:blue;" font-weight="bold" text-decoration="underline" x="0" y="0">5</text></g></g></svg>', f.getValue()); |
| 85 | }),300); |
| 86 | return d; |
| 87 | } |
| 88 | }); |
| 89 | doh.register("placeDoubleShape",{ |
| 90 | timeout: 1500, |
| 91 | runTest:function(t){ |
| 92 | var d = new doh.Deferred(); |
| 93 | helper.selectShape('double'); |
| 94 | helper.drawShape({x:200,y:100},{x:100,y:200}); |
| 95 | doh.robot.sequence(d.getTestCallback(function(){ |
| 96 | t.is('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dojoxsketch="http://dojotoolkit.org/dojox/sketch" width="1000" height="855"><g><image xlink:href="images/figure2.gif" x="0" y="0" width="1000" height="855" /><g id="ann-1" dojoxsketch:type="Lead" transform="translate(437,169)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M0,0 Q100,-50 200,0" /><text style="fill:blue;text-anchor:start" font-weight="bold" x="204" y="-2">1</text></g><g id="ann-2" dojoxsketch:type="Preexisting" transform="translate(526,408)"><rect style="stroke:blue;stroke-width:1;fill:none;" x="0" width="104" y="0" height="210" rx="8" ry="8" /><text style="fill:blue;text-anchor:end" font-weight="bold" x="100" y="206">2</text></g><g id="ann-3" dojoxsketch:type="SingleArrow" transform="translate(537,804)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M-44,13 Q-137,38 -162,-23" /><g transform="translate(-44,13) rotate(164.9536)"><path style="fill:blue;" d="M0,0 l20,-5, -3,5, 3,5 Z" /></g><text style="fill:blue;text-anchor:middle" font-weight="bold" x="-160.36065573770492" y="-27">3</text></g><g id="ann-4" dojoxsketch:type="DoubleArrow" transform="translate(329,-7)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M249,306 Q505,242 426,389" /><g transform="translate(249,306) rotate(-14.0362)"><path style="fill:blue;" d="M0,0 l20,-5, -3,5, 3,5 Z" /></g><g transform="rotate(118.2542, 426, 389)"><path style="fill:blue;" d="M426,389 l-20,-5, 3,5, -3,5 Z" /></g><text style="fill:blue;text-anchor:middle" font-weight="bold" x="421.25" y="288.75">4</text></g><g id="ann-5" dojoxsketch:type="Underline" transform="translate(821,517)"><text style="fill:blue;" font-weight="bold" text-decoration="underline" x="0" y="0">5</text></g><g id="annotation-7" dojoxsketch:type="DoubleArrow" transform="translate(340,170)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M0,0 Q-80,80 -170,170" /><g transform="translate(0,0) rotate(135)"><path style="fill:blue;" d="M0,0 l20,-5, -3,5, 3,5 Z" /></g><g transform="rotate(135, -170, 170)"><path style="fill:blue;" d="M-170,170 l-20,-5, 3,5, -3,5 Z" /></g><text style="fill:blue;text-anchor:middle" font-weight="bold" x="-82.5" y="76.5"></text></g></g></svg>', f.getValue()); |
| 97 | }),500); |
| 98 | return d; |
| 99 | } |
| 100 | }); |
| 101 | doh.register("placeUnderlineShape",{ |
| 102 | timeout: 2000, |
| 103 | runTest:function(t){ |
| 104 | var d = new doh.Deferred(); |
| 105 | doh.robot.keyPress('z',100,{ctrl:true}); |
| 106 | helper.selectShape('underline'); |
| 107 | helper.drawShape({x:147,y:147},{x:147,y:147}); |
| 108 | doh.robot.sequence(d.getTestCallback(function(){ |
| 109 | t.is('<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:dojoxsketch="http://dojotoolkit.org/dojox/sketch" width="1000" height="855"><g><image xlink:href="images/figure2.gif" x="0" y="0" width="1000" height="855" /><g id="ann-1" dojoxsketch:type="Lead" transform="translate(437,169)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M0,0 Q100,-50 200,0" /><text style="fill:blue;text-anchor:start" font-weight="bold" x="204" y="-2">1</text></g><g id="ann-2" dojoxsketch:type="Preexisting" transform="translate(526,408)"><rect style="stroke:blue;stroke-width:1;fill:none;" x="0" width="104" y="0" height="210" rx="8" ry="8" /><text style="fill:blue;text-anchor:end" font-weight="bold" x="100" y="206">2</text></g><g id="ann-3" dojoxsketch:type="SingleArrow" transform="translate(537,804)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M-44,13 Q-137,38 -162,-23" /><g transform="translate(-44,13) rotate(164.9536)"><path style="fill:blue;" d="M0,0 l20,-5, -3,5, 3,5 Z" /></g><text style="fill:blue;text-anchor:middle" font-weight="bold" x="-160.36065573770492" y="-27">3</text></g><g id="ann-4" dojoxsketch:type="DoubleArrow" transform="translate(329,-7)"><path style="stroke:blue;stroke-width:2;fill:none;" d="M249,306 Q505,242 426,389" /><g transform="translate(249,306) rotate(-14.0362)"><path style="fill:blue;" d="M0,0 l20,-5, -3,5, 3,5 Z" /></g><g transform="rotate(118.2542, 426, 389)"><path style="fill:blue;" d="M426,389 l-20,-5, 3,5, -3,5 Z" /></g><text style="fill:blue;text-anchor:middle" font-weight="bold" x="421.25" y="288.75">4</text></g><g id="ann-5" dojoxsketch:type="Underline" transform="translate(821,517)"><text style="fill:blue;" font-weight="bold" text-decoration="underline" x="0" y="0">5</text></g><g id="annotation-8" dojoxsketch:type="Underline" transform="translate(250,250)"><text style="fill:blue;" font-weight="bold" text-decoration="underline" x="0" y="0">#</text></g></g></svg>', f.getValue()); |
| 110 | }),500); |
| 111 | return d; |
| 112 | } |
| 113 | }); |
| 114 | doh.run(); |
| 115 | } |
| 116 | </script> |
| 117 | </head> |
| 118 | <body class="tundra"> |
| 119 | <button onclick="rundoh()">FT</button> |
| 120 | <h1>Annotator/Figure Testing Platform</h1> |
| 121 | <p>This is a generic test to create a figure from an existing SVG file, to edit that figure, and to test the undo stack. Double click a shape to set new text for it.</p> |
| 122 | <div id="container"> |
| 123 | <div id="toolbar"></div> |
| 124 | <div id="canvasContainer"><div id="canvas" tabindex="-1"></div></div> |
| 125 | </div> |
| 126 | <h2>Serialized output</h2> |
| 127 | <textarea id="output" style="width:100%;height:180px;overflow:auto;font-size:0.8em;"></textarea> |
| 128 | </body> |
| 129 | </html> |