// 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: MenuScroller.java import java.applet.Applet; import java.applet.AppletContext; import java.awt.*; import java.net.MalformedURLException; import java.net.URL; import java.util.*; public class MenuScroller extends Canvas implements Runnable { public MenuScroller(MenuScrollTrial menuscrolltrial, String s1, int i, int j, int k, Color color1) { allowed = true; status = ""; clicked = false; link = false; paused = false; mouseexit = true; mousex = 0; mousey = 0; lastlined = 0; once = true; sColor = ""; checkError = true; error = ""; lineDown = 0; offscreen = null; offscreen2 = null; ypos = 0; startLines = 0; run = false; linkFrame = ""; linkColor = Color.blue; lineSelect = -1; lastLink = -1; lined = 0; lineVector = new Vector(10); mapVector = new Vector(10); vectorLineNumber = 0; textStart = -1; textEnd = -1; border = "up"; borderRaised = true; oldActiveVectorPointer = -1; oldActiveArrayPointer = -1; up = true; scrollSpeed = 8; pauseValue = 15; paint = false; makeIcalled = false; menuScroll = menuscrolltrial; menuName = s1; whichPanel = k; appletColor = color1; resize(i, j); path = menuscrolltrial.getCodeBase().toString(); lines = getNumber("numberOflines"); if(lines < 0) return; SImage = getParameter("image"); if(SImage != null && SImage.indexOf(".gif") <= 0 && SImage.indexOf(".jpg") <= 0 && SImage.indexOf(".GIF") <= 0 && SImage.indexOf(".JPG") <= 0) { error = "error: " + s1 + "-image value=\"" + SImage + "\""; return; } if(SImage != null) makeBackImage(); border = getParameter("border"); if(border == null) { error = "error: " + s1 + "-border value=\"" + border + "\""; return; } l = border.compareTo("line"); d = border.compareTo("down"); u = border.compareTo("up"); n = border.compareTo("no"); if(l != 0 && d != 0 && u != 0 && n != 0) { error = "error: " + s1 + "-border value=\"" + border + "\""; return; } if(n != 0) { borderColor = getColor("borderColor"); if(borderColor == null) return; } lineArray = new String[lines]; sizeArray = new int[lines]; colorArray = new Color[lines]; fontArray = new String[lines]; styleArray = new int[lines]; linkArray = new String[lines]; lineOffsetArray = new int[lines]; fontArray3 = new Font[lines]; separatorArray = new boolean[lines]; linkFrame = getParameter("linkFrame"); if(linkFrame == null || linkFrame.equals("")) { error = "error: " + s1 + "-linkFrame value=\"" + linkFrame + "\""; return; } linkClick = getNumber("linkClick"); if(linkClick < 0) linkClick = 1; if(linkClick > 2) linkClick = 2; color = getColor("linkColor"); if(color == null) return; linkColor = color; temp = getParameter("background"); if(temp == null) { error = "error: " + s1 + "-background value=\"" + temp + "\""; return; } color = getColor("background"); if(color == null) return; background = color; setBackground(color1); lineSpace = getNumber("lineSpace"); if(lineSpace < 0) return; scrollSpeed = getNumber("scrollSpeed"); if(scrollSpeed < 0) return; if(scrollSpeed < 1 || scrollSpeed > 20) { error = "error: " + s1 + "-scrollSpeed value=\"" + scrollSpeed + "\""; return; } for(int i1 = 0; i1 < lines; i1++) { separatorArray[i1] = false; lineArray[i1] = getParameter("lineDefault"); if(lineArray[i1] == null) lineArray[i1] = ""; sizeArray[i1] = getNumber("sizeDefault"); if(sizeArray[i1] < 0) return; color = getColor("colorDefault"); if(color == null) return; colorArray[i1] = color; tempInt = getFont("fontDefault"); if(tempInt < 0) return; fontArray[i1] = fontArray2[tempInt]; tempInt = getStyle("styleDefault"); if(tempInt < 0) return; styleArray[i1] = StyleMap[tempInt]; linkArray[i1] = getParameter("linkDefault"); if(linkArray[i1] == null) linkArray[i1] = ""; else linkArray[i1] = linkArray[i1].trim(); int j1 = linkArray[i1].compareTo(""); if(j1 != 0) link = true; if(k == 0 && s1.equals(linkArray[i1])) { int l1 = i1 + 1; error = "error: " + s1 + "-linkDefault value=\"" + linkArray[i1] + "\""; checkError = true; return; } lineOffsetArray[i1] = getNumber("lineOffsetDefault"); } for(int k1 = 0; k1 < lines; k1++) { separatorArray[k1] = setBoolean("separator" + Integer.toString(k1 + 1)); String s2 = "lineOffset" + Integer.toString(k1 + 1); tempInt = getNumber(s2); if(tempInt >= 0) lineOffsetArray[k1] = tempInt; else if(tempInt < -1) return; lineOffsetArray[k1] += 3; String s3 = "size" + Integer.toString(k1 + 1); tempInt = getNumber(s3); if(tempInt >= 0) sizeArray[k1] = tempInt; else if(tempInt < -1) return; String s4 = "color" + Integer.toString(k1 + 1); color = getColor(s4); if(color != null) colorArray[k1] = color; String s5 = "font" + Integer.toString(k1 + 1); tempInt = getFont(s5); if(tempInt >= 0) fontArray[k1] = fontArray2[tempInt]; else if(tempInt < -1) return; String s6 = "style" + Integer.toString(k1 + 1); tempInt = getStyle(s6); if(tempInt >= 0) styleArray[k1] = StyleMap[tempInt]; else if(tempInt < -1) return; String s7 = "link" + Integer.toString(k1 + 1); temp = getParameter(s7); if(temp != null) { linkArray[k1] = temp; link = true; } if(k == 0 && s1.equals(linkArray[k1])) { int i2 = k1 + 1; error = "error: " + s1 + "-link" + i2 + " value=\"" + linkArray[k1] + "\""; checkError = true; return; } fontArray3[k1] = new Font(fontArray[k1], styleArray[k1], sizeArray[k1]); String s8 = "line" + Integer.toString(k1 + 1); temp = getParameter(s8); if(temp != null) lineArray[k1] = temp; insertLineIntoVector(lineArray[k1], k1); } startLines = 0; totLines = lineSpace * lineVector.size(); height = size().height; ypos = size().height + scrollSpeed * 20; checkError = false; } void drawBoarder() { if(n != 0) { offscreeng.setColor(borderColor); if(d == 0) { for(int i = 0; i < 2; i++) offscreeng.draw3DRect(i, i, size().width - i * 2 - 1, size().height - i * 2 - 1, false); } else if(l == 0) offscreeng.drawRect(0, 0, size().width - 1, size().height - 1); else if(u == 0) { for(int j = 0; j < 2; j++) offscreeng.draw3DRect(j, j, size().width - j * 2 - 1, size().height - j * 2 - 1, true); } } } void drawImage() { int i = 0; int j = 0; if(setBoolean("imageCenter")) { i = tempImage.getWidth(this); j = tempImage.getHeight(this); offscreeng.drawImage(tempImage, size().width / 2 - i / 2, size().height / 2 - j / 2, this); return; } i = 0; j = 0; do { do { offscreeng.drawImage(tempImage, i, j, this); i += tempImage.getWidth(this); } while(i < size().width); j += tempImage.getHeight(this); i = 0; } while(j < size().height); } Color getColor(String s1) { s1 = menuName + "-" + s1; Color color1 = menuScroll.getColor(s1); if(color1 == null) { error = menuScroll.error; menuScroll.error = null; } return color1; } int getFont(String s1) { temp = getParameter(s1); if(temp == null) { error = "error: " + menuName + "-" + s1 + " value=\"" + temp + "\""; return -1; } for(int i = 0; i < fontArray2.length; i++) { int j = temp.compareTo(fontArray2[i]); if(j == 0) return i; } error = "error: " + menuName + "-" + s1 + " value=\"" + temp + "\""; return -2; } int getNumber(String s1) { int i = 0; temp = getParameter(s1); if(temp == null) { error = "error: " + menuName + "-" + s1 + " value=\"" + temp + "\""; return -1; } try { i = Integer.valueOf(temp).intValue(); } catch(NumberFormatException _ex) { error = "error: " + menuName + "-" + s1 + " value=\"" + temp + "\""; return -2; } return i; } String getParameter(String s1) { s1 = menuName + "-" + s1; String s2 = menuScroll.getParameter(s1); return s2; } int getStyle(String s1) { temp = getParameter(s1); if(temp == null) { error = "error: " + menuName + "-" + s1 + " value=\"" + temp + "\""; return -1; } for(int i = 0; i < SStyleArray.length; i++) { int j = temp.compareTo(SStyleArray[i]); if(j == 0) return i; } error = "error: " + menuName + "-" + s1 + " value=\"" + temp + "\""; return -2; } public boolean handleEvent(Event event) { highlight(event.x, event.y); mousex = event.x; mousey = event.y; return super.handleEvent(event); } void highlight(int i, int j) { if(!link || mouseexit || linkArray == null || !run) { return; } else { highlighted(i, j); return; } } synchronized void highlighted(int i, int j) { adjYpos = startLines + ypos; diff = j - adjYpos; lineSelect = diff / lineSpace; if(lastLink == lineSelect) return; if(lastLink >= 0) { passLine = lastLink; highliteLines(passLine, 1); } adjYpos = startLines + ypos; if(j < adjYpos || j > (adjYpos + totLines) - 1) { if(paused) repaint(); lastLink = -1; if(!menuScroll.status.equals(menuScroll.slogan)) { menuScroll.status = ""; showStatus(menuScroll.status); } return; } Vector vector = (Vector)mapVector.elementAt(lineSelect); Enumeration enumeration = vector.elements(); int k = ((Integer)enumeration.nextElement()).intValue(); if(linkArray[k].equals("")) { if(paused) repaint(); lastLink = -1; if(!menuScroll.status.equals(menuScroll.slogan)) { menuScroll.status = ""; showStatus(menuScroll.status); } return; } passLine = lineSelect; highliteLines(passLine, 0); if(paused) repaint(); boolean flag = false; for(int i1 = 0; i1 < menuScroll.menuScrollerArray.length; i1++) if(linkArray[k].equals(menuScroll.menuScrollerNameArray[i1])) flag = true; if(!flag) menuScroll.status = linkArray[k]; else menuScroll.status = ""; showStatus(menuScroll.status); lastLink = lineSelect; lastlined = lined; } public void highliteLines(int i, int j) { boolean flag = false; if(i < 0) return; Vector vector = (Vector)mapVector.elementAt(i); Enumeration enumeration = vector.elements(); int i1 = ((Integer)enumeration.nextElement()).intValue(); offscreeng.setFont(fontArray3[i1]); if(j == 0) offscreeng.setColor(linkColor); if(j == 1) offscreeng.setColor(colorArray[i1]); if(j == 2) offscreeng.setColor(Color.red); int j1; for(; enumeration.hasMoreElements(); offscreeng.drawString((String)lineVector.elementAt(j1), lineOffsetArray[i1], lined)) { j1 = ((Integer)enumeration.nextElement()).intValue(); int k = lineSpace * j1; k += startLines; lined = k + lineSpace; } } void insertLineIntoVector(String s1, int i) { Vector vector = new Vector(10); int j = vectorLineNumber; w = size().width; Font font = fontArray3[i]; fontMetrics = getFontMetrics(font); Vector vector1 = new Vector(10); offset = lineOffsetArray[i]; wordWrap(s1, vector, i); vector1.addElement(Integer.valueOf(Integer.toString(i))); for(int k = 0; k < vector.size(); k++) vector1.addElement(Integer.valueOf(Integer.toString(j++))); for(Enumeration enumeration = vector.elements(); enumeration.hasMoreElements();) { lineVector.addElement((String)enumeration.nextElement()); mapVector.addElement(vector1); vectorLineNumber++; } } void jumpToUrl(String s1) { try { if(!s1.startsWith("http") && !s1.startsWith("ftp") && !s1.startsWith("mailto:")) s1 = path + s1; URL url = new URL(s1); menuScroll.getAppletContext().showDocument(url, linkFrame); } catch(MalformedURLException malformedurlexception) { malformedurlexception.printStackTrace(); } } void makeBackImage() { mediaTracker = new MediaTracker(this); tempImage = menuScroll.getImage(menuScroll.getCodeBase(), SImage); mediaTracker.addImage(tempImage, 0); try { mediaTracker.waitForAll(); } catch(InterruptedException _ex) { } } synchronized void makeImage() { if(makeIcalled) return; makeIcalled = true; if(checkError) { showStatus(error); return; } offscreen2 = createImage(size().width, height); offscreeng2 = offscreen2.getGraphics(); offscreeng2.setColor(appletColor); offscreeng2.fillRect(0, 0, size().width, height); offscreen = createImage(size().width, height); offscreeng = offscreen.getGraphics(); offscreeng.setColor(background); offscreeng.fillRect(0, 0, size().width, height); drawBoarder(); if(SImage != null) drawImage(); lines = lineVector.size(); for(int i = 0; i < lineVector.size(); i++) { Vector vector = (Vector)mapVector.elementAt(i); int j = ((Integer)vector.elementAt(0)).intValue(); int k = ((Integer)vector.elementAt(1)).intValue(); fm = offscreeng.getFontMetrics(); offscreeng.setColor(colorArray[j]); fontArray3[j] = new Font(fontArray[j], styleArray[j], sizeArray[j]); offscreeng.setFont(fontArray3[j]); String s1 = (String)lineVector.elementAt(i); if(s1 == null) { s1 = getParameter("lineDefault"); if(s1 == null) s1 = ""; } offscreeng.drawString(s1, lineOffsetArray[j], startLines + lineSpace * (i + 1)); boolean flag = false; for(int i1 = 0; i1 < menuScroll.menuScrollerArray.length; i1++) if(linkArray[j].equals(menuScroll.menuScrollerNameArray[i1])) flag = true; int j1 = size().width - 3; int k1 = startLines + lineSpace * (i + 1); k1 -= sizeArray[j] / 3; if(whichPanel == 0 && !s1.trim().equals("") && flag && k == i) { offscreeng.setColor(menuScroll.arrowColor); Polygon polygon = new Polygon(); polygon.addPoint(j1 - 5, k1 - 5); polygon.addPoint(j1 - 5, k1 + 5); polygon.addPoint(j1, k1); offscreeng.fillPolygon(polygon); } if(separatorArray[j] && k == i) { offscreeng.setColor(new Color(51, 51, 51)); offscreeng.drawLine(15, k1 - 1, size().width - 15, k1 - 1); offscreeng.setColor(new Color(192, 192, 192)); offscreeng.drawLine(15, k1, size().width - 15, k1); } } startTime = System.currentTimeMillis(); } public boolean mouseDown(Event event, int i, int j) { int k = 0; int i1 = 0; if(!menuScroll.slideShow && whichPanel != 0 && menuScroll.activeSubMenu != this) return true; run = false; adjYpos = startLines + ypos; diff = j - adjYpos; if(j < adjYpos || j > (adjYpos + totLines) - 1) return true; int j1 = diff / lineSpace; lineDown = lineSpace * j1; lineDown += startLines; Vector vector = (Vector)mapVector.elementAt(j1); Enumeration enumeration = vector.elements(); k = ((Integer)enumeration.nextElement()).intValue(); i1 = ((Integer)enumeration.nextElement()).intValue(); if(k >= linkArray.length || linkArray[k].equals("")) { lineDown = 0; return true; } if(event.clickCount == linkClick) { clicked = true; if(whichPanel != 0 || menuScroll.slideShow) { jumpToUrl(linkArray[k]); menuScroll.status = linkArray[k]; showStatus(menuScroll.status); return true; } boolean flag = false; for(int k1 = 0; k1 < menuScroll.menuScrollerArray.length; k1++) if(linkArray[k].equals(menuScroll.menuScrollerNameArray[k1])) flag = true; if(flag) { s = k; q = i1; activeSubMenu = menuScroll.activeSubMenu; if(activeSubMenu != null) { int l1 = size().width - 3; int i2 = startLines + lineSpace * (oldActiveVectorPointer + 1); i2 -= sizeArray[oldActiveArrayPointer] / 3; offscreeng.setColor(menuScroll.arrowColor); Polygon polygon = new Polygon(); polygon.addPoint(l1 - 5, i2 - 5); polygon.addPoint(l1 - 5, i2 + 5); polygon.addPoint(l1, i2); offscreeng.fillPolygon(polygon); activeSubMenu.up = false; } if(activeSubMenu == null) scrollup(); } else { jumpToUrl(linkArray[k]); menuScroll.status = linkArray[k]; showStatus(menuScroll.status); } } return true; } public boolean mouseDrag(Event event, int i, int j) { if(!menuScroll.slideShow && whichPanel != 0 && menuScroll.activeSubMenu != this) return true; int k = startLines + ypos; ypos = j - startLines - diff; if(ypos <= 0) ypos = 0; repaint(); return true; } public boolean mouseEnter(Event event, int i, int j) { mouseexit = false; return true; } public boolean mouseExit(Event event, int i, int j) { mouseexit = true; if(!run) return true; if(lastLink >= 0) { passLine = lastLink; highliteLines(passLine, 1); lastLink = -1; repaint(); menuScroll.status = ""; showStatus(menuScroll.status); } lineSelect = -1; lastLink = -1; return true; } public boolean mouseUp(Event event, int i, int j) { if(!menuScroll.slideShow && whichPanel != 0 && menuScroll.activeSubMenu != this) return true; if(clicked) { passLine = lineSelect; highliteLines(passLine, 0); repaint(); clicked = false; } lineDown = 0; run = true; return true; } public void paint(Graphics g) { if(offscreen == null) makeImage(); if(checkError) { showStatus(error); return; } else { offscreeng2.setColor(appletColor); offscreeng2.fillRect(0, 0, size().width, height); offscreeng2.drawImage(offscreen, 0, ypos, this); g.drawImage(offscreen2, 0, 0, this); return; } } void pause(int i) { try { Thread.sleep(i); } catch(InterruptedException _ex) { } } public void run() { for(; thread.isAlive(); pause(pauseValue)) { if(run && up) { int i = ypos - scrollSpeed; if(i > scrollSpeed) ypos = ypos - scrollSpeed; else ypos = 0; } if(run && !up) if(ypos < size().height + scrollSpeed * 20) { ypos = ypos + scrollSpeed; } else { run = false; paint = false; menuScroll.menuScrollerArray[0].scrollup(); } if(whichPanel == 0 || paint) { repaint(); highlight(mousex, mousey); } } } void scrollup() { if(menuScroll.slideShow) return; menuScroll.layout.show(menuScroll.p2, linkArray[s]); MStemp = menuScroll.getMenu(linkArray[s]); if(menuScroll.activeSubMenu == MStemp) { menuScroll.activeSubMenu = null; return; } else { MStemp.paint = true; MStemp.up = true; MStemp.run = true; menuScroll.activeSubMenu = MStemp; menuScroll.status = ""; showStatus(menuScroll.status); int i = size().width - 3; int j = startLines + lineSpace * (q + 1); j -= sizeArray[s] / 3; offscreeng.setColor(menuScroll.arrowHighliteColor); Polygon polygon = new Polygon(); polygon.addPoint(i - 5, j - 5); polygon.addPoint(i - 5, j + 5); polygon.addPoint(i, j); offscreeng.fillPolygon(polygon); oldActiveVectorPointer = q; oldActiveArrayPointer = s; return; } } boolean setBoolean(String s1) { String s2 = getParameter(s1); if(s2 == null) return false; z = s2.compareTo("yes"); return z == 0; } void showStatus(String s1) { if(checkError) menuScroll.showStatus(error); else menuScroll.showStatus(menuScroll.status); } public void start() { if(thread == null) { thread = new Thread(this); thread.start(); } } public void stop() { if(thread != null) thread.stop(); thread = null; } public void update(Graphics g) { paint(g); } void wordWrap(String s1, Vector vector, int i) { int j = 2; if(whichPanel == 0) { boolean flag = false; for(int k = 0; k < menuScroll.menuScrollerArray.length; k++) if(linkArray[i].equals(menuScroll.menuScrollerNameArray[k])) flag = true; if(flag) j += 6; } String s2 = ""; for(StringTokenizer stringtokenizer = new StringTokenizer(s1, " "); stringtokenizer.hasMoreTokens();) { String s3 = stringtokenizer.nextToken(); if(s2.equals("")) s2 = s3; else if(fontMetrics.stringWidth(s2 + " " + s3) < w - offset - j) { s2 = s2 + " " + s3; } else { vector.addElement(s2); s2 = s3; } } vector.addElement(s2); } String stringFont1; int stringStyle; int stringSize; int offset; int w; FontMetrics fontMetrics; boolean allowed; String status; int z; boolean clicked; Color color; int linkClick; long startTime; boolean link; boolean paused; Font fontArray3[]; boolean mouseexit; int mousex; int mousey; int lastlined; boolean once; String sColor; int tempInt; boolean checkError; String error; int lines; String lineArray[]; int sizeArray[]; Color colorArray[]; boolean separatorArray[]; String linkArray[]; String temp; String fontArray[]; int styleArray[]; int lineOffsetArray[]; int lineDown; Thread thread; Image offscreen; Image offscreen2; Graphics offscreeng; Graphics offscreeng2; int height; Font f; FontMetrics fm; int fs; int ypos; int lineSpace; int diff; int startLines; Color background; int totLines; int adjYpos; boolean run; String linkFrame; int lineOffsetDefault; Color linkColor; String SStyleArray[] = { "PLAIN", "ITALIC", "BOLD" }; int StyleMap[] = { 0, 2, 1 }; String fontArray2[] = { "Dialog", "Helvetica", "TimesRoman", "Courier" }; int lineSelect; int lastLink; int lined; long diffTime; Vector lineVector; Vector mapVector; int vectorLineNumber; int passLine; String path; int textStart; int textEnd; String menuName; MenuScrollTrial menuScroll; int whichPanel; MenuScroller MStemp; MenuScroller activeSubMenu; Color appletColor; String border; boolean borderRaised; Color borderColor; int oldActiveVectorPointer; int oldActiveArrayPointer; int l; int d; int u; int n; MediaTracker mediaTracker; Image tempImage; String SImage; boolean up; int s; int q; int scrollSpeed; int pauseValue; boolean paint; boolean makeIcalled; }