01: /*
02: * ====================================================================
03: * Copyright (c) 2004 Marc Strapetz, marc.strapetz@smartsvn.com.
04: * All rights reserved.
05: *
06: * This software is licensed as described in the file COPYING, which
07: * you should have received as part of this distribution. Use is
08: * subject to license terms.
09: * ====================================================================
10: */
11:
12: package de.regnis.q.sequence.core;
13:
14: /**
15: * @author Marc Strapetz
16: */
17: class QSequenceDeePathForwardExtender extends QSequenceDeePathExtender {
18:
19: // Setup ==================================================================
20:
21: public QSequenceDeePathForwardExtender(int maximumMediaLeftLength,
22: int maximumMediaRightLength) {
23: super (new QSequenceDeePathExtenderArray(maximumMediaLeftLength
24: + maximumMediaRightLength));
25: }
26:
27: // Accessing ==============================================================
28:
29: protected int getNextX(QSequenceDeePathExtenderArray xs,
30: int diagonal, int dee) {
31: if (diagonal == -dee
32: || (diagonal != dee && xs.get(diagonal - 1) < xs
33: .get(diagonal + 1))) {
34: return xs.get(diagonal + 1);
35: }
36:
37: return xs.get(diagonal - 1) + 1;
38: }
39:
40: protected int getSnakeX(QSequenceMedia media, int x, int y)
41: throws QSequenceException {
42: for (; x < media.getLeftLength() && y < media.getRightLength()
43: && media.equals(x + 1, y + 1);) {
44: x++;
45: y++;
46: }
47:
48: return x;
49: }
50:
51: protected final void reset(QSequenceMedia media,
52: QSequenceDeePathExtenderArray xs) {
53: xs.set(1, 0);
54: }
55:
56: public int getProgress(int diagonal) {
57: return getLeft(diagonal) + getRight(diagonal);
58: }
59: }
|