// Path: src/dk/cego/spritemapper/guillotine/OptimalGuillotineLayouter.java
// public class OptimalGuillotineLayouter extends OptimalLayouter {
//     public OptimalGuillotineLayouter() {
//         FreeSpaceChooser freeSpaceChoosers[] = new FreeSpaceChooser[] {
//             new BestFitChooser(),
//             new BestShortSideChooser(),
//             new BestLongSideChooser(),
//             new TopLeftChooser()
//         };
//         FreeSpaceSplitStrategy splitStrategies[] = new FreeSpaceSplitStrategy[] {
//             new LongestAxisSplitStrategy(),
//             new ShortestAxisSplitStrategy(),
//             new LongestLeftoverAxisSplitStrategy(),
//             new ShortestLeftoverAxisSplitStrategy(),
//             new MaximumAreaDifferenceSplitStrategy(),
//             new MinimumAreaDifferenceSplitStrategy()
//         };
// 
//         for (FreeSpaceChooser chooser : freeSpaceChoosers) {
//             for (FreeSpaceSplitStrategy splitStrategy : splitStrategies) {
//                 add(new GuillotineLayouter().setFreeSpaceChooser(chooser).setFreeSpaceSplitStrategy(splitStrategy));
//             }
//         }
//     }
// }
// 
// Path: src/dk/cego/spritemapper/shelf/ShelfLayouter.java
// public class ShelfLayouter extends SpriteLayouter {
// 	private final static int MAX_HEIGHT = 1024 * 1024 * 1024;
// 	
//     public int layout(int maxWidth, int maxHeight, List<Sprite> sprites) {
//     	if (sprites.isEmpty()) {
//     		return 0;
//     	}
//     	
//         if (maxHeight == 0) {
//             maxHeight = MAX_HEIGHT;
//         }
//         
//         int x = 0, y = 0, nextY = 0;
//         int spacing = getSpacing();
//         
//         int mapNumber = 0;
// 
//         for (Sprite s : sprites) {
//             if (x + s.w > maxWidth) {
//                 // try to rotate sprite.
//                 if (x + s.h <= maxWidth) {
//                     s.rotate();
//                 } else {
//                     x = 0;
//                     y = nextY;
// 
//                     if (s.w > maxWidth && s.h <= maxWidth) {
//                         s.rotate();
//                     }
//                 }
//             }
// 
//             s.x = x;
//             s.y = y;
//             s.mapNumber = mapNumber;
//             
//             x = s.right() + spacing;
//             nextY = Math.max(nextY, s.bottom() + spacing);
//             
//             if (nextY > maxHeight) {
//             	if ((s.w > maxWidth && s.w > maxHeight) || (s.h > maxWidth && s.h > maxHeight)) {
//             		throw new RuntimeException("No free space can be found.");
//             	}
//             	
//             	mapNumber++;
//             	s.x = 0;
//             	s.y = 0;
//             	s.mapNumber = mapNumber;
//             	
//             	x = s.right() + spacing;
//             	nextY = s.bottom();
//             }
//         }
//         
//         mapNumber++;
//         return mapNumber;
//     }
// 
//     public String toString() {
//         return "Shelf()";
//     }
// }
// 
// Path: src/dk/cego/spritemapper/maxrects/OptimalMaxRectsLayouter.java
// public class OptimalMaxRectsLayouter extends OptimalLayouter {
//     public OptimalMaxRectsLayouter() {
//         FreeSpaceChooser freeSpaceChoosers[] = new FreeSpaceChooser[] {
//             new BestFitChooser(),
//             new BestShortSideChooser(),
//             new BestLongSideChooser(),
//             new TopLeftChooser()
//         };
//         for (FreeSpaceChooser chooser : freeSpaceChoosers) {
//             add(new MaxRectsLayouter().setFreeSpaceChooser(chooser));
//         }
//     }
// }


import dk.cego.spritemapper.guillotine.OptimalGuillotineLayouter;
import dk.cego.spritemapper.shelf.ShelfLayouter;
import dk.cego.spritemapper.maxrects.OptimalMaxRectsLayouter;
import java.util.Map;
import java.util.TreeMap;
/**
 * Copyright (C) 2011 CEGO ApS
 * Written by Robert Larsen <robert@komogvind.dk> for CEGO ApS
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package dk.cego.spritemapper;



/**
 * This layouter knows all the different algorithms and chooses
 * the best one for the specific set of sprites.
 */
public class OptimalAlgorithmLayouter extends OptimalLayouter {
	private Map<String, SpriteLayouter> layouterNames;

    public OptimalAlgorithmLayouter() {
    	layouterNames = new TreeMap<String, SpriteLayouter>();
// Path: src/dk/cego/spritemapper/guillotine/OptimalGuillotineLayouter.java
// public class OptimalGuillotineLayouter extends OptimalLayouter {
//     public OptimalGuillotineLayouter() {
//         FreeSpaceChooser freeSpaceChoosers[] = new FreeSpaceChooser[] {
//             new BestFitChooser(),
//             new BestShortSideChooser(),
//             new BestLongSideChooser(),
//             new TopLeftChooser()
//         };
//         FreeSpaceSplitStrategy splitStrategies[] = new FreeSpaceSplitStrategy[] {
//             new LongestAxisSplitStrategy(),
//             new ShortestAxisSplitStrategy(),
//             new LongestLeftoverAxisSplitStrategy(),
//             new ShortestLeftoverAxisSplitStrategy(),
//             new MaximumAreaDifferenceSplitStrategy(),
//             new MinimumAreaDifferenceSplitStrategy()
//         };
// 
//         for (FreeSpaceChooser chooser : freeSpaceChoosers) {
//             for (FreeSpaceSplitStrategy splitStrategy : splitStrategies) {
//                 add(new GuillotineLayouter().setFreeSpaceChooser(chooser).setFreeSpaceSplitStrategy(splitStrategy));
//             }
//         }
//     }
// }
// 
// Path: src/dk/cego/spritemapper/shelf/ShelfLayouter.java
// public class ShelfLayouter extends SpriteLayouter {
// 	private final static int MAX_HEIGHT = 1024 * 1024 * 1024;
// 	
//     public int layout(int maxWidth, int maxHeight, List<Sprite> sprites) {
//     	if (sprites.isEmpty()) {
//     		return 0;
//     	}
//     	
//         if (maxHeight == 0) {
//             maxHeight = MAX_HEIGHT;
//         }
//         
//         int x = 0, y = 0, nextY = 0;
//         int spacing = getSpacing();
//         
//         int mapNumber = 0;
// 
//         for (Sprite s : sprites) {
//             if (x + s.w > maxWidth) {
//                 // try to rotate sprite.
//                 if (x + s.h <= maxWidth) {
//                     s.rotate();
//                 } else {
//                     x = 0;
//                     y = nextY;
// 
//                     if (s.w > maxWidth && s.h <= maxWidth) {
//                         s.rotate();
//                     }
//                 }
//             }
// 
//             s.x = x;
//             s.y = y;
//             s.mapNumber = mapNumber;
//             
//             x = s.right() + spacing;
//             nextY = Math.max(nextY, s.bottom() + spacing);
//             
//             if (nextY > maxHeight) {
//             	if ((s.w > maxWidth && s.w > maxHeight) || (s.h > maxWidth && s.h > maxHeight)) {
//             		throw new RuntimeException("No free space can be found.");
//             	}
//             	
//             	mapNumber++;
//             	s.x = 0;
//             	s.y = 0;
//             	s.mapNumber = mapNumber;
//             	
//             	x = s.right() + spacing;
//             	nextY = s.bottom();
//             }
//         }
//         
//         mapNumber++;
//         return mapNumber;
//     }
// 
//     public String toString() {
//         return "Shelf()";
//     }
// }
// 
// Path: src/dk/cego/spritemapper/maxrects/OptimalMaxRectsLayouter.java
// public class OptimalMaxRectsLayouter extends OptimalLayouter {
//     public OptimalMaxRectsLayouter() {
//         FreeSpaceChooser freeSpaceChoosers[] = new FreeSpaceChooser[] {
//             new BestFitChooser(),
//             new BestShortSideChooser(),
//             new BestLongSideChooser(),
//             new TopLeftChooser()
//         };
//         for (FreeSpaceChooser chooser : freeSpaceChoosers) {
//             add(new MaxRectsLayouter().setFreeSpaceChooser(chooser));
//         }
//     }
// }


// Path: src/dk/cego/spritemapper/OptimalAlgorithmLayouter.java
import dk.cego.spritemapper.guillotine.OptimalGuillotineLayouter;
import dk.cego.spritemapper.shelf.ShelfLayouter;
import dk.cego.spritemapper.maxrects.OptimalMaxRectsLayouter;
import java.util.Map;
import java.util.TreeMap;

/**
 * Copyright (C) 2011 CEGO ApS
 * Written by Robert Larsen <robert@komogvind.dk> for CEGO ApS
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
package dk.cego.spritemapper;



/**
 * This layouter knows all the different algorithms and chooses
 * the best one for the specific set of sprites.
 */
public class OptimalAlgorithmLayouter extends OptimalLayouter {
	private Map<String, SpriteLayouter> layouterNames;

    public OptimalAlgorithmLayouter() {
    	layouterNames = new TreeMap<String, SpriteLayouter>();
    	layouterNames.put("guillotine", new OptimalGuillotineLayouter());