Skip to content

Commit d408a41

Browse files
committed
VImage x/y offset
1 parent 6d8d076 commit d408a41

2 files changed

Lines changed: 60 additions & 2 deletions

File tree

epics-vtype/vtype/src/main/java/org/epics/vtype/IVImage.java

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,27 @@ public class IVImage extends VImage {
1515

1616
private final int height;
1717
private final int width;
18+
private final int xoffset;
19+
private final int yoffset;
1820
private final ListNumber data;
1921
private final VImageDataType imageDataType;
2022
private final VImageType imageType;
2123

2224
IVImage(int height, int width, ListNumber data, VImageDataType imageDataType, VImageType imageType, Alarm alarm,
2325
Time time) {
24-
super();
26+
this(height, width, 0, 0, data, imageDataType, imageType, alarm, time);
27+
}
28+
29+
IVImage(int height, int width, int xoffset, int yoffset, ListNumber data, VImageDataType imageDataType, VImageType imageType, Alarm alarm,
30+
Time time) {
2531
VType.argumentNotNull("alarm", alarm);
2632
VType.argumentNotNull("time", time);
2733
this.alarm = alarm;
2834
this.time = time;
2935
this.height = height;
3036
this.width = width;
37+
this.xoffset = xoffset;
38+
this.yoffset = yoffset;
3139
this.data = data;
3240
this.imageDataType = imageDataType;
3341
this.imageType = imageType;
@@ -41,6 +49,14 @@ public int getWidth() {
4149
return width;
4250
}
4351

52+
public int getXOffset() {
53+
return xoffset;
54+
}
55+
56+
public int getYOffset() {
57+
return yoffset;
58+
}
59+
4460
public ListNumber getData() {
4561
return data;
4662
}

epics-vtype/vtype/src/main/java/org/epics/vtype/VImage.java

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ public abstract class VImage extends VType implements AlarmProvider, TimeProvide
2929
*/
3030
public abstract int getWidth();
3131

32+
/**
33+
* Horizontal pixel offset.
34+
* For sub-images within a larger image,
35+
* this is the X offset.
36+
* Defaults to zero.
37+
*
38+
* @return pixel offset
39+
*/
40+
public abstract int getXOffset();
41+
42+
/**
43+
* Vertical pixel offset.
44+
* For sub-images within a larger image,
45+
* this is the Y offset.
46+
* Defaults to zero.
47+
*
48+
* @return pixel offset
49+
*/
50+
public abstract int getYOffset();
51+
3252
/**
3353
* Image data;
3454
*
@@ -65,7 +85,25 @@ public abstract class VImage extends VType implements AlarmProvider, TimeProvide
6585
* @return a new instance of VImage
6686
*/
6787
public static VImage of(int height, int width, final ListNumber data, VImageDataType imageDataType, VImageType vImageType, Alarm alarm, Time time) {
68-
return new IVImage(height, width, data, imageDataType, vImageType, alarm, time);
88+
return of(height, width, 0, 0, data, imageDataType, vImageType, alarm, time);
89+
}
90+
91+
/**
92+
* Creates a new VImage.
93+
*
94+
* @param height image height
95+
* @param width image width
96+
* @param xoffset horizontal offset
97+
* @param yoffset vertical offset
98+
* @param data image data
99+
* @param imageDataType image data type
100+
* @param vImageType image type
101+
* @param alarm alarm information
102+
* @param time timestamp
103+
* @return a new instance of VImage
104+
*/
105+
public static VImage of(int height, int width, int xoffset, int yoffset, final ListNumber data, VImageDataType imageDataType, VImageType vImageType, Alarm alarm, Time time) {
106+
return new IVImage(height, width, xoffset, yoffset, data, imageDataType, vImageType, alarm, time);
69107
}
70108

71109
@Override
@@ -80,6 +118,8 @@ public final boolean equals(Object obj) {
80118
return getClass().equals(other.getClass())
81119
&& getHeight() == other.getHeight()
82120
&& getWidth() == other.getWidth()
121+
&& getXOffset() == other.getXOffset()
122+
&& getYOffset() == other.getYOffset()
83123
&& getData().equals(other.getData())
84124
&& getDataType().equals(other.getDataType())
85125
&& getVImageType().equals(other.getVImageType())
@@ -95,6 +135,8 @@ public final int hashCode() {
95135
int hash = 7;
96136
hash = 23 * hash + Objects.hashCode(getHeight());
97137
hash = 23 * hash + Objects.hashCode(getWidth());
138+
hash = 23 * hash + Objects.hashCode(getXOffset());
139+
hash = 23 * hash + Objects.hashCode(getYOffset());
98140
hash = 23 * hash + Objects.hashCode(getData());
99141
hash = 23 * hash + Objects.hashCode(getDataType());
100142
hash = 23 * hash + Objects.hashCode(getVImageType());

0 commit comments

Comments
 (0)