This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 126532 - ConnectionWidget labels constraint should be able to specify the distance relative to the target anchor
Summary: ConnectionWidget labels constraint should be able to specify the distance rel...
Status: NEW
Alias: None
Product: platform
Classification: Unclassified
Component: Graph (show other bugs)
Version: 6.x
Hardware: All All
: P2 blocker (vote)
Assignee: Kris Richards
Depends on:
Blocks: 105060
  Show dependency tree
Reported: 2008-02-01 22:37 UTC by Trey Spiva
Modified: 2008-02-22 12:30 UTC (History)
0 users

See Also:
Exception Reporter:


Note You need to log in before you can comment on or make changes to this bug.
Description Trey Spiva 2008-02-01 22:37:03 UTC
Currently the API only allows you to specify the distance relative to the source end, or you can specify the percentage.  The problem with the percentage is 
that as the target node move way from the source node, the number of pixels per 1 percent grows.  If you want to say I want the label to be 10 pixels from 
the target, you have to calculate the size of the connection widget (which the connection widget layout is already doing).  However calculating the length of 
the connection widget approach still does not work because the calculated distance is no longer valid after the target or source anchors are moved.  Therefore specifying this type of information at the time of the label creation does not work correctly.  

A work around would be to create a dependency listener that is designed to update the labels associated with the target anchor end of the connection.  This is 
very cumbersome.  A better approach would to have a constraint what allows you to specify the number of pixels relative to a specified end.  The Connection 
Widget Layout can then handle calculating the absolute position.  Similar to the percent constraint.
Comment 1 Trey Spiva 2008-02-21 17:10:15 UTC
After looking at the code I have discovered that if the distance value is  a negative number, that the distance is relative to the target end not the source end.  
This satisfies my request.  

The problem is that the Javadoc does not state this feature.  The Javadoc says "placementAtDistance - the placement on a path in pixels as a distance from 
the source anchor".  However, when the value is negative, the value is the number of pixels as a distance from the target anchor.

In the matter of consistency, should we do the same thing for the percentage?
Comment 2 David Kaspar 2008-02-22 12:30:32 UTC
Regarding percentage:
The negative-value approach applies only to distance specified with "integer" value. It is due to possibility to
express: I want to be placed 20px from the target location -> Then use "-20". For distance specified with "float" value,
it is not necessary since you
are able to say: I want to be placed 10% from the target location ->
Then use "0.9f". Therefore I do not think it is important to have the same approach for "float" value. Additionally it
would change semantics of the "setConstraint" method which is incompatible change.