Debian Codegraph @

dojox/gfx/tests/svgweb/test_text.html

raw symbols SCIP
1 <html>
2 <head>
3 <title>Testing text</title>
4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <style type="text/css">
6 @import "../../../../dojo/resources/dojo.css";
7 @import "../../../../dijit/tests/css/dijitTests.css";
8 </style>
9 <!-- SVGWEB { -->
10 <meta name="svg.render.forceflash" content="true"/>
11 <script src="svgweb/src/svg.js" data-path="svgweb/src"></script>
12 <script src="../../../../dojo/dojo.js" data-dojo-config="isDebug:true,forceGfxRenderer:'svg'" type="text/javascript"></script>
13 <!-- } -->
14 <script type="text/javascript">
15 dojo.require("dojox.gfx");
16
17 var ROTATION = 30;
18
19 var surface = null, t1, t2, t3, t4, t5;
20
21 var placeAnchor = function(surface, x, y){
22 surface.createLine({x1: x - 2, y1: y, x2: x + 2, y2: y}).setStroke("blue");
23 surface.createLine({x1: x, y1: y - 2, x2: x, y2: y + 2}).setStroke("blue");
24 };
25
26 var makeText = function(surface, text, font, fill, stroke){
27 var t = surface.createText(text);
28 if(font) t.setFont(font);
29 if(fill) t.setFill(fill);
30 if(stroke) t.setStroke(stroke);
31 placeAnchor(surface, text.x, text.y);
32 return t;
33 };
34
35 makeShapes = function(){
36 surface = dojox.gfx.createSurface("test", 500, 500);
37 /* SVGWEB { */
38 surface.whenLoaded(function() {
39 var m = dojox.gfx.matrix;
40 surface.createLine({x1: 250, y1: 0, x2: 250, y2: 500}).setStroke("green");
41 t1 = makeText(surface, {x: 250, y: 50, text: "Start", align: "start"},
42 {family: "Times", size: "36pt", weight: "bold"}, "black", "red")
43 .setTransform(m.rotategAt(ROTATION, 250, 50));
44 t2 = makeText(surface, {x: 250, y: 100, text: "Middle", align: "middle"},
45 {family: "Symbol", size: "24pt"}, "red", "black")
46 .setTransform(m.rotategAt(ROTATION, 250, 100));
47 t3 = makeText(surface, {x: 250, y: 150, text: "End", align: "end"},
48 {family: "Helvetica", style: "italic", size: "18pt", rotated: true}, "#FF8000")
49 .setTransform(m.rotategAt(ROTATION, 250, 150));
50 t4 = makeText(surface, {x: 250, y: 200, text: "Define Shuffle Tiff", align: "middle", kerning: true},
51 {family: "serif", size: "36pt"}, "black")
52 .setTransform(m.rotategAt(0, 250, 200));
53 t5 = makeText(surface, {x: 250, y: 250, text: "Define Shuffle Tiff", align: "middle", kerning: false},
54 {family: "serif", size: "36pt"}, "black")
55 .setTransform(m.rotategAt(0, 250, 250));
56 });
57 /* } */
58 };
59
60 getSizes = function(){
61 var t = [];
62 dojo.forEach(["t1", "t2", "t3", "t4", "t5"], function(name){
63 var node = eval("(" + name + ")");
64 t.push(node.getShape().text + " = " + node.getTextWidth());
65 });
66 dojo.byId("sizes").innerHTML = t.join("<br/>");
67 };
68
69 dojo.addOnLoad(makeShapes);
70
71 </script>
72 </head>
73 <body>
74 <h1>dojox.gfx Text test</h1>
75 <div id="test" style="width: 500px; height: 500px;"></div>
76 <div><button onclick="surface.clear();">Clear</button>&nbsp;<button onclick="getSizes();">Get sizes</button></div>
77 <p id="sizes">&nbsp;</p>
78 <p>That's all Folks!</p>
79 </body>
80 </html>