// Decompiled by Jad v1.5.7f. Copyright 2000 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html // Decompiler options: packimports(3) // Source File Name: MenuScrollTrial.java import java.applet.Applet; import java.awt.*; import java.util.StringTokenizer; public class MenuScrollTrial extends Applet implements Runnable { public MenuScrollTrial() { ColorMap = (new Color[] { Color.black, Color.blue, Color.cyan, Color.darkGray, Color.gray, Color.green, Color.lightGray, Color.magenta, Color.orange, Color.pink, Color.red, Color.white, Color.yellow }); unregistered = "Unregistered: Contact support@consultcom.com"; error = null; mainMenuWidth = 0; mainMenuHeight = 0; slideShow = false; slideShowIndex = 0; done = false; progressWidth = 100; progressHeight = 20; percentage = 0.0F; offscreenImg = null; progressColor = new Color(200, 0, 0); progressBackground = Color.lightGray; paint = true; status = ""; displayStatus = 0L; nextDispl = 5000; slogan = "FREE Java Applets at www.consultcom.com"; once = true; } boolean checkSecurity() { String s = getParameter("copyright"); if(s == null) { error = unregistered; return false; } int j = s.compareTo("Menu Scroll v1.0 Copyright (c) 1999, consulting.com Inc."); if(j == 0) { return true; } else { error = unregistered; return false; } } Color getColor(String s) { int j = 0; boolean flag = false; boolean flag1 = false; String s1 = ""; String s3 = ""; String s5 = ""; temp = getParameter(s); if(temp == null) { error = "error: " + s + " value=\"" + temp + "\""; return null; } j = temp.indexOf(","); if(j > 0) { String s2 = temp.substring(0, j); int k = temp.indexOf(",", j + 1); if(k < 0) { error = "error: " + s + " value=\"" + temp + "\""; return null; } String s4 = temp.substring(j + 1, k); String s6 = temp.substring(k + 1, temp.length()); try { j = Integer.valueOf(s2).intValue(); } catch(NumberFormatException _ex) { error = "error: " + s + " value=\"" + temp + "\""; return null; } try { k = Integer.valueOf(s4).intValue(); } catch(NumberFormatException _ex) { error = "error: " + s + " value=\"" + temp + "\""; return null; } int l; try { l = Integer.valueOf(s6).intValue(); } catch(NumberFormatException _ex) { error = "error: " + s + " value=\"" + temp + "\""; return null; } if(j > 255 || k > 255 || l > 255) { error = "error: " + s + " value=\"" + temp + "\""; return null; } else { return new Color(j, k, l); } } for(int i1 = 0; i1 < SColorArray.length; i1++) { int j1 = temp.compareTo(SColorArray[i1]); if(j1 == 0) return ColorMap[i1]; } error = "error: " + s + " value=\"" + temp + "\""; return null; } MenuScroller getMenu(String s) { for(int j = 0; j < menuScrollerArray.length; j++) if(s.equals(menuScrollerArray[j].menuName)) return menuScrollerArray[j]; return null; } int getNumber(String s) { int j = 0; temp = getParameter(s); if(temp == null) return -1; try { j = Integer.valueOf(temp).intValue(); } catch(NumberFormatException _ex) { } return j; } boolean getSize(String s) { String s1 = ""; String s3 = ""; String s5 = getParameter(s); if(s5 == null) { error = "error: " + s + " value=\"" + s5 + "\""; return false; } width = s5.indexOf(","); if(width > 0) { String s2 = s5.substring(0, width); String s4 = s5.substring(width + 1, s5.length()); try { width = Integer.valueOf(s2).intValue(); } catch(NumberFormatException _ex) { error = "error: " + s + " value=\"" + s5 + "\""; return false; } try { height = Integer.valueOf(s4).intValue(); } catch(NumberFormatException _ex) { error = "error: " + s + " value=\"" + s5 + "\""; return false; } } return true; } public void init() { setLayout(null); error = null; if(!checkSecurity()) return; slideShow = false; appletColor = getColor("appletColor"); if(appletColor == null) return; setBackground(appletColor); if(!menuInit()) return; windows = getParameter("windows"); if(windows == null) { error = "error: windows value=\"" + windows + "\""; return; } if(windows.indexOf(";") == -1) { error = "error: windows value=\"" + windows + "\""; return; } else { f = new Font("Helvetica", 0, 12); paint = true; return; } } boolean menuInit() { arrowColor = getColor("arrowColor"); if(arrowColor == null) return false; arrowHighliteColor = getColor("arrowHighliteColor"); if(arrowHighliteColor == null) return false; if(getSize("mainMenuSize")) { mainMenuWidth = width; mainMenuHeight = height; } else { return false; } temp = getParameter("subMenuHeight"); if(temp == null) { error = "error: subMenuHeight value=\"" + temp + "\""; return false; } try { subMenuHeight = Integer.valueOf(temp).intValue(); } catch(NumberFormatException _ex) { error = "error: subMenuHeight value=\"" + temp + "\""; return false; } return true; } boolean menuSetUp() { subMenuWidth = appletWidth - mainMenuWidth; st = new StringTokenizer(windows, ";"); numberOfMenus = 0; while(st.hasMoreTokens()) { numberOfMenus++; String s = st.nextToken(); } menuScrollerArray = new MenuScroller[numberOfMenus]; menuScrollerNameArray = new String[numberOfMenus]; st = new StringTokenizer(windows, ";"); for(i = 0; st.hasMoreTokens(); i++) menuScrollerNameArray[i] = st.nextToken(); int j = 0; menuScrollerArray[0] = new MenuScroller(this, menuScrollerNameArray[0], mainMenuWidth, mainMenuHeight, 0, appletColor); percentage = 1.0F / (float)numberOfMenus; repaint(); pause(50); if(menuScrollerArray[0].checkError) { error = menuScrollerArray[0].error; return false; } p1 = new Panel(); p1.setLayout(new CardLayout()); p1.add("Center", menuScrollerArray[0]); j++; p2 = new Panel(); layout = new CardLayout(); p2.setLayout(layout); for(int k = j; k < menuScrollerArray.length; k++) { menuScrollerArray[k] = new MenuScroller(this, menuScrollerNameArray[k], subMenuWidth, subMenuHeight, 1, appletColor); percentage = (float)(k + 1) / (float)numberOfMenus; repaint(); pause(50); if(menuScrollerArray[k].checkError) { error = menuScrollerArray[k].error; return false; } p2.add(menuScrollerNameArray[k], menuScrollerArray[k]); } paint = false; Graphics g = getGraphics(); g.setColor(appletColor); g.fillRect(0, 0, size().width, size().height); add(p1); p1.reshape(0, appletHeight - mainMenuHeight, mainMenuWidth, mainMenuHeight); add(p2); p2.reshape(mainMenuWidth, appletHeight - subMenuHeight, subMenuWidth, subMenuHeight); activeSubMenu = null; for(int l = 0; l < menuScrollerArray.length; l++) menuScrollerArray[l].makeImage(); return true; } public void paint(Graphics g) { boolean flag = false; boolean flag1 = false; if(paint) { g.setFont(f); FontMetrics fontmetrics = getFontMetrics(f); int l = fontmetrics.stringWidth("Creating objects..."); g.setColor(new Color(127, 127, 127)); g.drawString("Creating objects...", size().width / 2 - l / 2, size().height / 2 - progressHeight); if(offscreenImg == null) offscreenImg = createImage(progressWidth, progressHeight); offscreenG = offscreenImg.getGraphics(); offscreenG.setFont(f); int j = offscreenImg.getWidth(this); int k = offscreenImg.getHeight(this); offscreenG.setColor(progressBackground); offscreenG.fillRect(0, 0, j, k); offscreenG.setColor(progressColor); offscreenG.fillRect(0, 0, (int)((float)j * percentage), k); offscreenG.drawString(Integer.toString((int)(percentage * 100F)) + "% complete", 7, k / 2 + 5); offscreenG.clipRect(0, 0, (int)((float)j * percentage), k); offscreenG.setColor(progressBackground); offscreenG.drawString(Integer.toString((int)(percentage * 100F)) + "% complete", 7, k / 2 + 5); g.setColor(progressBackground); g.drawRect(size().width / 2 - progressWidth / 2 - 2, size().height / 2 - progressHeight / 2 - 2, progressWidth + 3, progressHeight + 3); g.drawImage(offscreenImg, size().width / 2 - progressWidth / 2, size().height / 2 - progressHeight / 2, this); } } void pause(int j) { try { Thread.sleep(j); } catch(InterruptedException _ex) { } } public void run() { if(error == null) setUp(); once = false; for(; thread.isAlive(); pause(100)) { if(error != null) showStatus(error); if(done && System.currentTimeMillis() > displayStatus) { status = slogan; showStatus(status); displayStatus = System.currentTimeMillis() + (long)nextDispl; } } } boolean setBoolean(String s) { String s1 = getParameter(s); if(s1 == null) return false; int j = s1.compareTo("yes"); return j == 0; } void setUp() { percentage = 0.0F; done = false; paint = true; error = null; appletWidth = size().width; appletHeight = size().height; if(once && !menuSetUp()) return; for(int j = 0; j < menuScrollerArray.length; j++) menuScrollerArray[j].start(); menuScrollerArray[0].run = true; done = true; } public void start() { if(thread == null) { thread = new Thread(this); thread.start(); } } public void stop() { for(int j = 0; j < menuScrollerArray.length; j++) menuScrollerArray[j].stop(); percentage = 0.0F; if(thread != null) thread.stop(); thread = null; } public void update(Graphics g) { paint(g); } String SColorArray[] = { "black", "blue", "cyan", "darkGray", "gray", "green", "lightGray", "magenta", "orange", "pink", "red", "white", "yellow" }; Color ColorMap[]; Panel p1; Panel p2; CardLayout layout; String temp; Thread thread; int numberOfMenus; String windows; StringTokenizer st; String unregistered; MenuScroller menuScrollerArray[]; String menuScrollerNameArray[]; MenuScroller activeSubMenu; String error; int width; int height; int appletWidth; int appletHeight; int mainMenuWidth; int mainMenuHeight; int subMenuWidth; int subMenuHeight; Color appletColor; int i; boolean slideShow; int slideShowIndex; long slideShowPause; boolean done; Color arrowColor; Color arrowHighliteColor; long slidePause; int progressWidth; int progressHeight; float percentage; Image offscreenImg; Graphics offscreenG; Color progressColor; Color progressBackground; Font f; boolean paint; String status; long displayStatus; int nextDispl; String slogan; boolean once; }