/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package jgrow;
import java.awt.Color;
/**
*
* @author maryam
*/
public class InfoTiles {
int numTiles = 0;
int [] north;
int [] east;
int [] south;
int [] west;
double [] concs;
String [] names;
Color [] colorColor;
int [] colors;
double gmc=0;
public int size() {
return numTiles;
}
public void reset() {
numTiles = 0;
north = null;
east = null;
south = null;
west = null;
concs = null;
names = null;
colorColor = null;
colors = null;
}
public boolean deleteTile(int index) {
if(numTiles == 1) {
reset();
return true;
} else {
numTiles--;
int []old;
old = north;
north = new int[numTiles];
for(int i=0, j=0;i<numTiles; i++,j++) {
if(i==index) j++;
north[i] = old[j];
}
old = east;
east = new int[numTiles];
for(int i=0, j=0;i<numTiles; i++,j++) {
if(i==index) j++;
east[i] = old[j];
}
old = south;
south = new int[numTiles];
for(int i=0, j=0;i<numTiles; i++,j++) {
if(i==index) j++;
south[i] = old[j];
}
old = west;
west = new int[numTiles];
for(int i=0, j=0;i<numTiles; i++,j++) {
if(i==index) j++;
west[i] = old[j];
}
double []oldd = concs;
concs = new double[numTiles];
for(int i=0, j=0;i<numTiles; i++,j++) {
if(i==index) j++;
concs[i] = oldd[j];
}
String []olds = names;
names = new String[numTiles];
for(int i=0, j=0;i<numTiles; i++,j++) {
if(i==index) j++;
names[i] = olds[j];
}
Color[] oldc = colorColor;
colorColor = new Color[numTiles];
for(int i=0, j=0;i<numTiles; i++,j++) {
if(i==index) j++;
colorColor[i] = oldc[j];
}
old = colors;
colors = new int[numTiles];
for(int i=0, j=0;i<numTiles; i++,j++) {
if(i==index) j++;
colors[i] = old[j];
}
return true;
}
}
public boolean editTile(int [] sts,Color col, String concentration,String name, int index) {
double temp;
try {
temp = Double.parseDouble(concentration);
} catch(Exception e) {
e.printStackTrace();
return false;
}
north[index] = sts[0];
east[index] = sts[1];
south[index] = sts[2];
west[index] = sts[3];
names[index] = name;
colorColor[index] = col;
colors[index] = col.getRed() | col.getGreen()*0x100 | col.getBlue()*0x10000;
concs[index] = temp;
return true;
}
public boolean addTile(int [] sts,Color col, String concentration,String name) {
if(numTiles > 0) {
int []old;
old = north;
north = new int[numTiles+1];
for(int i=0;i<numTiles; i++) {
north[i] = old[i];
}
old = east;
east = new int[numTiles+1];
for(int i=0;i<numTiles; i++) {
east[i] = old[i];
}
old = south;
south = new int[numTiles+1];
for(int i=0;i<numTiles; i++) {
south[i] = old[i];
}
old = west;
west = new int[numTiles+1];
for(int i=0;i<numTiles; i++) {
west[i] = old[i];
}
double []oldd = concs;
concs = new double[numTiles+1];
for(int i=0;i<numTiles; i++) {
concs[i] = oldd[i];
}
String []olds = names;
names = new String[numTiles+1];
for(int i=0;i<numTiles; i++) {
names[i] = olds[i];
}
Color[] oldc = colorColor;
colorColor = new Color[numTiles+1];
for(int i=0;i<numTiles; i++) {
colorColor[i] = oldc[i];
}
old = colors;
colors = new int[numTiles+1];
for(int i=0;i<numTiles; i++) {
colors[i] = old[i];
}
} else {
north = new int[1];
east = new int[1];
south = new int[1];
west = new int[1];
concs = new double[1];
names = new String[1];
colorColor = new Color[1];
colors = new int[1];
}
double temp;
try {
temp = Double.parseDouble(concentration);
} catch(Exception e) {
e.printStackTrace();
return false;
}
north[numTiles] = sts[0];
east[numTiles] = sts[1];
south[numTiles] = sts[2];
west[numTiles] = sts[3];
names[numTiles] = name;
colorColor[numTiles] = col;
colors[numTiles] = col.getRed() | col.getGreen()*0x100 | col.getBlue()*0x10000;
concs[numTiles] = temp;
numTiles++;
return true;
}
public boolean addTile(int [] sts,int R,int G,int B, String concentration,String name) {
return addTile(sts,new Color(R,G,B),concentration,name);
}
public boolean isEmpty() {
return numTiles == 0;
}
public void setGmc(double newGmc) {
gmc = newGmc;
}
}
# |
Change |
User |
Description |
Committed |
|
#2
|
7857 |
renat_bekbolatov |
sync |
|
|
#1
|
7851 |
renat_bekbolatov |
new files |
|
|