• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 *     http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16/// <reference path='./import.ts' />
17class ArkCommonShapeComponent extends ArkComponent implements CommonShapeMethod<ShapeAttribute> {
18  constructor(nativePtr: KNode, classType?: ModifierType) {
19    super(nativePtr, classType);
20  }
21  viewPort(value: {
22    x?: string | number | undefined;
23    y?: string | number | undefined; width?: string | number | undefined;
24    height?: string | number | undefined;
25  }): this {
26    throw new Error('Method not implemented.');
27  }
28  stroke(value: ResourceColor): this {
29    modifierWithKey(this._modifiersWithKeys, StrokeModifier.identity, StrokeModifier, value);
30    return this;
31  }
32  fill(value: ResourceColor): this {
33    modifierWithKey(this._modifiersWithKeys, FillModifier.identity, FillModifier, value);
34    return this;
35  }
36  strokeDashOffset(value: string | number): this {
37    modifierWithKey(this._modifiersWithKeys, StrokeDashOffsetModifier.identity,
38      StrokeDashOffsetModifier, value);
39    return this;
40  }
41  strokeLineCap(value: LineCapStyle): this {
42    modifierWithKey(this._modifiersWithKeys, StrokeLineCapModifier.identity, StrokeLineCapModifier, value);
43    return this;
44  }
45  strokeLineJoin(value: LineJoinStyle): this {
46    modifierWithKey(this._modifiersWithKeys, StrokeLineJoinModifier.identity, StrokeLineJoinModifier, value);
47    return this;
48  }
49  strokeMiterLimit(value: string | number): this {
50    modifierWithKey(this._modifiersWithKeys, StrokeMiterLimitModifier.identity,
51      StrokeMiterLimitModifier, value);
52    return this;
53  }
54  strokeOpacity(value: number | string | Resource): this {
55    modifierWithKey(this._modifiersWithKeys, StrokeOpacityModifier.identity, StrokeOpacityModifier, value);
56    return this;
57  }
58  fillOpacity(value: number | string | Resource): this {
59    modifierWithKey(this._modifiersWithKeys, FillOpacityModifier.identity, FillOpacityModifier, value);
60    return this;
61  }
62  strokeWidth(value: string | number): this {
63    modifierWithKey(this._modifiersWithKeys, StrokeWidthModifier.identity, StrokeWidthModifier, value);
64    return this;
65  }
66  antiAlias(value: boolean): this {
67    modifierWithKey(this._modifiersWithKeys, AntiAliasModifier.identity, AntiAliasModifier, value);
68    return this;
69  }
70  strokeDashArray(value: any[]): this {
71    modifierWithKey(this._modifiersWithKeys, StrokeDashArrayModifier.identity, StrokeDashArrayModifier, value);
72    return this;
73  }
74  mesh(value: any[], column: number, row: number): this {
75    throw new Error('Method not implemented.');
76  }
77  height(value: Length): this {
78    modifierWithKey(this._modifiersWithKeys, CommonShapeHeightModifier.identity, CommonShapeHeightModifier, value);
79    return this;
80  }
81  width(value: Length): this {
82    modifierWithKey(this._modifiersWithKeys, CommonShapeWidthModifier.identity, CommonShapeWidthModifier, value);
83    return this;
84  }
85  foregroundColor(value: string | number | Resource | Color): this {
86    modifierWithKey(
87      this._modifiersWithKeys, CommonShapeForegroundColorModifier.identity, CommonShapeForegroundColorModifier, value);
88    return this;
89  }
90}
91
92class StrokeDashArrayModifier extends ModifierWithKey<object> {
93  constructor(value: object) {
94    super(value);
95  }
96  static identity: Symbol = Symbol('strokeDashArray');
97  applyPeer(node: KNode, reset: boolean): void {
98    if (reset) {
99      getUINativeModule().commonShape.resetStrokeDashArray(node);
100    } else {
101      getUINativeModule().commonShape.setStrokeDashArray(node, this.value);
102    }
103  }
104
105  checkObjectDiff(): boolean {
106    return !isBaseOrResourceEqual(this.stageValue, this.value);
107  }
108}
109
110class StrokeModifier extends ModifierWithKey<ResourceColor> {
111  constructor(value: ResourceColor) {
112    super(value);
113  }
114  static identity: Symbol = Symbol('stroke');
115  applyPeer(node: KNode, reset: boolean): void {
116    if (reset) {
117      getUINativeModule().commonShape.resetStroke(node);
118    } else {
119      getUINativeModule().commonShape.setStroke(node, this.value);
120    }
121  }
122
123  checkObjectDiff(): boolean {
124    return !isBaseOrResourceEqual(this.stageValue, this.value);
125  }
126}
127
128class FillModifier extends ModifierWithKey<ResourceColor> {
129  constructor(value: ResourceColor) {
130    super(value);
131  }
132  static identity: Symbol = Symbol('fill');
133  applyPeer(node: KNode, reset: boolean): void {
134    if (reset) {
135      getUINativeModule().commonShape.resetFill(node);
136    } else {
137      getUINativeModule().commonShape.setFill(node, this.value);
138    }
139  }
140
141  checkObjectDiff(): boolean {
142    return !isBaseOrResourceEqual(this.stageValue, this.value);
143  }
144}
145
146class StrokeDashOffsetModifier extends ModifierWithKey<number | string> {
147  constructor(value: number | string) {
148    super(value);
149  }
150  static identity: Symbol = Symbol('strokeDashOffset');
151  applyPeer(node: KNode, reset: boolean): void {
152    if (reset) {
153      getUINativeModule().commonShape.resetStrokeDashOffset(node);
154    } else {
155      getUINativeModule().commonShape.setStrokeDashOffset(node, this.value);
156    }
157  }
158
159  checkObjectDiff(): boolean {
160    return !isBaseOrResourceEqual(this.stageValue, this.value);
161  }
162}
163
164class StrokeLineCapModifier extends ModifierWithKey<number> {
165  constructor(value: number) {
166    super(value);
167  }
168  static identity: Symbol = Symbol('strokeLineCap');
169  applyPeer(node: KNode, reset: boolean): void {
170    if (reset) {
171      getUINativeModule().commonShape.resetStrokeLineCap(node);
172    } else {
173      getUINativeModule().commonShape.setStrokeLineCap(node, this.value);
174    }
175  }
176}
177
178class StrokeLineJoinModifier extends ModifierWithKey<number> {
179  constructor(value: number) {
180    super(value);
181  }
182  static identity: Symbol = Symbol('strokeLineJoin');
183  applyPeer(node: KNode, reset: boolean): void {
184    if (reset) {
185      getUINativeModule().commonShape.resetStrokeLineJoin(node);
186    } else {
187      getUINativeModule().commonShape.setStrokeLineJoin(node, this.value);
188    }
189  }
190}
191
192class StrokeMiterLimitModifier extends ModifierWithKey<number | string> {
193  constructor(value: number | string) {
194    super(value);
195  }
196  static identity: Symbol = Symbol('strokeMiterLimit');
197  applyPeer(node: KNode, reset: boolean): void {
198    if (reset) {
199      getUINativeModule().commonShape.resetStrokeMiterLimit(node);
200    } else {
201      getUINativeModule().commonShape.setStrokeMiterLimit(node, this.value);
202    }
203  }
204}
205
206class FillOpacityModifier extends ModifierWithKey<number | string | Resource> {
207  constructor(value: number | string | Resource) {
208    super(value);
209  }
210  static identity: Symbol = Symbol('FillOpacity');
211  applyPeer(node: KNode, reset: boolean): void {
212    if (reset) {
213      getUINativeModule().commonShape.resetFillOpacity(node);
214    } else {
215      getUINativeModule().commonShape.setFillOpacity(node, this.value);
216    }
217  }
218  checkObjectDiff(): boolean {
219    return !isBaseOrResourceEqual(this.stageValue, this.value);
220  }
221}
222
223class StrokeOpacityModifier extends ModifierWithKey<number | string | Resource> {
224  constructor(value: number | string | Resource) {
225    super(value);
226  }
227  static identity: Symbol = Symbol('StrokeOpacity');
228  applyPeer(node: KNode, reset: boolean): void {
229    if (reset) {
230      getUINativeModule().commonShape.resetStrokeOpacity(node);
231    } else {
232      getUINativeModule().commonShape.setStrokeOpacity(node, this.value);
233    }
234  }
235  checkObjectDiff(): boolean {
236    return !isBaseOrResourceEqual(this.stageValue, this.value);
237  }
238}
239
240class StrokeWidthModifier extends ModifierWithKey<number | string> {
241  constructor(value: number | string) {
242    super(value);
243  }
244  static identity: Symbol = Symbol('strokeWidth');
245  applyPeer(node: KNode, reset: boolean): void {
246    if (reset) {
247      getUINativeModule().commonShape.resetStrokeWidth(node);
248    } else {
249      getUINativeModule().commonShape.setStrokeWidth(node, this.value);
250    }
251  }
252}
253
254class AntiAliasModifier extends ModifierWithKey<boolean> {
255  constructor(value: boolean) {
256    super(value);
257  }
258  static identity: Symbol = Symbol('antiAlias');
259  applyPeer(node: KNode, reset: boolean): void {
260    if (reset) {
261      getUINativeModule().commonShape.resetAntiAlias(node);
262    } else {
263      getUINativeModule().commonShape.setAntiAlias(node, this.value);
264    }
265  }
266}
267
268class CommonShapeHeightModifier extends ModifierWithKey<Length> {
269  constructor(value: Length) {
270    super(value);
271  }
272  static identity: Symbol = Symbol('commonShapeHeight');
273  applyPeer(node: KNode, reset: boolean): void {
274    if (reset) {
275      getUINativeModule().commonShape.resetHeight(node);
276    } else {
277      getUINativeModule().commonShape.setHeight(node, this.value);
278    }
279  }
280  checkObjectDiff(): boolean {
281    return !isBaseOrResourceEqual(this.stageValue, this.value);
282  }
283}
284
285class CommonShapeWidthModifier extends ModifierWithKey<Length> {
286  constructor(value: Length) {
287    super(value);
288  }
289  static identity: Symbol = Symbol('commonShapeWidth');
290  applyPeer(node: KNode, reset: boolean): void {
291    if (reset) {
292      getUINativeModule().commonShape.resetWidth(node);
293    } else {
294      getUINativeModule().commonShape.setWidth(node, this.value);
295    }
296  }
297  checkObjectDiff(): boolean {
298    return !isBaseOrResourceEqual(this.stageValue, this.value);
299  }
300}
301
302class CommonShapeForegroundColorModifier extends ModifierWithKey<string | number | Resource | Color> {
303  constructor(value: string | number | Resource | Color) {
304    super(value);
305  }
306  static identity: Symbol = Symbol('commonShapeForegroundColor');
307  applyPeer(node: KNode, reset: boolean): void {
308    if (reset) {
309      getUINativeModule().commonShape.resetForegroundColor(node);
310    } else {
311      getUINativeModule().commonShape.setForegroundColor(node, this.value);
312    }
313  }
314  checkObjectDiff(): boolean {
315    return !isBaseOrResourceEqual(this.stageValue, this.value);
316  }
317}