textcomponent: add option to outline text
This commit is contained in:
@@ -43,6 +43,7 @@ public class TextComponent implements RenderableEntity
|
|||||||
private String text;
|
private String text;
|
||||||
private Point position = new Point();
|
private Point position = new Point();
|
||||||
private Color color = Color.WHITE;
|
private Color color = Color.WHITE;
|
||||||
|
private boolean outline;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dimension render(Graphics2D graphics)
|
public Dimension render(Graphics2D graphics)
|
||||||
@@ -63,6 +64,13 @@ public class TextComponent implements RenderableEntity
|
|||||||
graphics.setColor(Color.BLACK);
|
graphics.setColor(Color.BLACK);
|
||||||
graphics.drawString(textWithoutCol, x + 1, position.y + 1);
|
graphics.drawString(textWithoutCol, x + 1, position.y + 1);
|
||||||
|
|
||||||
|
if (outline)
|
||||||
|
{
|
||||||
|
graphics.drawString(textWithoutCol, x - 1, position.y - 1);
|
||||||
|
graphics.drawString(textWithoutCol, x - 1, position.y + 1);
|
||||||
|
graphics.drawString(textWithoutCol, x + 1, position.y - 1);
|
||||||
|
}
|
||||||
|
|
||||||
// actual text
|
// actual text
|
||||||
graphics.setColor(Color.decode("#" + colColor));
|
graphics.setColor(Color.decode("#" + colColor));
|
||||||
graphics.drawString(textWithoutCol, x, position.y);
|
graphics.drawString(textWithoutCol, x, position.y);
|
||||||
@@ -76,6 +84,13 @@ public class TextComponent implements RenderableEntity
|
|||||||
graphics.setColor(Color.BLACK);
|
graphics.setColor(Color.BLACK);
|
||||||
graphics.drawString(text, position.x + 1, position.y + 1);
|
graphics.drawString(text, position.x + 1, position.y + 1);
|
||||||
|
|
||||||
|
if (outline)
|
||||||
|
{
|
||||||
|
graphics.drawString(text, position.x - 1, position.y - 1);
|
||||||
|
graphics.drawString(text, position.x - 1, position.y + 1);
|
||||||
|
graphics.drawString(text, position.x + 1, position.y - 1);
|
||||||
|
}
|
||||||
|
|
||||||
// actual text
|
// actual text
|
||||||
graphics.setColor(color);
|
graphics.setColor(color);
|
||||||
graphics.drawString(text, position.x, position.y);
|
graphics.drawString(text, position.x, position.y);
|
||||||
|
|||||||
Reference in New Issue
Block a user