import java.applet.Applet; import java.awt.*; //import java.awt.event.*; import java.util.*; public class menu extends Applet implements Runnable { Image off; Image star_img; Image back; Image star; Graphics back_g; Graphics off_g; Thread th; MediaTracker mt; //top_char t_char[] = new top_char[30]; //Vector t_char; Vector pt_char; int char_prog; int mouse_x; int mouse_y; double ra; double char_ra; int fast_draw[]; int count_f; int last_draw[]; int count_l; //BackEffect3 be3[] = new BackEffect3[10]; //title t[] = new title[10]; Vector t; //int title_num; Font font1; Font font2; Color color[][][] = new Color[9][9][9]; boolean back_draw; /*********init()***********/ public void init(){ off = createImage(500,500); off_g = off.getGraphics(); th = null; mt = new MediaTracker(this); Vector s = new Vector(); s.addElement("Welcome to My Homepage!"); s.addElement("Java is very easy"); char_prog = 0; int l = 0; pt_char = new Vector(); for (int i = 0; i < s.size(); i++){ pt_char.addElement(new Vector()); if ( ((String)s.elementAt(i)).length() > l ) l = ((String)s.elementAt(i)).length(); for (int i2 = 0; i2 < ((String)s.elementAt(i)).length(); i2++) ((Vector)pt_char.elementAt(i)).addElement(new top_char(((String)s.elementAt(i)).charAt(i2))); } fast_draw = new int[l]; last_draw = new int[l]; //addMouseListener(this); //addMouseMotionListener(this); star_img = getImage(getCodeBase(),"back.gif"); mt.addImage(star_img,0); back = createImage(500,500); back_g = back.getGraphics(); star = getImage(getCodeBase(),"star.gif"); mt.addImage(star,0); count_f = 0; count_l = 0; mouse_x = 200; mouse_y = 200; ra = Math.PI/2; char_ra = Math.PI*2; //System.out.println(getCodeBase()); //System.out.println(getDocumentBase().toExternalForm()); String url = getDocumentBase().toString(); url = url.substring(0,url.lastIndexOf("/")+1); //System.out.println(url); t = new Vector(); t.addElement(new title("Profile",url+"profile.html", new Color(0xddddff),0)); t.addElement(new title("Program",url+"prog.html", new Color(0xccffcc),0)); t.addElement(new title("Games",url+"games.html", new Color(0xffffbb),0)); t.addElement(new title("Movie",url+"movie.html", new Color(0xffddff),0)); t.addElement(new title("BBS", "http://www.telejapan.com/af/cgi/aizu/bbs/jawanote.cgi", new Color(0xffddff),1)); t.addElement(new title("Chat", "http://www.telejapan.com/af/cgi/aizu/chat/index.html", new Color(0xccddff),1)); t.addElement(new title("Link",url+"link.html", new Color(0xddffdd),0)); //title_num = 7; font1 = new Font("Dialog",Font.PLAIN,20); font2 = new Font("Serif",Font.ITALIC,30); for (int r = 0; r < 9; r++){ for (int g = 0; g < 9; g++){ for (int b = 0; b < 9; b++){ color[r][g][b] = new Color(r>0?(r*32)-1:0, g>0?(g*32)-1:0, b>0?(b*32)-1:0); } } } back_draw = false; } /*********start()**********/ public void start(){ if(th == null){ th = new Thread(this); th.start(); } } /********update()**********/ public void update(Graphics g){ paint(g); } /********run()***********/ public void run(){ while (true){ if (mt.checkID(0)){ repaint(); } else { try { mt.waitForID(0); }catch(InterruptedException e){} } /********sleep*********/ try{ th.sleep(120); } catch (InterruptedException e){} } } /*********paint()*********/ public void paint(Graphics g){ if (mt.isErrorID(0)){ off_g.setColor(Color.black); off_g.fillRect(0,0,getSize().width,getSize().height); off_g.setColor(Color.white); off_g.drawString("Load Error...",50,50); } else if (mt.checkID(0)){ if (!back_draw){ for (int x = 0; x < 500; x += 150){ for (int y = 0; y < 500; y+= 150){ back_g.drawImage(star_img,x,y,this); back_draw = true; } } } off_g.drawImage(back,0,0,this); /********マウスの位置とくらべる******/ for (int i = 0; i < t.size(); i++) ((title)t.elementAt(i)).mouse_move(mouse_x,mouse_y,getFontMetrics(font2)); /********タイトルをうごかす***********/ for (int i = 0; i < t.size(); i++){ double ra2 = ra + ((Math.PI*2)/t.size())*i; ((title)t.elementAt(i)).setXY(ra2); } for (int i = 0; i < ((Vector)pt_char.elementAt(char_prog)).size(); i++){ double char_ra2 = char_ra + ((Math.PI/16)*i); ((top_char)((Vector)pt_char.elementAt(char_prog)).elementAt(i)).setXY(char_ra2,color); if (char_ra2 < Math.PI && char_ra2 > 0){ if (count_f < fast_draw.length) fast_draw[count_f++] = i; } else if (char_ra2 < Math.PI*2 && char_ra2 >= Math.PI){ if (count_l < last_draw.length) last_draw[count_l++] = i; } } off_g.setFont(font1); for (int i = 0; i < count_f; i++) ((top_char)((Vector)pt_char.elementAt(char_prog)).elementAt(fast_draw[i])).draw(off_g); off_g.drawImage(star,(getSize().width/2)-90, (getSize().height/2)-69,this); off_g.setFont(font1); for (int i = 0; i < count_l; i++) ((top_char)((Vector)pt_char.elementAt(char_prog)).elementAt(last_draw[i])).draw(off_g); /********タイトルを書く************/ off_g.setFont(font2); for (int i = 0; i < t.size(); i++) ((title)t.elementAt(i)).draw(off_g,off_g.getFontMetrics()); // for (int i = 0; i < 5; i++) // be3[i].draw(mouse_x, mouse_y, off_g); // for (int i = 5; i < 10; i++) // be3[i].draw2(mouse_x,mouse_y,off_g); /*********raをうごかす**********/ if (ra >= (Math.PI/2)+((Math.PI/(64*2))*((64*2)-1)*2)) ra = Math.PI/2; else ra += Math.PI/(64*2); //if (char_ra < Math.PI/16) //char_ra = Math.PI*2; //else if ((((Vector)pt_char.elementAt(char_prog)).size()*Math.PI/16)+char_ra < 0){ if (char_prog < pt_char.size() - 1) char_prog++; else char_prog = 0; char_ra = Math.PI*2; } else { char_ra -= Math.PI/16; } count_f = 0; count_l = 0; } else { off_g.setColor(Color.black); off_g.fillRect(0,0,getSize().width,getSize().height); off_g.setColor(Color.white); off_g.drawString("Now Loading...",50,50); } g.drawImage(off,0,0,this); } public boolean mouseDown(Event evt,int x, int y){ for (int i = 0; i < t.size(); i++) ((title)t.elementAt(i)).clic(getAppletContext()); return true; } /* public void mouseClicked (MouseEvent e){ } */ /* public void mouseMoved (MouseEvent e){ mouse_x = e.getX(); mouse_y = e.getY(); } */ public boolean mouseMove(Event evt,int x, int y){ mouse_x = x; mouse_y = y; return true; } public void stop(){ if (th != null){ th.stop(); th = null; } } }