Variable size depending on width of text
This commit is contained in:
parent
1360dc278a
commit
2ca552fa23
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -4,7 +4,7 @@ plugins {
|
|||||||
}
|
}
|
||||||
|
|
||||||
group 'tech.nevets.vcardgen'
|
group 'tech.nevets.vcardgen'
|
||||||
version '1.0'
|
version '1.1'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -17,9 +17,11 @@ public class Main {
|
|||||||
private static final Color GREEN = new Color(101, 142, 61);
|
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 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 ARIAL45 = new Font("Arial", Font.PLAIN, 45);
|
||||||
private static final Font ARIAL45I = new Font("Arial", Font.ITALIC, 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);
|
private static final Font ARIAL38 = new Font("Arial", Font.ITALIC, 38);
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
@ -49,12 +51,28 @@ public class Main {
|
|||||||
|
|
||||||
g.drawImage(background, 0, 0, null);
|
g.drawImage(background, 0, 0, null);
|
||||||
|
|
||||||
|
FontMetrics fm = g.getFontMetrics(ARIAL65);
|
||||||
|
|
||||||
g.setColor(WHITE);
|
g.setColor(WHITE);
|
||||||
|
if (fm.stringWidth(name) <= 969){
|
||||||
g.setFont(ARIAL65);
|
g.setFont(ARIAL65);
|
||||||
|
} else {
|
||||||
|
g.setFont(ARIAL55);
|
||||||
|
}
|
||||||
g.drawString(name, 85, 112);
|
g.drawString(name, 85, 112);
|
||||||
|
|
||||||
|
fm = g.getFontMetrics(ARIAL45I);
|
||||||
|
if (fm.stringWidth(title) <= 970) {
|
||||||
g.setFont(ARIAL45I);
|
g.setFont(ARIAL45I);
|
||||||
g.drawString(title, 91, 176);
|
} else {
|
||||||
|
g.setFont(ARIAL40I);
|
||||||
|
}
|
||||||
|
g.drawString(title, 89, 176);
|
||||||
|
|
||||||
|
boolean directLine = false;
|
||||||
|
if (hasExtension && extension.length() == 0) {
|
||||||
|
directLine = true;
|
||||||
|
}
|
||||||
|
|
||||||
int yOffset = 0;
|
int yOffset = 0;
|
||||||
if (hasExtension && hasCell) {
|
if (hasExtension && hasCell) {
|
||||||
@ -65,7 +83,7 @@ public class Main {
|
|||||||
g.drawString(email, 62, 380 - yOffset);
|
g.drawString(email, 62, 380 - yOffset);
|
||||||
|
|
||||||
g.setColor(GREEN);
|
g.setColor(GREEN);
|
||||||
g.setFont(ARIAL44);
|
g.setFont(ARIAL44I);
|
||||||
g.drawString(location, 59, 447 - yOffset);
|
g.drawString(location, 59, 447 - yOffset);
|
||||||
|
|
||||||
g.setFont(ARIAL38);
|
g.setFont(ARIAL38);
|
||||||
@ -73,15 +91,23 @@ public class Main {
|
|||||||
|
|
||||||
String number = "";
|
String number = "";
|
||||||
if (hasExtension && !hasCell) {
|
if (hasExtension && !hasCell) {
|
||||||
|
if (directLine) {
|
||||||
|
number = "W: " + schoolNumber;
|
||||||
|
} else {
|
||||||
number = "W: " + schoolNumber + " x" + extension;
|
number = "W: " + schoolNumber + " x" + extension;
|
||||||
|
}
|
||||||
} else if (!hasExtension && hasCell) {
|
} else if (!hasExtension && hasCell) {
|
||||||
number = "C: " + cellNumber;
|
number = "C: " + cellNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(hasExtension && hasCell)) {
|
if (!(hasExtension && hasCell)) {
|
||||||
g.drawString(number, 59, 536);
|
g.drawString(number, 59, 536);
|
||||||
|
} else {
|
||||||
|
if (directLine) {
|
||||||
|
g.drawString("W: " + schoolNumber, 59, 496);
|
||||||
} else {
|
} else {
|
||||||
g.drawString("W: " + schoolNumber + " x" + extension, 59, 496);
|
g.drawString("W: " + schoolNumber + " x" + extension, 59, 496);
|
||||||
|
}
|
||||||
g.drawString("C: " + cellNumber, 59, 540);
|
g.drawString("C: " + cellNumber, 59, 540);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user