home *** CD-ROM | disk | FTP | other *** search
- package jclass.util;
-
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Image;
- import java.awt.image.MemoryImageSource;
-
- public class JCImageCreator {
- protected int curRow;
- protected int width;
- protected int height;
- protected int[] colorMap;
- protected int[] pixels;
- protected Component comp;
-
- public JCImageCreator(Component var1, int var2, int var3) {
- this(var1);
- this.setSize(var2, var3);
- }
-
- public JCImageCreator(Component var1) {
- this.colorMap = new int[256];
- this.colorMap[32] = 0;
- this.comp = var1;
- }
-
- public synchronized void clear() {
- if (this.width != 0 && this.height != 0) {
- this.pixels = new int[this.width * this.height];
- }
-
- this.curRow = 0;
- }
-
- public synchronized Image create() {
- if (this.pixels == null) {
- return null;
- } else {
- MemoryImageSource var1 = new MemoryImageSource(this.width, this.height, this.pixels, 0, this.width);
- Image var2 = this.comp.createImage(var1);
- return JCUtilConverter.waitForImage(this.comp, var2) ? var2 : null;
- }
- }
-
- public synchronized Image create(String[] var1) {
- this.clear();
- this.setPixels(var1);
- return this.create();
- }
-
- public synchronized void setColor(char var1, int var2) {
- if (var1 < 256) {
- this.colorMap[var1] = var2;
- }
-
- }
-
- public synchronized void setColor(char var1, Color var2) {
- this.setColor(var1, var2.getRGB());
- }
-
- public synchronized void setSize(int var1, int var2) {
- if (var1 != this.width || var2 != this.height) {
- this.width = var1;
- this.height = var2;
- if (var1 == 0 && var2 == 0) {
- this.pixels = null;
- } else {
- this.pixels = new int[var1 * var2];
- }
- }
- }
-
- public synchronized void setPixels(String[] var1) {
- for(int var2 = 0; var2 < var1.length && var2 < this.height; ++var2) {
- this.setPixels(this.curRow++, var1[var2]);
- }
-
- }
-
- public synchronized void setPixels(String var1) {
- this.setPixels(this.curRow++, var1);
- }
-
- public synchronized void setPixels(int var1, String var2) {
- if (var2.length() == this.width) {
- int var3 = 0;
-
- for(int var4 = var1 * this.width; var3 < this.width; ++var3) {
- this.pixels[var3 + var4] = this.colorMap[var2.charAt(var3)];
- }
-
- }
- }
- }
-