home *** CD-ROM | disk | FTP | other *** search
- import corel.transitions.Transition;
- import java.applet.Applet;
- import java.awt.Dimension;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.Rectangle;
- import java.awt.Window;
- import java.io.DataInputStream;
- import java.io.IOException;
- import java.util.Hashtable;
- import java.util.StringTokenizer;
- import java.util.Vector;
-
- public final class VDoc {
- public Barista m_Applet;
- private Hashtable m_AppParams;
- private static final int m_iNoOfCachePgs = 5;
- int m_nPrevPage;
- int m_iCurrPage;
- int m_nNumOfPages;
- int m_cBkColor;
- int m_defaultDpi = 96;
- int m_xyDpi = 96;
- short m_sVersion;
- short m_fZoomFactor = 1;
- String m_PageDirName;
- boolean m_bDisplayToolBar = true;
- boolean m_bIsMultiPage = true;
- boolean m_bPageChanged = false;
- Dimension m_LogExtent;
- Dimension m_DevExtent;
- DataInputStream m_HtmlDataInpStream;
- ZStorage m_Storage;
- VPanel m_MainPanel;
- Window m_PopUp;
- Vector m_skBookmarkList;
- private AutoScroll m_AutoScroll;
- private Transition m_Transition;
- public boolean m_bDoubleBufferingDisabled = false;
-
- public VDoc(Applet var1) {
- this.m_Applet = (Barista)var1;
- this.m_nPrevPage = 1;
- this.m_iCurrPage = 1;
- this.m_nNumOfPages = 1;
- this.m_skBookmarkList = new Vector(40);
- this.m_LogExtent = new Dimension(1, 1);
- this.m_DevExtent = new Dimension(1, 1);
- this.m_AppParams = new Hashtable();
- this.m_Storage = new ZStorage(this);
- if (this.m_PageDirName != null) {
- this.m_Storage.start(this.m_iCurrPage, true);
- } else {
- this.m_Storage.start();
- }
- }
-
- VPage GetCurrPage() {
- return this.m_Storage != null ? (VPage)this.m_Storage.get("P" + this.m_iCurrPage) : null;
- }
-
- VPage GetPage(String var1) {
- return this.m_Storage != null ? (VPage)this.m_Storage.get(var1) : null;
- }
-
- boolean NextPage() {
- if (this.m_iCurrPage < this.m_nNumOfPages) {
- this.m_Applet.m_Document.PrevView(this.m_Applet.m_Document.m_iCurrPage);
- ++this.m_iCurrPage;
- if (this.m_PageDirName != null) {
- int var1 = this.GetFreeMemPercent();
- if (var1 <= 15) {
- this.m_Storage.DelPgFromMem();
- }
- }
-
- this.m_bPageChanged = true;
- this.m_Storage.start(this.m_iCurrPage, true);
- this.m_MainPanel.SetPage("P" + this.m_iCurrPage);
- this.UpdateView();
- return false;
- } else {
- return true;
- }
- }
-
- boolean PrevPage() {
- if (this.m_iCurrPage > 1) {
- this.m_Applet.m_Document.PrevView(this.m_Applet.m_Document.m_iCurrPage);
- --this.m_iCurrPage;
- if (this.m_PageDirName != null) {
- int var1 = this.GetFreeMemPercent();
- if (var1 <= 15) {
- this.m_Storage.DelPgFromMem();
- }
- }
-
- this.m_bPageChanged = true;
- this.m_Storage.start(this.m_iCurrPage, true);
- this.m_MainPanel.SetPage("P" + this.m_iCurrPage);
- this.UpdateView();
- return false;
- } else {
- return true;
- }
- }
-
- void PrevView(int var1) {
- this.m_nPrevPage = var1;
- }
-
- void GoToPage(int var1) {
- if (var1 == this.m_iCurrPage - 1) {
- this.PrevPage();
- } else if (var1 == this.m_iCurrPage + 1) {
- this.NextPage();
- } else if (var1 != this.m_iCurrPage) {
- if (var1 >= 1 && var1 <= this.m_nNumOfPages) {
- this.m_Applet.m_Document.PrevView(this.m_Applet.m_Document.m_iCurrPage);
- this.m_iCurrPage = var1;
- if (this.m_PageDirName != null) {
- int var2 = this.GetFreeMemPercent();
- if (var2 <= 20) {
- for(int var3 = 0; var3 < 5; ++var3) {
- this.m_Storage.DelPgFromMem();
- }
- }
- }
-
- this.m_bPageChanged = true;
- this.m_Storage.start(this.m_iCurrPage, true);
- this.m_MainPanel.SetPage("P" + this.m_iCurrPage);
- this.UpdateView();
- }
-
- }
- }
-
- private final int GetFreeMemPercent() {
- Runtime var1 = Runtime.getRuntime();
- long var2 = var1.totalMemory();
- float var4 = (float)var2;
- long var5 = var1.freeMemory();
- float var7 = (float)var5;
- float var8 = var7 / var4;
- float var9 = var8 * 100.0F;
- int var10 = (int)var9;
- return var10;
- }
-
- void SetMainPanel(VPanel var1) {
- this.m_MainPanel = var1;
- }
-
- void UpdateView() {
- if (this.m_MainPanel != null) {
- this.UpdateToolBar();
- this.m_MainPanel.validate();
- this.m_MainPanel.repaint();
- }
-
- }
-
- void UpdateToolBar() {
- if (this.m_bDisplayToolBar) {
- if (this.m_Applet.m_ToolBarTop != null) {
- ((VToolbar)this.m_Applet.m_ToolBarTop).UpdateButtons(this.m_iCurrPage);
- }
-
- if (this.m_Applet.m_ToolBarBot != null) {
- ((VToolbar)this.m_Applet.m_ToolBarBot).UpdateButtons(this.m_iCurrPage);
- }
- }
-
- }
-
- public void ZoomWindow(int var1) {
- }
-
- public void destroy() {
- }
-
- String GetValueGivenName(String var1) {
- String var2 = null;
- if (this.m_AppParams != null) {
- var2 = (String)this.m_AppParams.get(var1.toLowerCase());
- }
-
- return var2;
- }
-
- public void ParsePageHTML() {
- if (this.m_HtmlDataInpStream != null) {
- Object var2 = null;
-
- while(true) {
- try {
- if (this.m_HtmlDataInpStream != null) {
- var10 = this.m_HtmlDataInpStream.readLine();
- } else {
- var10 = null;
- }
-
- if (var10 == null || var10.equalsIgnoreCase("</HTML>")) {
- break;
- }
- } catch (IOException var8) {
- break;
- }
-
- if (this.CheckIfTokenExists(var10, "param")) {
- Object var3 = null;
- Object var4 = null;
-
- try {
- while(var10.indexOf(62) == -1) {
- String var13 = this.m_HtmlDataInpStream.readLine();
- if (var13 != null) {
- var13 = var13.trim();
- String var11 = var10.concat(" ");
- var10 = var11.concat(var13);
- }
- }
- } catch (IOException var9) {
- }
-
- String var12 = this.GetKey(var10);
- var12.toLowerCase();
- int var5 = var10.indexOf(34);
- int var6 = var10.lastIndexOf(34);
- String var1 = var10.substring(var5 + 1, var6);
- if (var12 != null && var1 != null) {
- this.m_AppParams.put(var12.toLowerCase(), var1);
- }
- }
- }
-
- try {
- if (this.m_HtmlDataInpStream != null) {
- this.m_HtmlDataInpStream.close();
- }
- } catch (IOException var7) {
- }
-
- this.m_HtmlDataInpStream = null;
- }
-
- }
-
- private String GetKey(String var1) {
- StringTokenizer var2 = new StringTokenizer(var1);
- var2.nextToken("=");
- String var3 = var2.nextToken(" ");
- return var3.substring(1);
- }
-
- private boolean CheckIfTokenExists(String var1, String var2) {
- if (var1 != null) {
- String var3 = new String(var1);
- StringTokenizer var4 = new StringTokenizer(var3);
-
- for(int var5 = 0; var5 < var4.countTokens(); ++var5) {
- String var6 = var4.nextToken();
- if (var6.charAt(0) == '<') {
- var6 = var6.substring(1);
- }
-
- if (var6.equalsIgnoreCase(var2)) {
- return true;
- }
- }
- }
-
- return false;
- }
-
- public void ClearContents() {
- this.m_AppParams.clear();
- }
-
- public final boolean StartAutoScroll(boolean var1, boolean var2, boolean var3, boolean var4) {
- boolean var5 = false;
- if (this.AutoScrollEnabled()) {
- if (var2) {
- this.m_AutoScroll.ViewUpdated();
- }
-
- var5 = this.m_AutoScroll.Start(var1, var3, var4);
- this.UpdateToolBar();
- }
-
- return var5;
- }
-
- public final boolean DoTransition(Graphics var1, VPanel var2, boolean var3) {
- boolean var4 = false;
- if (this.AutoScrollEnabled()) {
- VPage var5 = this.GetCurrPage();
- Rectangle var6;
- if (var5 != null) {
- var6 = var5.GetPageBounds();
- } else {
- var6 = new Rectangle(-1, -1, 0, 0);
- }
-
- var4 = this.m_AutoScroll.GetTransition().DoTransition(var1, var2, this.m_iCurrPage - 1, true, var3, var6);
- if (var3) {
- this.m_AutoScroll.PlayAudioClip(this.m_iCurrPage - 1);
- }
- }
-
- return var4;
- }
-
- public final boolean DoingTransition() {
- return this.AutoScrollEnabled() ? this.m_AutoScroll.DoingTransition() : false;
- }
-
- public final boolean AutoScrollEnabled() {
- return this.m_AutoScroll != null;
- }
-
- public final void CreateAutoScroll(String var1) {
- if (!this.AutoScrollEnabled()) {
- this.m_AutoScroll = new AutoScroll(this, Integer.valueOf(var1));
- }
-
- }
-
- public final boolean StoreAutoScrollData(int var1, AutoScrollObj var2) {
- return this.AutoScrollEnabled() ? this.m_AutoScroll.StoreData(var1, var2.iPauseType, var2.iTransitionType, var2.iTransitionDirection, var2.iTransitionSpeed, var2.lPauseTime, var2.strPauseSound) : false;
- }
-
- public final void ShowAutoScrollStatus() {
- if (this.AutoScrollEnabled()) {
- this.m_AutoScroll.ShowStatus();
- } else {
- this.m_Applet.showStatus(this.m_Applet.GetVersionStatusString());
- }
- }
-
- public final boolean AutoScrollStatus(int var1) {
- return this.AutoScrollEnabled() ? this.m_AutoScroll.ScrollingStatus(var1) : false;
- }
-
- public final void CreateTransition() {
- this.m_Transition = new Transition(this.m_Applet, this.m_nNumOfPages, this.m_Applet.GetVersionStatusString());
- }
-
- public final boolean DoDoubleBuffering(Graphics var1, VPanel var2, boolean var3) {
- if (this.m_Transition != null) {
- VPage var4 = this.GetCurrPage();
- Rectangle var5;
- if (var4 != null) {
- var5 = var4.GetPageBounds();
- } else {
- var5 = new Rectangle(-1, -1, 0, 0);
- }
-
- return this.m_Transition.DoTransition(var1, var2, this.m_iCurrPage - 1, false, var3, var5);
- } else {
- return false;
- }
- }
-
- public final boolean drawImage(Graphics var1, Image var2, int var3, int var4, int var5, int var6, VPanel var7) {
- if (this.AutoScrollEnabled()) {
- return this.m_AutoScroll.GetTransition().drawImage(var1, var2, var3, var4, var5, var6, var7, this.m_iCurrPage - 1);
- } else {
- return this.m_Transition != null ? this.m_Transition.drawImage(var1, var2, var3, var4, var5, var6, var7, this.m_iCurrPage - 1) : var1.drawImage(var2, var3, var4, var5, var6, var7);
- }
- }
- }
-