package pl.vgtworld.imagedraw.filters.emboss;

import java.util.HashMap;
import java.util.Map;

import pl.vgtworld.imagedraw.ImageDrawEntity;
import pl.vgtworld.imagedraw.filters.ImageDrawFilter;
import pl.vgtworld.imagedraw.filters.matrix.MatrixFilter;

public class EmbossFilter implements ImageDrawFilter {
	
	private static final Map<EmbossDirection, float[][]> matrices = new HashMap<>();
	
	private EmbossDirection direction;
	
	private float strength;
	
	static {
		matrices.put(EmbossDirection.LOWER_RIGHT, new float[][] {
				{ -2, -1, 0 },
				{ -1, 1, 1 },
				{ 0, 1, 2 }
		});
		matrices.put(EmbossDirection.LOWER_LEFT, new float[][] {
				{ 0, -1, -2 },
				{ 1, 1, -1 },
				{ 2, 1, 0 }
		});
		matrices.put(EmbossDirection.UPPER_LEFT, new float[][] {
				{ 2, 1, 0 },
				{ 1, 1, -1 },
				{ 0, -1, -2 }
		});
		matrices.put(EmbossDirection.UPPER_RIGHT, new float[][] {
				{ 0, 1, 2 },
				{ -1, 1, 1 },
				{ -2, -1, 0 }
		});
	}
	
	public EmbossFilter(EmbossDirection direction) {
		this.direction = direction;
	}
	
	public EmbossFilter(EmbossDirection direction, float strength) {
		this.direction = direction;
		this.strength = strength;
	}
	
	@Override
	public void doFilter(ImageDrawEntity image, int x, int y, int width, int height) {
		if (direction == null) {
			throw new IllegalStateException("Direction is not defined.");
		}
		float[][] matrix = matrices.get(direction);
		if (strength != 1) {
			MatrixScaleHelper scaleHelper = new MatrixScaleHelper();
			matrix = scaleHelper.scaleMatrix(matrix, strength);
		}
		MatrixFilter filter = new MatrixFilter(matrix);
		filter.doFilter(image, x, y, width, height);
	}
	
}

@@ -248,16 +248,67 @@
 ilter;%0A%0A
+/**%0A * Filter applying emboss effect to image.%0A */%0A
 public c
@@ -996,94 +996,330 @@
 %0A%09%7D%0A
-%09%0A%09public EmbossFilter(EmbossDirection direction) %7B%0A%09%09this.direction = direction;%0A%09%7D%0A%09
+%0A%09/**%0A%09 * Creates filter with custom configuration.%0A%09 * %0A%09 * @param direction Effect direction.%0A%09 */%0A%09public EmbossFilter(EmbossDirection direction) %7B%0A%09%09this.direction = direction;%0A%09%7D%0A%09%0A%09/**%0A%09 * Creates filter with custom configuration.%0A%09 * %0A%09 * @param direction Effect direction.%0A%09 * @param strength Effect strength.%0A%09 */
 %0A%09pu

Add documentation.