diff options
author | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
---|---|---|
committer | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
commit | e44a7e37b6c7b5961adaffc62b9042b8d442938e (patch) | |
tree | 95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojox/gfx/tests/test_text.html | |
parent | a62b9742ee5e28bcec6872d88f50f25b820914f6 (diff) | |
download | semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2 |
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojox/gfx/tests/test_text.html')
-rw-r--r-- | includes/js/dojox/gfx/tests/test_text.html | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/includes/js/dojox/gfx/tests/test_text.html b/includes/js/dojox/gfx/tests/test_text.html new file mode 100644 index 0000000..446156f --- /dev/null +++ b/includes/js/dojox/gfx/tests/test_text.html @@ -0,0 +1,88 @@ +<html> +<head> +<title>Testing text</title> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<style type="text/css"> + @import "../../../dojo/resources/dojo.css"; + @import "../../../dijit/tests/css/dijitTests.css"; +</style> +<!-- +The next line should include Microsoft's Silverligth.js, if you plan to use the silverlight backend +<script type="text/javascript" src="Silverlight.js"></script> +--> +<script type="text/javascript" src="../../../dojo/dojo.js" djConfig="isDebug: true"></script> +<!-- +<script type="text/javascript" src="../common.js"></script> +<script type="text/javascript" src="../shape.js"></script> +--> +<!--<script type="text/javascript" src="../vml.js"></script>--> +<!--<script type="text/javascript" src="../svg.js"></script>--> +<!--<script type="text/javascript" src="../silverlight.js"></script>--> +<script type="text/javascript"> +dojo.require("dojox.gfx"); + +var ROTATION = 30; + +var surface = null, t1, t2, t3, t4, t5; + +var placeAnchor = function(surface, x, y){ + surface.createLine({x1: x - 2, y1: y, x2: x + 2, y2: y}).setStroke("blue"); + surface.createLine({x1: x, y1: y - 2, x2: x, y2: y + 2}).setStroke("blue"); +}; + +var makeText = function(surface, text, font, fill, stroke){ + var t = surface.createText(text); + if(font) t.setFont(font); + if(fill) t.setFill(fill); + if(stroke) t.setStroke(stroke); + placeAnchor(surface, text.x, text.y); + return t; +}; + +makeShapes = function(){ + surface = dojox.gfx.createSurface("test", 500, 500); + var m = dojox.gfx.matrix; + surface.createLine({x1: 250, y1: 0, x2: 250, y2: 500}).setStroke("green"); + t1 = makeText(surface, {x: 250, y: 50, text: "Start", align: "start"}, + {family: "Times", size: "36pt", weight: "bold"}, "black", "red") + .setTransform(m.rotategAt(ROTATION, 250, 50)) + ; + t2 = makeText(surface, {x: 250, y: 100, text: "Middle", align: "middle"}, + {family: "Symbol", size: "24pt"}, "red", "black") + .setTransform(m.rotategAt(ROTATION, 250, 100)) + ; + t3 = makeText(surface, {x: 250, y: 150, text: "End", align: "end"}, + {family: "Helvetica", style: "italic", size: "18pt", rotated: true}, "#FF8000") + .setTransform(m.rotategAt(ROTATION, 250, 150)) + ; + t4 = makeText(surface, {x: 250, y: 200, text: "Define Shuffle Tiff", align: "middle", kerning: true}, + {family: "serif", size: "36pt"}, "black") + .setTransform(m.rotategAt(0, 250, 200)) + ; + t5 = makeText(surface, {x: 250, y: 250, text: "Define Shuffle Tiff", align: "middle", kerning: false}, + {family: "serif", size: "36pt"}, "black") + .setTransform(m.rotategAt(0, 250, 250)) + ; +}; + +getSizes = function(){ + var t = []; + dojo.forEach(["t1", "t2", "t3", "t4", "t5"], function(name){ + var node = eval("(" + name + ")"); + t.push(node.getShape().text + " = " + node.getTextWidth()); + }); + dojo.byId("sizes").innerHTML = t.join("<br/>"); +}; + +dojo.addOnLoad(makeShapes); + +</script> +</head> +<body> + <h1>dojox.gfx Text test</h1> +<div id="test" style="width: 500px; height: 500px;"></div> +<div><button onclick="surface.clear();">Clear</button> <button onclick="getSizes();">Get sizes</button></div> +<p id="sizes"> </p> +<p>That's all Folks!</p> +</body> +</html> |