Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial commit

  • Loading branch information...
commit 110034f83b76c262c4b47c1f5304a4f69f99915c 1 parent 33dec37
@leadVisionary authored
View
6 src/com/visionarysoftwaresolutions/picture/BoundingBox.java
@@ -0,0 +1,6 @@
+package com.visionarysoftwaresolutions.picture;
+
+public interface BoundingBox {
+ int getWidth();
+ int getHeight();
+}
View
5 src/com/visionarysoftwaresolutions/picture/Color.java
@@ -0,0 +1,5 @@
+package com.visionarysoftwaresolutions.picture;
+
+public interface Color {
+ Number decimalValue();
+}
View
6 src/com/visionarysoftwaresolutions/picture/Picture.java
@@ -0,0 +1,6 @@
+package com.visionarysoftwaresolutions.picture;
+
+public interface Picture {
+ Pixel[] getContents();
+ BoundingBox getDimensions();
+}
View
7 src/com/visionarysoftwaresolutions/picture/Pixel.java
@@ -0,0 +1,7 @@
+package com.visionarysoftwaresolutions.picture;
+
+
+public interface Pixel {
+ Point2D point();
+ Color color();
+}
View
6 src/com/visionarysoftwaresolutions/picture/Point2D.java
@@ -0,0 +1,6 @@
+package com.visionarysoftwaresolutions.picture;
+
+public interface Point2D {
+ int getX();
+ int getY();
+}
View
25 src/com/visionarysoftwaresolutions/picture/domain/BasicPicture.java
@@ -0,0 +1,25 @@
+package com.visionarysoftwaresolutions.picture.domain;
+
+import com.visionarysoftwaresolutions.picture.BoundingBox;
+import com.visionarysoftwaresolutions.picture.Picture;
+import com.visionarysoftwaresolutions.picture.Pixel;
+
+public class BasicPicture implements Picture {
+ private final BoundingBox dimensions;
+ private final Pixel[] contents;
+
+ public BasicPicture(final BoundingBox dims, final Pixel[] results) {
+ contents = results;
+ dimensions = dims;
+ }
+ @Override
+ public Pixel[] getContents() {
+ return contents;
+ }
+
+ @Override
+ public BoundingBox getDimensions() {
+ return dimensions;
+ }
+
+}
View
26 src/com/visionarysoftwaresolutions/picture/domain/BasicPixel.java
@@ -0,0 +1,26 @@
+package com.visionarysoftwaresolutions.picture.domain;
+
+import com.visionarysoftwaresolutions.picture.Color;
+import com.visionarysoftwaresolutions.picture.Pixel;
+import com.visionarysoftwaresolutions.picture.Point2D;
+
+public class BasicPixel implements Pixel {
+ final Point2D point;
+ final Color color;
+
+ public BasicPixel(final Point2D pt, final Color c) {
+ point = pt;
+ color = c;
+ }
+
+ @Override
+ public Point2D point() {
+ return point;
+ }
+
+ @Override
+ public Color color() {
+ return color;
+ }
+
+}
View
23 src/com/visionarysoftwaresolutions/picture/domain/BasicPoint.java
@@ -0,0 +1,23 @@
+package com.visionarysoftwaresolutions.picture.domain;
+
+import com.visionarysoftwaresolutions.picture.Point2D;
+
+public class BasicPoint implements Point2D {
+ final int x,y;
+
+ public BasicPoint(final int xCordinate, final int yCordinate) {
+ x = xCordinate;
+ y = yCordinate;
+ }
+
+ @Override
+ public int getX() {
+ return x;
+ }
+
+ @Override
+ public int getY() {
+ return y;
+ }
+
+}
View
14 src/com/visionarysoftwaresolutions/picture/domain/RGB.java
@@ -0,0 +1,14 @@
+package com.visionarysoftwaresolutions.picture.domain;
+
+import com.visionarysoftwaresolutions.picture.Color;
+import com.visionarysoftwaresolutions.picture.factories.ColorFactory;
+
+public class RGB implements ColorFactory {
+
+ @Override
+ public Color create(int decimalValue) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
View
29 src/com/visionarysoftwaresolutions/picture/domain/Screen.java
@@ -0,0 +1,29 @@
+package com.visionarysoftwaresolutions.picture.domain;
+
+import com.visionarysoftwaresolutions.picture.BoundingBox;
+
+public class Screen implements BoundingBox {
+ private final int width,height;
+
+ public Screen(final int width, final int height) {
+ this.width = setIfNonNegative(width);
+ this.height = setIfNonNegative(height);
+ }
+
+ private int setIfNonNegative(int number) {
+ if(number < 0) {
+ throw new IllegalArgumentException("cannot have negative dimensions");
+ }
+ return number;
+ }
+
+ @Override
+ public int getWidth() {
+ return width;
+ }
+
+ @Override
+ public int getHeight() {
+ return height;
+ }
+}
View
7 src/com/visionarysoftwaresolutions/picture/factories/ColorFactory.java
@@ -0,0 +1,7 @@
+package com.visionarysoftwaresolutions.picture.factories;
+
+import com.visionarysoftwaresolutions.picture.Color;
+
+public interface ColorFactory {
+ Color create(int decimalValue);
+}
View
9 src/com/visionarysoftwaresolutions/picture/factories/PictureFactory.java
@@ -0,0 +1,9 @@
+package com.visionarysoftwaresolutions.picture.factories;
+
+import com.visionarysoftwaresolutions.picture.BoundingBox;
+import com.visionarysoftwaresolutions.picture.Picture;
+import com.visionarysoftwaresolutions.picture.Pixel;
+
+public interface PictureFactory {
+ Picture create(BoundingBox dimensions, Pixel[] pixels);
+}
View
11 src/com/visionarysoftwaresolutions/picture/factories/PixelFactory.java
@@ -0,0 +1,11 @@
+package com.visionarysoftwaresolutions.picture.factories;
+
+import com.visionarysoftwaresolutions.picture.BoundingBox;
+import com.visionarysoftwaresolutions.picture.Color;
+import com.visionarysoftwaresolutions.picture.Pixel;
+import com.visionarysoftwaresolutions.picture.Point2D;
+
+public interface PixelFactory {
+ Pixel create(Point2D place, Color value);
+ Pixel[] pixels(BoundingBox captured);
+}
View
11 test/com/visionarysoftwaresolutions/picture/BasicPictureFactory.java
@@ -0,0 +1,11 @@
+package com.visionarysoftwaresolutions.picture;
+
+import com.visionarysoftwaresolutions.picture.domain.BasicPicture;
+import com.visionarysoftwaresolutions.picture.factories.PictureFactory;
+
+class BasicPictureFactory implements PictureFactory {
+ @Override
+ public Picture create(BoundingBox dimensions, Pixel[] pixels) {
+ return new BasicPicture(dimensions, pixels);
+ }
+}
View
33 test/com/visionarysoftwaresolutions/picture/PictureFactoryTests.java
@@ -0,0 +1,33 @@
+package com.visionarysoftwaresolutions.picture;
+
+import static org.junit.Assert.*;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.visionarysoftwaresolutions.picture.Picture;
+import com.visionarysoftwaresolutions.picture.Pixel;
+import com.visionarysoftwaresolutions.picture.domain.BasicPixel;
+import com.visionarysoftwaresolutions.picture.domain.Screen;
+import com.visionarysoftwaresolutions.picture.factories.PictureFactory;
+
+public class PictureFactoryTests {
+ PictureFactory toTest;
+ int width, height;
+ BoundingBox dims;
+ Pixel[] results;
+
+ @Before
+ public void setup() {
+ width = 200;
+ height = 200;
+ dims = new Screen(width,height);
+ results = new BasicPixel[width+height];
+ toTest = new BasicPictureFactory();
+ }
+ @Test
+ public void canGetAPictureFromADimensionAndByteArray() {
+ Picture result = toTest.create(dims, results);
+ assertNotNull(result);
+ }
+}
View
24 test/com/visionarysoftwaresolutions/picture/domain/PictureTests.java
@@ -0,0 +1,24 @@
+package com.visionarysoftwaresolutions.picture.domain;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+
+import com.visionarysoftwaresolutions.picture.BoundingBox;
+import com.visionarysoftwaresolutions.picture.Picture;
+import com.visionarysoftwaresolutions.picture.Pixel;
+import com.visionarysoftwaresolutions.picture.domain.BasicPicture;
+import com.visionarysoftwaresolutions.picture.domain.BasicPixel;
+import com.visionarysoftwaresolutions.picture.domain.Screen;
+
+public class PictureTests {
+ @Test
+ public void canCreateAPicture() {
+ int width = 200, height = 200;
+ BoundingBox dim = new Screen(width, height);
+ Pixel[] pix = new BasicPixel[width*height*3];
+ Picture toTest = new BasicPicture(dim,pix);
+ assertEquals(dim, toTest.getDimensions());
+ assertArrayEquals(pix, toTest.getContents());
+ }
+}
Please sign in to comment.
Something went wrong with that request. Please try again.