62 lines
1.4 KiB
Java
62 lines
1.4 KiB
Java
|
/**
|
||
|
*
|
||
|
*/
|
||
|
package visualizationElements;
|
||
|
|
||
|
import java.awt.Graphics;
|
||
|
import java.util.Vector;
|
||
|
|
||
|
/**
|
||
|
* Represents a queue to visualize.
|
||
|
* @author MSchaefer
|
||
|
*
|
||
|
*/
|
||
|
public class Queue extends List {
|
||
|
|
||
|
/**
|
||
|
* Creates a new Queue.
|
||
|
* @param values The values to of the queue.
|
||
|
*/
|
||
|
public Queue(Vector<?> values){
|
||
|
super(values);
|
||
|
}
|
||
|
|
||
|
|
||
|
/**
|
||
|
* Creates a new Queue.
|
||
|
* @param values The values to of the queue.
|
||
|
*/
|
||
|
public Queue(Object[] values){
|
||
|
super(values);
|
||
|
}
|
||
|
|
||
|
@Override
|
||
|
public void draw(Graphics g) {
|
||
|
numberOfRows = valueTable.length;
|
||
|
numberOfColumns = valueTable[0].length;
|
||
|
|
||
|
int xpos = START_X_POS;
|
||
|
int ypos = START_Y_POS;
|
||
|
|
||
|
for(int j = 0; j < numberOfColumns; j++){
|
||
|
xpos = xpos + CELL_WIDTH;
|
||
|
ypos = START_Y_POS;
|
||
|
|
||
|
for(int i = 0; i < numberOfRows; i++){
|
||
|
|
||
|
ypos = ypos + CELL_HEIGHT;
|
||
|
g.drawRect(xpos, ypos, CELL_WIDTH, CELL_HEIGHT);
|
||
|
if(valueTable[i][j] != null){
|
||
|
g.drawString(valueTable[numberOfRows-(i+1)][numberOfColumns-(j+1)].toString(), xpos + CELL_HEIGHT, ypos + 15);
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
g.drawLine(START_X_POS, ypos - 3, xpos + CELL_WIDTH, ypos - 3);
|
||
|
g.drawLine(START_X_POS, ypos + CELL_HEIGHT + 3, xpos + CELL_WIDTH, ypos + CELL_HEIGHT + 3);
|
||
|
|
||
|
g.drawLine(START_X_POS, ypos - 4, xpos + CELL_WIDTH, ypos - 4);
|
||
|
g.drawLine(START_X_POS, ypos + CELL_HEIGHT + 4, xpos + CELL_WIDTH, ypos + CELL_HEIGHT + 4);
|
||
|
}
|
||
|
}
|