Add rectangle support to config

This commit is contained in:
WooxSolo
2018-04-27 04:32:01 +02:00
committed by Adam
parent 20fcaf8d81
commit aa718b1a99

View File

@@ -30,6 +30,7 @@ import com.google.common.eventbus.EventBus;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
@@ -449,6 +450,15 @@ public class ConfigManager
int height = Integer.parseInt(splitStr[1]);
return new Point(width, height);
}
if (type == Rectangle.class)
{
String[] splitStr = str.split(":");
int x = Integer.parseInt(splitStr[0]);
int y = Integer.parseInt(splitStr[1]);
int width = Integer.parseInt(splitStr[2]);
int height = Integer.parseInt(splitStr[3]);
return new Rectangle(x, y, width, height);
}
if (type.isEnum())
{
return Enum.valueOf((Class<? extends Enum>) type, str);
@@ -476,6 +486,11 @@ public class ConfigManager
Point p = (Point) object;
return p.x + ":" + p.y;
}
if (object instanceof Rectangle)
{
Rectangle r = (Rectangle)object;
return r.x + ":" + r.y + ":" + r.width + ":" + r.height;
}
return object.toString();
}
}