Skip to content

Commit 7617fd4

Browse files
committed
Scale labels with configured label margin
1 parent 6d18990 commit 7617fd4

File tree

3 files changed

+19
-13
lines changed

3 files changed

+19
-13
lines changed

app/utils/elk-layouter.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -257,20 +257,18 @@ export function convertElkToBoxLayout(
257257
zOffset = 0,
258258
depth = 0
259259
): Map<string, BoxLayout> {
260-
const SCALAR = 0.3;
261-
262260
let height = COMPONENT_HEIGHT;
263261
if (elkGraph.id.startsWith(CLASS_PREFIX)) {
264262
height = 5;
265263
}
266264

267265
const boxLayout = new BoxLayout();
268-
boxLayout.positionX = (xOffset + elkGraph.x!) * SCALAR;
266+
boxLayout.positionX = xOffset + elkGraph.x!;
269267
boxLayout.positionY = COMPONENT_HEIGHT * depth;
270-
boxLayout.positionZ = (zOffset + elkGraph.y!) * SCALAR;
268+
boxLayout.positionZ = zOffset + elkGraph.y!;
271269
// Prevent 0 value for width and depth
272-
boxLayout.width = elkGraph.width! * SCALAR || CLASS_FOOTPRINT;
273-
boxLayout.depth = elkGraph.height! * SCALAR || CLASS_FOOTPRINT;
270+
boxLayout.width = elkGraph.width || CLASS_FOOTPRINT;
271+
boxLayout.depth = elkGraph.height || CLASS_FOOTPRINT;
274272
boxLayout.height = height;
275273

276274
// Landscape and applications are on the same level

app/utils/settings/default-settings.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,10 @@ export const defaultVizSettings: VisualizationSettings = {
327327
isRangeSetting: true,
328328
},
329329
openedComponentHeight: {
330-
value: 1.5,
330+
value: 7.5,
331331
range: {
332332
min: 0.1,
333-
max: 10.0,
333+
max: 100.0,
334334
step: 0.1,
335335
},
336336
group: 'Layout',
@@ -340,10 +340,10 @@ export const defaultVizSettings: VisualizationSettings = {
340340
isRangeSetting: true,
341341
},
342342
closedComponentHeight: {
343-
value: 6,
343+
value: 20,
344344
range: {
345345
min: 0.1,
346-
max: 20.0,
346+
max: 100,
347347
step: 0.1,
348348
},
349349
group: 'Layout',

app/view-objects/3d/application/component-label-mesh.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import LabelMesh from '../label-mesh';
55
import ComponentMesh from './component-mesh';
66
import FoundationMesh from './foundation-mesh';
77
import K8sMesh from '../k8s/k8s-mesh';
8+
import { getStoredNumberSetting } from 'explorviz-frontend/utils/settings/local-storage-settings';
89

910
export default class ComponentLabelMesh extends LabelMesh {
1011
minHeight: number;
@@ -35,8 +36,7 @@ export default class ComponentLabelMesh extends LabelMesh {
3536
*/
3637
computeLabel(
3738
componentMesh: ComponentMesh | FoundationMesh | K8sMesh,
38-
labelText = this.labelText,
39-
scalar = 1
39+
labelText = this.labelText
4040
) {
4141
/**
4242
* Updates bounding box of geometry and returns respective dimensions
@@ -48,11 +48,19 @@ export default class ComponentLabelMesh extends LabelMesh {
4848
return { x: boxDimensions.x, y: boxDimensions.y, z: boxDimensions.z };
4949
}
5050

51+
let labelMargin;
52+
if (componentMesh instanceof ComponentMesh) {
53+
labelMargin = getStoredNumberSetting('packageLabelMargin') || 0.1;
54+
} else {
55+
labelMargin = getStoredNumberSetting('appLabelMargin') || 0.1;
56+
}
57+
5158
const parentScale = componentMesh.scale;
5259
const parentAspectRatio = parentScale.z / parentScale.x;
5360

5461
// Adjust desired text size with possible scaling
55-
const textSize = (2.0 / parentScale.z) * parentAspectRatio * scalar;
62+
const textSize =
63+
(2.0 / parentScale.z) * parentAspectRatio * (labelMargin / 4);
5664
// Text should look like it is written on the parent's box (no height required)
5765
const textHeight = 0.0;
5866

0 commit comments

Comments
 (0)