| Summary: | draw2d.Label alignment misleading | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Christian M. Schweda <schweda> | ||||
| Component: | GEF-Legacy Draw2d | Assignee: | gef-inbox <gef-inbox> | ||||
| Status: | RESOLVED INVALID | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | ahunter.eclipse, nyssen | ||||
| Version: | 3.3 | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows Vista | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Hi Christian, I need you to attach a patch so we can determine the changes made to the code. You attached the entire Label class. Hi Anthony,
sorry for providing the entire class. Below, I provide a snippet of the old implementation and add the potential fix, I thought of:
<Old>
private void calculateLocations() {
//...
switch (labelAlignment) {
case CENTER:
offset.scale(0.5f);
break;
case LEFT:
offset.scale(0.0f);
break;
case RIGHT:
offset.scale(1.0f);
break;
case TOP:
offset.height = 0;
offset.scale(0.5f);
break;
case BOTTOM:
offset.height = offset.height * 2;
offset.scale(0.5f);
break;
default:
offset.scale(0.5f);
break;
}
//...
</Old>
This first switch block should be replaced by the two if-statements as below.
<New>
private void calculateLocations() {
//...
if ((this.labelAlignment & LEFT) != 0) {
offset.width = 0;
} else if ((this.labelAlignment & CENTER) != 0) {
offset.width /= 2;
}
if ((this.labelAlignment & TOP) != 0) {
offset.height = 0;
} else if ((this.labelAlignment & MIDDLE) != 0) {
offset.height /= 2;
}
//...
</New>
Hope, this comment is helpful - sorry again for not directly adding a patch - I am not that deep into the bugzilla thing.
Hi Christian, I really need a patch contribution so we can add to the IP Log. Did you need help with this? According to its internal design and its documentation, Label is not intended to support boolean combinations of horizontal and vertical alignments, but allows only label alignments of LEFT, TOP, RIGHT, CENTER, or BOTTOM. Closing this thus as invalid. Please re-open a separate feature request if you need to have support for additional alignments. |
Created attachment 98538 [details] Proposal for an adapted calculateLocations() Method Build ID: I20070621-1340 Steps To Reproduce: When you use the labelAlignment property, you can (as it is realized as an int-bitarray) e.g. set the label to LEFT and TOP. Nevertheless, the label is not correctly aligned, in this particular case LEFT will be applied, ignoring TOP. Potential cause: Maybe, I am missing a point how to use this method - if not, the implementation of org.eclipse.draw2d.Label#calculateLocations() might cause this behavior. Imho, the switch-block is not correct and should be replaced by respective if-statements.