From 89cdf3efb49335e7c07a68a5a64657eeec2288a6 Mon Sep 17 00:00:00 2001 From: Alexander Pickering Date: Mon, 6 Feb 2017 11:41:36 -0500 Subject: Inital commit --- labs/lab02_simpleRGB/RGBComponent.java | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 labs/lab02_simpleRGB/RGBComponent.java (limited to 'labs/lab02_simpleRGB/RGBComponent.java') 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(); + } +} -- cgit v1.2.3-70-g09d2