diff --git a/app/display/editor/src/main/java/org/csstudio/display/builder/editor/actions/ActionDescription.java b/app/display/editor/src/main/java/org/csstudio/display/builder/editor/actions/ActionDescription.java index 24ea44716c..30416e01b4 100644 --- a/app/display/editor/src/main/java/org/csstudio/display/builder/editor/actions/ActionDescription.java +++ b/app/display/editor/src/main/java/org/csstudio/display/builder/editor/actions/ActionDescription.java @@ -506,7 +506,7 @@ public void run(final DisplayEditor editor, final boolean selected) .mapToInt(w -> w.propWidth().getValue()) .sum(); - final int offset = ( max - min - totalWidth ) / ( N - 1 ); + final double offset = (double) (max - min - totalWidth) / (double) (N - 1); final List sortedWidgets = widgets.stream() .sorted(( w1, w2 ) -> { @@ -550,7 +550,7 @@ else if ( w1x >= w2x && w1x + w1w >= w2x + w2w ) // Equal gap distribution... // ------------------------------------------------------------ Widget widget = sortedWidgets.get(0); - int location = widget.propX().getValue(); + double location = (double) widget.propX().getValue(); int width = widget.propWidth().getValue(); for ( int i = 1; i < N - 1; i++ ) @@ -558,7 +558,7 @@ else if ( w1x >= w2x && w1x + w1w >= w2x + w2w ) widget = sortedWidgets.get(i); location += width + offset; - undo.execute(new SetWidgetPropertyAction<>(widget.propX(), location)); + undo.execute(new SetWidgetPropertyAction<>(widget.propX(), (int) Math.round(location))); width = widget.propWidth().getValue(); } @@ -575,20 +575,20 @@ else if ( offset < 0 ) int location = widget.propX().getValue(); int width = widget.propWidth().getValue(); - final int rightCenter = location + width / 2; + final double rightCenter = (double) location + (double) width / 2.0; widget = sortedWidgets.get(0); location = widget.propX().getValue(); width = widget.propWidth().getValue(); final int leftCenter = location + width / 2; - final int coffset = ( rightCenter - leftCenter ) / ( N - 1 ); + final double coffset = (rightCenter - (double) leftCenter) / (double) (N - 1); for ( int i = 1; i < N - 1; i++ ) { widget = sortedWidgets.get(i); width = widget.propWidth().getValue(); - undo.execute(new SetWidgetPropertyAction<>(widget.propX(), ( leftCenter + i * coffset ) - width / 2)); + undo.execute(new SetWidgetPropertyAction<>(widget.propX(), (int) Math.round((leftCenter + (double) i * coffset - (double) width / 2.0)))); } } } @@ -620,7 +620,7 @@ public void run(final DisplayEditor editor, final boolean selected) .mapToInt(w -> w.propHeight().getValue()) .sum(); - final int offset = ( max - min - totalHeight ) / ( N - 1 ); + final double offset = (double) (max - min - totalHeight ) / (double) (N - 1); final List sortedWidgets = widgets.stream() .sorted(( w1, w2 ) -> { @@ -680,14 +680,14 @@ else if ( w1y >= w2y && w1y + w1h >= w2y + w2h ) // Equal gap distribution... // ------------------------------------------------------------ Widget widget = sortedWidgets.get(0); - int location = widget.propY().getValue(); + double location = widget.propY().getValue(); int height = widget.propHeight().getValue(); for ( int i = 1; i < N - 1; i++ ) { widget = sortedWidgets.get(i); location += height + offset; - undo.execute(new SetWidgetPropertyAction<>(widget.propY(), location)); + undo.execute(new SetWidgetPropertyAction<>(widget.propY(), (int) Math.round(location))); height = widget.propHeight().getValue(); } } @@ -703,19 +703,19 @@ else if ( offset < 0 ) int location = widget.propY().getValue(); int height = widget.propHeight().getValue(); - final int bottomCenter = location + height / 2; + final double bottomCenter = (double) location + (double) height / 2.0; widget = sortedWidgets.get(0); location = widget.propY().getValue(); height = widget.propHeight().getValue(); - final int topCenter = location + height / 2; - final int coffset = ( bottomCenter - topCenter ) / ( N - 1 ); + final double topCenter = (double) location + (double) height / 2.0; + final double coffset = (bottomCenter - topCenter) / (double) (N - 1); for ( int i = 1; i < N - 1; i++ ) { widget = sortedWidgets.get(i); height = widget.propHeight().getValue(); - undo.execute(new SetWidgetPropertyAction<>(widget.propY(), ( topCenter + i * coffset ) - height / 2)); + undo.execute(new SetWidgetPropertyAction<>(widget.propY(), (int) Math.round((topCenter + (double) i * coffset - (double) height / 2.0)))); } } }