blob: 23759ab42fad75449a571e914b1b36bbff2eee51 [file] [log] [blame]
Sean Condon83fc39f2018-04-19 18:56:13 +01001/*
2 * Copyright 2015-present Open Networking Foundation
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 */
16import { Injectable } from '@angular/core';
17import { FnService } from '../util/fn.service';
18import { LogService } from '../../log.service';
19
20/**
21 * ONOS GUI -- SVG -- Util Service
22 *
23 * The SVG Util Service provides a miscellany of utility functions.
24 */
Sean Condonfd6d11b2018-06-02 20:29:49 +010025@Injectable({
Bhavesh72ead492018-07-19 16:29:18 +053026 providedIn: 'root',
Sean Condonfd6d11b2018-06-02 20:29:49 +010027})
Sean Condon83fc39f2018-04-19 18:56:13 +010028export class SvgUtilService {
29
30 constructor(
31 private fs: FnService,
32 private log: LogService
33 ) {
34 this.log.debug('SvgUtilService constructed');
35 }
36
Sean Condonfd6d11b2018-06-02 20:29:49 +010037 translate(x: number[], y?: any): string {
Sean Condon83fc39f2018-04-19 18:56:13 +010038 if (this.fs.isA(x) && x.length === 2 && !y) {
39 return 'translate(' + x[0] + ',' + x[1] + ')';
40 }
41 return 'translate(' + x + ',' + y + ')';
42 }
43}