Skip to content

Commit

Permalink
automated resize of components
Browse files Browse the repository at this point in the history
  • Loading branch information
r0light committed Mar 11, 2024
1 parent 3908d0d commit bc1f831
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/core/qualitymodel/specifications/qualitymodel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ export const qualityModel: QualityModelSpec = {
},
"storageReplicationLevel": {
"name": "Storage Replication level",
"calculation": "",
"calculation": "The average value of replicas per storage backing service",
"sources": ["Guerron2020", "Souza2016"]
},
"servicePortability": {
Expand Down
25 changes: 25 additions & 0 deletions src/modeling/views/ModelingArea.vue
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,31 @@ onMounted(() => {
'element:contextmenu': function (cellView, evt, x, y) {
cellView.showTools();
},
"element:pointerup": function (elementView, evt) {
if (elementView.model.isEmbedded()) {
// make sure there is enough space for embedded elements
let parent = elementView.model.getParentCell() as dia.Element;
let availableArea = parent.size().height * parent.size().width;
let childrenArea = parent.getEmbeddedCells().map(cell => (cell as dia.Element).size().height * (cell as dia.Element).size().width * 1.5).reduce((accumulator, currentValue) => { return accumulator + currentValue},0);
if (childrenArea >= availableArea * 0.3) {
let newWidth = parent.size().width + 100;
let oldHeight = parent.size().height;
let newHeight = oldHeight;
if (parent.prop("entity/type") !== EntityTypes.INFRASTRUCTURE) {
// ensure aspect ratio except for infrastructure
const defaultEntitySize = parent.prop("defaults/size");
const aspectRatio = defaultEntitySize.height / defaultEntitySize.width;
newHeight = Number((aspectRatio * (newWidth as number)).toFixed(2));
}
parent.resize(newWidth as number, newHeight, { deep: true });
parent.position(parent.position().x - 50, parent.position().y - (newHeight - oldHeight) * 0.5);
}
}
},
"link:pointerclick": function (linkView: dia.LinkView, evt) {
removeHighlightingFromAllLinks();
Expand Down
9 changes: 6 additions & 3 deletions src/modeling/views/detailsSidebar/DetailsSidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -671,15 +671,18 @@ function onEnterProperty(propertyOptions: EditPropertySection[]) {
selectedEntityElement.position(selectedEntityElement.position().x, propertyOption.value as number, { deep: true, restrictedArea: props.paper.getArea() });
break;
case "entity-width":
let newWidth = propertyOption.value;
let currentWidth = selectedEntityElement.size().width;
let newWidth = propertyOption.value as number;
let oldHeight = selectedEntityElement.size().height;
let updatedHeight = oldHeight;
if (selectedEntityElement.prop("entity/type") !== EntityTypes.INFRASTRUCTURE) {
// ensure aspect ratio except for infrastructure
const defaultEntitySize = selectedEntityElement.prop("defaults/size");
const aspectRatio = defaultEntitySize.height / defaultEntitySize.width;
oldHeight = Number((aspectRatio * (newWidth as number)).toFixed(2));
updatedHeight = Number((aspectRatio * (newWidth as number)).toFixed(2));
}
selectedEntityElement.resize(newWidth as number, oldHeight, { deep: true });
selectedEntityElement.resize(newWidth as number, updatedHeight, { deep: true });
selectedEntityElement.position(selectedEntityElement.position().x - (newWidth - currentWidth) * 0.5, selectedEntityElement.position().y - (updatedHeight - oldHeight) * 0.5);
break;
case "entity-height":
let newHeight = propertyOption.value;
Expand Down

0 comments on commit bc1f831

Please sign in to comment.