blob: 30221c82eb76831cc60650a7513ecac4d233d0b7 [file] [log] [blame]
Simon Hunta1028c42017-02-07 20:08:03 -08001/*
Brian O'Connora09fe5b2017-08-03 21:12:30 -07002 * Copyright 2017-present Open Networking Foundation
Simon Hunta1028c42017-02-07 20:08:03 -08003 *
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 -- SVG -- Sprite Data Service
19 * Bundled sprite and layout definitions.
20 */
21(function () {
22 'use strict';
23
24 // ----------------------------------------------------------------------
25 // === Sprite Data ===
26
27 var cloud = {
28 // TODO: define cloud sprite...
29 vbox: '0 0 305 186',
30 d: [
Steven Burrows1c2a9682017-07-14 16:52:46 +010031 'M91.2,48.4C121.2,6.3,187.9-13.4,219,45.6',
32 'M43.1,139.6C21.8,142.9-15.6,108.4,26.1,79',
33 'M103.7,150C89,205.2-11.2,167.4,30.5,138',
34 'M192.3,147.3c-33.5,48-82.1,32.3-94.5-8.2',
35 'M267.1,115c27.9,67.8-77.6,74.3-83.1,41',
36 'M34.3,89.9C10.8,79,59.5,10.7,97.2,39.6',
37 'M211.9,34.2c51.9-38.8,118,57.4,59,94.5',
Simon Hunta1028c42017-02-07 20:08:03 -080038 ],
39 style: {
40 fill: 'none',
Steven Burrows1c2a9682017-07-14 16:52:46 +010041 'stroke-miterlimit': 10,
42 },
Simon Hunta1028c42017-02-07 20:08:03 -080043 };
44
45 // TODO: define other core sprites here...
46
47 // ----------------------------------------------------------------------
48 // === API functions ===
49
50 function registerCoreSprites(ssApi) {
51 ssApi.registerSprite(cloud);
52
53 // TODO: add base set of sprites here ...
54
55 // ----------------------------------------------------------$$$
56 // This following code is for initial development of Topo2 sprite layer
57 ssApi.createSprite('rack', 40, 50)
Steven Burrows1c2a9682017-07-14 16:52:46 +010058 .addRect(0, 0, 40, 50, { fill: 'gold1' })
Simon Hunta1028c42017-02-07 20:08:03 -080059 .addPath([
60 'M5,20h30v5h-30z',
61 'M5,30h30v5h-30z',
Steven Burrows1c2a9682017-07-14 16:52:46 +010062 'M5,40h30v5h-30z',
63 ], { stroke: 'gray1' })
Simon Hunta1028c42017-02-07 20:08:03 -080064 .register();
65
66 ssApi.createLayout('segmentRouting', 130, 75)
67 .addSprite('rack', 10, 40, 20)
68 .addSprite('rack', 40, 40, 20)
69 .addSprite('rack', 70, 40, 20)
70 .addSprite('rack', 100, 40, 20)
Steven Burrows1c2a9682017-07-14 16:52:46 +010071 .addLabel('Segment Routing', 120, 10, { anchor: 'right' })
Simon Hunta1028c42017-02-07 20:08:03 -080072 .register();
73
Simon Huntc4ca7102017-04-08 22:28:04 -070074 ssApi.createLayout('segmentRoutingTwo', 70, 75)
75 .addSprite('rack', 10, 40, 20)
76 .addSprite('rack', 40, 40, 20)
Steven Burrows1c2a9682017-07-14 16:52:46 +010077 .addLabel('Segment Routing 2', 120, 10, { anchor: 'right' })
Simon Huntc4ca7102017-04-08 22:28:04 -070078 .register();
79
Simon Hunt0ee20bf2017-05-10 19:59:17 -070080 ssApi.createLayout('plain', 80, 60)
81 .register();
82
Simon Hunta1028c42017-02-07 20:08:03 -080083 ssApi.dump();
84 // ----------------------------------------------------------$$$
85 }
86
87 // ----------------------------------------------------------------------
88
89 angular.module('onosSvg')
90 .factory('SpriteDataService', [
91 function () {
92 return {
Steven Burrows1c2a9682017-07-14 16:52:46 +010093 registerCoreSprites: registerCoreSprites,
Simon Hunta1028c42017-02-07 20:08:03 -080094 };
Steven Burrows1c2a9682017-07-14 16:52:46 +010095 },
Simon Hunta1028c42017-02-07 20:08:03 -080096 ]);
97
98}());