package Optimize;
|
|
import org.json.JSONArray;
|
import org.json.JSONException;
|
import org.json.JSONObject;
|
|
public class OptimizationResult {
|
|
public Boolean Success;
|
public String ErrorMessage;
|
public String btContent;
|
public Layout[] Layouts;
|
|
public OptimizationResult(JSONObject obj) throws JSONException{
|
this.Success=obj.getBoolean("Success");
|
this.ErrorMessage=obj.getString("ErrorMessage");
|
if(obj.has("btContent"))
|
this.btContent=obj.getString("btContent");
|
if(obj.has("Layouts")){
|
JSONArray arr=obj.getJSONArray("Layouts");
|
Layouts=new Layout[arr.length()];
|
for(int i=0;i<Layouts.length;i++){
|
this.Layouts[i]=new Layout(arr.getJSONObject(i));
|
}
|
}
|
}
|
|
|
public JSONObject toJson() throws JSONException {
|
JSONObject obj=new JSONObject();
|
obj.put("Success", this.Success);
|
obj.put("ErrorMessage", this.ErrorMessage);
|
|
obj.put("btContent", this.btContent==null?JSONObject.NULL:this.btContent);
|
if(Layouts==null)
|
obj.put("Layouts",JSONObject.NULL);
|
else{
|
JSONArray ar=new JSONArray();
|
for(int i=0;i<Layouts.length;i++){
|
ar.put(this.Layouts[i].toJson());
|
}
|
obj.put("Layouts",ar);
|
}
|
|
return obj;
|
}
|
|
|
|
public class Layout{
|
public Rect[] rects;
|
public int number;
|
public String wuliao;
|
public int width;
|
public int height;
|
public int SameCount;
|
|
public Layout(JSONObject obj) throws JSONException{
|
this.number=obj.getInt("number");
|
this.wuliao=obj.getString("wuliao");
|
this.width=obj.getInt("width");
|
this.height=obj.getInt("height");
|
this.SameCount=obj.getInt("SameCount");
|
JSONArray arr=obj.getJSONArray("rects");
|
this.rects=new Rect[arr.length()];
|
for(int i=0;i<this.rects.length;i++){
|
this.rects[i]=new Rect(arr.getJSONObject(i));
|
}
|
}
|
public JSONObject toJson() throws JSONException{
|
JSONObject ret=new JSONObject();
|
ret.put("mnumber", number);
|
ret.put("wuliao", this.wuliao);
|
ret.put("width", this.width);
|
ret.put("height",this.height);
|
ret.put("SameCount", this.SameCount);
|
JSONArray arr=new JSONArray();
|
for(int i=0;i<this.rects.length;i++){
|
arr.put(this.rects[i].toJson());
|
}
|
ret.put("rects", arr);
|
return ret;
|
}
|
}
|
|
public class Rect{
|
public double x;
|
public double y;
|
public double w;
|
public double h;
|
public double DM1;
|
public double DM2;
|
public double LM1;
|
public double LM2;
|
public int rownumber;
|
public String xuhao;
|
public boolean isRemain;
|
public String liuchengka;
|
public String JiaHao;
|
|
public Rect(JSONObject obj) throws JSONException{
|
this.x=obj.getDouble("x");
|
this.y=obj.getDouble("y");
|
this.w=obj.getDouble("w");
|
this.h=obj.getDouble("h");
|
this.DM1=obj.getDouble("DM1");
|
this.DM2=obj.getDouble("DM2");
|
this.LM1=obj.getDouble("LM1");
|
this.LM2=obj.getDouble("LM1");
|
this.rownumber=obj.getInt("rownumber");
|
this.xuhao=obj.getString("xuhao");
|
this.isRemain=obj.getBoolean("isRemain");
|
this.liuchengka=obj.getString("liuchengka");
|
this.JiaHao=obj.getString("JiaHao");
|
}
|
|
public JSONObject toJson() throws JSONException{
|
JSONObject obj=new JSONObject();
|
obj.put("x", x);
|
obj.put("y", y);
|
obj.put("w", w);
|
obj.put("h", h);
|
obj.put("DM1", DM1);
|
obj.put("DM2", DM2);
|
obj.put("LM1", LM1);
|
obj.put("LM2", LM2);
|
obj.put("rownumber", rownumber);
|
obj.put("xuhao", xuhao);
|
obj.put("isRemain", isRemain);
|
obj.put("liuchengka", liuchengka);
|
obj.put("JiaHao", JiaHao);
|
return obj;
|
}
|
}
|
|
|
}
|