From d1607e4767fcc6264b5796fef7101852e942b6c3 Mon Sep 17 00:00:00 2001 From: TeterinaSvetlana <40786685+TeterinaSvetlana@users.noreply.github.com> Date: Thu, 13 Feb 2020 15:39:23 +0500 Subject: [PATCH 1/6] Change actors size with proportions --- addon/components/fd-uml-diagram.js | 23 ++++++++++++-- .../uml-primitives/fd-uml-primitive.js | 3 ++ .../uml-primitives/fd-uml-usecase-actor.js | 30 +++++++++++++++++++ 3 files changed, 53 insertions(+), 3 deletions(-) diff --git a/addon/components/fd-uml-diagram.js b/addon/components/fd-uml-diagram.js index f66968c0f..697d53927 100644 --- a/addon/components/fd-uml-diagram.js +++ b/addon/components/fd-uml-diagram.js @@ -595,9 +595,25 @@ export default Component.extend({ const shift = data.shift; if (data.widthResize || data.heightResize) { const oldSize = data.ghost.size(); - const position = data.ghost.position(); - let coordinates = forPointerMethodOverrideResizeAndDnd(evt, x, y); - data.ghost.resize(data.widthResize ? Math.max(coordinates.x - position.x, view.model.attributes.inputWidth || 0, view.model.attributes.minWidth || 0) : oldSize.width, data.heightResize ? Math.max(coordinates.y - position.y, view.model.attributes.inputHeight || 0, view.model.attributes.minHeight || 0) : oldSize.height); + let newSize = { + width: oldSize.width, + height: oldSize.height + }; + if (data.prop) { + if (data.widthResize && data.heightResize) { + newSize.width = x - view.model.getBBox().x; + } else { + if (data.widthResize) { + newSize.width = x - view.model.getBBox().x + } + if (data.heightResize) { + newSize.height = y - view.model.getBBox().y + } + } + let propHeight = newSize.height + ((newSize.width - oldSize.width) / oldSize.width) * newSize.height; + let propWidth = newSize.width + ((newSize.height - oldSize.height) / oldSize.height) * newSize.width; + data.ghost.resize(propWidth, propHeight); + } } else { data.ghost.position(x + shift.x, y + shift.y); } @@ -621,6 +637,7 @@ export default Component.extend({ const button = $(evt.target.parentElement); evt.data.widthResize = button.hasClass('right-down-size-button') || button.hasClass('right-size-button'); evt.data.heightResize = button.hasClass('right-down-size-button') || button.hasClass('down-size-button'); + evt.data.prop = button.hasClass('prop'); evt.data.shift = { x: bbox.x - x, y: bbox.y - y}; } }, diff --git a/addon/objects/uml-primitives/fd-uml-primitive.js b/addon/objects/uml-primitives/fd-uml-primitive.js index ee2f72b94..4e1800686 100644 --- a/addon/objects/uml-primitives/fd-uml-primitive.js +++ b/addon/objects/uml-primitives/fd-uml-primitive.js @@ -435,6 +435,9 @@ joint.shapes.flexberry.uml.PrimitiveElementView = joint.dia.ElementView.extend({ buttons.addObjects(sizeChangers); buttons.forEach(button => { let style = {}; + if (button.name.contains(' ')) { + button.name = button.name.replace(' ', '.'); + } style[`.${get(button, 'name')}`] = get(button, 'attrs.element'); style[`.${get(button, 'name')}>circle`] = get(button, 'attrs.circle'); style[`.${get(button, 'name')}>text`] = get(button, 'attrs.text'); diff --git a/addon/objects/uml-primitives/fd-uml-usecase-actor.js b/addon/objects/uml-primitives/fd-uml-usecase-actor.js index 7d02f219e..6224e2ffd 100644 --- a/addon/objects/uml-primitives/fd-uml-usecase-actor.js +++ b/addon/objects/uml-primitives/fd-uml-usecase-actor.js @@ -4,6 +4,7 @@ import { computed } from '@ember/object'; import { isArray } from '@ember/array'; import $ from 'jquery'; +import { A } from '@ember/array'; import FdUmlElement from './fd-uml-element'; import { BaseObject } from './fd-uml-baseobject'; @@ -108,10 +109,39 @@ joint.shapes.flexberry.uml.UsecaseActorView = joint.shapes.flexberry.uml.BaseObj '' ].join(''), + getSizeChangers() { + return A([{ + name: 'right-size-button prop', + text: '', + attrs: { + 'element': { 'ref-dx': 0, 'ref-y': 0.5, 'ref': '.joint-highlight-stroke' }, + 'circle': { r: 6, fill: '#007aff', stroke: '#007aff', 'stroke-width': 1 }, + 'text': { fill: '#ffffff','font-size': 10, 'text-anchor': 'middle', x: 0.5, y: 3.5, 'font-family': 'Icons' }, + } + }, { + name: 'right-down-size-button prop', + text: '', + attrs: { + 'element': { 'ref-dx': 0, 'ref-dy': 0, 'ref': '.joint-highlight-stroke' }, + 'circle': { r: 6, fill: '#007aff', stroke: '#007aff', 'stroke-width': 1 }, + 'text': { fill: '#ffffff','font-size': 10, 'text-anchor': 'middle', x: 0.5, y: 3.5, 'transform': 'rotate(45)', 'font-family': 'Icons' }, + } + }, { + name: 'down-size-button prop', + text: '', + attrs: { + 'element': { 'ref-x': 0.5, 'ref-dy': 0, 'ref': '.joint-highlight-stroke' }, + 'circle': { r: 6, fill: '#007aff', stroke: '#007aff', 'stroke-width': 1 }, + 'text': { fill: '#ffffff','font-size': 10, 'text-anchor': 'middle', x: 0, y: 3.5, 'font-family': 'Icons' }, + } + }]); + }, + updateRectangles: function (resizedWidth, resizedHeight) { const minWidth = this.model.attributes.minWidth; const minHeight = this.model.attributes.minHeight; const oldSize = this.model.size(); + this.getSizeChangers(); let newHeight = Math.max( resizedHeight || oldSize.height, minHeight) let newWidth = Math.max( resizedWidth || oldSize.width, minWidth) From cdbdb330790a5f0587a60844c2542d2d18f3838b Mon Sep 17 00:00:00 2001 From: TeterinaSvetlana <40786685+TeterinaSvetlana@users.noreply.github.com> Date: Thu, 13 Feb 2020 18:31:18 +0500 Subject: [PATCH 2/6] Fix error --- addon/components/fd-uml-diagram.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addon/components/fd-uml-diagram.js b/addon/components/fd-uml-diagram.js index 697d53927..738e9e0a9 100644 --- a/addon/components/fd-uml-diagram.js +++ b/addon/components/fd-uml-diagram.js @@ -613,6 +613,10 @@ export default Component.extend({ let propHeight = newSize.height + ((newSize.width - oldSize.width) / oldSize.width) * newSize.height; let propWidth = newSize.width + ((newSize.height - oldSize.height) / oldSize.height) * newSize.width; data.ghost.resize(propWidth, propHeight); + } else { + const position = data.ghost.position(); + let coordinates = forPointerMethodOverrideResizeAndDnd(evt, x, y); + data.ghost.resize(data.widthResize ? Math.max(coordinates.x - position.x, view.model.attributes.inputWidth || 0, view.model.attributes.minWidth || 0) : oldSize.width, data.heightResize ? Math.max(coordinates.y - position.y, view.model.attributes.inputHeight || 0, view.model.attributes.minHeight || 0) : oldSize.height); } } else { data.ghost.position(x + shift.x, y + shift.y); From 9b5689359bde8d27cc0203708dbce021d08c1fe1 Mon Sep 17 00:00:00 2001 From: TeterinaSvetlana <40786685+TeterinaSvetlana@users.noreply.github.com> Date: Tue, 18 Feb 2020 11:54:07 +0500 Subject: [PATCH 3/6] Feature 629 usecase diagram elements appearance --- .../fd-actions-for-ucd-primitives.js | 2 +- addon/objects/uml-primitives/fd-uml-note.js | 11 ++++++++++- addon/objects/uml-primitives/fd-uml-use-case.js | 17 +++++++++++++++++ 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/addon/mixins/actions-for-primitives/fd-actions-for-ucd-primitives.js b/addon/mixins/actions-for-primitives/fd-actions-for-ucd-primitives.js index a37a7760e..8deb23924 100644 --- a/addon/mixins/actions-for-primitives/fd-actions-for-ucd-primitives.js +++ b/addon/mixins/actions-for-primitives/fd-actions-for-ucd-primitives.js @@ -47,7 +47,7 @@ export default Mixin.create({ let jsonObject = getJsonForElement( 'STORMCASE.UML.ucd.Actor, UMLUCD', { x, y }, - { width: 25, height: 50 }, + { width: 5, height: 60 }, { Name: '' } ); let usecaseActorObject = fdUseCaseActor.create({ primitive: jsonObject }); diff --git a/addon/objects/uml-primitives/fd-uml-note.js b/addon/objects/uml-primitives/fd-uml-note.js index c1fba61b8..2ba9936af 100644 --- a/addon/objects/uml-primitives/fd-uml-note.js +++ b/addon/objects/uml-primitives/fd-uml-note.js @@ -95,8 +95,17 @@ joint.util.setByPath(joint.shapes, 'flexberry.uml.Note', Note, '.'); joint.shapes.flexberry.uml.NoteView = joint.shapes.flexberry.uml.BaseObjectView.extend({ template: [ '