public void layoutContainer(Container target) {
        //Let's make a local copy of components to avoid concurrent modification
        //which could happen if someone adds something to the layout outside
        //of the EDT. This is faster than do any synchronization or brute force
        //exception catching
        LinkedList<Component> components = (LinkedList) this.components.clone();
        int numberOfItems = this.numberOfItems;
        
        recalculateCarosel();
        // these variables hold the position where we can draw components
        // taking into account insets
        Insets insets = target.getInsets();
        int    width  = target.getSize().width - (insets.left + insets.right);
        int    height = target.getSize().height - (insets.top + insets.bottom);
        
        //No longer calculate the width based on prefered sizes, we're going to control 
        //it by the component not the content'
        int widestWidth = neutralContentWidth;
        int highestHeight = 0;
                
        width -= widestWidth;
        
 
        int    radiusX = width /2;
        int    radiusY = radiusX/3;
        Dimension radius = getCarouselRadius(target,insets,width,height,widestWidth);
        if (radius!=null){
            radiusX = radius.width;
            radiusY = radius.height;
        }
        
        Point  center = calculateCenter(insets,width,height,widestWidth);
        int    centerX = center.x;
        int    centerY = center.y;
        
        //Go through each visible component and set the scale and z-order, and eventually the bounds
        //Need to protected against other things adding components at the same time
        Iterator i = components.iterator();
        int p = 0;
        CaroselPosition z_order[] = new CaroselPosition[numberOfItems];
        while (i.hasNext()){
            Component comp = (Component) i.next();
            CaroselPosition position = getPosition(comp);
            double finalAngle = position.getAngle()+this.rotationalOffset;
            
            double x = (Math.sin(finalAngle) * (double) radiusX)+(double) centerX;
            double y = (Math.cos(finalAngle) * (double) radiusY)+(double) centerY;
            
            double initialWidth = (double) comp.getPreferredSize().width;
            double initialHeight = ((double) comp.getPreferredSize().height) * (initialWidth / (double) comp.getPreferredSize().width);
            
            double s = getScale(finalAngle, x,y,(double) centerX, (double) centerY);//(y / (double) centerY);
            double boundsWidth = initialWidth * s;
            double boundsHeight = initialHeight * s;
            
            if (!shouldHide(comp, finalAngle,s)){
                //Even scaling only to avoid windows jitter...
                int finalWidth = (int)boundsWidth / 1;
                int finalHeight = (int)boundsHeight / 1;
                finalWidth = (int) finalWidth & 0xFFFFFFFE;
                finalHeight = (int) finalHeight & 0xFFFFFFFE;
                comp.setBounds((int)x - ((int)boundsWidth/2),(int) y - ((int)boundsHeight /2),finalWidth, finalHeight);
            } else {
                comp.setBounds(-100,-100,32,32);
            }
                        
            position.setZ(s);
            z_order[p++] = position;
        }
        
        //Now sort out the z, we may need to cache the dimensions, do the z and then reset the bounds, see what happens on redraw first
        //bubble sort is actually very fast for a small number of items, and this layout shouldn't be used for loads.
        boolean swaps = true;
        int     limit = numberOfItems-1;
        while (swaps){
            swaps = false;
            for (int j=0;j<limit;j++){
                if (z_order[j].getZ()<z_order[j+1].getZ()){
                    CaroselPosition temp = z_order[j+1];
                    z_order[j+1]=z_order[j];
                    z_order[j]=temp;
                    swaps=true;
                }
            }
            limit--;
            //We must be done if we hit the bottom
            if (limit==0){
                swaps=false;
            }
        }
        
        //Re-order everything (yet as little as possible :-)
        for (int j=0;j<numberOfItems;j++){
            if (target.getComponentZOrder(z_order[j].getComponent())!=j){
                target.setComponentZOrder(z_order[j].getComponent(),j);
            }
        }
    }