Add new code new version
[sdc.git] / dox-sequence-diagram-ui / src / main / webapp / lib / ecomp / asdc / sequencer / common / Options.js
1 /*!
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
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
13  * or implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16
17 import _merge from 'lodash/merge';
18
19 import Logger from './Logger';
20
21 /**
22  * A wrapper for an options object. User-supplied options are merged with defaults,
23  * and the result -- runtime options -- are available by calling #getOptions().
24  */
25 export default class Options {
26
27   // ///////////////////////////////////////////////////////////////////////////////////////////////
28
29   /**
30    * Construct options, applying defaults.
31    * @param options optional override options.
32    */
33   constructor(options = {}) {
34     this.options = _merge({}, Options.DEFAULTS, options);
35   }
36
37   // ///////////////////////////////////////////////////////////////////////////////////////////////
38
39   /**
40    * Unwrap options.
41    * @returns {*}
42    */
43   unwrap() {
44     return this.options;
45   }
46 }
47
48 // /////////////////////////////////////////////////////////////////////////////////////////////////
49
50 /**
51  * Default options, overridden by anything of the same name.
52  */
53 Options.DEFAULTS = {
54   log: {
55     level: Logger.WARN,
56   },
57   demo: false,
58   useHtmlSelect: true,
59   diagram: {
60     svg: {
61       x: 0,
62       y: 0,
63       width: 1600,
64       height: 1200,
65       margin: 50,
66       floodColor: '#009fdb',
67       scale: {
68         height: true,
69         width: true,
70         minimum: 0.25,
71       },
72     },
73     title: {
74       height: 0,
75     },
76     metadata: false,
77     lifelines: {
78       header: {
79         height: 225,
80         width: 350,
81         wrapWords: 14,
82         wrapLines: 18,
83         maxLines: 5,
84       },
85       occurrences: {
86         marginTop: 50,
87         marginBottom: 75,
88         foreshortening: 5,
89         width: 50,
90       },
91       spacing: {
92         horizontal: 400,
93         vertical: 400,
94       },
95     },
96     messages: {
97       label: {
98         wrapWords: 14,
99         wrapLines: 18,
100         maxLines: 4,
101       },
102     },
103     fragments: {
104       leftMargin: 150,
105       topMargin: 200,
106       widthMargin: 300,
107       heightMargin: 350,
108       label: {
109         wrapWords: 50,
110         wrapLines: 50,
111         maxLines: 2,
112       },
113     },
114   },
115   validation: {
116     lifeline: {
117       maxLength: 100,
118       defaultValue: '',
119       replace: /[^\-\.\+ &%#@\?\(\)\[\]<>\w\d]/g,
120     },
121     message: {
122       maxLength: 100,
123       defaultValue: '',
124       replace: /[^\-\.\+ &%#@\?\(\)\[\]<>\w\d]/g,
125     },
126     notes: {
127       maxLength: 255,
128       defaultValue: '',
129     },
130     guard: {
131       maxLength: 80,
132       defaultValue: '',
133       replace: /[^\-\.\+ &%#@\?\(\)\[\]<>\w\d]/g,
134     },
135   },
136 };