Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame^] | 1 | <!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, |
| 73 | h = 400, |
| 74 | 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 | |
| 86 | function translate(loc) { |
| 87 | return 'translate(' + loc[0] + ',' + loc[1] +')'; |
| 88 | } |
| 89 | |
| 90 | function icon(what, id, loc, color, bg, size) { |
| 91 | var i = '#' + id, |
| 92 | c = color || 'black', |
| 93 | b = bg || '#eef', |
| 94 | z = size || 40, |
| 95 | g; |
| 96 | |
| 97 | g = what.append('g') |
| 98 | .attr({ 'class': 'icon', transform: translate(loc) }); |
| 99 | |
| 100 | g.append('rect') |
| 101 | .attr({ width: z, height: z, rx: 4 }) |
| 102 | .style('fill', b) |
| 103 | .style('stroke', 'black') |
| 104 | .style('stroke-width', 0.5); |
| 105 | |
| 106 | g.append('use') |
| 107 | .attr({ 'class': 'glyph', width: z, height: z, 'xlink:href': i }) |
| 108 | .style('fill', c); |
| 109 | |
| 110 | if (id !== 'bird') { |
| 111 | g.append('text') |
| 112 | .text(id) |
| 113 | .attr({ x: z / 2, y: z + 8 }) |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | |
| 118 | // import glyphs... |
| 119 | libs.glyphs.defBird(defs); |
| 120 | libs.glyphs.defGlyphs(defs); |
| 121 | libs.glyphs.defBadges(defs); |
| 122 | |
| 123 | // bird, top right corner |
| 124 | icon(svg, 'bird', [830,10], '#800', '#ecc', 160); |
| 125 | |
| 126 | // show icons... |
| 127 | icon(grp, 'unknown', [ 0, 0]); |
| 128 | icon(grp, 'node', [ 50, 0]); |
| 129 | icon(grp, 'switch', [100, 0]); |
| 130 | icon(grp, 'roadm', [150, 0]); |
| 131 | icon(grp, 'endstation', [200, 0]); |
| 132 | icon(grp, 'router', [250, 0]); |
| 133 | icon(grp, 'bgpSpeaker', [300, 0]); |
| 134 | icon(grp, 'uiAttached', [350, 0]); |
| 135 | |
| 136 | icon(grp, 'chain', [ 0, 60]); |
| 137 | |
| 138 | // more goodies to come soon..... |
| 139 | })(); |
| 140 | </script> |
| 141 | |
| 142 | </body> |
| 143 | </html> |