This commit is contained in:
gac-S_Changer
2018-09-06 12:10:05 +02:00
parent 61ca6a6bc4
commit 9053e14c41
4 changed files with 195 additions and 106 deletions

View File

@@ -171,24 +171,23 @@ public class PuckGraphics {
}
Font getLabelFont() {
if (basePlateGraphics!=null) {
return new Font("Segoe UI", Font.BOLD, 12);
}
return new Font("Segoe UI", Font.BOLD, 18);
}
return new Font("Segoe UI", Font.BOLD, 14);
}
Font getIdFont() {
if (basePlateGraphics!=null) {
return new Font("Times New Roman", Font.PLAIN, 9);
return new Font("Segoe UI", Font.PLAIN, 9);
}
return new Font("Times New Roman", Font.PLAIN, 12);
return new Font("Segoe UI", Font.PLAIN, 9);
}
Point getLabelDrawPosition(String text, Graphics g, boolean drawBackground) {
Point getLabelDrawPosition(String text, Graphics g, boolean drawBackground, boolean hasId) {
Point pos = drawBackground ? getDrawPosition() : getDrawPosition(labelPositionWithImage);
Dimension textSize = SwingUtils.getTextSize(text, g.getFontMetrics());
return new Point(pos.x - textSize.width / 2 , pos.y + (g.getFontMetrics().getAscent() / 2));
return new Point(pos.x - textSize.width / 2 , pos.y + (g.getFontMetrics().getAscent() / 2) - (hasId ? 5: 0));
}
Color getBorderColor(boolean drawBackground) {
@@ -200,7 +199,7 @@ public class PuckGraphics {
return new Color(0, 0, 0);
}
return Color.GRAY;
}
}
return isHighlithted() ? new Color(0, 208, 0) : new Color(0, 128, 0);
}
@@ -266,19 +265,17 @@ public class PuckGraphics {
}
//Draw text
String id = puck.getId();
boolean hasId = drawId && (id!= null);
String text = puck.getName(); //String.valueOf(getIndex() + 1);
g.setColor(getLabelColor(drawBackground));
g.setFont(getLabelFont());
Point labelPosition = getLabelDrawPosition(text, g, drawBackground);
Point labelPosition = getLabelDrawPosition(text, g, drawBackground, hasId);
g.drawString(text, labelPosition.x, labelPosition.y);
if (drawId) {
String id = puck.getId();
if (id != null) {
labelPosition.setLocation(labelPosition.x, labelPosition.y - 6);
g.setFont(getIdFont());
Dimension textSize = SwingUtils.getTextSize(id, g.getFontMetrics());
g.drawString(id, getDrawPosition().x - textSize.width/2 , getDrawPosition().y + 10 );
}
if (hasId) {
g.setFont(getIdFont());
Dimension textSize = SwingUtils.getTextSize(id, g.getFontMetrics());
g.drawString(id, getDrawPosition().x - textSize.width/2 , getDrawPosition().y + 14);
}
}
}