public static TupleBvr opened (NumberBvr leftInd, int side) {
Behavior newBvrs[] = {leftInd , add(leftInd, toBvr(1)),
emptyGeometry, endSnd.pan(toBvr(side))};
TupleBvr tuple = new TupleBvr(newBvrs);
return (TupleBvr)untilEx(tuple, orEvent(rightEventNotify,
leftEventNotify));
}
public static TupleBvr backState () {
NumberBvr leftInd = toBvr(A3DM.numPics);
Behavior newBvrs[] = {leftInd, add(leftInd, toBvr(1)),
emptyGeometry, endSnd.pan(-1)};
TupleBvr tuple = new TupleBvr(newBvrs);
return (TupleBvr)untilEx(tuple, rightEventNotify);
}
This notifier object flips the center page to the left side until the
completion of the page flip. At that point if we've flipped
the last page then we go to the back state, else we go to
the opened state, which is the nominal one.
Notice how we extract the present left page index from the "previous"
parameter of the "notify" method. |
class TransLeft extends Statics implements UntilNotifier {
public Behavior notify(Object eventData, Behavior previous, BvrsToRun blst) {
NumberBvr leftInd = (NumberBvr)((TupleBvr)previous).nth(0);
Behavior newBvrs[] = {leftInd, add(leftInd, toBvr(2)),
A3DM.flip(add(leftInd, toBvr(1)), -1), A3DM.flippingSnd(-1)};
return (TupleBvr) until(new TupleBvr(newBvrs), A3DM.endFlip,
cond(eq(leftInd, toBvr(A3DM.numPics - 1)),
A3DM.backState(),
A3DM.opened(add(leftInd, toBvr(1)), -1)));
}
}
class TransRight extends Statics implements UntilNotifier {
public Behavior notify(Object eventData, Behavior previous, BvrsToRun blst) {
NumberBvr leftInd = sub((NumberBvr)((TupleBvr)previous).nth(0), toBvr(1));
Behavior newBvrs[] = {leftInd, add(leftInd, toBvr(2)),
A3DM.flip(add(leftInd, toBvr(1)), +1), A3DM.flippingSnd(+1)};
return (TupleBvr) until(new TupleBvr(newBvrs), A3DM.endFlip,
cond(eq(leftInd, toBvr(0)),
A3DM.frontState(),
A3DM.opened(leftInd, +1)));
}
}
interaction events
Right and left arrows to flip pages. |
static final DXMEvent rightEvent = keyDown(Event.RIGHT);
static final DXMEvent leftEvent = keyDown(Event.LEFT);
signals the conclusion of a page flip animation |
static final DXMEvent endFlip = timer(toBvr(period));
instantiate the notifier objects |
static final TransRight transRight = new TransRight();
static final TransLeft transLeft = new TransLeft();
Define notify events based on the previous objects,
these events get used in the state machine. |
static final DXMEvent rightEventNotify = rightEvent.notifyEvent(transRight);
static final DXMEvent leftEventNotify = leftEvent.notifyEvent(transLeft);
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.