svn commit: r16856 - trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/PathItemPlacement.java
Dave Thompson <[email protected]>
| Newsgroups | gmane.comp.lang.uml.argouml.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: dthompson
Date: 2009-03-04 12:19:03-0800
New Revision: 16856
Modified:
trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/PathItemPlacement.java
Log:
Issue 5703: Improved label dragging to make it less jerky.
Modified: trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/PathItemPlacement.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/PathItemPlacement.java?view=diff&pathrev=16856&r1=16855&r2=16856
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/PathItemPlacement.java (original)
+++ trunk/src/argouml-app/src/org/argouml/uml/diagram/ui/PathItemPlacement.java 2009-03-04 12:19:03-0800
@@ -268,11 +268,11 @@
}
double slope = getSlope();
- applyOffset(slope, vectorOffset, result);
+ result.setLocation(applyOffset(slope, vectorOffset, anchor));
// Check for a collision between our computed position and the edge
if (useCollisionCheck) {
- double scaleFactor = 1.2; // increase offset by 20% at a time
+ int increment = 2; // increase offset by 2px at a time
// TODO: The size of text figs, which is what we care about most,
// isn't computed correctly by GEF. If we got ambitious, we could
@@ -285,19 +285,16 @@
Point[] points = fp.getPoints();
if (intersects(points, result, size)) {
- // increase offset by 20% at a time until we're clear
- int scaledOffset = (int) (vectorOffset * scaleFactor);
- // If offset is zero, use a default based on the size of the fig
- if (scaledOffset == 0) {
- scaledOffset = (size.width + size.height) / 4;
- }
+ // increase offset by increments until we're clear
+ int scaledOffset = vectorOffset + increment;
int limit = 20;
int count = 0;
// limit our retries in case its too hard to get free
while (intersects(points, result, size) && count++ < limit) {
- applyOffset(slope, scaledOffset, result);
- scaledOffset *= scaleFactor;
+ result.setLocation(
+ applyOffset(slope, scaledOffset, anchor));
+ scaledOffset += increment;
}
// If we timed out, give it one more try on the other side
if (false /* count >= limit */) {
@@ -306,13 +303,15 @@
// TODO: This works for 90 degree angles, but is suboptimal
// for other angles. It should reflect the angle, rather
// than just using a negative offset along the same vector
- applyOffset(slope, -vectorOffset, result);
+ result.setLocation(
+ applyOffset(slope, -vectorOffset, anchor));
count = 0;
scaledOffset = -scaledOffset;
while (intersects(points, result, size)
&& count++ < limit) {
- applyOffset(slope, scaledOffset, result);
- scaledOffset *= scaleFactor;
+ result.setLocation(
+ applyOffset(slope, scaledOffset, anchor));
+ scaledOffset += increment;
}
}
// LOG.debug("Final point #" + count + " " + result
@@ -577,13 +576,15 @@
* @param p1 point one of line to use in computing normal vector
* @param p2 point two of line to use in computing normal vector
* @param theOffset distance to displace fig along normal vector
- * @param result computed point returned
- * @return computed point. A modified version of the point provided as
- * input.
+ * @param anchor The start point to apply the offset from. Not modified.
+ * @return A new computed point describing the location after the offset
+ * has been applied to the anchor.
*/
private Point applyOffset(double theta, int theOffset,
- Point result) {
+ Point anchor) {
+ Point result = new Point(anchor);
+
// Set the following for some backward compatibility with old algorithm
final boolean aboveAndRight = false;
------------------------------------------------------
http://argouml.tigris.org/ds/viewMessage.do?dsForumId=5905&dsMessageId=1268389
To unsubscribe from this discussion, e-mail: [[email protected]].