Test page for displaying custom glyphs.
Change-Id: I58d2d181ee8967e2665179db5b63fb1d4e9f2a87
Showing
2 changed files
with
217 additions
and
0 deletions
web/gui/src/main/webapp/_sdh/big-icon.html
0 → 100644
1 | +<!DOCTYPE html> | ||
2 | +<!-- | ||
3 | + ~ Copyright 2016 Open Networking Laboratory | ||
4 | + ~ | ||
5 | + ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
6 | + ~ you may not use this file except in compliance with the License. | ||
7 | + ~ You may obtain a copy of the License at | ||
8 | + ~ | ||
9 | + ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
10 | + ~ | ||
11 | + ~ Unless required by applicable law or agreed to in writing, software | ||
12 | + ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
13 | + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
14 | + ~ See the License for the specific language governing permissions and | ||
15 | + ~ limitations under the License. | ||
16 | + --> | ||
17 | + | ||
18 | +<!-- | ||
19 | + ONOS -- Display a glyph with Angular test page | ||
20 | + --> | ||
21 | + | ||
22 | +<html> | ||
23 | +<head lang="en"> | ||
24 | + <meta charset="UTF-8"> | ||
25 | + <title>Show Icons Angular</title> | ||
26 | + | ||
27 | + <script type="text/javascript" src="../tp/angular.js"></script> | ||
28 | + <script type="text/javascript" src="../tp/angular-route.js"></script> | ||
29 | + | ||
30 | + <script type="text/javascript" src="../tp/d3.js"></script> | ||
31 | + | ||
32 | + <script type="text/javascript" src="../app/fw/util/util.js"></script> | ||
33 | + <script type="text/javascript" src="../app/fw/util/fn.js"></script> | ||
34 | + | ||
35 | + <script type="text/javascript" src="../app/fw/svg/svg.js"></script> | ||
36 | + <script type="text/javascript" src="../app/fw/svg/svgUtil.js"></script> | ||
37 | + <script type="text/javascript" src="../app/fw/svg/glyph.js"></script> | ||
38 | + | ||
39 | + <script type="text/javascript" src="big-icon.js"></script> | ||
40 | + | ||
41 | + <link rel="stylesheet" href="../app/common.css"> | ||
42 | + <link rel="stylesheet" href="../app/fw/svg/icon.css"> | ||
43 | + | ||
44 | + <style> | ||
45 | + html, | ||
46 | + body { | ||
47 | + background-color: #ddf; | ||
48 | + font-family: Arial, Helvetica, sans-serif; | ||
49 | + font-size: 9pt; | ||
50 | + } | ||
51 | + | ||
52 | + h2 { | ||
53 | + color: darkred; | ||
54 | + } | ||
55 | + | ||
56 | + svg .glyph { | ||
57 | + stroke: none; | ||
58 | + fill: #123456; | ||
59 | + fill-rule: evenodd; | ||
60 | + } | ||
61 | + | ||
62 | + svg.embeddedGlyph .glyph rect { | ||
63 | + fill: #fff | ||
64 | + } | ||
65 | + | ||
66 | + </style> | ||
67 | + | ||
68 | +</head> | ||
69 | +<!-- outline for using a controller in Angular --> | ||
70 | +<body class="light" ng-app="showGlyph" ng-controller="OvShowGlyph as ctrl"> | ||
71 | + <h2>Display a Glyph</h2> | ||
72 | + <div id="showGlyphs"></div> | ||
73 | + <svg><defs></defs></svg> | ||
74 | +</body> | ||
75 | +</html> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
web/gui/src/main/webapp/_sdh/big-icon.js
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +/* | ||
18 | + ONOS GUI -- Test code for displaying custom glyphs | ||
19 | + */ | ||
20 | + | ||
21 | +(function () { | ||
22 | + 'use strict'; | ||
23 | + | ||
24 | + // assuming the glyph is a square | ||
25 | + // div is a D3 selection of the <DIV> element into which icon should load | ||
26 | + // size is the size of the glyph | ||
27 | + // id is the symbol id | ||
28 | + function createGlyph(div, size, id) { | ||
29 | + var dim = size || 20, | ||
30 | + texty = 30, | ||
31 | + gid = id || 'unknown', | ||
32 | + rx = 4, | ||
33 | + svgCls = 'embeddedGlyph', | ||
34 | + svg, g; | ||
35 | + | ||
36 | + svg = div.append('svg').attr({ | ||
37 | + 'class': svgCls, | ||
38 | + width: dim, | ||
39 | + height: dim + texty, | ||
40 | + viewBox: '0 0 ' + dim + ' ' + dim | ||
41 | + }); | ||
42 | + | ||
43 | + g = svg.append('g').attr({ | ||
44 | + 'class': 'glyph' | ||
45 | + }); | ||
46 | + | ||
47 | + g.append('rect').attr({ | ||
48 | + width: dim, | ||
49 | + height: dim, | ||
50 | + rx: rx | ||
51 | + }); | ||
52 | + | ||
53 | + g.append('use').attr({ | ||
54 | + width: dim, | ||
55 | + height: dim, | ||
56 | + 'class': 'glyph', | ||
57 | + 'xlink:href': '#' + gid | ||
58 | + }); | ||
59 | + | ||
60 | + g.append('text') | ||
61 | + .attr({ | ||
62 | + 'text-anchor': 'left', | ||
63 | + y: '1em', | ||
64 | + x: 0, | ||
65 | + transform: 'translate(0, ' + dim + ')' | ||
66 | + }) | ||
67 | + .style('fill', '#800') | ||
68 | + .text(id); | ||
69 | + } | ||
70 | + | ||
71 | + var clock = 'M92.9,61.3a39,39,0,1,1-39-39,39,39,0,0,1,39,39h0Z' + | ||
72 | + 'M44,19.3c-4.4-7.4-14.8-9.3-23.2-4.2S9.1,30.2,13.5,37.6m80.8,0' + | ||
73 | + 'c4.4-7.4,1.2-17.5-7.3-22.5s-18.8-3.2-23.3,4.2m-8.4,1.8V16.5h4.4' + | ||
74 | + 'V11.9H48.2v4.6h4.6v4.6M51.6,56.4H51.5' + | ||
75 | + 'a5.4,5.4,0,0,0,2.4,10.3,4.7,4.7,0,0,0,4.9-3.1H74.5' + | ||
76 | + 'a2.2,2.2,0,0,0,2.4-2.2,2.4,2.4,0,0,0-2.4-2.3H58.8' + | ||
77 | + 'a5.3,5.3,0,0,0-2.5-2.6H56.2V32.9' + | ||
78 | + 'a2.3,2.3,0,0,0-.6-1.7,2.2,2.2,0,0,0-1.6-.7,2.4,2.4,0,0,0-2.4,2.4' + | ||
79 | + 'h0V56.4M82.2,91.1l-7.1,5.3-0.2.2-1.2,2.1a0.6,0.6,0,0,0,.2.8' + | ||
80 | + 'h0.2c2.6,0.4,10.7.9,10.3-1.2m-60.8,0c-0.4,2.1,7.7,1.6,10.3,1.2' + | ||
81 | + 'h0.2a0.6,0.6,0,0,0,.2-0.8l-1.2-2.1-0.2-.2-7.1-5.3'; | ||
82 | + | ||
83 | + var clocks = "M65.7,26.6A34.7,34.7,0,0,0,31,61.5c0,19,16,35.2,35.5,34.8" + | ||
84 | + "a35.1,35.1,0,0,0,34-35.1A34.7,34.7,0,0,0,65.7,26.6Z" + | ||
85 | + "m8.6-2.7,27.4,16.4a31.3,31.3,0,0,0,1.2-3.1c1.3-5,0-9.4-3.2-13.2" + | ||
86 | + "a16.9,16.9,0,0,0-16-6.2A12.8,12.8,0,0,0,74.3,23.9Z" + | ||
87 | + "M57,23.9L56.4,23a12.9,12.9,0,0,0-10.7-5.5,16.9,16.9,0,0,0-15.1,8," + | ||
88 | + "14.1,14.1,0,0,0-2.3,11.2,10.4,10.4,0,0,0,1.4,3.5Z" + | ||
89 | + "M26.9,31.6A33.7,33.7,0,0,0,9.7,59.3C9.2,72.8,14.9,83.1,26,90.7l1-1.9" + | ||
90 | + "a0.6,0.6,0,0,0-.2-1A34.2,34.2,0,0,1,15.5,50.4" + | ||
91 | + "a33.8,33.8,0,0,1,10.8-16,1.2,1.2,0,0,0,.5-0.6" + | ||
92 | + "C26.9,33.1,26.9,32.4,26.9,31.6Z" + | ||
93 | + "m1,8.1C14.6,55.9,19.2,81,37.6,91.1l1-2.3-2.8-2.4" + | ||
94 | + "C26.4,77.6,22.9,66.7,25.1,54" + | ||
95 | + "a31.6,31.6,0,0,1,4.2-10.8,0.8,0.8,0,0,0,.1-0.6Z" + | ||
96 | + "M12,38.4a11.2,11.2,0,0,1-1.4-5.8A13.7,13.7,0,0,1,14.3,24" + | ||
97 | + "a17.3,17.3,0,0,1,10.5-5.7h0.4C19,18,13.7,20,9.9,25.2" + | ||
98 | + "a14.5,14.5,0,0,0-3,11,11.2,11.2,0,0,0,1.6,4.3Z" + | ||
99 | + "m5.5-2.7L21,33" + | ||
100 | + "a1,1,0,0,0,.3-0.7,14,14,0,0,1,3.9-8.6,17.3,17.3,0,0,1,10.2-5.4" + | ||
101 | + "l0.6-.2C24.4,17.3,16.4,27,17.4,35.7Z" + | ||
102 | + "M70.9,17.2H60.7v4.1h4v4.2H67V21.3h3.9V17.2Z" + | ||
103 | + "M90.9,87.9l-0.5.3L86,91.5a7.9,7.9,0,0,0-2.6,3.1" + | ||
104 | + "c-0.3.6-.2,0.8,0.5,0.9a27.9,27.9,0,0,0,6.8.2l1.6-.4" + | ||
105 | + "a0.8,0.8,0,0,0,.6-1.2l-0.4-1.4Z" + | ||
106 | + "m-50.2,0-1.8,6c-0.3,1.1-.1,1.4.9,1.7h0.7a26.3,26.3,0,0,0,7.2-.1" + | ||
107 | + "c0.8-.1.9-0.4,0.5-1.1a8.2,8.2,0,0,0-2.7-3.1Z" + | ||
108 | + "m-10.8-.4-0.2.6L28,93.5a0.9,0.9,0,0,0,.7,1.3,7.7,7.7,0,0,0,2.2.4" + | ||
109 | + "l5.9-.2c0.5,0,.7-0.3.5-0.8a7.6,7.6,0,0,0-2.2-2.9Z" + | ||
110 | + "m-11.3,0-0.2.7-1.6,5.4c-0.2.8-.1,1.2,0.7,1.4a8,8,0,0,0,2.2.4l6-.2" + | ||
111 | + "c0.4,0,.7-0.3.5-0.6a7.1,7.1,0,0,0-1.9-2.7l-2.8-2.1Z" + | ||
112 | + "M65.7,26.6m-2,30.3a4.4,4.4,0,0,0-2.2,2,4.8,4.8,0,0,0,4,7.2," + | ||
113 | + "4.1,4.1,0,0,0,4.3-2.3,0.8,0.8,0,0,1,.8-0.5H84.1" + | ||
114 | + "a1.9,1.9,0,0,0,2-1.7,2.1,2.1,0,0,0-1.7-2.2H70.8" + | ||
115 | + "a1,1,0,0,1-1-.5,6.4,6.4,0,0,0-1.5-1.6,1.1,1.1,0,0,1-.5-1" + | ||
116 | + "q0-10.1,0-20.3a1.9,1.9,0,0,0-2.2-2.1,2.1,2.1,0,0,0-1.8,2.2" + | ||
117 | + "q0,6.1,0,12.2C63.7,51.2,63.7,54,63.7,56.9Z"; | ||
118 | + | ||
119 | + var glyphData = { | ||
120 | + _viewbox: "0 0 110 110", | ||
121 | + alarm: clock, | ||
122 | + alarms: clocks | ||
123 | + }; | ||
124 | + | ||
125 | + var gids = [ | ||
126 | + 'alarm', | ||
127 | + 'alarms' | ||
128 | + ]; | ||
129 | + | ||
130 | + angular.module('showGlyph', ['onosSvg']) | ||
131 | + .controller('OvShowGlyph', ['$log', 'GlyphService', | ||
132 | + | ||
133 | + function ($log, gs) { | ||
134 | + var gDiv = d3.select('#showGlyphs'), | ||
135 | + defs = d3.select('defs'); | ||
136 | + | ||
137 | + gs.registerGlyphSet(glyphData); | ||
138 | + gs.loadDefs(defs, gids); | ||
139 | + | ||
140 | + createGlyph(gDiv, 400, 'alarms'); | ||
141 | + }]); | ||
142 | +}()); |
-
Please register or login to post a comment