wu
2024-12-31 1edefcae08fe7c8df6a177e5dbbc8ab8f8194187
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
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;
          }
    }
    
    
}