Author: daceywang
Date: Thu Apr 30 15:18:26 2009
New Revision: 3032

Modified:
   trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java

Log:
Now the relationship label supports vertical text when the horizontal space is not enough while the vertical one is. Currently only implemented for PkTable faces left or right and FkTable faces left or right. I personally think other cases don't need the vertical label. But If you don't think so, it's easy for you to implement.

Modified: trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java
==============================================================================
--- trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java (original) +++ trunk/src/ca/sqlpower/architect/swingui/BasicRelationshipUI.java Thu Apr 30 15:18:26 2009
@@ -50,6 +50,8 @@
        implements PropertyChangeListener, java.io.Serializable {

private static Logger logger = Logger.getLogger(BasicRelationshipUI.class);
+       
+       private static final double NINETY_DEGREES = Math.toRadians(90.0);

        protected Relationship relationship;

@@ -185,25 +187,63 @@
                        // XXX: could optimise by checking if PK or FK tables 
have moved
                        containmentPath = new 
GeneralPath(GeneralPath.WIND_NON_ZERO, 10);
                        
-                       float parentToChildLabelStart = 0;
-                       float childToParentLabelStart = 0;
+                       /**
+                        * The proper x-coordinate point for 
<code>parentToChild</code>.
+                        */
+                       float parentToChildLabelStartX = 0;
+                       
+                       /**
+                        * The proper x-coordinate point for 
<code>childToParent</code>.
+                        */
+                       float childToParentLabelStartX = 0;
+                       
+                       /**
+                        * The proper x-coordinate point for 
<code>parentToChild</code>.
+                        */
+                       float parentToChildLabelStartY = 0;
+                       
+                       /**
+                        * The proper x-coordinate point for 
<code>childToParent</code>.
+                        */
+                       float childToParentLabelStartY = 0;
                        g2.setColor(r.getForegroundColor());
                        
                        float leftmost = 0;
             float rightmost = 0;
+            /**
+             * The highest point is actually smaller than the lowest point
+             */
+            float highest = 0;
+            /**
+             * The lowest point is actually bigger than the highest point
+             */
+            float lowest = 0;
             if (r.displayRelationshipLabel()) {
                 if (lineStart.x > lineEnd.x) {
- logger.debug("Parent is at the right side of children");
+                    logger.debug("Parent is at the right side of child");
                     leftmost = lineEnd.x;
                     rightmost = lineStart.x;
                 } else {
-                    logger.debug("Parent is at the left side of children");
+                    logger.debug("Parent is at the left side of child");
                     leftmost = lineStart.x;
                     rightmost = lineEnd.x;
                 }
- parentToChildLabelStart = calculateRelationshipLabelStart(leftmost, rightmost,
+                if (lineStart.y > lineEnd.y) {
+                    logger.debug("Parent is below the child");
+                    highest = lineEnd.y;
+                    lowest = lineStart.y;
+                } else {
+                    logger.debug("Parent is above the child");
+                    highest = lineStart.y;
+                    lowest = lineEnd.y;
+                }
+ parentToChildLabelStartX = calculateRelationshipLabelStart(leftmost, rightmost, + fm.stringWidth(r.getTextForParentLabel())); + childToParentLabelStartX = calculateRelationshipLabelStart(leftmost, rightmost, + fm.stringWidth(r.getTextForChildLabel())); + parentToChildLabelStartY = calculateRelationshipLabelStart(highest, lowest, fm.stringWidth(r.getTextForParentLabel())); - childToParentLabelStart = calculateRelationshipLabelStart(leftmost, rightmost, + childToParentLabelStartY = calculateRelationshipLabelStart(highest, lowest, fm.stringWidth(r.getTextForChildLabel()));
             }

@@ -222,22 +262,24 @@
                 if (r.displayRelationshipLabel()) {
                     leftmost = lineEnd.x - getTerminationLength();
                     rightmost = lineStart.x;
- parentToChildLabelStart = calculateRelationshipLabelStart(leftmost, rightmost, + parentToChildLabelStartX = calculateRelationshipLabelStart(leftmost, rightmost, fm.stringWidth(r.getTextForParentLabel())); - childToParentLabelStart = calculateRelationshipLabelStart(leftmost, rightmost, + childToParentLabelStartX = calculateRelationshipLabelStart(leftmost, rightmost, fm.stringWidth(r.getTextForChildLabel())); - logger.debug("relationship label starts at: " + parentToChildLabelStart); - g2.translate(parentToChildLabelStart,lineStart.y + getTerminationLength() - fm.getHeight()); + logger.debug("relationship label starts at: " + parentToChildLabelStartX); + g2.translate(parentToChildLabelStartX,lineStart.y + getTerminationLength() - fm.getHeight());
+                    parentToChild.setIcon(null);
                     parentToChild.setText(r.getTextForParentLabel());
parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                     parentToChild.paint(g2);
- g2.translate(-parentToChildLabelStart, -(lineStart.y + getTerminationLength()) + fm.getHeight()); + g2.translate(-parentToChildLabelStartX, -(lineStart.y + getTerminationLength()) + fm.getHeight());

- g2.translate(childToParentLabelStart,lineStart.y + getTerminationLength()); + g2.translate(childToParentLabelStartX,lineStart.y + getTerminationLength());
+                    childToParent.setIcon(null);
                     childToParent.setText(r.getTextForChildLabel());
childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                     childToParent.paint(g2);
- g2.translate(-childToParentLabelStart, -(lineStart.y + getTerminationLength())); + g2.translate(-childToParentLabelStartX, -(lineStart.y + getTerminationLength()));
                 }
                                
                                containmentPath.lineTo(lineEnd.x - 
getTerminationLength(), lineEnd.y);
@@ -264,62 +306,144 @@
                                // draw relationship labels
                                if (r.displayRelationshipLabel()) {
                                if ((orientation & PARENT_FACES_LEFT) != 0) {
- logger.debug("The startpoint is : " + lineStart + "; The endpoint is: " + lineEnd);
                                    if (lineStart.y < lineEnd.y) {
                                        logger.debug("pk table is at right and 
higher");
                                
-                                       
g2.translate(parentToChildLabelStart,lineEnd.y);
-                           parentToChild.setText(r.getTextForParentLabel());
- parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
-                           parentToChild.paint(g2);
- g2.translate(-parentToChildLabelStart, -lineEnd.y);
-       
- g2.translate(childToParentLabelStart,lineStart.y - fm.getHeight());
-                           childToParent.setText(r.getTextForChildLabel());
- childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
-                           childToParent.paint(g2);
- g2.translate(-childToParentLabelStart, -(lineStart.y - fm.getHeight())); + if ((lineStart.x - lineEnd.x) > (lineEnd.y - lineStart.y)) {
+                                               
g2.translate(parentToChildLabelStartX, lineEnd.y);
+                                               parentToChild.setIcon(null);
+ parentToChild.setText(r.getTextForParentLabel()); + parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
+                                   parentToChild.paint(g2);
+ g2.translate(-parentToChildLabelStartX, -lineEnd.y);
+               
+ g2.translate(childToParentLabelStartX, lineStart.y - fm.getHeight());
+                                   childToParent.setIcon(null);
+ childToParent.setText(r.getTextForChildLabel()); + childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
+                                childToParent.paint(g2);
+ g2.translate(-childToParentLabelStartX, -(lineStart.y - fm.getHeight()));
+                                       } else {
+ g2.translate(midx + fm.getHeight() + fm.getDescent(), parentToChildLabelStartY);
+                                           g2.rotate(NINETY_DEGREES);
+                                           
parentToChild.setText(r.getTextForParentLabel());
+ parentToChild.setBounds(0, 0, (int)(lowest - highest), fm.getHeight());
+                                parentToChild.paint(g2);
+                                g2.rotate(-NINETY_DEGREES);
+ g2.translate(-midx - fm.getHeight() - fm.getDescent(), -parentToChildLabelStartY);
+
+ g2.translate(midx, childToParentLabelStartY);
+                                g2.rotate(NINETY_DEGREES);
+ childToParent.setText(r.getTextForChildLabel()); + childToParent.setBounds(0, 0, (int)(lowest - highest), fm.getHeight());
+                                childToParent.paint(g2);
+                                g2.rotate(-NINETY_DEGREES);
+ g2.translate(-midx, -childToParentLabelStartY);
+                                       }
                                    } else {
                                        logger.debug("pk table is at right and 
lower");
-                                       
g2.translate(parentToChildLabelStart,lineStart.y);
- parentToChild.setText(r.getTextForParentLabel()); - parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
-                            parentToChild.paint(g2);
- g2.translate(-parentToChildLabelStart, -lineStart.y);
-
- g2.translate(childToParentLabelStart,lineEnd.y - fm.getHeight()); - childToParent.setText(r.getTextForChildLabel()); - childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
-                            childToParent.paint(g2);
- g2.translate(-childToParentLabelStart, -(lineEnd.y - fm.getHeight()));
+                               
+ if ((lineStart.x - lineEnd.x) > (lineStart.y - lineEnd.y)) {
+                                               
g2.translate(parentToChildLabelStartX,lineStart.y);
+                                               parentToChild.setIcon(null);
+ parentToChild.setText(r.getTextForParentLabel()); + parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
+                                parentToChild.paint(g2);
+ g2.translate(-parentToChildLabelStartX, -lineStart.y);
+
+ g2.translate(childToParentLabelStartX,lineEnd.y - fm.getHeight());
+                                childToParent.setIcon(null);
+ childToParent.setText(r.getTextForChildLabel()); + childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
+                                childToParent.paint(g2);
+ g2.translate(-childToParentLabelStartX, -(lineEnd.y - fm.getHeight()));
+                                       } else {
+                                           g2.translate(midx, 
parentToChildLabelStartY);
+                                g2.rotate(NINETY_DEGREES);
+ parentToChild.setText(r.getTextForParentLabel()); + parentToChild.setBounds(0, 0, (int)(lowest - highest), fm.getHeight());
+                                parentToChild.paint(g2);
+                                g2.rotate(-NINETY_DEGREES);
+ g2.translate(-midx, -parentToChildLabelStartY);
+
+ g2.translate(midx + fm.getHeight() + fm.getDescent(), childToParentLabelStartY);
+                                g2.rotate(NINETY_DEGREES);
+ childToParent.setText(r.getTextForChildLabel()); + childToParent.setBounds(0, 0, (int)(lowest - highest), fm.getHeight());
+                                childToParent.paint(g2);
+                                g2.rotate(-NINETY_DEGREES);
+ g2.translate(-midx - fm.getHeight() - fm.getDescent(), -childToParentLabelStartY);
+                                       }
                                    }
                                } else {
                                    if (lineStart.y < lineEnd.y) {
                                        logger.debug("pk table is at left and 
higher");
- g2.translate(parentToChildLabelStart,lineStart.y - fm.getHeight()); - parentToChild.setText(r.getTextForParentLabel()); - parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
-                            parentToChild.paint(g2);
- g2.translate(-parentToChildLabelStart, -(lineStart.y - fm.getHeight()));
-
- g2.translate(childToParentLabelStart,lineEnd.y); - childToParent.setText(r.getTextForChildLabel()); - childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
-                            childToParent.paint(g2);
- g2.translate(-childToParentLabelStart, -lineEnd.y);
+                               
+ if ((lineEnd.x - lineStart.x) > (lineEnd.y - lineStart.y)) { + g2.translate(parentToChildLabelStartX,lineStart.y - fm.getHeight());
+                                               parentToChild.setIcon(null);
+                                               
parentToChild.setText(r.getTextForParentLabel());
+ parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
+                                parentToChild.paint(g2);
+ g2.translate(-parentToChildLabelStartX, -(lineStart.y - fm.getHeight()));
+
+ g2.translate(childToParentLabelStartX,lineEnd.y);
+                                childToParent.setIcon(null);
+ childToParent.setText(r.getTextForChildLabel()); + childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
+                                childToParent.paint(g2);
+ g2.translate(-childToParentLabelStartX, -lineEnd.y);
+                                       } else {
+ g2.translate(midx + fm.getHeight() + fm.getDescent(), parentToChildLabelStartY);
+                                g2.rotate(NINETY_DEGREES);
+ parentToChild.setText(r.getTextForParentLabel()); + parentToChild.setBounds(0, 0, (int)(lowest - highest), fm.getHeight());
+                                parentToChild.paint(g2);
+                                g2.rotate(-NINETY_DEGREES);
+ g2.translate(-midx - fm.getHeight() - fm.getDescent(), -parentToChildLabelStartY);
+
+ g2.translate(midx, childToParentLabelStartY);
+                                g2.rotate(NINETY_DEGREES);
+ childToParent.setText(r.getTextForChildLabel()); + childToParent.setBounds(0, 0, (int)(lowest - highest), fm.getHeight());
+                                childToParent.paint(g2);
+                                g2.rotate(-NINETY_DEGREES);
+ g2.translate(-midx, -childToParentLabelStartY);
+                                       }
                         } else {
                             logger.debug("pk table is at left and lower");
- g2.translate(parentToChildLabelStart,lineEnd.y - fm.getHeight()); - parentToChild.setText(r.getTextForParentLabel()); - parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
-                            parentToChild.paint(g2);
- g2.translate(-parentToChildLabelStart, -(lineEnd.y - fm.getHeight()));

- g2.translate(childToParentLabelStart,lineStart.y); - childToParent.setText(r.getTextForChildLabel()); - childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
-                            childToParent.paint(g2);
- g2.translate(-childToParentLabelStart, -lineStart.y); + if ((lineEnd.x - lineStart.x) > (lineStart.y - lineEnd.y)) { + g2.translate(parentToChildLabelStartX,lineEnd.y - fm.getHeight());
+                                parentToChild.setIcon(null);
+ parentToChild.setText(r.getTextForParentLabel()); + parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
+                                parentToChild.paint(g2);
+ g2.translate(-parentToChildLabelStartX, -(lineEnd.y - fm.getHeight()));
+
+ g2.translate(childToParentLabelStartX,lineStart.y);
+                                childToParent.setIcon(null);
+ childToParent.setText(r.getTextForChildLabel()); + childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
+                                childToParent.paint(g2);
+ g2.translate(-childToParentLabelStartX, -lineStart.y);
+                            } else {
+ g2.translate(midx, parentToChildLabelStartY);
+                                g2.rotate(NINETY_DEGREES);
+ parentToChild.setText(r.getTextForParentLabel()); + parentToChild.setBounds(0, 0, (int)(lowest - highest), fm.getHeight());
+                                parentToChild.paint(g2);
+                                g2.rotate(-NINETY_DEGREES);
+ g2.translate(-midx, -parentToChildLabelStartY);
+
+ g2.translate(midx + fm.getHeight() + fm.getDescent(), childToParentLabelStartY);
+                                g2.rotate(NINETY_DEGREES);
+ childToParent.setText(r.getTextForChildLabel()); + childToParent.setBounds(0, 0, (int)(lowest - highest), fm.getHeight());
+                                childToParent.paint(g2);
+                                g2.rotate(-NINETY_DEGREES);
+ g2.translate(-midx - fm.getHeight() - fm.getDescent(), -childToParentLabelStartY);
+                            }
                         }
                                }
                                }
@@ -339,32 +463,34 @@
                                path = new GeneralPath(containmentPath);
                                // draw relationship labels
                                if (r.displayRelationshipLabel()) {
+                                   parentToChild.setIcon(null);
+                                   childToParent.setIcon(null);
                     if (lineStart.x > lineEnd.x) {
                         logger.debug("TOP-BOTTOM : pk table is at right");
-                        g2.translate(parentToChildLabelStart,midy);
+                        g2.translate(parentToChildLabelStartX,midy);
                         parentToChild.setText(r.getTextForParentLabel());
parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         parentToChild.paint(g2);
-                        g2.translate(-parentToChildLabelStart, -midy);
+                        g2.translate(-parentToChildLabelStartX, -midy);

- g2.translate(childToParentLabelStart, midy - fm.getHeight()); + g2.translate(childToParentLabelStartX, midy - fm.getHeight());
                         childToParent.setText(r.getTextForChildLabel());
childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         childToParent.paint(g2);
- g2.translate(-childToParentLabelStart, -(midy - fm.getHeight())); + g2.translate(-childToParentLabelStartX, -(midy - fm.getHeight()));
                     } else {
                         logger.debug("TOP-BOTTOM : pk table is at left");
- g2.translate(parentToChildLabelStart,midy - fm.getHeight()); + g2.translate(parentToChildLabelStartX,midy - fm.getHeight());
                         parentToChild.setText(r.getTextForParentLabel());
parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         parentToChild.paint(g2);
- g2.translate(-parentToChildLabelStart, -(midy - fm.getHeight())); + g2.translate(-parentToChildLabelStartX, -(midy - fm.getHeight()));

-                        g2.translate(childToParentLabelStart, midy);
+                        g2.translate(childToParentLabelStartX, midy);
                         childToParent.setText(r.getTextForChildLabel());
childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         childToParent.paint(g2);
-                        g2.translate(-childToParentLabelStart, -midy);
+                        g2.translate(-childToParentLabelStartX, -midy);
                     }
                                }
                                
@@ -381,32 +507,34 @@
                                path = new GeneralPath(containmentPath);
                                // draw relationship labels
                                if (r.displayRelationshipLabel()) {
+                                   parentToChild.setIcon(null);
+                    childToParent.setIcon(null);
                                if ((orientation & PARENT_FACES_LEFT) != 0) {
                         logger.debug("pk table is at right");
-                        g2.translate(parentToChildLabelStart,lineStart.y);
+                        g2.translate(parentToChildLabelStartX,lineStart.y);
                         parentToChild.setText(r.getTextForParentLabel());
parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         parentToChild.paint(g2);
- g2.translate(-parentToChildLabelStart, -lineStart.y); + g2.translate(-parentToChildLabelStartX, -lineStart.y);

- g2.translate(childToParentLabelStart,lineStart.y - fm.getHeight()); + g2.translate(childToParentLabelStartX,lineStart.y - fm.getHeight());
                         childToParent.setText(r.getTextForChildLabel());
childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         childToParent.paint(g2);
- g2.translate(-childToParentLabelStart, -(lineStart.y - fm.getHeight())); + g2.translate(-childToParentLabelStartX, -(lineStart.y - fm.getHeight()));
                     } else {
                         logger.debug("pk table is at left");
- g2.translate(parentToChildLabelStart,lineStart.y - fm.getHeight()); + g2.translate(parentToChildLabelStartX,lineStart.y - fm.getHeight());
                         parentToChild.setText(r.getTextForParentLabel());
parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         parentToChild.paint(g2);
- g2.translate(-parentToChildLabelStart, -(lineStart.y - fm.getHeight())); + g2.translate(-parentToChildLabelStartX, -(lineStart.y - fm.getHeight()));

-                        g2.translate(childToParentLabelStart,lineStart.y);
+                        g2.translate(childToParentLabelStartX,lineStart.y);
                         childToParent.setText(r.getTextForChildLabel());
childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         childToParent.paint(g2);
- g2.translate(-childToParentLabelStart, -lineStart.y); + g2.translate(-childToParentLabelStartX, -lineStart.y);
                     }
                                }
                                
@@ -422,32 +550,34 @@
                                path = new GeneralPath(containmentPath);
                                // draw relationship labels
                                if (r.displayRelationshipLabel()) {
+                                   parentToChild.setIcon(null);
+                    childToParent.setIcon(null);
                     if (lineStart.x > lineEnd.x) {
logger.debug("TOP_BOTTOM--LEFT_RIGHT pk table is at right");
-                        g2.translate(parentToChildLabelStart,lineEnd.y);
+                        g2.translate(parentToChildLabelStartX,lineEnd.y);
                         parentToChild.setText(r.getTextForParentLabel());
parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         parentToChild.paint(g2);
-                        g2.translate(-parentToChildLabelStart, -lineEnd.y);
+ g2.translate(-parentToChildLabelStartX, -lineEnd.y);

- g2.translate(childToParentLabelStart,lineEnd.y - fm.getHeight()); + g2.translate(childToParentLabelStartX,lineEnd.y - fm.getHeight());
                         childToParent.setText(r.getTextForChildLabel());
childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         childToParent.paint(g2);
- g2.translate(-childToParentLabelStart, -(lineEnd.y - fm.getHeight())); + g2.translate(-childToParentLabelStartX, -(lineEnd.y - fm.getHeight()));
                     } else {
logger.debug("TOP_BOTTOM--LEFT_RIGHT pk table is at left"); - g2.translate(parentToChildLabelStart,lineEnd.y - fm.getHeight()); + g2.translate(parentToChildLabelStartX,lineEnd.y - fm.getHeight());
                         parentToChild.setText(r.getTextForParentLabel());
parentToChild.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         parentToChild.paint(g2);
- g2.translate(-parentToChildLabelStart, -(lineEnd.y - fm.getHeight())); + g2.translate(-parentToChildLabelStartX, -(lineEnd.y - fm.getHeight()));

-                        g2.translate(childToParentLabelStart,lineEnd.y);
+                        g2.translate(childToParentLabelStartX,lineEnd.y);
                         childToParent.setText(r.getTextForChildLabel());
childToParent.setBounds(0, 0, (int) (rightmost - leftmost), fm.getHeight());
                         childToParent.paint(g2);
-                        g2.translate(-childToParentLabelStart, -lineEnd.y);
+ g2.translate(-childToParentLabelStartX, -lineEnd.y);
                     }
                                }
                                
@@ -461,6 +591,9 @@
                 containmentPath.lineTo(lineEnd.x, lineEnd.y);
                 containmentPath.lineTo(end.x, end.y);
                 path = new GeneralPath(containmentPath);
+
+                parentToChild.setIcon(null);
+                childToParent.setIcon(null);
                        }
                        if (!r.isSelected()) {
                                g2.setColor(r.getForegroundColor());
@@ -1157,8 +1290,10 @@
                                        fkLimits.x),
                                        Math.max(pkLimits.y,
                                                        fkLimits.y));
-                       computedBounds = new Rectangle(topLeft.x, topLeft.y - 
fm.getAscent(),
- bottomRight.x - topLeft.x, bottomRight.y - topLeft.y + fm.getHeight() + fm.getDescent());
+                       computedBounds = new Rectangle(topLeft.x - 
fm.getHeight(),
+                                                      topLeft.y - 
fm.getAscent(),
+ bottomRight.x - topLeft.x + 2*fm.getHeight(), + bottomRight.y - topLeft.y + fm.getHeight() + fm.getDescent());
                        if (logger.isDebugEnabled()) {
                                logger.debug("Updating bounds to 
"+computedBounds
                                                +" (topleft="+topLeft+"; 
bottomRight="+bottomRight+")");
@@ -1377,16 +1512,16 @@

        /**
         * Calculate and return the appropriate x-position for relationship 
label.
-        * @param leftmost The leftmost x coordinate of the relationship line
-        * @param rightmost The rightmost x coordinate of the relationship line
+ * @param smaller The leftmost x coordinate or highest y coordinate of the relationship line + * @param bigger The rightmost x coordinate or lowest y coordinate of the relationship line * @param StringWidth The width of the display string under the specified fontMetrics
         */
- private float calculateRelationshipLabelStart(float leftmost, float rightmost, float StringWidth) { + private float calculateRelationshipLabelStart(float smaller, float bigger, float StringWidth) {
            float x;
-           if (rightmost - leftmost - StringWidth >= 0) {
-               x = leftmost + (rightmost - leftmost - StringWidth)/2;
+           if (bigger - smaller - StringWidth >= 0) {
+               x = smaller + (bigger - smaller - StringWidth)/2;
            } else {
-               x = leftmost;
+               x = smaller;
            }
            return x;
        }

Reply via email to