From 2b907348d522aab3c652eb5b4b5d0ef7100ef5f6 Mon Sep 17 00:00:00 2001 From: mauriziovitale84 Date: Tue, 25 Oct 2016 10:18:03 +0100 Subject: [PATCH] Add boundary event component --- .../diagram-boundary-event.component.html | 5 ++ .../diagram-boundary-event.component.ts | 54 ++++++++++++++ .../diagrams/boundary-events/index.ts | 25 +++++++ .../diagrams/diagram.component.html | 3 + ...iagram-container-icon-event.component.html | 5 ++ .../diagram-container-icon-event.component.ts | 42 +++++++++++ .../icons/diagram-icon-timer.component.html | 4 ++ .../icons/diagram-icon-timer.component.ts | 56 +++++++++++++++ .../src/components/diagrams/icons/index.ts | 8 ++- .../src/components/diagrams/index.ts | 5 +- .../src/components/raphael/icons/index.ts | 5 +- .../icons/raphael-icon-timer.component.ts | 72 +++++++++++++++++++ 12 files changed, 281 insertions(+), 3 deletions(-) create mode 100644 ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/diagram-boundary-event.component.html create mode 100644 ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/diagram-boundary-event.component.ts create mode 100644 ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/index.ts create mode 100644 ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-container-icon-event.component.html create mode 100644 ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-container-icon-event.component.ts create mode 100644 ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-icon-timer.component.html create mode 100644 ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-icon-timer.component.ts create mode 100644 ng2-components/ng2-activiti-analytics/src/components/raphael/icons/raphael-icon-timer.component.ts diff --git a/ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/diagram-boundary-event.component.html b/ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/diagram-boundary-event.component.html new file mode 100644 index 0000000000..b5eb151f55 --- /dev/null +++ b/ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/diagram-boundary-event.component.html @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/diagram-boundary-event.component.ts b/ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/diagram-boundary-event.component.ts new file mode 100644 index 0000000000..c306de4ba8 --- /dev/null +++ b/ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/diagram-boundary-event.component.ts @@ -0,0 +1,54 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Component, ElementRef, Input, Output, EventEmitter } from '@angular/core'; +import { DiagramColorService } from './../services/diagram-color.service'; + +@Component({ + moduleId: module.id, + selector: 'diagram-boundary-event', + templateUrl: './diagram-boundary-event.component.html', + styleUrls: ['./diagram-boundary-event.component.css'] +}) +export class DiagramBoundaryEventComponent { + @Input() + data: any; + + @Output() + onError = new EventEmitter(); + + center: any = {}; + options: any = {stroke: '', fillColors: '', fillOpacity: '', strokeWidth: 1}; + + circleRadiusInner: number; + circleRadiusOuter: number; + + constructor(public elementRef: ElementRef, + private diagramColorService: DiagramColorService) {} + + ngOnInit() { + this.center.x = this.data.x + (this.data.width / 2); + this.center.y = this.data.y + (this.data.height / 2); + + this.circleRadiusInner = 12; + this.circleRadiusOuter = 15; + + this.options.stroke = this.diagramColorService.getBpmnColor(this.data, DiagramColorService.MAIN_STROKE_COLOR); + this.options.fillColors = this.diagramColorService.getFillColour(this.data.id); + this.options.fillOpacity = this.diagramColorService.getFillOpacity(); + } +} diff --git a/ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/index.ts b/ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/index.ts new file mode 100644 index 0000000000..e42095b039 --- /dev/null +++ b/ng2-components/ng2-activiti-analytics/src/components/diagrams/boundary-events/index.ts @@ -0,0 +1,25 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { DiagramBoundaryEventComponent } from './diagram-boundary-event.component'; + +// primitives +export * from './diagram-boundary-event.component'; + +export const DIAGRAM_BOUNDARY_EVENTS_DIRECTIVES: any[] = [ + DiagramBoundaryEventComponent +]; diff --git a/ng2-components/ng2-activiti-analytics/src/components/diagrams/diagram.component.html b/ng2-components/ng2-activiti-analytics/src/components/diagrams/diagram.component.html index 3d50a010b2..d10c601cc0 100644 --- a/ng2-components/ng2-activiti-analytics/src/components/diagrams/diagram.component.html +++ b/ng2-components/ng2-activiti-analytics/src/components/diagrams/diagram.component.html @@ -37,6 +37,9 @@
+
+ +
diff --git a/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-container-icon-event.component.html b/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-container-icon-event.component.html new file mode 100644 index 0000000000..25b1262bac --- /dev/null +++ b/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-container-icon-event.component.html @@ -0,0 +1,5 @@ +
+
+ +
+
\ No newline at end of file diff --git a/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-container-icon-event.component.ts b/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-container-icon-event.component.ts new file mode 100644 index 0000000000..6939692c60 --- /dev/null +++ b/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-container-icon-event.component.ts @@ -0,0 +1,42 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Component, ElementRef, Input, Output, EventEmitter } from '@angular/core'; +import { DiagramColorService } from './../services/diagram-color.service'; + +@Component({ + moduleId: module.id, + selector: 'diagram-container-icon-event', + templateUrl: './diagram-container-icon-event.component.html', + styleUrls: ['./diagram-container-icon-event.component.css'] +}) +export class DiagramContainerIconEventTaskComponent { + @Input() + data: any; + + @Input() + type: string; + + @Output() + onError = new EventEmitter(); + + constructor(public elementRef: ElementRef, + private diagramColorService: DiagramColorService) {} + + ngOnInit() { + } +} diff --git a/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-icon-timer.component.html b/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-icon-timer.component.html new file mode 100644 index 0000000000..1bb93fff2a --- /dev/null +++ b/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-icon-timer.component.html @@ -0,0 +1,4 @@ + + \ No newline at end of file diff --git a/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-icon-timer.component.ts b/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-icon-timer.component.ts new file mode 100644 index 0000000000..4c3ad4b014 --- /dev/null +++ b/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/diagram-icon-timer.component.ts @@ -0,0 +1,56 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Component, ElementRef, Input, Output, EventEmitter } from '@angular/core'; +import { DiagramColorService } from './../services/diagram-color.service'; + +@Component({ + moduleId: module.id, + selector: 'diagram-icon-timer', + templateUrl: './diagram-icon-timer.component.html', + styleUrls: ['./diagram-icon-timer.component.css'] +}) +export class DiagramIconTimerComponent { + @Input() + data: any; + + @Output() + onError = new EventEmitter(); + + center: any = {}; + position: any; + + circleRadius: number; + + circleOptions: any = {stroke: '', fillColors: '', fillOpacity: '', strokeWidth: ''}; + timerOptions: any = {stroke: '', fillColors: '', fillOpacity: '', strokeWidth: ''}; + + constructor(public elementRef: ElementRef, + private diagramColorService: DiagramColorService) {} + + ngOnInit() { + this.center.x = this.data.x + (this.data.width / 2); + this.center.y = this.data.y + (this.data.height / 2); + this.circleRadius = 10; + this.position = {x: this.data.x + 5, y: this.data.y + 5}; + + this.circleOptions.stroke = 'black' ; + this.circleOptions.fillColors = 'none' ; + this.timerOptions.stroke = 'none' ; + this.timerOptions.fillColors = '#585858' ; + } +} diff --git a/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/index.ts b/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/index.ts index 01585c1b42..8012f75124 100644 --- a/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/index.ts +++ b/ng2-components/ng2-activiti-analytics/src/components/diagrams/icons/index.ts @@ -28,6 +28,8 @@ import { DiagramIconBoxPublishTaskComponent } from './diagram-icon-box-publish-t import { DiagramIconReceiveTaskComponent } from './diagram-icon-receive-task.component'; import { DiagramIconScriptTaskComponent } from './diagram-icon-script-task.component'; import { DiagramIconBusinessRuleTaskComponent } from './diagram-icon-business-rule-task.component'; +import { DiagramContainerIconEventTaskComponent } from './diagram-container-icon-event.component'; +import { DiagramIconTimerComponent } from './diagram-icon-timer.component'; // primitives export * from './diagram-icon-service-task.component'; @@ -43,6 +45,8 @@ export * from './diagram-icon-box-publish-task.component'; export * from './diagram-icon-receive-task.component'; export * from './diagram-icon-script-task.component'; export * from './diagram-icon-business-rule-task.component'; +export * from './diagram-container-icon-event.component'; +export * from './diagram-icon-timer.component'; export const DIAGRAM_ICONS_DIRECTIVES: any[] = [ DiagramIconServiceTaskComponent, @@ -57,5 +61,7 @@ export const DIAGRAM_ICONS_DIRECTIVES: any[] = [ DiagramIconBoxPublishTaskComponent, DiagramIconReceiveTaskComponent, DiagramIconScriptTaskComponent, - DiagramIconBusinessRuleTaskComponent + DiagramIconBusinessRuleTaskComponent, + DiagramContainerIconEventTaskComponent, + DiagramIconTimerComponent ]; diff --git a/ng2-components/ng2-activiti-analytics/src/components/diagrams/index.ts b/ng2-components/ng2-activiti-analytics/src/components/diagrams/index.ts index 983ea885f0..a8ac0e0a49 100644 --- a/ng2-components/ng2-activiti-analytics/src/components/diagrams/index.ts +++ b/ng2-components/ng2-activiti-analytics/src/components/diagrams/index.ts @@ -21,6 +21,7 @@ import { DIAGRAM_ACTIVITIES_DIRECTIVES } from './activities/index'; import { DIAGRAM_EVENTS_DIRECTIVES } from './events/index'; import { DIAGRAM_GATEWAY_DIRECTIVES } from './gateways/index'; import { DIAGRAM_ICONS_DIRECTIVES } from './icons/index'; +import { DIAGRAM_BOUNDARY_EVENTS_DIRECTIVES } from './boundary-events/index'; import { DiagramColorService } from './services/diagram-color.service'; @@ -30,6 +31,7 @@ export * from './events/index'; export * from './activities/index'; export * from './icons/index'; export * from './diagram-sequence-flow.component'; +export * from './boundary-events/index'; export const DIAGRAM_DIRECTIVES: any[] = [ DiagramComponent, @@ -37,7 +39,8 @@ export const DIAGRAM_DIRECTIVES: any[] = [ DIAGRAM_ACTIVITIES_DIRECTIVES, DiagramSequenceFlowComponent, DIAGRAM_GATEWAY_DIRECTIVES, - DIAGRAM_ICONS_DIRECTIVES + DIAGRAM_ICONS_DIRECTIVES, + DIAGRAM_BOUNDARY_EVENTS_DIRECTIVES ]; export const DIAGRAM_PROVIDERS: any[] = [ diff --git a/ng2-components/ng2-activiti-analytics/src/components/raphael/icons/index.ts b/ng2-components/ng2-activiti-analytics/src/components/raphael/icons/index.ts index 8edbc173d8..93d19057b8 100644 --- a/ng2-components/ng2-activiti-analytics/src/components/raphael/icons/index.ts +++ b/ng2-components/ng2-activiti-analytics/src/components/raphael/icons/index.ts @@ -28,6 +28,7 @@ import { RaphaelIconBoxPublishDirective } from './raphael-icon-box-publish.compo import { RaphaelIconReceiveDirective } from './raphael-icon-receive.component'; import { RaphaelIconScriptDirective } from './raphael-icon-script.component'; import { RaphaelIconBusinessRuleDirective } from './raphael-icon-business-rule.component'; +import { RaphaelIconTimerDirective } from './raphael-icon-timer.component'; // primitives export * from './raphael-icon-service.component'; @@ -43,6 +44,7 @@ export * from './raphael-icon-box-publish.component'; export * from './raphael-icon-receive.component'; export * from './raphael-icon-script.component'; export * from './raphael-icon-business-rule.component'; +export * from './raphael-icon-timer.component'; export const RAPHAEL_ICONS_DIRECTIVES: any[] = [ RaphaelIconServiceDirective, @@ -57,5 +59,6 @@ export const RAPHAEL_ICONS_DIRECTIVES: any[] = [ RaphaelIconBoxPublishDirective, RaphaelIconReceiveDirective, RaphaelIconScriptDirective, - RaphaelIconBusinessRuleDirective + RaphaelIconBusinessRuleDirective, + RaphaelIconTimerDirective ]; diff --git a/ng2-components/ng2-activiti-analytics/src/components/raphael/icons/raphael-icon-timer.component.ts b/ng2-components/ng2-activiti-analytics/src/components/raphael/icons/raphael-icon-timer.component.ts new file mode 100644 index 0000000000..22156b044a --- /dev/null +++ b/ng2-components/ng2-activiti-analytics/src/components/raphael/icons/raphael-icon-timer.component.ts @@ -0,0 +1,72 @@ +/*! + * @license + * Copyright 2016 Alfresco Software, Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { Directive, OnInit, ElementRef, Input, Output, EventEmitter } from '@angular/core'; +import { Point } from './../models/point'; +import { RaphaelBase } from './../raphael-base'; +import { RaphaelService } from './../raphael.service'; + +@Directive({selector: 'raphael-icon-timer'}) +export class RaphaelIconTimerDirective extends RaphaelBase implements OnInit { + @Input() + paper: any; + + @Input() + position: Point; + + @Input() + text: string; + + @Output() + onError = new EventEmitter(); + + @Input() + strokeWidth: number; + + @Input() + fillColors: any; + + @Input() + stroke: any; + + @Input() + fillOpacity: any; + + constructor(public elementRef: ElementRef, + raphaelService: RaphaelService) { + super(elementRef, raphaelService); + } + + ngOnInit() { + console.log(this.elementRef); + this.draw(this.position); + } + + public draw(position: Point) { + let path1 = this.paper.path(`M 10 0 C 4.4771525 0 0 4.4771525 0 10 C 0 15.522847 4.4771525 20 10 20 C 15.522847 20 20 15.522847 20 + 10 C 20 4.4771525 15.522847 1.1842379e-15 10 0 z M 9.09375 1.03125 C 9.2292164 1.0174926 9.362825 1.0389311 9.5 1.03125 L 9.5 3.5 + L 10.5 3.5 L 10.5 1.03125 C 15.063526 1.2867831 18.713217 4.9364738 18.96875 9.5 L 16.5 9.5 L 16.5 10.5 L 18.96875 10.5 C 18.713217 + 15.063526 15.063526 18.713217 10.5 18.96875 L 10.5 16.5 L 9.5 16.5 L 9.5 18.96875 C 4.9364738 18.713217 1.2867831 15.063526 1.03125 + 10.5 L 3.5 10.5 L 3.5 9.5 L 1.03125 9.5 C 1.279102 5.0736488 4.7225326 1.4751713 9.09375 1.03125 z M 9.5 5 L 9.5 8.0625 C 8.6373007 + 8.2844627 8 9.0680195 8 10 C 8 11.104569 8.8954305 12 10 12 C 10.931981 12 11.715537 11.362699 11.9375 10.5 L 14 10.5 L 14 9.5 + L 11.9375 9.5 C 11.756642 8.7970599 11.20294 8.2433585 10.5 8.0625 L 10.5 5 L 9.5 5 z`).attr({ + 'stroke': this.stroke, + 'fill': this.fillColors + }); + return path1.transform('T' + position.x + ',' + position.y); + } +}