@Test public void testAddingImageOnlyWiderThanAtlasWithPaddingReturnsNull() { assertNull(GENERATOR.addImage(96, 1, "image")); }
@Nullable public Result addImage(final int imageWidth, final int imageHeight, @Nonnull final String imageName) { if (imageWidth < 0) { throw new IllegalArgumentException("image width must be non-negative"); } else if (imageHeight < 0) { throw new IllegalArgumentException("image height must be non-negative"); } if (! shouldAddImage(imageWidth, imageHeight)) { return null; } Node node = root.insert(imageWidth, imageHeight, atlasPadding); if (node == null) { return null; } rectangleMap.put(imageName, node); return new Result(node.rect.x, node.rect.y, imageWidth, imageHeight); }
TextureAtlasGenerator { @Nullable public Result addImage(final int imageWidth, final int imageHeight, @Nonnull final String imageName) { if (imageWidth < 0) { throw new IllegalArgumentException("image width must be non-negative"); } else if (imageHeight < 0) { throw new IllegalArgumentException("image height must be non-negative"); } if (! shouldAddImage(imageWidth, imageHeight)) { return null; } Node node = root.insert(imageWidth, imageHeight, atlasPadding); if (node == null) { return null; } rectangleMap.put(imageName, node); return new Result(node.rect.x, node.rect.y, imageWidth, imageHeight); } }
TextureAtlasGenerator { @Nullable public Result addImage(final int imageWidth, final int imageHeight, @Nonnull final String imageName) { if (imageWidth < 0) { throw new IllegalArgumentException("image width must be non-negative"); } else if (imageHeight < 0) { throw new IllegalArgumentException("image height must be non-negative"); } if (! shouldAddImage(imageWidth, imageHeight)) { return null; } Node node = root.insert(imageWidth, imageHeight, atlasPadding); if (node == null) { return null; } rectangleMap.put(imageName, node); return new Result(node.rect.x, node.rect.y, imageWidth, imageHeight); } TextureAtlasGenerator(final int atlasWidth,
                               final int atlasHeight,
                               final int atlasPadding,
                               final float atlasTolerance); }
TextureAtlasGenerator { @Nullable public Result addImage(final int imageWidth, final int imageHeight, @Nonnull final String imageName) { if (imageWidth < 0) { throw new IllegalArgumentException("image width must be non-negative"); } else if (imageHeight < 0) { throw new IllegalArgumentException("image height must be non-negative"); } if (! shouldAddImage(imageWidth, imageHeight)) { return null; } Node node = root.insert(imageWidth, imageHeight, atlasPadding); if (node == null) { return null; } rectangleMap.put(imageName, node); return new Result(node.rect.x, node.rect.y, imageWidth, imageHeight); } TextureAtlasGenerator(final int atlasWidth,
                               final int atlasHeight,
                               final int atlasPadding,
                               final float atlasTolerance); @Nullable Result addImage(final int imageWidth, final int imageHeight, @Nonnull final String imageName); boolean shouldAddImage(final int imageWidth, final int imageHeight); @Nullable Result removeImage(@Nonnull final String name); int getAtlasWidth(); int getAtlasHeight(); @Nonnull List<Result> rebuild(
      final int width,
      final int height); void reset(); }
TextureAtlasGenerator { @Nullable public Result addImage(final int imageWidth, final int imageHeight, @Nonnull final String imageName) { if (imageWidth < 0) { throw new IllegalArgumentException("image width must be non-negative"); } else if (imageHeight < 0) { throw new IllegalArgumentException("image height must be non-negative"); } if (! shouldAddImage(imageWidth, imageHeight)) { return null; } Node node = root.insert(imageWidth, imageHeight, atlasPadding); if (node == null) { return null; } rectangleMap.put(imageName, node); return new Result(node.rect.x, node.rect.y, imageWidth, imageHeight); } TextureAtlasGenerator(final int atlasWidth,
                               final int atlasHeight,
                               final int atlasPadding,
                               final float atlasTolerance); @Nullable Result addImage(final int imageWidth, final int imageHeight, @Nonnull final String imageName); boolean shouldAddImage(final int imageWidth, final int imageHeight); @Nullable Result removeImage(@Nonnull final String name); int getAtlasWidth(); int getAtlasHeight(); @Nonnull List<Result> rebuild(
      final int width,
      final int height); void reset();  }