home *** CD-ROM | disk | FTP | other *** search
- import corel.transitions.Transition;
- import java.applet.AudioClip;
-
- public class AutoScroll implements Runnable {
- public static final int m_iConstScrollOnUndefined = 0;
- public static final int m_iConstScrollOnTime = 1;
- public static final int m_iConstScrollOnEvents = 2;
- public static final int m_iConstScrollOnSound = 3;
- public static final int m_iConstStatusScrollingStopped = 1;
- private VDoc m_Document;
- private int[] m_iAutoScrollPauseTypes;
- private long[] m_lAutoScrollPauseTimes;
- private String[] m_strAutoScrollPauseSounds;
- private boolean[] m_bNonDefaultValues;
- private boolean m_bForward;
- private boolean m_bScrollingStopped;
- private Thread m_ThreadAutoScroll;
- private boolean m_bViewUpdated;
- private Transition m_Transition;
- private AudioClip m_AudioClip;
-
- public AutoScroll(VDoc var1, int var2) {
- int var4 = var1.m_nNumOfPages;
- this.m_Document = var1;
- this.m_iAutoScrollPauseTypes = new int[var4];
- this.m_lAutoScrollPauseTimes = new long[var4];
- this.m_strAutoScrollPauseSounds = new String[var4];
- this.m_bNonDefaultValues = new boolean[var4];
-
- for(int var3 = 0; var3 < var4; ++var3) {
- this.m_iAutoScrollPauseTypes[var3] = 2;
- }
-
- this.m_Transition = new Transition(this.m_Document.m_Applet, var4, this.m_Document.m_Applet.GetVersionStatusString());
- }
-
- public void run() {
- this.m_bViewUpdated = false;
- this.DoScrollActions();
- if (this.m_ThreadAutoScroll.isAlive()) {
- try {
- this.m_ThreadAutoScroll.stop();
- } catch (ThreadDeath var2) {
- this.m_ThreadAutoScroll = null;
- throw var2;
- }
- }
- }
-
- private final void DoScrollActions() {
- label40: {
- if (this.m_Document.m_nNumOfPages > 1 && (this.m_bForward && this.m_Document.m_iCurrPage < this.m_Document.m_nNumOfPages || !this.m_bForward && this.m_Document.m_iCurrPage > 1)) {
- switch (this.m_iAutoScrollPauseTypes[this.m_Document.m_iCurrPage - 1]) {
- case 1:
- case 3:
- if (this.m_Transition.DoingTransition()) {
- do {
- this.WaitScrollTime(200L);
- } while(this.m_Transition.DoingTransition());
- }
-
- if (!this.WaitScrollTime(0L)) {
- break;
- }
-
- if (this.m_bScrollingStopped) {
- return;
- }
- case 2:
- break label40;
- }
- }
-
- return;
- }
-
- this.ScrollPage();
- }
-
- public final boolean Start(boolean var1, boolean var2, boolean var3) {
- if (var3) {
- if (!this.m_bScrollingStopped) {
- this.m_bScrollingStopped = true;
- this.ShowStatus();
- this.NotifyScrollTime();
- if (this.m_AudioClip != null) {
- this.m_AudioClip.stop();
- }
-
- return true;
- }
-
- this.m_bScrollingStopped = false;
- this.ShowStatus();
- this.PlayAudioClip(this.m_Document.m_iCurrPage - 1);
- if (this.m_iAutoScrollPauseTypes[this.m_Document.m_iCurrPage - 1] == 2) {
- return true;
- }
- } else if (this.m_bScrollingStopped) {
- return true;
- }
-
- switch (this.m_iAutoScrollPauseTypes[this.m_Document.m_iCurrPage - 1]) {
- case 1:
- case 3:
- if (!this.m_bViewUpdated) {
- return false;
- }
- break;
- case 2:
- if (!var1) {
- return false;
- }
- }
-
- if (this.m_ThreadAutoScroll != null && this.m_ThreadAutoScroll.isAlive()) {
- return false;
- } else {
- this.m_bForward = var2;
- this.m_ThreadAutoScroll = new Thread(this);
- this.m_ThreadAutoScroll.start();
- return true;
- }
- }
-
- private final synchronized boolean WaitScrollTime(long var1) {
- try {
- this.wait(var1 == 0L ? this.m_lAutoScrollPauseTimes[this.m_Document.m_iCurrPage - 1] : var1);
- return true;
- } catch (InterruptedException var3) {
- return false;
- } catch (IllegalMonitorStateException var4) {
- return false;
- }
- }
-
- private final synchronized void NotifyScrollTime() {
- try {
- this.notify();
- } catch (IllegalMonitorStateException var1) {
- }
- }
-
- private final synchronized void ScrollPage() {
- if (this.m_bForward) {
- this.m_Document.NextPage();
- } else {
- this.m_Document.PrevPage();
- }
- }
-
- public final void ViewUpdated() {
- this.m_bViewUpdated = true;
- }
-
- public final Transition GetTransition() {
- return this.m_Transition;
- }
-
- public final boolean DoingTransition() {
- return !this.m_bViewUpdated || this.m_Transition.DoingTransition();
- }
-
- public final boolean StoreData(int var1, int var2, int var3, int var4, int var5, long var6, String var8) {
- if (var1 >= this.m_Document.m_nNumOfPages) {
- return false;
- } else {
- if (!this.m_bNonDefaultValues[var1]) {
- this.m_bNonDefaultValues[var1] = true;
-
- do {
- this.m_iAutoScrollPauseTypes[var1] = var2;
- this.m_lAutoScrollPauseTimes[var1] = var6;
- this.m_strAutoScrollPauseSounds[var1] = var8;
- if (!this.m_Transition.StoreData(var1, var3, var4, var5)) {
- return false;
- }
-
- ++var1;
- } while(var1 < this.m_Document.m_nNumOfPages && !this.m_bNonDefaultValues[var1]);
- }
-
- return true;
- }
- }
-
- public final void ShowStatus() {
- if (this.m_bScrollingStopped) {
- this.m_Document.m_Applet.showStatus(this.m_Document.m_Applet.m_BaristaLoc.m_StringAutoScrollStopped);
- } else {
- this.m_Document.m_Applet.showStatus(this.m_Document.m_Applet.GetVersionStatusString());
- }
- }
-
- public final boolean ScrollingStatus(int var1) {
- switch (var1) {
- case 1:
- return this.m_bScrollingStopped;
- default:
- return false;
- }
- }
-
- public final void PlayAudioClip(int var1) {
- if (this.m_iAutoScrollPauseTypes[var1] == 3 && !this.m_bScrollingStopped && this.m_strAutoScrollPauseSounds[var1] != null) {
- AudioClip var2 = null;
-
- try {
- if (this.m_Document.m_PageDirName != null) {
- var2 = this.m_Document.m_Applet.getAudioClip(this.m_Document.m_Applet.getDocumentBase(), this.m_Document.m_PageDirName + "/" + this.m_strAutoScrollPauseSounds[var1]);
- } else {
- var2 = this.m_Document.m_Applet.getAudioClip(this.m_Document.m_Applet.getDocumentBase(), this.m_strAutoScrollPauseSounds[var1]);
- }
- } catch (Exception var3) {
- }
-
- if (this.m_AudioClip != null) {
- this.m_AudioClip.stop();
- }
-
- this.m_AudioClip = var2;
- if (this.m_AudioClip != null) {
- this.m_AudioClip.play();
- }
- }
-
- }
- }
-