-
Notifications
You must be signed in to change notification settings - Fork 5
/
Field.java
85 lines (71 loc) · 2.51 KB
/
Field.java
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
package org.genericsystem.cv.classifier.newmodel;
import org.genericsystem.api.core.annotations.Components;
import org.genericsystem.api.core.annotations.InstanceClass;
import org.genericsystem.api.core.annotations.SystemGeneric;
import org.genericsystem.api.core.annotations.constraints.InstanceValueClassConstraint;
import org.genericsystem.api.core.annotations.constraints.PropertyConstraint;
import org.genericsystem.common.Generic;
import org.genericsystem.cv.classifier.newmodel.Fields.FieldsInstance;
import org.opencv.core.Rect;
@SystemGeneric
@Components(Fields.class)
@InstanceClass(Field.FieldInstance.class)
public class Field implements Generic {
@SystemGeneric
public static class FieldInstance implements Generic {
public FieldsInstance getFields() {
return (FieldsInstance) getBaseComponent();
}
public Field.FieldInstance setField(Rect rect, String consolidated) {
setHolder(getRoot().find(RectX.class), rect.x);
setHolder(getRoot().find(RectY.class), rect.y);
setHolder(getRoot().find(RectW.class), rect.width);
setHolder(getRoot().find(RectH.class), rect.height);
setHolder(getRoot().find(Consolidated.class), consolidated);
return this;
}
public Rect getRect() {
int x = (int) getHolder(getRoot().find(RectX.class)).getValue();
int y = (int) getHolder(getRoot().find(RectY.class)).getValue();
int width = (int) getHolder(getRoot().find(RectW.class)).getValue();
int height = (int) getHolder(getRoot().find(RectH.class)).getValue();
return new Rect(x, y, width, height);
}
public String getConsolidated() {
return String.valueOf(getHolder(getRoot().find(Consolidated.class)).getValue());
}
public boolean isConsolidated() {
return getConsolidated() != null;
}
}
@SystemGeneric
@Components(Field.class)
@InstanceValueClassConstraint(Integer.class)
@PropertyConstraint
public static class RectX implements Generic {
}
@SystemGeneric
@Components(Field.class)
@InstanceValueClassConstraint(Integer.class)
@PropertyConstraint
public static class RectY implements Generic {
}
@SystemGeneric
@Components(Field.class)
@InstanceValueClassConstraint(Integer.class)
@PropertyConstraint
public static class RectW implements Generic {
}
@SystemGeneric
@Components(Field.class)
@InstanceValueClassConstraint(Integer.class)
@PropertyConstraint
public static class RectH implements Generic {
}
@SystemGeneric
@Components(Field.class)
@InstanceValueClassConstraint(String.class)
@PropertyConstraint
public static class Consolidated implements Generic {
}
}