Permalink
Browse files

Fixed height detection for mouseDragged on use cases, and added calcu…

…lation for actor movement
  • Loading branch information...
predominant committed Apr 3, 2011
1 parent 4207647 commit 9587f105a347dc0ebd28c6a2b92f8f7a61e4516b
Showing with 7 additions and 3 deletions.
  1. +7 −3 jsdiagram.pjs
View
@@ -25,14 +25,14 @@ void draw() {
}
void mouseDragged() {
- for (var i = 0; i < items.size(); i++) {
+ for (var i = items.size() - 1; i >= 0; i--) {
UMLItem item = (UMLItem)items.get(i);
if (item.inBounds(mouseX, mouseY)) {
item.move(mouseX, mouseY);
- redraw();
break;
}
}
+ redraw();
}
@@ -91,7 +91,7 @@ class Case extends UMLItem {
}
boolean inBounds(xPos, yPos) {
- return xPos >= x - round(size / 2) && xPos <= x + round(size / 2) && yPos >= y - round(size / 3) && yPos <= y + round(size / 3);
+ return xPos >= x - round(size / 2) && xPos <= x + round(size / 2) && yPos >= y - round(size / 3 / 2) && yPos <= y + round(size / 3 / 2);
}
}
@@ -113,4 +113,8 @@ class Actor extends UMLItem {
line(x, y + sixth, x - sixth, y + third + sixth);
line(x, y + sixth, x + sixth, y + third + sixth);
}
+
+ boolean inBounds(xPos, yPos) {
+ return xPos >= x - sixth && xPos <= xPos + sixth && yPos >= y - sixth - third && yPos <= y + sixth + third;
+ }
}

0 comments on commit 9587f10

Please sign in to comment.