mirror of
https://github.com/2006-Scape/Parabot.git
synced 2026-07-07 08:39:12 +00:00
[FEATURE] Changed layout of VerboseLoader
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<ParabotFont> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
BIN
Binary file not shown.
Vendored
BIN
Binary file not shown.
Binary file not shown.
BIN
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 130 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 89 KiB |
Reference in New Issue
Block a user