Ejemplo n.º 1
0
    public ImageContainer PopImageContainers(int n)
    {
        ImageContainer t          = top;
        ImageContainer popStart   = null;
        ImageContainer lastPopped = null;
        int            i          = 0;

        while (t != null && i++ < n)
        {
            if (lastPopped == null)
            {
                popStart = t;
            }
            lastPopped = t;
            //they are already linked so ne need to link them again
            //just move the top down
            top = top.getNext();
            //reduce the total perimeter in the image bank
            this.perimeter -= t.getWidth();
            this.totalContainers--;
            t = t.getNext();
        }
        if (lastPopped != null)
        {
            lastPopped.setNext(null);            //to terminate the list
        }
        return(popStart);
    }
Ejemplo n.º 2
0
    private int MakeImageContainerListAndComputePerimeter(Album album)
    {
        int total = 0;
//		ImageContainer top=null;
        ImageContainer last = null;

        this.perimeter = 0;
        for (int i = 0; i < album.photoList.Length; i++)
        {
            Photo          photo            = album.photoList[i];
            double         normalizedWidth  = (photo.width / this.largestWidthOfAPhoto) * maxWidth;
            double         normalizedHeight = (photo.width / this.largestHeightOfAPhoto) * maxHeight;
            ImageContainer imageContainer   = new ImageContainer(photo, normalizedWidth, normalizedHeight);

            if (last == null)
            {
                top = imageContainer;
            }
            else
            {
                last.setNext(imageContainer);
            }
            last = imageContainer;
            total++;
            this.perimeter += imageContainer.getWidth();
        }
        return(total);
    }