Commit 9b0c5666 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

text alignment with TOP align was incorrect

parent a25ceafa
......@@ -220,20 +220,20 @@ public abstract class SpeciesConverter<T extends Species> extends ElementConvert
*/
protected void drawText(final Rectangle2D border, final String text, final Graphics2D graphics,
HorizontalAlign horizontalAlign, VerticalAlign verticalAlign) {
double height = getTextHeight(text, graphics);
double textHeight = getTextHeight(text, graphics);
double y = border.getY();
String[] lines = text.split("\n");
double lineHeight = graphics.getFontMetrics().getHeight();
switch (verticalAlign) {
case TOP:
y = border.getMinY();
y = border.getMinY() + graphics.getFontMetrics().getAscent();
break;
case MIDDLE:
y = border.getCenterY() - (height / 2 - graphics.getFontMetrics().getAscent());
y = border.getCenterY() - (textHeight / 2 - graphics.getFontMetrics().getAscent());
break;
case BOTTOM:
y = border.getMaxY() - (height - graphics.getFontMetrics().getAscent());
y = border.getMaxY() - (textHeight - graphics.getFontMetrics().getAscent());
break;
default:
throw new InvalidArgumentException("Don't know how to align text with: " + verticalAlign);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment