if (s == null) return;
    public void paintTrain(Graphics g, TrainModel train) {        TrainPath s = train.getPosition();        //renderer engine.        renderWagon(g, s, 0, train.getEngineType(), true);	int n = train.getNumberOfWagons() + 1;        //renderer wagons.				        for (int i = 1; i < n; i++) {            int wagonType = train.getWagon(i - 1);            renderWagon(g, s, i, wagonType, false);        }    }