@@ -506,7 +506,7 @@ public void run(final DisplayEditor editor, final boolean selected)
506506 .mapToInt (w -> w .propWidth ().getValue ())
507507 .sum ();
508508
509- final int offset = ( max - min - totalWidth ) / ( N - 1 );
509+ final double offset = (double ) ( max - min - totalWidth ) / (double ) ( N - 1 );
510510 final List <Widget > sortedWidgets = widgets .stream ()
511511 .sorted (( w1 , w2 ) ->
512512 {
@@ -550,15 +550,15 @@ else if ( w1x >= w2x && w1x + w1w >= w2x + w2w )
550550 // Equal gap distribution...
551551 // ------------------------------------------------------------
552552 Widget widget = sortedWidgets .get (0 );
553- int location = widget .propX ().getValue ();
553+ double location = ( double ) widget .propX ().getValue ();
554554 int width = widget .propWidth ().getValue ();
555555
556556 for ( int i = 1 ; i < N - 1 ; i ++ )
557557 {
558558 widget = sortedWidgets .get (i );
559559 location += width + offset ;
560560
561- undo .execute (new SetWidgetPropertyAction <>(widget .propX (), location ));
561+ undo .execute (new SetWidgetPropertyAction <>(widget .propX (), ( int ) Math . round ( location ) ));
562562
563563 width = widget .propWidth ().getValue ();
564564 }
@@ -575,20 +575,20 @@ else if ( offset < 0 )
575575 int location = widget .propX ().getValue ();
576576 int width = widget .propWidth ().getValue ();
577577
578- final int rightCenter = location + width / 2 ;
578+ final double rightCenter = ( double ) location + ( double ) width / 2.0 ;
579579
580580 widget = sortedWidgets .get (0 );
581581 location = widget .propX ().getValue ();
582582 width = widget .propWidth ().getValue ();
583583
584584 final int leftCenter = location + width / 2 ;
585- final int coffset = ( rightCenter - leftCenter ) / ( N - 1 );
585+ final double coffset = (rightCenter - ( double ) leftCenter ) / ( double ) ( N - 1 );
586586
587587 for ( int i = 1 ; i < N - 1 ; i ++ )
588588 {
589589 widget = sortedWidgets .get (i );
590590 width = widget .propWidth ().getValue ();
591- undo .execute (new SetWidgetPropertyAction <>(widget .propX (), ( leftCenter + i * coffset ) - width / 2 ));
591+ undo .execute (new SetWidgetPropertyAction <>(widget .propX (), (int ) Math . round (( leftCenter + ( double ) i * coffset - ( double ) width / 2.0 )) ));
592592 }
593593 }
594594 }
@@ -620,7 +620,7 @@ public void run(final DisplayEditor editor, final boolean selected)
620620 .mapToInt (w -> w .propHeight ().getValue ())
621621 .sum ();
622622
623- final int offset = ( max - min - totalHeight ) / ( N - 1 );
623+ final double offset = (double ) ( max - min - totalHeight ) / (double ) ( N - 1 );
624624 final List <Widget > sortedWidgets = widgets .stream ()
625625 .sorted (( w1 , w2 ) ->
626626 {
@@ -680,14 +680,14 @@ else if ( w1y >= w2y && w1y + w1h >= w2y + w2h )
680680 // Equal gap distribution...
681681 // ------------------------------------------------------------
682682 Widget widget = sortedWidgets .get (0 );
683- int location = widget .propY ().getValue ();
683+ double location = widget .propY ().getValue ();
684684 int height = widget .propHeight ().getValue ();
685685
686686 for ( int i = 1 ; i < N - 1 ; i ++ )
687687 {
688688 widget = sortedWidgets .get (i );
689689 location += height + offset ;
690- undo .execute (new SetWidgetPropertyAction <>(widget .propY (), location ));
690+ undo .execute (new SetWidgetPropertyAction <>(widget .propY (), ( int ) Math . round ( location ) ));
691691 height = widget .propHeight ().getValue ();
692692 }
693693 }
@@ -703,19 +703,19 @@ else if ( offset < 0 )
703703 int location = widget .propY ().getValue ();
704704 int height = widget .propHeight ().getValue ();
705705
706- final int bottomCenter = location + height / 2 ;
706+ final double bottomCenter = ( double ) location + ( double ) height / 2.0 ;
707707
708708 widget = sortedWidgets .get (0 );
709709 location = widget .propY ().getValue ();
710710 height = widget .propHeight ().getValue ();
711711
712- final int topCenter = location + height / 2 ;
713- final int coffset = ( bottomCenter - topCenter ) / ( N - 1 );
712+ final double topCenter = ( double ) location + ( double ) height / 2.0 ;
713+ final double coffset = (bottomCenter - topCenter ) / ( double ) ( N - 1 );
714714 for ( int i = 1 ; i < N - 1 ; i ++ )
715715 {
716716 widget = sortedWidgets .get (i );
717717 height = widget .propHeight ().getValue ();
718- undo .execute (new SetWidgetPropertyAction <>(widget .propY (), ( topCenter + i * coffset ) - height / 2 ));
718+ undo .execute (new SetWidgetPropertyAction <>(widget .propY (), (int ) Math . round (( topCenter + ( double ) i * coffset - ( double ) height / 2.0 )) ));
719719 }
720720 }
721721 }
0 commit comments