FiberSlice.java
Go to the documentation of this file.00001 package theba.core;
00002
00003 import java.awt.Graphics;
00004 import java.awt.Rectangle;
00005 import java.awt.Transparency;
00006 import java.awt.image.BufferedImage;
00007
00014 public class FiberSlice implements Comparable {
00015
00016 private int ox;
00017
00018 private int oy;
00019
00020 private int z;
00021
00022 boolean valid = false;
00023
00024 public short[] lumendata;
00025
00026 BufferedImage image;
00027
00028 boolean isCracked;
00029
00030 double circlish;
00031
00032 int regionSize = -1;
00033
00034 private int id;
00035
00036 public FiberSlice(short[] lumendata, int regsize, double circlish,
00037 boolean isCracked, int z) {
00038 this.lumendata = lumendata;
00039 this.circlish = circlish;
00040 this.isCracked = isCracked;
00041 this.regionSize = regsize;
00042 this.z = z;
00043 }
00044
00045 public FiberSlice(byte[] wall, byte[] lumendata, int width, int height,
00046 Rectangle bounds) {
00047 this.ox = bounds.x;
00048 this.oy = bounds.y;
00049
00050 image = new BufferedImage(bounds.width, bounds.height,
00051 Transparency.TRANSLUCENT);
00052
00053 for (int x = 0; x < bounds.width; x++)
00054 for (int y = 0; y < bounds.height; y++) {
00055
00056 if (wall[(x + ox) + (y + oy) * width] != 0)
00057 image.setRGB(x, y, 0x99ff0000);
00058 if ((lumendata[(x + ox) + (y + oy) * width] & 0xff) > 0)
00059 image.setRGB(x, y, 0x9900ff00);
00060
00061 }
00062
00063 }
00064
00065 public FiberSlice(byte[] bs, byte id, int width, int height,
00066 Rectangle bounds) {
00067
00068 this.ox = bounds.x;
00069 this.oy = bounds.y;
00070
00071 image = new BufferedImage(bounds.width, bounds.height,
00072 Transparency.TRANSLUCENT);
00073
00074 for (int x = 0; x < bounds.width; x++)
00075 for (int y = 0; y < bounds.height; y++) {
00076
00077 int index = x + ox + (y + oy) * width;
00078 if ((bs[index]) == id) {
00079 valid = true;
00080 image.setRGB(x, y, 0x9900ff00);
00081 }
00082 }
00083
00084 }
00085
00086 public FiberSlice(short[] lumendata, int regsize, int z, int fid) {
00087 this.lumendata = lumendata;
00088 this.regionSize = regsize;
00089 this.z = z;
00090 this.id = fid;
00091 }
00092
00093 public int getX() {
00094 return ox;
00095 }
00096
00097 public int getY() {
00098 return oy;
00099 }
00100
00101 public void paint(Graphics g) {
00102 g.drawImage(image, ox, oy, null);
00103 }
00104
00105 public boolean isValid() {
00106 return valid;
00107 }
00108
00109 public void setValid(boolean valid) {
00110 this.valid = valid;
00111 }
00112
00113 public double getCirclish() {
00114 return circlish;
00115 }
00116
00117 public void setCirclish(double circlish) {
00118 this.circlish = circlish;
00119 }
00120
00121 public boolean isCracked() {
00122 return isCracked;
00123 }
00124
00125 public void setCracked(boolean isCracked) {
00126 this.isCracked = isCracked;
00127 }
00128
00129 public short[] getLumendata() {
00130 return lumendata;
00131 }
00132
00133 public void setLumendata(short[] lumendata) {
00134 this.lumendata = lumendata;
00135 }
00136
00137 public int getRegionSize() {
00138 return regionSize;
00139 }
00140
00141 public void setRegionSize(int regionSize) {
00142 this.regionSize = regionSize;
00143 }
00144
00145 public int getZ() {
00146 return z;
00147 }
00148
00149 public void setZ(int z) {
00150 this.z = z;
00151 }
00152
00153 public int getId() {
00154 return id;
00155 }
00156
00157 public void setId(int id) {
00158 this.id = id;
00159 }
00160
00161 public int compareTo(Object o) {
00162 if (o instanceof FiberSlice) {
00163 FiberSlice obj = (FiberSlice) o;
00164 return regionSize - obj.getRegionSize();
00165 }
00166 return 0;
00167 }
00168
00169 }