Menu

#27 Labels have a fixed y position when drawn.

open
Swing/AWT (4)
5
2008-04-12
2008-04-12
Vhati
No

Barbecue 1.5b1
Data: Any accptable length of digits.
Parameters: Defaults

When using the Barcode.draw() method, the text is always painted as if draw() were given y=0. When y is anything else, the bars move down/up as expected, but the label doesn't move with them.

I noticed this using linear.upc.UPCABarcode.
On lines 220-223, I added 'y' to the shortBarHeight to fix it.
I'm not familiar enough with the API to know if this is the proper place for the correction, but it worked for me.
----------
if (drawingText) {
output.drawText(leadChar, LabelLayoutFactory.createMarginLayout(startTextPos, y+shortBarHeight, startTextW, textHeight));
output.drawText(firstSet, LabelLayoutFactory.createMarginLayout(firstTextPos, y+shortBarHeight, firstTextW, textHeight));
output.drawText(lastSet, LabelLayoutFactory.createMarginLayout(secondTextPos, y+shortBarHeight, secondTextW, textHeight));
output.drawText(endChar, LabelLayoutFactory.createMarginLayout(endTextPos, y+shortBarHeight, endTextW, textHeight));
}
----------
I tried EAN13Barcode, and it had the problem too. Presumably others are similarly affected.

Discussion


Log in to post a comment.