Skip to content

Commit

Permalink
prmr#402 Save and restore the text alignment when drawing strings
Browse files Browse the repository at this point in the history
  • Loading branch information
yannsartori authored and louib committed Aug 15, 2021
1 parent 956458f commit ac5c545
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ca/mcgill/cs/jetuml/views/StringViewer.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,8 @@ else if(aAlignment == Align.RIGHT)
public void draw(String pString, GraphicsContext pGraphics, Rectangle pRectangle)
{
Text label = getLabel(pString);
final VPos oldVPos = pGraphics.getTextBaseline();
final TextAlignment oldAlign = pGraphics.getTextAlign();

pGraphics.setTextAlign(label.getTextAlignment());

Expand Down Expand Up @@ -177,5 +179,7 @@ else if(aAlignment == Align.RIGHT)
(int) (textX-xOffset+bounds.getWidth()), textY+yOffset, LineStyle.SOLID);
}
pGraphics.translate(-pRectangle.getX(), -pRectangle.getY());
pGraphics.setTextBaseline(oldVPos);
pGraphics.setTextAlign(oldAlign);
}
}

0 comments on commit ac5c545

Please sign in to comment.