Variable size depending on width of text
This commit is contained in:
@@ -17,9 +17,11 @@ public class Main {
|
||||
private static final Color GREEN = new Color(101, 142, 61);
|
||||
|
||||
private static final Font ARIAL65 = new Font("Arial", Font.PLAIN, 65);
|
||||
private static final Font ARIAL55 = new Font("Arial", Font.PLAIN, 55);
|
||||
private static final Font ARIAL45 = new Font("Arial", Font.PLAIN, 45);
|
||||
private static final Font ARIAL45I = new Font("Arial", Font.ITALIC, 45);
|
||||
private static final Font ARIAL44 = new Font("Arial", Font.ITALIC, 44);
|
||||
private static final Font ARIAL44I = new Font("Arial", Font.ITALIC, 44);
|
||||
private static final Font ARIAL40I = new Font("Arial", Font.ITALIC, 40);
|
||||
private static final Font ARIAL38 = new Font("Arial", Font.ITALIC, 38);
|
||||
|
||||
public static void main(String[] args) {
|
||||
@@ -49,12 +51,28 @@ public class Main {
|
||||
|
||||
g.drawImage(background, 0, 0, null);
|
||||
|
||||
FontMetrics fm = g.getFontMetrics(ARIAL65);
|
||||
|
||||
g.setColor(WHITE);
|
||||
g.setFont(ARIAL65);
|
||||
if (fm.stringWidth(name) <= 969){
|
||||
g.setFont(ARIAL65);
|
||||
} else {
|
||||
g.setFont(ARIAL55);
|
||||
}
|
||||
g.drawString(name, 85, 112);
|
||||
|
||||
g.setFont(ARIAL45I);
|
||||
g.drawString(title, 91, 176);
|
||||
fm = g.getFontMetrics(ARIAL45I);
|
||||
if (fm.stringWidth(title) <= 970) {
|
||||
g.setFont(ARIAL45I);
|
||||
} else {
|
||||
g.setFont(ARIAL40I);
|
||||
}
|
||||
g.drawString(title, 89, 176);
|
||||
|
||||
boolean directLine = false;
|
||||
if (hasExtension && extension.length() == 0) {
|
||||
directLine = true;
|
||||
}
|
||||
|
||||
int yOffset = 0;
|
||||
if (hasExtension && hasCell) {
|
||||
@@ -65,7 +83,7 @@ public class Main {
|
||||
g.drawString(email, 62, 380 - yOffset);
|
||||
|
||||
g.setColor(GREEN);
|
||||
g.setFont(ARIAL44);
|
||||
g.setFont(ARIAL44I);
|
||||
g.drawString(location, 59, 447 - yOffset);
|
||||
|
||||
g.setFont(ARIAL38);
|
||||
@@ -73,7 +91,11 @@ public class Main {
|
||||
|
||||
String number = "";
|
||||
if (hasExtension && !hasCell) {
|
||||
number = "W: " + schoolNumber + " x" + extension;
|
||||
if (directLine) {
|
||||
number = "W: " + schoolNumber;
|
||||
} else {
|
||||
number = "W: " + schoolNumber + " x" + extension;
|
||||
}
|
||||
} else if (!hasExtension && hasCell) {
|
||||
number = "C: " + cellNumber;
|
||||
}
|
||||
@@ -81,7 +103,11 @@ public class Main {
|
||||
if (!(hasExtension && hasCell)) {
|
||||
g.drawString(number, 59, 536);
|
||||
} else {
|
||||
g.drawString("W: " + schoolNumber + " x" + extension, 59, 496);
|
||||
if (directLine) {
|
||||
g.drawString("W: " + schoolNumber, 59, 496);
|
||||
} else {
|
||||
g.drawString("W: " + schoolNumber + " x" + extension, 59, 496);
|
||||
}
|
||||
g.drawString("C: " + cellNumber, 59, 540);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user