this.drawBasic = function() {
var borderColor;
if (this.parent.getExclusive()) {
if (this.parent.getOpenStatus()) {
borderColor = this.readyColor;
} else {
borderColor = this.waitingColor;
}
} else {
borderColor = this.neutralColor;
}
//if (this.parent.getComponentType() != "Path") {
if (this.isJourney) {
globalCTX.strokeStyle = borderColor;
globalCTX.beginPath();
if (this.innode) {
globalCTX.moveTo(this.x1-5-globalBaseX+0.5,this.y1-5-globalBaseY+0.5);
globalCTX.lineTo(this.x1+4-globalBaseX+0.5,this.y1-5-globalBaseY+0.5);
globalCTX.lineTo(this.x1+4-globalBaseX+0.5,this.y1+4-globalBaseY+0.5);
globalCTX.lineTo(this.x1-5-globalBaseX+0.5,this.y1+4-globalBaseY+0.5);
globalCTX.lineTo(this.x1-5-globalBaseX+0.5,this.y1-5-globalBaseY+0.5);
} else { //outnode
globalCTX.moveTo(this.x2-5-globalBaseX+0.5,this.y2-5-globalBaseY+0.5);
globalCTX.lineTo(this.x2+4-globalBaseX+0.5,this.y2-5-globalBaseY+0.5);
globalCTX.lineTo(this.x2+4-globalBaseX+0.5,this.y2+4-globalBaseY+0.5);
globalCTX.lineTo(this.x2-5-globalBaseX+0.5,this.y2+4-globalBaseY+0.5);
globalCTX.lineTo(this.x2-5-globalBaseX+0.5,this.y2-5-globalBaseY+0.5);
}
globalCTX.stroke();
//do nothing
} else if (!this.isPath) {
var runningHeight = 15;
globalCTX.strokeStyle = borderColor;
globalCTX.beginPath();
globalCTX.moveTo(this.x1-globalBaseX+0.5,this.y1-globalBaseY+0.5);
globalCTX.lineTo(this.x2-globalBaseX+0.5,this.y1-globalBaseY+0.5);
globalCTX.lineTo(this.x2-globalBaseX+0.5,this.y2-globalBaseY+0.5);
globalCTX.lineTo(this.x1-globalBaseX+0.5,this.y2-globalBaseY+0.5);
globalCTX.lineTo(this.x1-globalBaseX+0.5,this.y1-globalBaseY+0.5);
globalCTX.stroke();
globalCTX.font = "12px Arial";
globalCTX.fillStyle = this.labelColor;
globalCTX.textAlign = "center";
globalCTX.fillText(this.label,this.x1+this.nodexi-globalBaseX,this.y1+runningHeight-globalBaseY);
runningHeight += 12;
if (this.traverse) {
globalCTX.textAlign = "right";
var waitChar = "P:";
if (this.parent.getComponentType() == "Queue") {
waitChar = "T:";
} else if (this.parent.getComponentType() == "Process") {
waitChar = "P:";
}
globalCTX.fillText(waitChar,x1-globalBaseX+15,this.y1-globalBaseY+runningHeight);
globalCTX.fillStyle = this.valueColor;
globalCTX.textAlign = "left";
globalCTX.fillText(this.traverseValue,x1-globalBaseX+17,this.y1-globalBaseY+runningHeight);
runningHeight += 12;
}
if (this.count) {
globalCTX.fillStyle = this.labelColor;
globalCTX.textAlign = "right";
globalCTX.fillText("Q:",x1-globalBaseX+15,this.y1-globalBaseY+runningHeight);
globalCTX.fillStyle = this.valueColor;
globalCTX.textAlign = "left";
globalCTX.fillText(this.countValue,x1-globalBaseX+17,this.y1-globalBaseY+runningHeight);
runningHeight += 12;
}
} else {
globalCTX.strokeStyle = borderColor;
globalCTX.beginPath();
globalCTX.moveTo(this.x1-globalBaseX+0.5,this.y1-globalBaseY+0.5);
globalCTX.lineTo(this.x2-globalBaseX+0.5,this.y2-globalBaseY+0.5);
globalCTX.stroke();
}
};
this.drawNodes = function() {
//if (this.parent.getComponentType() != "Path") {
if (this.isJourney) {
if (this.innode) {
drawNode(this.x1-globalBaseX,this.y1-globalBaseY,3,this.nodeColor);
}
if (this.outnode) {
drawNode(this.x2-globalBaseX,this.y2-globalBaseY,3,this.nodeColor);
}
} else if (!this.isPath) {
if (this.innode) {
drawNode(this.x1+this.nodexi-globalBaseX,this.y1+this.nodeyi-globalBaseY,3,this.nodeColor);
}
if (this.outnode) {
drawNode(this.x1+this.nodexo-globalBaseX,this.y1+this.nodeyo-globalBaseY,3,this.nodeColor);
}
} else {
if (this.parent.previousComponent.getComponentType() == "Path") {
drawNode(this.x1-globalBaseX,this.y1-globalBaseY,3,this.nodeColor);
}
if (this.parent.nextComponent.getComponentType() == "Path") {
drawNode(this.x2-globalBaseX,this.y2-globalBaseY,3,this.nodeColor);
}
}
};
this.drawEntities = function() {
var i;
var drawCount;
var drawColor;
var xx;
var yy;
var qCount;
//if (this.parent.getComponentType() == "Path") {
if (this.isPath) {
drawCount = this.parent.entityQueue.length;
for (i=0; i<drawCount; i++) {
var location = this.parent.entityQueue[i].getLocation();
drawNode(location.x-globalBaseX,location.y-globalBaseY,5,this.readyColor);
drawNode(location.x-globalBaseX,location.y-globalBaseY,3,this.parent.entityQueue[i].getEntityColor())
}
} else if (this.parent.getComponentType() == "Bag") {
drawCount = this.parent.maxCapacity; //should be < this.entityLocs.length
drawColor = this.waitingColor;
for (i=0; i<drawCount; i++) {
if (this.parent.entityQueue[i] != null) {
xx = this.entityLocs[0][i].x-globalBaseX;
yy = this.entityLocs[0][i].y-globalBaseY;
drawNode(this.x1+xx,this.y1+yy,5,drawColor);
drawNode(this.x1+xx,this.y1+yy,3,this.parent.entityQueue[i].getEntityColor());
if (this.parent.subEntityQueue[i] != null) {
drawNode(this.x1+xx+3,this.y1+yy-3,5,drawColor);
drawNode(this.x1+xx+3,this.y1+yy-3,3,this.parent.subEntityQueue[i].getEntityColor());
}
}
}
drawCount = this.entityLocs[0].length - this.parent.maxCapacity;
if (this.parent.exitQueue.length < drawCount) {
drawCount = this.parent.exitQueue.length;
}
drawColor = this.readyColor;
for (i=0; i<drawCount; i++) {
//locs for exit queue in order from maxCapacity
xx = this.entityLocs[0][this.parent.maxCapacity + i].x-globalBaseX;
yy = this.entityLocs[0][this.parent.maxCapacity + i].y-globalBaseY;
drawNode(this.x1+xx,this.y1+yy,5,drawColor);
//exit queue items in reverse order
drawNode(this.x1+xx,this.y1+yy,3,this.parent.exitQueue[this.parent.exitQueue.length-1-i].getEntityColor());
}
} else if (this.parent.getComponentType()== "Combined") {
//var locs = this.entityLocs.length;
qCount = this.countValue - this.traverseValue;
//drawCount = locs - this.parent.processCapacity;
drawCount = this.locsCount[0] - this.parent.processCapacity;
if (this.parent.entityQueue.length < drawCount) {
drawCount = this.parent.entityQueue.length;
}
for (i=0; i<drawCount; i++) {
if (i < qCount) {
drawColor = this.readyColor;
} else {
drawColor = this.waitingColor;
}
xx = this.entityLocs[0][i].x-globalBaseX;
yy = this.entityLocs[0][i].y-globalBaseY;
drawNode(this.x1+xx,this.y1+yy,5,drawColor);
drawNode(this.x1+xx,this.y1+yy,3,this.parent.entityQueue[i].getEntityColor());
}
var pCount = this.parent.countInProcessQueue - this.parent.countInProcess;
drawCount = this.parent.countInProcessQueue;
//start from end of entityLocs
for (i=0; i<drawCount; i++) {
if (i < pCount) {
drawColor = this.readyColor;
} else {
drawColor = this.waitingColor;
}
xx = this.entityLocs[0][this.locsCount[0]-i-1].x-globalBaseX;
yy = this.entityLocs[0][this.locsCount[0]-i-1].y-globalBaseY;
drawNode(this.x1+xx,this.y1+yy,5,drawColor);
drawNode(this.x1+xx,this.y1+yy,3,this.parent.processQueue[drawCount-i-1].getEntityColor());
}
} else if (this.parent.getComponentType() != "Arrivals") {
if (this.parent.componentName == "Q0") {
dummy1 = 6;
}
qCount = this.countValue - this.traverseValue;
if (this.countValue > this.locsCount[0]) {
drawCount = this.locsCount[0];
} else {
drawCount = this.countValue;
}
for (i=0; i<drawCount; i++) {
if (i < qCount) {
drawColor = this.readyColor;
} else {
drawColor = this.waitingColor;
}
xx = this.entityLocs[0][i].x-globalBaseX;
yy = this.entityLocs[0][i].y-globalBaseY;
drawNode(this.x1+xx,this.y1+yy,5,drawColor);
drawNode(this.x1+xx,this.y1+yy,3,this.parent.entityQueue[i].getEntityColor());
}
}
};