Simon Hunt | 12ce12e | 2014-11-15 21:13:19 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2014 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 | /* |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 18 | ONOS -- SVG Glyphs Library. |
Simon Hunt | 12ce12e | 2014-11-15 21:13:19 -0800 | [diff] [blame] | 19 | |
| 20 | @author Simon Hunt |
| 21 | */ |
| 22 | |
| 23 | |
| 24 | (function (onos) { |
| 25 | 'use strict'; |
| 26 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 27 | var birdViewBox = '352 224 113 112', |
Simon Hunt | 7fa116d | 2014-11-17 14:16:55 -0800 | [diff] [blame] | 28 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 29 | birdData = { |
| 30 | bird: "M427.7,300.4 c-6.9,0.6-13.1,5-19.2,7.1c-18.1,6.2-33.9," + |
| 31 | "9.1-56.5,4.7c24.6,17.2,36.6,13,63.7,0.1c-0.5,0.6-0.7,1.3-1.3," + |
| 32 | "1.9c1.4-0.4,2.4-1.7,3.4-2.2c-0.4,0.7-0.9,1.5-1.4,1.9c2.2-0.6," + |
| 33 | "3.7-2.3,5.9-3.9c-2.4,2.1-4.2,5-6,8c-1.5,2.5-3.1,4.8-5.1,6.9c-1," + |
| 34 | "1-1.9,1.9-2.9,2.9c-1.4,1.3-2.9,2.5-5.1,2.9c1.7,0.1,3.6-0.3,6.5" + |
| 35 | "-1.9c-1.6,2.4-7.1,6.2-9.9,7.2c10.5-2.6,19.2-15.9,25.7-18c18.3" + |
| 36 | "-5.9,13.8-3.4,27-14.2c1.6-1.3,3-1,5.1-0.8c1.1,0.1,2.1,0.3,3.2," + |
| 37 | "0.5c0.8,0.2,1.4,0.4,2.2,0.8l1.8,0.9c-1.9-4.5-2.3-4.1-5.9-6c-2.3" + |
| 38 | "-1.3-3.3-3.8-6.2-4.9c-7.1-2.6-11.9,11.7-11.7-5c0.1-8,4.2-14.4," + |
| 39 | "6.4-22c1.1-3.8,2.3-7.6,2.4-11.5c0.1-2.3,0-4.7-0.4-7c-2-11.2-8.4" + |
| 40 | "-21.5-19.7-24.8c-1-0.3-1.1-0.3-0.9,0c9.6,17.1,7.2,38.3,3.1,54.2" + |
| 41 | "C429.9,285.5,426.7,293.2,427.7,300.4z" |
| 42 | }, |
Simon Hunt | 12ce12e | 2014-11-15 21:13:19 -0800 | [diff] [blame] | 43 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 44 | glyphViewBox = '0 0 110 110', |
Simon Hunt | 12ce12e | 2014-11-15 21:13:19 -0800 | [diff] [blame] | 45 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 46 | glyphData = { |
| 47 | unknown: "M35,40a5,5,0,0,1,5-5h30a5,5,0,0,1,5,5v30a5,5,0,0,1-5,5" + |
| 48 | "h-30a5,5,0,0,1-5-5z", |
Simon Hunt | c72967b | 2014-11-20 09:21:42 -0800 | [diff] [blame] | 49 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 50 | node: "M15,100a5,5,0,0,1-5-5v-65a5,5,0,0,1,5-5h80a5,5,0,0,1,5,5" + |
| 51 | "v65a5,5,0,0,1-5,5zM14,22.5l11-11a10,3,0,0,1,10-2h40a10,3,0,0,1," + |
| 52 | "10,2l11,11zM16,35a5,5,0,0,1,10,0a5,5,0,0,1-10,0z", |
Simon Hunt | b82f690 | 2014-11-22 11:53:15 -0800 | [diff] [blame] | 53 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 54 | switch: "M10,20a10,10,0,0,1,10-10h70a10,10,0,0,1,10,10v70a10,10," + |
| 55 | "0,0,1-10,10h-70a10,10,0,0,1-10-10zM60,26l12,0,0-8,18,13-18,13,0" + |
| 56 | "-8-12,0zM60,60l12,0,0-8,18,13-18,13,0-8-12,0zM50,40l-12,0,0-8" + |
| 57 | "-18,13,18,13,0-8,12,0zM50,74l-12,0,0-8-18,13,18,13,0-8,12,0z", |
Simon Hunt | b82f690 | 2014-11-22 11:53:15 -0800 | [diff] [blame] | 58 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 59 | roadm: "M10,35l25-25h40l25,25v40l-25,25h-40l-25-25zM58,26l12,0,0" + |
| 60 | "-8,18,13-18,13,0-8-12,0zM58,60l12,0,0-8,18,13-18,13,0-8-12,0z" + |
| 61 | "M52,40l-12,0,0-8-18,13,18,13,0-8,12,0zM52,74l-12,0,0-8-18,13," + |
| 62 | "18,13,0-8,12,0z", |
Simon Hunt | b82f690 | 2014-11-22 11:53:15 -0800 | [diff] [blame] | 63 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 64 | endstation: "M10,15a5,5,0,0,1,5-5h65a5,5,0,0,1,5,5v80a5,5,0,0,1" + |
| 65 | "-5,5h-65a5,5,0,0,1-5-5zM87.5,14l11,11a3,10,0,0,1,2,10v40a3,10," + |
| 66 | "0,0,1,-2,10l-11,11zM17,19a2,2,0,0,1,2-2h56a2,2,0,0,1,2,2v26a2," + |
| 67 | "2,0,0,1-2,2h-56a2,2,0,0,1-2-2zM20,20h54v10h-54zM20,33h54v10h" + |
| 68 | "-54zM42,70a5,5,0,0,1,10,0a5,5,0,0,1-10,0z", |
Simon Hunt | b82f690 | 2014-11-22 11:53:15 -0800 | [diff] [blame] | 69 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 70 | router: "M10,55A45,45,0,0,1,100,55A45,45,0,0,1,10,55M20,50l12,0," + |
| 71 | "0-8,18,13-18,13,0-8-12,0zM90,50l-12,0,0-8-18,13,18,13,0-8,12,0z" + |
| 72 | "M50,47l0-12-8,0,13-18,13,18-8,0,0,12zM50,63l0,12-8,0,13,18,13" + |
| 73 | "-18-8,0,0-12z", |
Simon Hunt | b82f690 | 2014-11-22 11:53:15 -0800 | [diff] [blame] | 74 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 75 | bgpSpeaker: "M10,40a45,35,0,0,1,90,0Q100,77,55,100Q10,77,10,40z" + |
| 76 | "M50,29l12,0,0-8,18,13-18,13,0-8-12,0zM60,57l-12,0,0-8-18,13," + |
| 77 | "18,13,0-8,12,0z", |
| 78 | |
| 79 | chain: "M60.4,77.6c-4.9,5.2-9.6,11.3-15.3,16.3c-8.6,7.5-20.4,6.8" + |
| 80 | "-28-0.8c-7.7-7.7-8.4-19.6-0.8-28.4c6.5-7.4,13.5-14.4,20.9-20.9" + |
| 81 | "c7.5-6.7,19.2-6.7,26.5-0.8c3.5,2.8,4.4,6.1,2.2,8.7c-2.7,3.1" + |
| 82 | "-5.5,2.5-8.5,0.3c-4.7-3.4-9.7-3.2-14,0.9C37.1,58.7,31,64.8," + |
| 83 | "25.2,71c-4.2,4.4-4.2,10.6-0.6,14.3c3.7,3.7,9.7,3.7,14.3-0.4" + |
| 84 | "c2.9-2.5,5.3-5.5,8.3-8c1-0.9,3-1.1,4.4-0.9C54.8,76.3,57.9,77.1," + |
| 85 | "60.4,77.6zM49.2,32.2c5-5.2,9.7-10.9,15.2-15.7c12.8-11,31.2" + |
| 86 | "-4.9,34.3,11.2C100,34.2,98.3,40.2,94,45c-6.7,7.4-13.7,14.6" + |
| 87 | "-21.2,21.2C65.1,73,53.2,72.7,46,66.5c-3.2-2.8-3.9-5.8-1.6-8.4" + |
| 88 | "c2.6-2.9,5.3-2.4,8.2-0.3c5.2,3.7,10,3.3,14.7-1.1c5.8-5.6,11.6" + |
| 89 | "-11.3,17.2-17.2c4.6-4.8,4.9-11.1,0.9-15c-3.9-3.9-10.1-3.4-15," + |
| 90 | "1.2c-3.1,2.9-5.7,7.4-9.3,8.5C57.6,35.3,53,33,49.2,32.2z" |
| 91 | }, |
Simon Hunt | c72967b | 2014-11-20 09:21:42 -0800 | [diff] [blame] | 92 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 93 | badgeViewBox = '0 0 10 10', |
Simon Hunt | c72967b | 2014-11-20 09:21:42 -0800 | [diff] [blame] | 94 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 95 | badgeData = { |
| 96 | uiAttached: "M2,2.5a.5,.5,0,0,1,.5-.5h5a.5,.5,0,0,1,.5,.5v3" + |
| 97 | "a.5,.5,0,0,1-.5,.5h-5a.5,.5,0,0,1-.5-.5zM2.5,2.8a.3,.3,0,0,1," + |
| 98 | ".3-.3h4.4a.3,.3,0,0,1,.3,.3v2.4a.3,.3,0,0,1-.3,.3h-4.4" + |
| 99 | "a.3,.3,0,0,1-.3-.3zM2,6.55h6l1,1.45h-8z" |
| 100 | }; |
Simon Hunt | b82f690 | 2014-11-22 11:53:15 -0800 | [diff] [blame] | 101 | |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 102 | function defStuff(defs, viewbox, data) { |
Simon Hunt | b82f690 | 2014-11-22 11:53:15 -0800 | [diff] [blame] | 103 | d3.map(data).keys().forEach(function (key) { |
| 104 | defs.append('symbol') |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 105 | .attr({ id: key, viewBox: viewbox }) |
Simon Hunt | b82f690 | 2014-11-22 11:53:15 -0800 | [diff] [blame] | 106 | .append('path').attr('d', data[key]); |
Simon Hunt | c72967b | 2014-11-20 09:21:42 -0800 | [diff] [blame] | 107 | }); |
| 108 | } |
| 109 | |
Simon Hunt | 12ce12e | 2014-11-15 21:13:19 -0800 | [diff] [blame] | 110 | onos.ui.addLib('glyphs', { |
Simon Hunt | 71fbdb3 | 2014-12-01 14:32:25 -0800 | [diff] [blame] | 111 | defBird: function (defs) { defStuff(defs, birdViewBox, birdData); }, |
| 112 | defGlyphs: function (defs) { defStuff(defs, glyphViewBox, glyphData); }, |
| 113 | defBadges: function (defs) { defStuff(defs, badgeViewBox, badgeData); } |
Simon Hunt | 12ce12e | 2014-11-15 21:13:19 -0800 | [diff] [blame] | 114 | }); |
| 115 | |
| 116 | }(ONOS)); |