コード例 #1
0
        // ===========================================================
        // Getter & Setter
        // ===========================================================

        // ===========================================================
        // Methods for/from SuperClass/Interfaces
        // ===========================================================

        //@SuppressWarnings("deprecation")
        //@Override
        //public override void pack(final BuildableTexture pBuildableTexture, final ArrayList<TextureSourceWithWithLocationCallback> pTextureSourcesWithLocationCallback) throws IllegalArgumentException {
        public /* override */ void Pack(BuildableTexture pBuildableTexture, List <TextureSourceWithLocationCallback> pTextureSourcesWithLocationCallback)
        {
            //Collections.sort(pTextureSourcesWithLocationCallback, TEXTURESOURCE_COMPARATOR);
            pTextureSourcesWithLocationCallback.Sort((IComparer <TextureSourceWithLocationCallback>)TEXTURESOURCE_COMPARER);

            NodeClass root = new NodeClass(new RectClass(0, 0, pBuildableTexture.GetWidth(), pBuildableTexture.GetHeight()));

            int textureSourceCount = pTextureSourcesWithLocationCallback.Count;

            for (int i = 0; i < textureSourceCount; i++)
            {
                TextureSourceWithLocationCallback textureSourceWithLocationCallback = pTextureSourcesWithLocationCallback[i];
                ITextureSource textureSource = textureSourceWithLocationCallback.GetTextureSource();

                NodeClass inserted = root.Insert(textureSource, pBuildableTexture.GetWidth(), pBuildableTexture.GetHeight(), this.mTextureSourceSpacing);

                if (inserted == null)
                {
                    throw new IllegalArgumentException("Could not pack: " + textureSource.ToString());
                }
                TextureSourceWithLocation textureSourceWithLocation = pBuildableTexture.AddTextureSource(textureSource, inserted.mRect.mLeft, inserted.mRect.mTop);
                textureSourceWithLocationCallback.GetCallback().OnCallback(textureSourceWithLocation);
            }
        }