blob: 835d9466891467e6d2d27508e7202fc5877848c1 [file] [log] [blame]
Simon Hunt71fbdb32014-12-01 14:32:25 -08001<!DOCTYPE html>
2<!--
3 ~ Copyright 2014 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 -- Glyphs library test page
20
21 @author Simon Hunt
22 -->
23<html>
24<head>
25 <meta charset="utf-8">
26 <title>Glyphs</title>
27
28 <script src="../tp/d3.js"></script>
29
30 <style>
31 html,
32 body {
33 background-color: #ddf;
34 font-family: Arial, Helvetica, sans-serif;
35 font-size: 9pt;
36 }
37
38 svg {
39 background-color: #fff;
40 }
41
42 svg .glyph {
43 stroke: none;
44 fill: black;
45 fill-rule: evenodd;
46 }
47
48 svg .icon text {
49 text-anchor: middle;
50 font-size: 5pt;
51 fill: green;
52 stroke: none;
53 }
54
55 </style>
56</head>
57<body>
58 <!-- minimal framework to access glyphs library module -->
59 <script>
60 var libs = {};
61 var ONOS = { ui: { addLib: function (id, things) { libs[id] = things; }}};
62 </script>
63
64 <!-- import the glyphs library -->
65 <script src="../glyphs.js"></script>
66
67 <svg></svg>
68
69 <!-- code to display the glyphs in the library -->
70 <script>
71 (function () {
72 var w = 1000,
Simon Hunt21909592014-12-02 16:40:41 -080073 h = 800,
Simon Hunt71fbdb32014-12-01 14:32:25 -080074 vb = '0 0 ' + w + ' ' + h;
75
76 var svg = d3.select('svg')
77 .attr({ width: w, height: h, viewBox: vb });
78
79 // create definitions element...
80 var defs = svg.append('defs');
81
82 // create scaling group
83 var grp = svg.append('g')
84 .attr('transform', 'translate(20,20)scale(2)');
85
Simon Hunt21909592014-12-02 16:40:41 -080086 var mag = svg.append('g')
87 .attr('transform', 'translate(20,20)scale(12)');
88
Simon Hunt71fbdb32014-12-01 14:32:25 -080089 function translate(loc) {
90 return 'translate(' + loc[0] + ',' + loc[1] +')';
91 }
92
93 function icon(what, id, loc, color, bg, size) {
94 var i = '#' + id,
95 c = color || 'black',
96 b = bg || '#eef',
97 z = size || 40,
98 g;
99
100 g = what.append('g')
101 .attr({ 'class': 'icon', transform: translate(loc) });
102
103 g.append('rect')
104 .attr({ width: z, height: z, rx: 4 })
105 .style('fill', b)
106 .style('stroke', 'black')
107 .style('stroke-width', 0.5);
108
109 g.append('use')
110 .attr({ 'class': 'glyph', width: z, height: z, 'xlink:href': i })
111 .style('fill', c);
112
113 if (id !== 'bird') {
114 g.append('text')
115 .text(id)
116 .attr({ x: z / 2, y: z + 8 })
117 }
118 }
119
120
121 // import glyphs...
Simon Hunt21909592014-12-02 16:40:41 -0800122 libs.glyphs.loadDefs(defs);
Simon Hunt71fbdb32014-12-01 14:32:25 -0800123
124 // bird, top right corner
125 icon(svg, 'bird', [830,10], '#800', '#ecc', 160);
126
127 // show icons...
128 icon(grp, 'unknown', [ 0, 0]);
129 icon(grp, 'node', [ 50, 0]);
130 icon(grp, 'switch', [100, 0]);
131 icon(grp, 'roadm', [150, 0]);
132 icon(grp, 'endstation', [200, 0]);
133 icon(grp, 'router', [250, 0]);
134 icon(grp, 'bgpSpeaker', [300, 0]);
135 icon(grp, 'uiAttached', [350, 0]);
136
137 icon(grp, 'chain', [ 0, 60]);
Simon Hunt21909592014-12-02 16:40:41 -0800138 icon(grp, 'crown', [ 50, 60]);
139
140// icon(mag, 'crown', [20, 15], 'rgba(240,120,120,1)', 'transparent');
Simon Hunt71fbdb32014-12-01 14:32:25 -0800141
142 // more goodies to come soon.....
143 })();
144 </script>
145
146</body>
147</html>