Revision: 3940
Author: [email protected]
Date: Tue Sep 7 12:32:13 2010
Log: Fixed bug 3039: critic badges are now drawn in more appropriate
locations for single-bend relationships.
http://code.google.com/p/power-architect/source/detail?r=3940
Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/BasicRelationshipUI.java
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/BasicRelationshipUI.java
Fri Jun 11 09:19:49 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/BasicRelationshipUI.java
Tue Sep 7 12:32:13 2010
@@ -1545,8 +1545,19 @@
}
public Point getPointForModelObject(Object modelObject) {
+ // Combine the two halves of the bitmask.
+ final int sidesUsed = relationship.getOrientation() / (PARENT_MASK +
1) +
+ relationship.getOrientation() % (PARENT_MASK + 1);
Dimension preferredSize = getPreferredSize();
- return new Point(relationship.getLocation().x + (preferredSize.width
/ 2),
- relationship.getLocation().y + (preferredSize.height / 2));
+ if (sidesUsed == PARENT_FACES_TOP + PARENT_FACES_BOTTOM ||
+ sidesUsed == PARENT_FACES_LEFT + PARENT_FACES_RIGHT) {
+ // Zero or two bends: center on the relationship line.
+ return new Point(relationship.getLocation().x +
(preferredSize.width /2) + 8,
+ relationship.getLocation().y + (preferredSize.height /2) -
4);
+ } else {
+ // One bend: choose corner positions based on the bitmask.
+ return new Point(relationship.getLocation().x + (sidesUsed%2 ==
1 ? preferredSize.width-25 : 44),
+ relationship.getLocation().y + (sidesUsed >=
PARENT_FACES_TOP ? 24 : preferredSize.height-32));
+ }
}
}