diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..94ef28e Binary files /dev/null and b/.DS_Store differ diff --git a/src/main/java/org/parabot/core/ui/fonts/ParabotFont.java b/src/main/java/org/parabot/core/ui/fonts/ParabotFont.java new file mode 100644 index 0000000..32ea07d --- /dev/null +++ b/src/main/java/org/parabot/core/ui/fonts/ParabotFont.java @@ -0,0 +1,64 @@ +package org.parabot.core.ui.fonts; + +import org.parabot.core.ui.utils.Fonts; + +import java.awt.*; +import java.io.IOException; + +/** + * @author Capslock + */ +public class ParabotFont { + + private String name; + private String location; + private Font font; + + public ParabotFont(String location, float size) { + if (!location.toLowerCase().startsWith("/storage/fonts/")){ + location = "/storage/fonts/" + location; + } + this.location = location; + + try { + this.font = createFont(size); + } catch (FontFormatException | IOException e) { + e.printStackTrace(); + } + } + + private Font createFont(float size) throws IOException, FontFormatException { + return Font.createFont(Font.TRUETYPE_FONT, Fonts.class.getResourceAsStream(this.location)).deriveFont(size); + } + + public float getSize() { + return font.getSize(); + } + + public String getLocation() { + return location; + } + + public String getName() { + return name; + } + + public Font getFont() { + return font; + } + + @Override + public boolean equals(Object obj) { + if (obj != null) { + if (obj instanceof ParabotFont) { + ParabotFont otherFont = (ParabotFont) obj; + if (otherFont.getName().equalsIgnoreCase(this.getName())) { + if (otherFont.getSize() == this.getSize()) { + return true; + } + } + } + } + return false; + } +} diff --git a/src/main/java/org/parabot/core/ui/utils/Fonts.java b/src/main/java/org/parabot/core/ui/utils/Fonts.java new file mode 100644 index 0000000..2c0ba07 --- /dev/null +++ b/src/main/java/org/parabot/core/ui/utils/Fonts.java @@ -0,0 +1,42 @@ +package org.parabot.core.ui.utils; + +import org.parabot.core.ui.fonts.ParabotFont; + +import java.awt.*; +import java.util.*; + +/** + * Created by Capslock + * On 28/04/16 + * With IntelliJ + */ +public class Fonts { + private static final java.util.List FONT_CACHE = new ArrayList<>(); + + /** + * Calls the getResource with the default size of 12 + * + * @param resource + * @return + */ + public static Font getResource(final String resource){ + return getResource(resource, 12f); + } + + public static Font getResource(final String fileName, float size) { + ParabotFont parabotFont = null; + + for (ParabotFont font : FONT_CACHE) { + if (font.getLocation().equalsIgnoreCase(fileName) && font.getSize() == size){ + parabotFont = font; + } + } + + if (parabotFont == null){ + parabotFont = new ParabotFont(fileName, size); + FONT_CACHE.add(parabotFont); + } + + return parabotFont.getFont(); + } +} diff --git a/src/main/resources/.DS_Store b/src/main/resources/.DS_Store new file mode 100644 index 0000000..2323c7f Binary files /dev/null and b/src/main/resources/.DS_Store differ diff --git a/src/main/resources/storage/.DS_Store b/src/main/resources/storage/.DS_Store new file mode 100644 index 0000000..5a456ba Binary files /dev/null and b/src/main/resources/storage/.DS_Store differ diff --git a/src/main/resources/storage/fonts/leelawadee.ttf b/src/main/resources/storage/fonts/leelawadee.ttf new file mode 100644 index 0000000..8d5e4b5 Binary files /dev/null and b/src/main/resources/storage/fonts/leelawadee.ttf differ diff --git a/src/main/resources/storage/images/.DS_Store b/src/main/resources/storage/images/.DS_Store new file mode 100644 index 0000000..c23a339 Binary files /dev/null and b/src/main/resources/storage/images/.DS_Store differ diff --git a/src/main/resources/storage/images/login.png b/src/main/resources/storage/images/login.png new file mode 100644 index 0000000..ef5014e Binary files /dev/null and b/src/main/resources/storage/images/login.png differ diff --git a/src/main/resources/storage/images/logo.png b/src/main/resources/storage/images/logo.png new file mode 100644 index 0000000..fe40317 Binary files /dev/null and b/src/main/resources/storage/images/logo.png differ