import java.awt.*; public class LCDTestGraphic { protected int width; protected int height; protected int step; protected int numberOfSteps; protected int outerColumnWidth; protected int innerColumnWidth; protected float stepHeight; protected int rowHeight; protected Image image; protected Graphics graphics; protected Color[] colors; public LCDTestGraphic(int width, int height, Image image, Color[] colors, int numberOfSteps, int rowsPerScreen) { this.width = width; this.height = height; this.colors = colors; this.numberOfSteps = numberOfSteps; outerColumnWidth = width / colors.length; innerColumnWidth = outerColumnWidth / colors.length; outerColumnWidth = innerColumnWidth * colors.length; stepHeight = (float) height / numberOfSteps; rowHeight = height / rowsPerScreen; this.image = image; graphics = (Graphics) image.getGraphics(); step = 0; } public Image getImage() { for (int i = 0; i < colors.length; i++) { graphics.setColor(colors[i]); graphics.fillRect(outerColumnWidth * i, 0, outerColumnWidth, height); } step++; if (step == numberOfSteps) { step = 0; } for (int i = 0; i < colors.length; i++) { graphics.setColor(colors[i]); for (int j = 0; j < colors.length; j++) { graphics.fillRect(outerColumnWidth * j + innerColumnWidth * i, (int) (step * stepHeight), innerColumnWidth, rowHeight); } } return image; } }