Make head displayed more precisely

This commit is contained in:
huanghongxun
2018-09-25 12:30:21 +08:00
parent 4d366397a8
commit 01ff1327f7
2 changed files with 7 additions and 7 deletions

View File

@@ -95,7 +95,7 @@ public final class AccountHelper {
public static Image getHead(Image skin, int scaleRatio) { public static Image getHead(Image skin, int scaleRatio) {
final int size = 8 * scaleRatio; final int size = 8 * scaleRatio;
final int faceOffset = (int) Math.floor(scaleRatio * 4d / 9d); final int faceOffset = (int) Math.round(scaleRatio * 4d / 9d);
BufferedImage image = SwingFXUtils.fromFXImage(skin, null); BufferedImage image = SwingFXUtils.fromFXImage(skin, null);
BufferedImage head = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB); BufferedImage head = new BufferedImage(size, size, BufferedImage.TYPE_INT_ARGB);
Graphics2D g2d = head.createGraphics(); Graphics2D g2d = head.createGraphics();

View File

@@ -43,7 +43,11 @@ public final class UUIDTypeAdapter extends TypeAdapter<UUID> {
@Override @Override
public UUID read(JsonReader reader) throws IOException { public UUID read(JsonReader reader) throws IOException {
return fromString(reader.nextString()); try {
return fromString(reader.nextString());
} catch (IllegalArgumentException e) {
throw new JsonParseException("UUID malformed");
}
} }
public static String fromUUID(UUID value) { public static String fromUUID(UUID value) {
@@ -51,11 +55,7 @@ public final class UUIDTypeAdapter extends TypeAdapter<UUID> {
} }
public static UUID fromString(String input) { public static UUID fromString(String input) {
try { return UUID.fromString(input.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));
return UUID.fromString(input.replaceFirst("(\\w{8})(\\w{4})(\\w{4})(\\w{4})(\\w{12})", "$1-$2-$3-$4-$5"));
} catch (IllegalArgumentException e) {
throw new JsonParseException("UUID malformed");
}
} }
} }