// Decompiled by Jad v1.5.8a. Copyright 2001 Pavel Kouznetsov. // Jad home page: http://www.geocities.com/kpdus/jad.html // Decompiler options: packimports(3) // Source File Name: Defile.java import java.applet.Applet; import java.applet.AppletContext; import java.awt.*; import java.io.PrintStream; import java.net.MalformedURLException; import java.net.URL; import java.util.StringTokenizer; import java.util.Vector; public class Defile extends Applet implements Runnable { public Defile() { hLine = -1; l_h = -1; last_h = -1; later_string = ""; m_scroll_delay = 20; m_def_textcolor = Color.black; m_bgcolor = Color.white; m_def_hlcolor = Color.blue; m_sb_text = "@lyon - Defilement de Texte"; m_xoffset = 5; m_def_loadwhere = "_self"; m_offsbtext = "Java Par @lyon"; m_sb_update_message = "Actualisation..."; m_file_update_scrolls = 1; m_overlap_local_load = true; m_jump = 1; first_connect_message = true; } public String CheckSPart(String s) { if(s.trim().length() == 0) return " "; else return s.trim(); } static String ConvertirDeHTML(String s) { if(s == null) return ""; if(s.indexOf("&") == -1) return s; String s1 = s; String s2 = ""; int i = 0; for(int j = 0; (j = s1.indexOf("&", i)) != -1;) { s2 = s2 + s1.substring(i, j); String s3 = s1.substring(j + 1, s1.indexOf(";", j)); if(s1.indexOf(";", j) == -1) { s2 = s2 + s1.substring(j, s1.length()); return s2; } if(s3.charAt(0) == '#') { char c = '\0'; for(int k = 1; k < s3.length(); k++) if(Character.isDigit(s3.charAt(k))) c = (char)(c * 10 + (s3.charAt(k) - 48)); s2 = s2 + c; } else { String s4 = new String(); for(int l = 160; l <= 255; l++) { if(s3.compareTo("quot") == 0) { s4 = "34"; break; } if(s3.compareTo("amp") == 0) { s4 = "38"; break; } if(s3.compareTo("lt") == 0) { s4 = "60"; break; } if(s3.compareTo("gt") == 0) { s4 = "62"; break; } if(s3.compareTo(Codes[l - 160]) != 0) continue; s4 = String.valueOf(l).toString(); break; } char c1 = '\0'; for(int i1 = 0; i1 < s4.length(); i1++) c1 = (char)(c1 * 10 + (s4.charAt(i1) - 48)); s2 = s2 + c1; } i = j + s3.length() + 2; } s2 = s2 + s.substring(i, s.length()); return s2; } public void DrawBG(Graphics g) { g.setColor(m_bgcolor); g.fillRect(0, 0, d.width, d.height); } public void HL(int i, Color color) { int j = re_draw[i]; g_off.setFont(m_font[i]); fm = g_off.getFontMetrics(m_font[i]); g_off.setColor(color); String as[] = NouvelleLigne(m_desc[i], m_xoffset * 2); for(int k = 0; k < as.length; k++) { j += fm.getHeight(); if(m_centertext[i] == 1) g_off.drawString(as[k], (d.width - fm.stringWidth(as[k])) / 2, j); else if(m_centertext[i] == 2) g_off.drawString(as[k], d.width - m_xoffset - fm.stringWidth(as[k]), j); else g_off.drawString(as[k], m_xoffset, j); } } public String[] NouvelleLigne(String s, int i) { int j = 0; int k = 0; int l = 0; int i1 = 0; Vector vector = new Vector(); int j1 = 0; boolean flag = false; boolean flag1 = true; while(k != -1) { k = s.indexOf(' ', l); if(k != -1) { flag1 = false; int k1 = fm.stringWidth(s.substring(i1, k)); j += k1; if(j >= d.width - i) { vector.addElement(CheckSPart(s.substring(j1, i1))); j1 = i1; j = k1; } l = k + 1; i1 = k; continue; } if(flag1) { vector.addElement(CheckSPart(s)); break; } int l1 = fm.stringWidth(s.substring(i1)); j += l1; if(j >= d.width - i) { vector.addElement(CheckSPart(s.substring(j1, i1))); vector.addElement(CheckSPart(s.substring(i1))); } else if(j1 < i1) vector.addElement(CheckSPart(s.substring(j1))); } String as[] = new String[vector.size()]; vector.copyInto(as); if(as.length < 1) { as = new String[1]; as[0] = " "; } return as; } public void NouvellePage(String s) { connect_message = "Chargement : " + s; first_connect_message = true; showStatus(connect_message); fr.stop(); fr = null; fichierSource = new Lecture(this, s); force_draw = true; fetching_file = true; fichierSource.refresh = true; fr = new Thread(fichierSource); fr.start(); } public void RafraichirDonnees() { boolean flag = false; temp_links = 0; num_descrips = fichierSource.infosSource.length; titre = new boolean[num_descrips]; mtitre = new boolean[num_descrips]; m_delay = new int[num_descrips]; m_textcolor = new Color[num_descrips]; m_desc = new String[num_descrips]; m_linkurl = new String[num_descrips]; m_font = new Font[num_descrips]; m_centertext = new int[num_descrips]; m_loadwhere = new String[num_descrips]; m_size_pause = new int[num_descrips]; line_coords = new int[num_descrips]; re_draw = new int[num_descrips]; for(int i = 0; i < fichierSource.infosSource.length; i++) { String s = fichierSource.infosSource[i]; if(s.startsWith("titre:")) { if(s.substring(7, s.lastIndexOf("\"")).length() != 0) m_desc[i] = ConvertirDeHTML(s.substring(7, s.lastIndexOf("\""))); else m_desc[i] = ""; m_linkurl[i] = "-1"; m_font[i] = m_policeTitre; m_centertext[i] = 0; m_textcolor[i] = m_couleurTitre; m_loadwhere[i] = m_def_loadwhere; titre[i] = true; mtitre[i] = false; } if(s.startsWith("texte:")) { if(s.substring(7, s.indexOf("\"|\"")).length() != 0) { temp_links++; m_linkurl[i] = s.substring(7, s.indexOf("\"|\"")); } else { m_linkurl[i] = "-1"; } if(s.substring(s.indexOf("\"|\"") + 3, s.lastIndexOf("\"")).length() != 0) m_desc[i] = ConvertirDeHTML(s.substring(s.indexOf("\"|\"") + 3, s.lastIndexOf("\""))); else m_desc[i] = ""; m_centertext[i] = 0; m_font[i] = m_policeTexte; m_textcolor[i] = m_couleurTexte; m_loadwhere[i] = m_def_loadwhere; titre[i] = false; mtitre[i] = false; } } } private void affiche(int i) { if(l_h != hLine) { if(l_h != -1) { HL(l_h, m_textcolor[l_h]); showStatus(m_sb_text); } if(hLine != -1) { HL(hLine, m_def_hlcolor); showStatus(link_urls[i]); } if(paused) soff = 1; else soff = 0; getGraphics().drawImage(off, 0, scroll_y + soff, this); } l_h = hLine; } public void afficheDefilement() { Object obj = null; boolean flag = false; boolean flag1 = false; int i = 0; int j = 0; boolean flag2 = false; num_links = temp_links; link_cords = new int[num_links * 3]; link_urls = new String[num_links]; int k = 0; do { int l = 0; for(int i1 = 0; i1 < num_descrips; i1++) if(k == 0) { fm = getFontMetrics(m_font[i1]); int j1 = l; if(m_size_pause[i1] == 1) { j = j1; flag2 = true; } else if(!flag2) j = j1; String as[] = NouvelleLigne(m_desc[i1], m_xoffset * 2); for(int l1 = 0; l1 < as.length; l1++) l += fm.getHeight(); if(i1 == m_desc.length - 1) { i_h = l + fm.getDescent() + 5; off = createImage(d.width, i_h); g_off = off.getGraphics(); g_off.setColor(m_bgcolor); g_off.fillRect(0, 0, d.width, i_h); } else if(l - j < d.height && m_size_pause[i1] == 2) { l = l + (d.height - (l - j)) + 1; flag2 = false; } } else { g_off.setFont(m_font[i1]); fm = g_off.getFontMetrics(m_font[i1]); int k1 = l; if(m_size_pause[i1] == 1) { j = k1; flag2 = true; } else if(!flag2) j = k1; line_coords[i1] = l + fm.getDescent() + 1; re_draw[i1] = l; String as1[] = NouvelleLigne(m_desc[i1], m_xoffset * 2); for(int i2 = 0; i2 < as1.length; i2++) { l += fm.getHeight(); if(titre[i1]) { if(!mtitre[i1]) { g_off.setColor(m_couleurPuces); g_off.fillRect(m_xoffset, l - m_taillePuce, m_taillePuce, m_taillePuce); g_off.setColor(m_textcolor[i1]); if(m_centertext[i1] == 1) g_off.drawString(as1[i2], (d.width - fm.stringWidth(as1[i2])) / 2, l); else if(m_centertext[i1] == 2) g_off.drawString(as1[i2], d.width - m_xoffset - fm.stringWidth(as1[i2]), l); else g_off.drawString(as1[i2], m_xoffset + 3 + m_taillePuce, l); mtitre[i1] = true; } else { g_off.setColor(m_textcolor[i1]); if(m_centertext[i1] == 1) g_off.drawString(as1[i2], (d.width - fm.stringWidth(as1[i2])) / 2, l); else if(m_centertext[i1] == 2) g_off.drawString(as1[i2], d.width - m_xoffset - fm.stringWidth(as1[i2]), l); else g_off.drawString(as1[i2], m_xoffset + 3, l); } } else { g_off.setColor(m_textcolor[i1]); if(m_centertext[i1] == 1) g_off.drawString(as1[i2], (d.width - fm.stringWidth(as1[i2])) / 2, l); else if(m_centertext[i1] == 2) g_off.drawString(as1[i2], d.width - m_xoffset - fm.stringWidth(as1[i2]), l); else g_off.drawString(as1[i2], m_xoffset, l); } } if(m_linkurl[i1].length() > 3) { if(i1 == m_desc.length - 1) l += fm.getDescent(); link_cords[i * 3] = k1; link_cords[i * 3 + 1] = l; link_cords[i * 3 + 2] = i1; link_urls[i] = m_linkurl[i1]; i++; } if(i1 != m_desc.length - 1 && l - j < d.height && m_size_pause[i1] == 2) { l = l + (d.height - (l - j)) + 1; flag2 = false; } } } while(++k < 2); done_draw = true; } public void chargeFichier() { if(fichierSource.lectureOK) { if(!first_run) { first_run = true; RafraichirDonnees(); afficheDefilement(); } fetching_file = false; fichierSource.lectureOK = false; if(force_draw) { RafraichirDonnees(); afficheDefilement(); scroll_y = d.height; cur_dline = 0; hLine = -1; l_h = 0; if(!m_overlap_local_load) DrawBG(getGraphics()); force_draw = false; } else { update_si = true; } if(mouseIn) showStatus(m_sb_text); else showStatus(m_offsbtext); if(try_later) { try_later = false; NouvellePage(later_string); } } else if(fichierSource.erreur) { fichierSource.erreur = false; fetching_file = false; showStatus("Erreur de chargement du Document"); } else if(force_draw && first_connect_message) { showStatus(connect_message); first_connect_message = false; } } public static Color convertirEnCouleur(String s) { int i = 0; int j = 0; int k = 0; int l = 0; s.trim(); l = s.indexOf("#"); if(l != -1 && l + 1 != s.length()) { Color color = new Color(Integer.parseInt(s.substring(l + 1), 16)); return color; } StringTokenizer stringtokenizer = new StringTokenizer(s, ","); if(stringtokenizer.countTokens() > 3) return Color.black; while(stringtokenizer.hasMoreTokens()) { i = Integer.parseInt(stringtokenizer.nextToken().trim()); j = Integer.parseInt(stringtokenizer.nextToken().trim()); k = Integer.parseInt(stringtokenizer.nextToken().trim()); } stringtokenizer = null; if(i > 255) i = 255; if(j > 255) j = 255; if(k > 255) k = 255; Color color1 = new Color(i, j, k); return color1; } public void defilement(boolean flag) { if(flag && scroll_y == -line_coords[cur_dline]) { if(m_delay[cur_dline] > 0) { paused = true; for(next_time = System.currentTimeMillis() + (long)m_delay[cur_dline]; System.currentTimeMillis() < next_time;) { try { Thread.sleep(100L); } catch(InterruptedException _ex) { } if(break_pause) { break_pause = false; break; } } paused = false; } if(cur_dline != num_descrips - 1) cur_dline++; } getGraphics().drawImage(off, 0, scroll_y, this); if(m_jump > 1 && scroll_y + i_h < d.height) getGraphics().drawImage(serase, 0, scroll_y + i_h, this); if(scroll_y < -off.getHeight(this)) { scroll_y = d.height; cur_dline = 0; if(m_file_update_scrolls > 0 && !fetching_file) { reload_count++; if(reload_count >= m_file_update_scrolls) { reload_count = 0; if(m_wait_for_file) { showStatus(m_sb_update_message); fichierSource.lectureOK = false; fetching_file = true; fichierSource.refresh = true; int i = 0; while(fetching_file) { chargeFichier(); if(++i > 300) break; try { Thread.sleep(50L); } catch(InterruptedException _ex) { } } RafraichirDonnees(); afficheDefilement(); } else { if(update_si) { update_si = false; RafraichirDonnees(); afficheDefilement(); } if(!fetching_file) { showStatus(m_sb_update_message); fichierSource.lectureOK = false; fichierSource.refresh = true; fetching_file = true; } } } } } } public String getAppletInfo() { return "Name : Defile 1.21\r\nAuthor : Loic Brigandat\r\nOrganisation : Association @lyon\r\n"; } private static Font getPolice(String s, String s1) { Font font1 = new Font("Helvetica", 0, 12); String as[] = new String[3]; int i = 0; try { StringTokenizer stringtokenizer = new StringTokenizer(s, s1); s.trim(); if(stringtokenizer.countTokens() != 3) return font1; while(stringtokenizer.hasMoreTokens()) { as[i] = stringtokenizer.nextToken().trim(); i++; } font1 = new Font(as[0], typePolice(as[1]), Integer.parseInt(as[2])); } catch(Exception _ex) { return font1; } return font1; } public void init() { System.out.println(getAppletInfo()); d = getSize(); scroll_y = d.height; font = new Font("Dialog", 0, 12); String s = getParameter("saut"); if(s != null) m_jump = Integer.parseInt(s); s = getParameter("rafraichissement"); if(s != null) m_file_update_scrolls = Integer.parseInt(s); s = getParameter("fichier"); if(s != null) { m_file_location = s; connect_message = "Chargement : " + s; } s = getParameter("attente"); if(s != null) m_wait_for_file = Boolean.valueOf(s).booleanValue(); s = getParameter("fond"); if(s != null) m_bgcolor = convertirEnCouleur(s); setBackground(m_bgcolor); s = getParameter("pauseInitiale"); if(s != null) m_scroll_delay = Integer.parseInt(s); s = getParameter("marge"); if(s != null) m_xoffset = Integer.parseInt(s); s = getParameter("couleurLien"); if(s != null) m_def_hlcolor = convertirEnCouleur(s); s = getParameter("policeTitre"); if(s != null) m_policeTitre = getPolice(s, ","); else m_policeTitre = getPolice("SansSerif,bold,20", ","); s = getParameter("couleurTitre"); if(s != null) m_couleurTitre = convertirEnCouleur(s); else m_couleurTitre = convertirEnCouleur("128,0,0"); s = getParameter("target"); if(s != null) m_def_loadwhere = s; else m_def_loadwhere = "_self"; s = getParameter("policeTexte"); if(s != null) m_policeTexte = getPolice(s, ","); else m_policeTexte = getPolice("SansSerif,plain,10", ","); s = getParameter("couleurTexte"); if(s != null) m_couleurTexte = convertirEnCouleur(s); else m_couleurTexte = convertirEnCouleur("0,0,0"); s = getParameter("CouleurPuce"); if(s != null) m_couleurPuces = convertirEnCouleur(s); else m_couleurPuces = Color.red; s = getParameter("TaillePuce"); if(s != null) m_taillePuce = Integer.parseInt(s); else m_taillePuce = 11; fichierSource = new Lecture(this, m_file_location); } public void ligneCourrante() { for(int i = num_descrips - 1; i > -1; i--) if(scroll_y > -line_coords[i]) cur_dline = i; } public void mCheck() { if(num_links == 0) return; for(int i = 0; i < num_links; i++) { if(!mouseIn) { hLine = -1; affiche(i); break; } if(my > link_cords[i * 3] + scroll_y && my < link_cords[i * 3 + 1] + scroll_y) { hLine = link_cords[i * 3 + 2]; link_ref = i; affiche(i); break; } if(i != num_links - 1) continue; hLine = -1; affiche(i); break; } } public boolean mouseDown(Event event, int i, int j) { mdown = true; hold_move = my; cur_dline = 0; if(hLine == -1 && paused) break_pause = true; return true; } public boolean mouseDrag(Event event, int i, int j) { my = j; if(hold_move != my) { if(paused) break_pause = true; if(!dragged && Math.abs(hold_move - my) > 1) { hLine = -1; affiche(0); dragged = true; } scroll_y = scroll_y + (my - hold_move); if(scroll_y > d.height || scroll_y < -i_h) { if(scroll_y > d.height) scroll_y = d.height; if(scroll_y < -i_h) scroll_y = -i_h; } defilement(false); int k = Math.abs(my - hold_move); erase = createImage(d.width, k); g_erase = erase.getGraphics(); g_erase.setColor(m_bgcolor); g_erase.fillRect(0, 0, d.width, k); if(scroll_y > 0) getGraphics().drawImage(erase, 0, scroll_y - k, this); if(scroll_y + i_h < d.height) getGraphics().drawImage(erase, 0, scroll_y + i_h, this); hold_move = my; return true; } else { return true; } } public boolean mouseEnter(Event event, int i, int j) { mouseIn = true; if(fetching_file) showStatus(connect_message); else showStatus(m_sb_text); return true; } public boolean mouseExit(Event event, int i, int j) { mouseIn = false; if(fetching_file) showStatus(connect_message); else showStatus(m_offsbtext); mCheck(); return true; } public boolean mouseMove(Event event, int i, int j) { my = j; if(paused) mCheck(); return true; } public boolean mouseUp(Event event, int i, int j) { ligneCourrante(); mdown = false; if(dragged) { dragged = false; return true; } if(hLine != -1 && !link_urls[link_ref].equals("-1")) if(m_loadwhere[hLine].equalsIgnoreCase("applet")) { if(!fetching_file) { NouvellePage(link_urls[link_ref]); } else { try_later = true; later_string = link_urls[link_ref]; } if(paused) break_pause = true; } else { try { goURL = new URL(getDocumentBase(), link_urls[link_ref]); } catch(MalformedURLException _ex) { } getAppletContext().showDocument(goURL, m_loadwhere[hLine]); //getAppletContext().showDocument(goURL, m_target); } return true; } public void paint(Graphics g) { if(done_draw) { DrawBG(g); g.drawImage(off, 0, scroll_y + 1, this); g.setColor(m_bgcolor); } } public void run() { do { if(fetching_file) { chargeFichier(); if(scrollafterlink) continue; } if(first_run && !mdown) { scroll_y = scroll_y - m_jump; defilement(true); mCheck(); } try { Thread.sleep(m_scroll_delay); } catch(InterruptedException _ex) { } } while(true); } public void start() { paused = false; if(!first_run) { DrawBG(getGraphics()); fichierSource.refresh = true; fetching_file = true; if(m_jump > 1) { serase = createImage(d.width, m_jump); g_serase = serase.getGraphics(); g_serase.setColor(m_bgcolor); g_serase.fillRect(0, 0, d.width, m_jump); } } if(first_run) ligneCourrante(); if(animation == null) { animation = new Thread(this); animation.start(); } if(fr == null) { fr = new Thread(fichierSource); fr.start(); } } public void stop() { if(animation != null) { animation.stop(); animation = null; } if(fr != null) { fr.stop(); fr = null; } } private static int typePolice(String s) { int i = 0; if(s.equalsIgnoreCase("bold")) i++; if(s.equalsIgnoreCase("bolditalic")) i += 3; if(s.equalsIgnoreCase("italic")) i += 2; return i; } Font font; FontMetrics fm; Thread animation; Thread fr; Lecture fichierSource; Dimension d; Graphics g_off; Graphics g_erase; Graphics g_serase; Image serase; Image erase; Image off; URL goURL; boolean scrollafterlink; boolean dragged; boolean break_pause; boolean mouseIn; boolean update_si; boolean try_later; boolean force_draw; boolean done_draw; boolean first_run; boolean paused; boolean mdown; boolean fetching_file; boolean first_connect_message; boolean first_update_message; int m_taillePuce; int reload_count; int my; int hLine; int l_h; int soff; int num_links; int temp_links; int font_style; int num_descrips; int scroll_y; int last_h; int cur_dline; int hold_move; int link_ref; int i_h; int link_cords[]; int line_coords[]; int re_draw[]; long next_time; String later_string; String connect_message; String link_urls[]; private boolean m_wait_for_file; private boolean m_overlap_local_load; private boolean titre[]; private boolean mtitre[]; private int m_def_delay; private int m_def_centertext; private int m_scroll_delay; private int m_xoffset; private int m_file_update_scrolls; private int m_jump; private int m_size_pause[]; private int m_delay[]; private int m_centertext[]; private Font m_policeTitre; private Font m_policeTexte; private Font m_font[]; private Color m_def_textcolor; private Color m_bgcolor; private Color m_def_hlcolor; private Color m_couleurPuces; private Color m_couleurTitre; private Color m_couleurTexte; private Color m_textcolor[]; private String m_sb_text; private String m_def_loadwhere; private String m_offsbtext; private String m_file_location; private String m_sb_update_message; private String m_desc[]; private String m_linkurl[]; private String m_loadwhere[]; private static String Codes[] = { "nbsp", "iexcl", "cent", "pound", "curren", "yen", "brvbar", "sect", "uml", "copy", "ordf", "laquo", "not", "shy", "reg", "macr", "deg", "plusmn", "sup2", "sup3", "acute", "micro", "para", "middot", "cedil", "sup1", "ordm", "raquo", "frac14", "frac12", "frac34", "iquest", "Agrave", "Aacute", "Acirc", "Atilde", "Auml", "Aring", "AElig", "Ccedil", "Egrave", "Eacute", "Ecirc", "Euml", "Igrave", "Iacute", "Icirc", "Iuml", "ETH", "Ntilde", "Ograve", "Oacute", "Ocirc", "Otilde", "Ouml", "times", "Oslash", "Ugrave", "Uacute", "Ucirc", "Uuml", "Yacute", "THORN", "szlig", "agrave", "aacute", "acirc", "atilde", "auml", "aring", "aelig", "ccedil", "egrave", "eacute", "ecirc", "euml", "igrave", "iacute", "icirc", "iuml", "eth", "ntilde", "ograve", "oacute", "ocirc", "otilde", "ouml", "divide", "oslash", "ugrave", "uacute", "ucirc", "uuml", "yacute", "thorn", "yuml" }; }