我有下面的代码.
一切正常,但令人讨厌的是,while循环中的打印行命令运行两次.有(我已经测试过),队列中只有唯一的项目,没有重复项.
public void paint(Graphics g) {
boolean isParent;
int drawCount = 1;
int x = 0, y = 0, width = 0, height = 0;
Color colour;
while (!qtreeQueue.empty()) {
drawNode = (QuadTreeNode) qtreeQueue.deque();
isParent = drawNode.getIsParent();
if (!isParent) {
x = drawNode.getRectangle().x;
y = drawNode.getRectangle().y;
width = drawNode.getRectangle().width;
height = drawNode.getRectangle().height;
colour = getRectangleColour(drawNode);
System.out.println(drawCount + ". Drawing: x = " + x + "; y = " + y +
"; width = " + …Run Code Online (Sandbox Code Playgroud)