blob: 6e6d7fae697dbf6aeb42e18246cf750a9dbdae31 [file] [log] [blame]
Steven Burrowsad74af82017-04-28 15:27:19 -04001/*
2 * Copyright 2017-present 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/*
18 ONOS GUI -- Topo2LinkLabel
19 A label positioned at the center point of a link
20 usage: new LinkLabel({text, icon}, DOM Element, Link);
21 */
22
23(function () {
24
25 angular.module('ovTopo2')
26 .factory('Topo2LinkLabel', [
27 'Topo2Label', 'Topo2ZoomService',
28 function (Label, t2zs) {
29 return Label.extend({
30 className: 'topo2-linklabel',
31 maxHeight: 30,
32 minHeight: 20,
33 setPosition: function () {
34 var link = this.options.link;
35 this.set({
36 x: (link.source.x + link.target.x) / 2,
37 y: (link.source.y + link.target.y) / 2
38 });
39 },
40 setScale: function () {
41 this.content.style('transform',
42 'scale(' + t2zs.adjustmentScale(20, 30) + ')');
43 }
44 });
45 }
46 ]);
47})();