/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package jgrow;
/**
*
* @author maryam
*/
public class InfoBonds {
public double []bondMatrix;
public String []names;
int bondSize = 0;
double gse=1;
public int size() {
return bondSize;
}
public void reset() {
bondSize = 0;
names = null;
bondMatrix = null;
}
public boolean editBond(String [] sts, String newName, int index) {
double [] entries = new double[sts.length];
for(int i=0; i<sts.length; i++) {
try {
entries[i] = Double.parseDouble(sts[i]);
} catch(Exception e) {
e.printStackTrace();
return false;
}
}
for(int i = 0; i<entries.length; i++) {
bondMatrix[i+bondSize*index] = entries[i];
}
for(int i = 0; i<entries.length; i++) {
bondMatrix[index+bondSize*i] = entries[i];
}
names[index] = newName;
return true;
}
public boolean addBond(String [] sts, String newName) {
double [] entries = new double[sts.length];
for(int i=0; i<sts.length; i++) {
try {
entries[i] = Double.parseDouble(sts[i]);
} catch(Exception e) {
e.printStackTrace();
return false;
}
}
return addBond(entries, newName);
}
public boolean addBond(double [] entries, String newName) {
if(newName == null) return false;
if(bondSize == 0) {
bondMatrix = new double[1];
names = new String[1];
} else {
double [] old = bondMatrix;
String [] oldNames = names;
bondMatrix = new double[(bondSize+1)*(bondSize+1)];
names = new String[bondSize+1];
for(int i=0,j=0; i<old.length; i++) {
bondMatrix[i+j] = old[i];
if(i%bondSize == bondSize-1) {
bondMatrix[i+j+1] = entries[j];
j++;
}
}
for(int i=0; i<oldNames.length; i++) {
names[i] = oldNames[i];
}
}
names[bondSize] = newName;
for(int i = 0; i<entries.length; i++) {
bondMatrix[i+bondSize*(bondSize+1)] = entries[i];
}
bondSize++;
return true;
}
public boolean isEmpty() {
return bondSize == 0;
}
public double getElementAtIndex(int index) {
return bondMatrix[index];
}
public String getName(int index) {
return names[index];
}
public void setGse(double newGse) {
gse = newGse;
}
}
# |
Change |
User |
Description |
Committed |
|
#2
|
7857 |
renat_bekbolatov |
sync |
|
|
#1
|
7851 |
renat_bekbolatov |
new files |
|
|