Lines 38-47
Link Here
|
38 |
{ |
38 |
{ |
39 |
public final static short sid = 0x25; |
39 |
public final static short sid = 0x25; |
40 |
private final static int SIZE = 9; |
40 |
private final static int SIZE = 9; |
41 |
private short field_1_first_row; |
41 |
/** zero based, unsigned 16 bit */ |
42 |
private short field_2_last_row; |
42 |
private int field_1_first_row; |
43 |
private short field_3_first_column; |
43 |
/** zero based, unsigned 16 bit */ |
44 |
private short field_4_last_column; |
44 |
private int field_2_last_row; |
|
|
45 |
/** zero based, unsigned 8 bit */ |
46 |
private int field_3_first_column; |
47 |
/** zero based, unsigned 8 bit */ |
48 |
private int field_4_last_column; |
45 |
|
49 |
|
46 |
private final static BitField rowRelative = BitFieldFactory.getInstance(0x8000); |
50 |
private final static BitField rowRelative = BitFieldFactory.getInstance(0x8000); |
47 |
private final static BitField colRelative = BitFieldFactory.getInstance(0x4000); |
51 |
private final static BitField colRelative = BitFieldFactory.getInstance(0x4000); |
Lines 55-63
Link Here
|
55 |
AreaReference ar = new AreaReference(arearef); |
59 |
AreaReference ar = new AreaReference(arearef); |
56 |
CellReference firstCell = ar.getFirstCell(); |
60 |
CellReference firstCell = ar.getFirstCell(); |
57 |
CellReference lastCell = ar.getLastCell(); |
61 |
CellReference lastCell = ar.getLastCell(); |
58 |
setFirstRow((short)firstCell.getRow()); |
62 |
setFirstRow(firstCell.getRow()); |
59 |
setFirstColumn(firstCell.getCol()); |
63 |
setFirstColumn(firstCell.getCol()); |
60 |
setLastRow((short)lastCell.getRow()); |
64 |
setLastRow(lastCell.getRow()); |
61 |
setLastColumn(lastCell.getCol()); |
65 |
setLastColumn(lastCell.getCol()); |
62 |
setFirstColRelative(!firstCell.isColAbsolute()); |
66 |
setFirstColRelative(!firstCell.isColAbsolute()); |
63 |
setLastColRelative(!lastCell.isColAbsolute()); |
67 |
setLastColRelative(!lastCell.isColAbsolute()); |
Lines 65-71
Link Here
|
65 |
setLastRowRelative(!lastCell.isRowAbsolute()); |
69 |
setLastRowRelative(!lastCell.isRowAbsolute()); |
66 |
} |
70 |
} |
67 |
|
71 |
|
68 |
public AreaPtg(short firstRow, short lastRow, short firstColumn, short lastColumn, boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) { |
72 |
public AreaPtg(int firstRow, int lastRow, int firstColumn, int lastColumn, |
|
|
73 |
boolean firstRowRelative, boolean lastRowRelative, boolean firstColRelative, boolean lastColRelative) { |
74 |
|
75 |
checkColumnBounds(firstColumn); |
76 |
checkColumnBounds(lastColumn); |
77 |
checkRowBounds(firstRow); |
78 |
checkRowBounds(lastRow); |
69 |
setFirstRow(firstRow); |
79 |
setFirstRow(firstRow); |
70 |
setLastRow(lastRow); |
80 |
setLastRow(lastRow); |
71 |
setFirstColumn(firstColumn); |
81 |
setFirstColumn(firstColumn); |
Lines 76-87
Link Here
|
76 |
setLastColRelative(lastColRelative); |
86 |
setLastColRelative(lastColRelative); |
77 |
} |
87 |
} |
78 |
|
88 |
|
|
|
89 |
private static void checkColumnBounds(int colIx) { |
90 |
if((colIx & 0x0FF) != colIx) { |
91 |
throw new IllegalArgumentException("colIx (" + colIx + ") is out of range"); |
92 |
} |
93 |
} |
94 |
private static void checkRowBounds(int rowIx) { |
95 |
if((rowIx & 0x0FFFF) != rowIx) { |
96 |
throw new IllegalArgumentException("rowIx (" + rowIx + ") is out of range"); |
97 |
} |
98 |
} |
99 |
|
79 |
public AreaPtg(RecordInputStream in) |
100 |
public AreaPtg(RecordInputStream in) |
80 |
{ |
101 |
{ |
81 |
field_1_first_row = in.readShort(); |
102 |
field_1_first_row = in.readUShort(); |
82 |
field_2_last_row = in.readShort(); |
103 |
field_2_last_row = in.readUShort(); |
83 |
field_3_first_column = in.readShort(); |
104 |
field_3_first_column = in.readUShort(); |
84 |
field_4_last_column = in.readShort(); |
105 |
field_4_last_column = in.readUShort(); |
85 |
//System.out.println(toString()); |
106 |
//System.out.println(toString()); |
86 |
} |
107 |
} |
87 |
|
108 |
|
Lines 110-119
Link Here
|
110 |
|
131 |
|
111 |
public void writeBytes(byte [] array, int offset) { |
132 |
public void writeBytes(byte [] array, int offset) { |
112 |
array[offset] = (byte) (sid + ptgClass); |
133 |
array[offset] = (byte) (sid + ptgClass); |
113 |
LittleEndian.putShort(array,offset+1,field_1_first_row); |
134 |
LittleEndian.putShort(array,offset+1,(short)field_1_first_row); |
114 |
LittleEndian.putShort(array,offset+3,field_2_last_row); |
135 |
LittleEndian.putShort(array,offset+3,(short)field_2_last_row); |
115 |
LittleEndian.putShort(array,offset+5,field_3_first_column); |
136 |
LittleEndian.putShort(array,offset+5,(short)field_3_first_column); |
116 |
LittleEndian.putShort(array,offset+7,field_4_last_column); |
137 |
LittleEndian.putShort(array,offset+7,(short)field_4_last_column); |
117 |
} |
138 |
} |
118 |
|
139 |
|
119 |
public int getSize() |
140 |
public int getSize() |
Lines 124-165
Link Here
|
124 |
/** |
145 |
/** |
125 |
* @return the first row in the area |
146 |
* @return the first row in the area |
126 |
*/ |
147 |
*/ |
127 |
public short getFirstRow() |
148 |
public int getFirstRow() |
128 |
{ |
149 |
{ |
129 |
return field_1_first_row; |
150 |
return field_1_first_row; |
130 |
} |
151 |
} |
131 |
|
152 |
|
132 |
/** |
153 |
/** |
133 |
* sets the first row |
154 |
* sets the first row |
134 |
* @param row number (0-based) |
155 |
* @param rowIx number (0-based) |
135 |
*/ |
156 |
*/ |
136 |
public void setFirstRow(short row) |
157 |
public void setFirstRow(int rowIx) { |
137 |
{ |
158 |
checkRowBounds(rowIx); |
138 |
field_1_first_row = row; |
159 |
field_1_first_row = rowIx; |
139 |
} |
160 |
} |
140 |
|
161 |
|
141 |
/** |
162 |
/** |
142 |
* @return last row in the range (x2 in x1,y1-x2,y2) |
163 |
* @return last row in the range (x2 in x1,y1-x2,y2) |
143 |
*/ |
164 |
*/ |
144 |
public short getLastRow() |
165 |
public int getLastRow() |
145 |
{ |
166 |
{ |
146 |
return field_2_last_row; |
167 |
return field_2_last_row; |
147 |
} |
168 |
} |
148 |
|
169 |
|
149 |
/** |
170 |
/** |
150 |
* @param row last row number in the area |
171 |
* @param rowIx last row number in the area |
151 |
*/ |
172 |
*/ |
152 |
public void setLastRow(short row) |
173 |
public void setLastRow(int rowIx) { |
153 |
{ |
174 |
checkRowBounds(rowIx); |
154 |
field_2_last_row = row; |
175 |
field_2_last_row = rowIx; |
155 |
} |
176 |
} |
156 |
|
177 |
|
157 |
/** |
178 |
/** |
158 |
* @return the first column number in the area. |
179 |
* @return the first column number in the area. |
159 |
*/ |
180 |
*/ |
160 |
public short getFirstColumn() |
181 |
public int getFirstColumn() |
161 |
{ |
182 |
{ |
162 |
return columnMask.getShortValue(field_3_first_column); |
183 |
return columnMask.getValue(field_3_first_column); |
163 |
} |
184 |
} |
164 |
|
185 |
|
165 |
/** |
186 |
/** |
Lines 167-173
Link Here
|
167 |
*/ |
188 |
*/ |
168 |
public short getFirstColumnRaw() |
189 |
public short getFirstColumnRaw() |
169 |
{ |
190 |
{ |
170 |
return field_3_first_column; |
191 |
return (short) field_3_first_column; // TODO |
171 |
} |
192 |
} |
172 |
|
193 |
|
173 |
/** |
194 |
/** |
Lines 183-189
Link Here
|
183 |
* @param rel is relative or not. |
204 |
* @param rel is relative or not. |
184 |
*/ |
205 |
*/ |
185 |
public void setFirstRowRelative(boolean rel) { |
206 |
public void setFirstRowRelative(boolean rel) { |
186 |
field_3_first_column=rowRelative.setShortBoolean(field_3_first_column,rel); |
207 |
field_3_first_column=rowRelative.setBoolean(field_3_first_column,rel); |
187 |
} |
208 |
} |
188 |
|
209 |
|
189 |
/** |
210 |
/** |
Lines 198-218
Link Here
|
198 |
* set whether the first column is relative |
219 |
* set whether the first column is relative |
199 |
*/ |
220 |
*/ |
200 |
public void setFirstColRelative(boolean rel) { |
221 |
public void setFirstColRelative(boolean rel) { |
201 |
field_3_first_column=colRelative.setShortBoolean(field_3_first_column,rel); |
222 |
field_3_first_column=colRelative.setBoolean(field_3_first_column,rel); |
202 |
} |
223 |
} |
203 |
|
224 |
|
204 |
/** |
225 |
/** |
205 |
* set the first column in the area |
226 |
* set the first column in the area |
206 |
*/ |
227 |
*/ |
207 |
public void setFirstColumn(short column) |
228 |
public void setFirstColumn(int colIx) { |
208 |
{ |
229 |
checkColumnBounds(colIx); |
209 |
field_3_first_column=columnMask.setShortValue(field_3_first_column, column); |
230 |
field_3_first_column=columnMask.setValue(field_3_first_column, colIx); |
210 |
} |
231 |
} |
211 |
|
232 |
|
212 |
/** |
233 |
/** |
213 |
* set the first column irespective of the bitmasks |
234 |
* set the first column irespective of the bitmasks |
214 |
*/ |
235 |
*/ |
215 |
public void setFirstColumnRaw(short column) |
236 |
public void setFirstColumnRaw(int column) |
216 |
{ |
237 |
{ |
217 |
field_3_first_column = column; |
238 |
field_3_first_column = column; |
218 |
} |
239 |
} |
Lines 220-228
Link Here
|
220 |
/** |
241 |
/** |
221 |
* @return lastcolumn in the area |
242 |
* @return lastcolumn in the area |
222 |
*/ |
243 |
*/ |
223 |
public short getLastColumn() |
244 |
public int getLastColumn() |
224 |
{ |
245 |
{ |
225 |
return columnMask.getShortValue(field_4_last_column); |
246 |
return columnMask.getValue(field_4_last_column); |
226 |
} |
247 |
} |
227 |
|
248 |
|
228 |
/** |
249 |
/** |
Lines 230-236
Link Here
|
230 |
*/ |
251 |
*/ |
231 |
public short getLastColumnRaw() |
252 |
public short getLastColumnRaw() |
232 |
{ |
253 |
{ |
233 |
return field_4_last_column; |
254 |
return (short) field_4_last_column; |
234 |
} |
255 |
} |
235 |
|
256 |
|
236 |
/** |
257 |
/** |
Lines 247-253
Link Here
|
247 |
* <code>false</code> |
268 |
* <code>false</code> |
248 |
*/ |
269 |
*/ |
249 |
public void setLastRowRelative(boolean rel) { |
270 |
public void setLastRowRelative(boolean rel) { |
250 |
field_4_last_column=rowRelative.setShortBoolean(field_4_last_column,rel); |
271 |
field_4_last_column=rowRelative.setBoolean(field_4_last_column,rel); |
251 |
} |
272 |
} |
252 |
|
273 |
|
253 |
/** |
274 |
/** |
Lines 262-277
Link Here
|
262 |
* set whether the last column should be relative or not |
283 |
* set whether the last column should be relative or not |
263 |
*/ |
284 |
*/ |
264 |
public void setLastColRelative(boolean rel) { |
285 |
public void setLastColRelative(boolean rel) { |
265 |
field_4_last_column=colRelative.setShortBoolean(field_4_last_column,rel); |
286 |
field_4_last_column=colRelative.setBoolean(field_4_last_column,rel); |
266 |
} |
287 |
} |
267 |
|
288 |
|
268 |
|
289 |
|
269 |
/** |
290 |
/** |
270 |
* set the last column in the area |
291 |
* set the last column in the area |
271 |
*/ |
292 |
*/ |
272 |
public void setLastColumn(short column) |
293 |
public void setLastColumn(int colIx) { |
273 |
{ |
294 |
checkColumnBounds(colIx); |
274 |
field_4_last_column=columnMask.setShortValue(field_4_last_column, column); |
295 |
field_4_last_column=columnMask.setValue(field_4_last_column, colIx); |
275 |
} |
296 |
} |
276 |
|
297 |
|
277 |
/** |
298 |
/** |