glyphs.html
4.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
<!DOCTYPE html>
<!--
~ Copyright 2016-present Open Networking Laboratory
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
<!--
ONOS -- Glyphs library test page (old version)
-->
<html>
<head>
<meta charset="utf-8">
<title>Glyphs</title>
<script src="../tp/d3.js"></script>
<style>
html,
body {
background-color: #ddf;
font-family: Arial, Helvetica, sans-serif;
font-size: 9pt;
}
svg {
background-color: #fff;
}
svg .glyph {
stroke: none;
fill: black;
fill-rule: evenodd;
}
svg .icon text {
text-anchor: middle;
font-size: 5pt;
fill: green;
stroke: none;
}
</style>
</head>
<body>
<!-- minimal framework to access glyphs library module -->
<script>
var libs = {};
var ONOS = { ui: { addLib: function (id, things) { libs[id] = things; }}};
</script>
<!-- import the glyphs library -->
<script src="../glyphs.js"></script>
<svg></svg>
<!-- code to display the glyphs in the library -->
<script>
(function () {
var w = 1000,
h = 800,
vb = '0 0 ' + w + ' ' + h;
var svg = d3.select('svg')
.attr({ width: w, height: h, viewBox: vb });
// create definitions element...
var defs = svg.append('defs');
// create scaling group
var grp = svg.append('g')
.attr('transform', 'translate(20,20)scale(2)');
var mag = svg.append('g')
.attr('transform', 'translate(20,20)scale(12)');
function translate(loc) {
return 'translate(' + loc[0] + ',' + loc[1] +')';
}
function icon(what, id, loc, color, bg, size) {
var i = '#' + id,
c = color || 'black',
b = bg || '#eef',
z = size || 40,
g;
g = what.append('g')
.attr({ 'class': 'icon', transform: translate(loc) });
g.append('rect')
.attr({ width: z, height: z, rx: 4 })
.style('fill', b)
.style('stroke', 'black')
.style('stroke-width', 0.5);
g.append('use')
.attr({ 'class': 'glyph', width: z, height: z, 'xlink:href': i })
.style('fill', c);
if (id !== 'bird') {
g.append('text')
.text(id)
.attr({ x: z / 2, y: z + 8 })
}
}
// import glyphs...
libs.glyphs.loadDefs(defs);
// bird, top right corner
icon(svg, 'bird', [830,10], '#800', '#ecc', 160);
// show icons...
icon(grp, 'unknown', [ 0, 0]);
icon(grp, 'node', [ 50, 0]);
icon(grp, 'switch', [100, 0]);
icon(grp, 'roadm', [150, 0]);
icon(grp, 'endstation', [200, 0]);
icon(grp, 'router', [250, 0]);
icon(grp, 'bgpSpeaker', [300, 0]);
icon(grp, 'uiAttached', [350, 0]);
icon(grp, 'otn', [400, 0]);
icon(grp, 'chain', [ 0, 60]);
icon(grp, 'crown', [ 50, 60]);
// icon(mag, 'crown', [20, 15], 'rgba(240,120,120,1)', 'transparent');
// more goodies to come soon.....
})();
</script>
</body>
</html>