Newer
Older
package nloc;
import java.util.ArrayList;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
public class Channel extends NlocEntity implements Comparable<Channel> {
private int pSteps, hSteps;
private List<Channel> parents;
private SortedSet<Channel> children;
private List<Droplet> dropletList;
public Channel(int pSteps, int hSteps) {
super();
this.pSteps = pSteps;
this.hSteps = hSteps;
this.parents = new ArrayList<Channel>();
this.dropletList = new ArrayList<Droplet>();
}
public boolean containsDroplets() {
return !dropletList.isEmpty();
}
public int getLastDropletDistance() {
int minDist = Integer.MAX_VALUE;
if (!this.containsDroplets()) {
minDist = -1;
} else {
for (Droplet dr : dropletList) {
int dist = dr.getPosition().getSteps();
if (dist < minDist) {
minDist = dist;
}
}
}
return minDist;
}
public void removeDroplet(Droplet droplet) {
dropletList.remove(droplet);
}
public void addDroplet(Droplet droplet) {
dropletList.add(droplet);
}
public void setDropletList(List<Droplet> dropletList) {
this.dropletList = dropletList;
}
protected void setHSteps(int hSteps) {
this.hSteps = hSteps;
}
protected void setPSteps(int pSteps) {
this.pSteps = pSteps;
}
public int getPSteps() {
return pSteps;
}
public int getHSteps() {
return hSteps;
}
public void addChild(Channel child) {
if (!children.contains(child)) {
children.add(child);
child.addParent(this);
}
}
public void addParent(Channel parent) {
if (!parents.contains(parent)) {
parents.add(parent);
parent.addChild(this);
}
}
public List<Channel> getChildrenList() {
return Arrays.asList(children.toArray(new Channel[0]));
}
public List<Channel> getParents() {
return parents;
}
public boolean isBifurcation() {
return children.size() > 1;
}
public boolean isTeeIntersect() {
return parents.size() > 1;
}