|
@@ -1,11 +1,15 @@
|
|
|
package utils;
|
|
|
|
|
|
+import com.google.gson.Gson;
|
|
|
import config.Config;
|
|
|
+import config.subConfig.*;
|
|
|
+import org.omg.IOP.ENCODING_CDR_ENCAPS;
|
|
|
import org.yaml.snakeyaml.Yaml;
|
|
|
|
|
|
import java.io.FileInputStream;
|
|
|
import java.io.FileNotFoundException;
|
|
|
import java.net.URL;
|
|
|
+import java.util.List;
|
|
|
|
|
|
/**
|
|
|
* @author duh
|
|
@@ -19,6 +23,10 @@ public class YmlUtils {
|
|
|
if(null != url){
|
|
|
try {
|
|
|
Config templateConfig = yaml.loadAs(new FileInputStream(url.getFile()), Config.class);
|
|
|
+ Gson gson = new Gson();
|
|
|
+ System.out.println(gson.toJson(templateConfig));
|
|
|
+ zoomLengthWidthXY(templateConfig);
|
|
|
+ System.out.println(gson.toJson(templateConfig));
|
|
|
return templateConfig;
|
|
|
} catch (FileNotFoundException e) {
|
|
|
e.printStackTrace();
|
|
@@ -26,4 +34,43 @@ public class YmlUtils {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+ private static void zoomLengthWidthXY(Config config){
|
|
|
+ int enlarge = config.getEnlarge();
|
|
|
+ int narrow = config.getNarrow();
|
|
|
+
|
|
|
+ zoomRoom(config, enlarge, narrow);
|
|
|
+ List<TemplateConfig> templates = config.getTemplates();
|
|
|
+ for(TemplateConfig templateConfig : templates){
|
|
|
+ zoomTemplate(templateConfig, enlarge, narrow);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void zoomTemplate(TemplateConfig templateConfig, int enlarge, int narrow) {
|
|
|
+ templateConfig.setLength(templateConfig.getLength()*enlarge/narrow);
|
|
|
+ templateConfig.setWidth(templateConfig.getWidth()*enlarge/narrow);
|
|
|
+ templateConfig.setX(templateConfig.getX()*enlarge/narrow);
|
|
|
+ templateConfig.setY(templateConfig.getY()*enlarge/narrow);
|
|
|
+ TemplateShadowConfig shadow = templateConfig.getShadow();
|
|
|
+ shadow.setRadis(shadow.getRadis()*enlarge/narrow);
|
|
|
+ shadow.setWidth(shadow.getWidth()*enlarge/narrow);
|
|
|
+ shadow.setX(shadow.getX()*enlarge/narrow);
|
|
|
+ shadow.setY(shadow.getY()*enlarge/narrow);
|
|
|
+ templateConfig.setShadow(shadow);
|
|
|
+ }
|
|
|
+
|
|
|
+ private static void zoomRoom(Config config, int enlarge, int narrow) {
|
|
|
+ RoomConfig room = config.getRoom();
|
|
|
+ room.setLength(room.getLength()*enlarge/narrow);
|
|
|
+ room.setWidth(room.getWidth()*enlarge/narrow);
|
|
|
+ room.setX(room.getX()*enlarge/narrow);
|
|
|
+ room.setY(room.getY()*enlarge/narrow);
|
|
|
+ config.setRoom(room);
|
|
|
+ DoorConfig door = config.getDoor();
|
|
|
+ door.setX(door.getX()*enlarge/narrow);
|
|
|
+ door.setY(door.getY()*enlarge/narrow);
|
|
|
+ door.setRadis(door.getRadis()*enlarge/narrow);
|
|
|
+ DoorShadowConfig doorShadow = door.getDoorShadow();
|
|
|
+ doorShadow.setRadis(doorShadow.getRadis()*enlarge/narrow);
|
|
|
+ }
|
|
|
}
|