(int direction, int moves)
| 1222 | } |
| 1223 | |
| 1224 | protected void smartMove(int direction, int moves) { |
| 1225 | cancelSearch(); |
| 1226 | |
| 1227 | if (moves < 1) |
| 1228 | moves = 1; |
| 1229 | |
| 1230 | while (moves-- > 0) |
| 1231 | { |
| 1232 | Adjustable hadj = pageScroll.getHAdjustable(); |
| 1233 | Adjustable vadj = pageScroll.getVAdjustable(); |
| 1234 | int slop_x = hadj.getMaximum() / 20; |
| 1235 | int slop_y = vadj.getMaximum() / 20; |
| 1236 | |
| 1237 | if (direction > 0) { |
| 1238 | int remaining_x = hadj.getMaximum() - hadj.getValue() - hadj.getVisibleAmount(); |
| 1239 | int remaining_y = vadj.getMaximum() - vadj.getValue() - vadj.getVisibleAmount(); |
| 1240 | |
| 1241 | if (remaining_y > slop_y) { |
| 1242 | int value = vadj.getValue() + vadj.getVisibleAmount() * 9 / 10; |
| 1243 | if (value > vadj.getMaximum()) |
| 1244 | value = vadj.getMaximum(); |
| 1245 | vadj.setValue(value); |
| 1246 | } else if (remaining_x > slop_x) { |
| 1247 | vadj.setValue(vadj.getMinimum()); |
| 1248 | int value = hadj.getValue() + hadj.getVisibleAmount() * 9 / 10; |
| 1249 | if (value > hadj.getMaximum()) |
| 1250 | value = hadj.getMaximum(); |
| 1251 | hadj.setValue(value); |
| 1252 | } else { |
| 1253 | doc.flipPages(+1, null); |
| 1254 | vadj.setValue(vadj.getMinimum()); |
| 1255 | hadj.setValue(hadj.getMinimum()); |
| 1256 | } |
| 1257 | } else { |
| 1258 | int remaining_x = Math.abs(hadj.getMinimum() - hadj.getValue()); |
| 1259 | int remaining_y = Math.abs(vadj.getMinimum() - vadj.getValue()); |
| 1260 | |
| 1261 | if (remaining_y > slop_y) { |
| 1262 | int value = vadj.getValue() - vadj.getVisibleAmount() * 9 / 10; |
| 1263 | if (value < vadj.getMinimum()) |
| 1264 | value = vadj.getMinimum(); |
| 1265 | vadj.setValue(value); |
| 1266 | } else if (remaining_x > slop_x) { |
| 1267 | vadj.setValue(vadj.getMaximum()); |
| 1268 | int value = hadj.getValue() - hadj.getVisibleAmount() * 9 / 10; |
| 1269 | if (value < hadj.getMinimum()) |
| 1270 | value = hadj.getMinimum(); |
| 1271 | hadj.setValue(value); |
| 1272 | } else { |
| 1273 | doc.flipPages(-1, null); |
| 1274 | vadj.setValue(vadj.getMaximum()); |
| 1275 | hadj.setValue(hadj.getMaximum()); |
| 1276 | } |
| 1277 | } |
| 1278 | } |
| 1279 | } |
| 1280 | |
| 1281 | protected void flipPages(int number) { |
no test coverage detected