-
Notifications
You must be signed in to change notification settings - Fork 5
/
ZoneGeneric.java
80 lines (67 loc) · 2.47 KB
/
ZoneGeneric.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
package org.genericsystem.cv.model;
import org.genericsystem.api.core.annotations.Components;
import org.genericsystem.api.core.annotations.Dependencies;
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.common.Generic;
import org.genericsystem.cv.Zone;
import org.genericsystem.cv.model.DocClass.DocClassInstance;
import org.genericsystem.cv.model.ZoneGeneric.ZoneH;
import org.genericsystem.cv.model.ZoneGeneric.ZoneInstance;
import org.genericsystem.cv.model.ZoneGeneric.ZoneW;
import org.genericsystem.cv.model.ZoneGeneric.ZoneX;
import org.genericsystem.cv.model.ZoneGeneric.ZoneY;
import org.opencv.core.Rect;
/**
* This class stores zones for given class of documents.
*
* @author Jean Mathorel
* @author Pierrik Lassalas
*
*/
@SystemGeneric
@Dependencies({ ZoneX.class, ZoneY.class, ZoneW.class, ZoneH.class })
@Components(DocClass.class)
@InstanceClass(ZoneInstance.class)
public class ZoneGeneric implements Generic {
public static class ZoneInstance implements Generic {
public DocClassInstance getDocClass() {
return (DocClassInstance) this.getHolder(getRoot().find(DocClass.class));
}
public Zone getZoneObject(){
int num = (int) getHolder(getRoot().find(ZoneGeneric.class)).getValue();
int x = (int) getHolder(getRoot().find(ZoneX.class)).getValue();
int y = (int) getHolder(getRoot().find(ZoneY.class)).getValue();
int width = (int) getHolder(getRoot().find(ZoneW.class)).getValue();
int height = (int) getHolder(getRoot().find(ZoneH.class)).getValue();
return new Zone(num, new Rect(x, y, width, height));
}
}
public ZoneInstance setZone(int numZone, DocClassInstance docClass) {
return (ZoneInstance) setInstance(numZone, docClass);
}
public ZoneInstance getZone(int numZone, DocClassInstance docClass) {
return (ZoneInstance) getInstance(numZone, docClass);
}
@SystemGeneric
@Components(ZoneGeneric.class)
@InstanceValueClassConstraint(Integer.class)
public static class ZoneX {
}
@SystemGeneric
@Components(ZoneGeneric.class)
@InstanceValueClassConstraint(Integer.class)
public static class ZoneY {
}
@SystemGeneric
@Components(ZoneGeneric.class)
@InstanceValueClassConstraint(Integer.class)
public static class ZoneW {
}
@SystemGeneric
@Components(ZoneGeneric.class)
@InstanceValueClassConstraint(Integer.class)
public static class ZoneH {
}
}