Buggy code:
public class CircuitGenerator { @ AllArgsConstructor private class PointBinder { @ Getter @ Setter Point p1 ; @ Getter @ Setter Point p2 ; } @ AllArgsConstructor private class Entry { Point point ; int length ; int vitesse ; int distanceEntreBagage ; Boolean autoGeneration ; } @ Getter @ Setter private VueHall vueHall ; @ Getter @ Setter private Hall hall ; @ Setter private HashMap < Point , Noeud > listePointsNoeuds ; @ Setter private Circuit circuit ; @ Getter @ Setter private List < CircuitGenerator . PointBinder > listOfSegement ; @ Getter @ Setter private List < CircuitGenerator . Entry > listOfEntrys ; @ Getter @ Setter private List < Point > listOfExits ; @ Getter @ Setter private List < Chariot > listOfChariot ; private HashMap < Chariot , Integer > mapOfChariot ; private HashMap < Integer , ElementCircuit > mapOfElems ; private LinkedList < Rail > listOfRail ; public CircuitGenerator ( VueHall vh ) { } public VueRail createSegment ( Point pointEntree , Point pointSortie ) { } public VueRail generateSegment ( Point pointEntree , Point pointSortie ) { Noeud noeudDebut = listePointsNoeuds . get ( pointEntree ) ; Noeud noeudFin = listePointsNoeuds . get ( pointSortie ) ; if ( noeudDebut == null ) { noeudDebut = createNode ( pointEntree ) . getNoeud ( ) ; } if ( noeudFin == null ) { noeudFin = createNode ( pointSortie ) . getNoeud ( ) ; } VueRail vueR = new VueRail ( vueHall ) ; vueHall . ajouterVue ( vueR , 0 ) ; Geom geom = new Geom ( ) ; vueR . setAngle ( ( ( float ) ( ( ( geom . getAngleSegment ( pointEntree , pointSortie ) ) * 180 ) // ( Math . PI ) ) ) ) ; Point centre = new Point ( ( ( ( pointSortie . x ) + ( pointEntree . x ) ) // 2 ) , ( ( ( pointSortie . y ) + ( pointEntree . y ) ) // 2 ) ) ; vueR . setX ( centre . x ) ; vueR . setY ( centre . y ) ; vueR . setWidth ( ( ( ( int ) ( Math . sqrt ( ( ( Math . pow ( ( ( centre . x ) - ( pointEntree . x ) ) , 2 ) ) + ( Math . pow ( ( ( centre . y ) - ( pointEntree . y ) ) , 2 ) ) ) ) ) ) * 2 ) ) ; Rail railAssocie = new Rail ( ) ; railAssocie . setNoeudPrecedent ( noeudDebut ) ; railAssocie . setNoeudSuivant ( noeudFin ) ; circuit . getElements ( ) . add ( railAssocie ) ; railAssocie . setParent ( circuit ) ; vueR . setRail ( railAssocie ) ; <START_BUG> railAssocie . setLength ( ( ( ( int ) ( Math . sqrt ( ( ( Math . pow ( ( ( centre . x ) - ( pointEntree . x ) ) , 2 ) ) + ( Math . pow ( ( ( centre . y ) - ( pointEntree . y ) ) , 2 ) ) ) ) ) ) * 4 ) ) ; <END_BUG> noeudDebut . addRailSortie ( railAssocie ) ; ViewSelector . getInstance ( ) . setKernelView ( railAssocie , vueR ) ; mapOfElems . put ( noeudDebut . getId ( ) , noeudDebut ) ; mapOfElems . put ( noeudFin . getId ( ) , noeudFin ) ; mapOfElems . put ( railAssocie . getId ( ) , railAssocie ) ; return vueR ; } private VueEmbranchement createNode ( Point point ) { } public VueTapisRoulant createEntry ( Point point , int length , int vitesse , int distanceEntreBagage , Boolean autoGeneration ) { } public VueTapisRoulant generateEntry ( Point point , int length , int vitesse , int distanceEntreBagage , Boolean autoGeneration ) { } public VueToboggan createExit ( Point point ) { } public VueToboggan generateExit ( Point point ) { } public VueChariot addChariot ( Noeud noeud , int maxMoveDistance , int length , Noeud destination , Bagage bagage , LinkedList < ElementCircuit > cheminPrevu ) { } public VueChariot addChariot ( Rail rail , int maxMoveDistance , int length , int position , Noeud destination , Bagage bagage , LinkedList < ElementCircuit > cheminPrevu ) { } private VueChariot generateChariot ( Noeud noeud , int maxMoveDistance , int length , Noeud destination , Bagage bagage , LinkedList < ElementCircuit > cheminPrevu ) { } private VueChariot generateChariot ( Rail rail , int maxMoveDistance , int length , int position , Noeud destination , Bagage bagage , LinkedList < ElementCircuit > cheminPrevu ) { } private void replaceNode ( Point point , Noeud noeud ) { } public void generateAll ( VueHall vueHall ) { } }

Fix:
railAssocie . setLength ( ( ( ( ( int ) ( Math . sqrt ( ( ( Math . pow ( ( ( centre . x ) - ( pointEntree . x ) ) , 2 ) ) + ( Math . pow ( ( ( centre . y ) - ( pointEntree . y ) ) , 2 ) ) ) ) ) ) * 4 ) - ( 2 * ( VueEmbranchement . defaultSizeOfNode ) ) ) ) ;