public TextureAtlas(int width, int height) { this.atlasWidth = width; this.atlasHeight = height; root = new Node(0, 0, width, height); locationMap = new TreeMap<String, TextureAtlasTile>(); mapNameMap = new HashMap<String, String>(); }
Node node = root.insert(image); if (node == null) { return false;
Node node = root.insert(image); if (node == null) { return false;
public Node insert(Image image) { if (!isLeaf()) { Node newNode = child[0].insert(image); return child[1].insert(image); } else { if (occupied) { child[0] = new Node(location.getX(), location.getY(), image.getWidth(), location.getHeight()); child[1] = new Node(location.getX() + image.getWidth(), location.getY(), location.getWidth() - image.getWidth(), location.getHeight()); } else { child[0] = new Node(location.getX(), location.getY(), location.getWidth(), image.getHeight()); child[1] = new Node(location.getX(), location.getY() + image.getHeight(), location.getWidth(), location.getHeight() - image.getHeight()); return child[0].insert(image);
public TextureAtlas(int width, int height) { this.atlasWidth = width; this.atlasHeight = height; root = new Node(0, 0, width, height); locationMap = new TreeMap<String, TextureAtlasTile>(); mapNameMap = new HashMap<String, String>(); }
public Node insert(Image image) { if (!isLeaf()) { Node newNode = child[0].insert(image); return child[1].insert(image); } else { if (occupied) { child[0] = new Node(location.getX(), location.getY(), image.getWidth(), location.getHeight()); child[1] = new Node(location.getX() + image.getWidth(), location.getY(), location.getWidth() - image.getWidth(), location.getHeight()); } else { child[0] = new Node(location.getX(), location.getY(), location.getWidth(), image.getHeight()); child[1] = new Node(location.getX(), location.getY() + image.getHeight(), location.getWidth(), location.getHeight() - image.getHeight()); return child[0].insert(image);