summaryrefslogtreecommitdiff
path: root/labs/lab02_simpleRGB/RGBComponent.java
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2017-02-06 11:41:36 -0500
committerAlexander Pickering <alexandermpickering@gmail.com>2017-02-06 11:41:36 -0500
commit89cdf3efb49335e7c07a68a5a64657eeec2288a6 (patch)
treecdc0fd8165e65b1637fa54cac11c932acefc8a89 /labs/lab02_simpleRGB/RGBComponent.java
downloadcoe0445-master.tar.gz
coe0445-master.tar.bz2
coe0445-master.zip
Inital commitHEADmaster
Diffstat (limited to 'labs/lab02_simpleRGB/RGBComponent.java')
-rw-r--r--labs/lab02_simpleRGB/RGBComponent.java46
1 files changed, 46 insertions, 0 deletions
diff --git a/labs/lab02_simpleRGB/RGBComponent.java b/labs/lab02_simpleRGB/RGBComponent.java
new file mode 100644
index 0000000..8a1576e
--- /dev/null
+++ b/labs/lab02_simpleRGB/RGBComponent.java
@@ -0,0 +1,46 @@
+import java.awt.Color;
+import java.awt.Graphics;
+import java.awt.Graphics2D;
+import java.awt.geom.Line2D;
+
+import javax.swing.JComponent;
+
+@SuppressWarnings("serial")
+public class RGBComponent extends JComponent
+{
+ private SimpleRGB image;
+ private int width;
+ private int height;
+
+ public RGBComponent(SimpleRGB anImage)
+ {
+ image = anImage;
+ width = image.getWidth();
+ height = image.getHeight();
+ }
+
+ public void paintComponent(Graphics g)
+ {
+ Graphics2D g2 = (Graphics2D) g;
+
+ Line2D.Double line = new Line2D.Double(0,0,0,0);
+
+ // Draw the Board
+
+ for(int w = 0; w < width; w++)
+ {
+ for(int h = 0; h < height; h++)
+ {
+ g2.setColor(new Color(image.getRed(w, h), image.getGreen(w, h), image.getBlue(w, h)));
+ line.setLine(w, h, w, h);
+ g2.draw(line);
+ }
+ }
+ }
+
+ public void setImage(SimpleRGB anImage)
+ {
+ image = anImage;
+ repaint();
+ }
+}