import java.applet.Applet; import java.awt.*; //import java.awt.event.*; 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; String s; char c[] = new char[30]; top_char t_char[] = new top_char[30]; int mouse_x; int mouse_y; double ra; double char_ra; int fast_draw[] = new int[30]; int count_f; int last_draw[] = new int[30]; int count_l; //BackEffect3 be3[] = new BackEffect3[10]; title t[] = new title[10]; 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); //addMouseListener(this); //addMouseMotionListener(this); star_img = getImage(getCodeBase(),"back.gif"); mt.addImage(star_img,0); back = createImage(500,500); back_g = back.getGraphics(); s = "Welcome to My Homepage!"; s.getChars(0,s.length(),c,0); for (int i = 0; i < s.length(); i++) t_char[i] = new top_char(c[i]); 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; // for (int i = 0; i < 10; i++) // be3[i] = new BackEffect3(); String url = getDocumentBase().toString(); url = url.substring(0,url.lastIndexOf("/")+1); //System.out.println(url); t[0] = new title("Profile",url+"profile.html",0); t[1] = new title("Program",url+"prog/prog.html",0); t[2] = new title("Games",url+"games/games.html",0); t[3] = new title("Movie",url+"dvd/movie.html",0); t[4] = new title("BBS", "http://www.kouenkai.org/~af/aizu/bbs/apeboard.cgi",1); t[5] = new title("Chat", "http://www.telejapan.com/~af/aizu/chat/index.html",1); t[6] = new title("Link",url+"link.html",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 < title_num; i++) t[i].mouse_move(mouse_x,mouse_y,getFontMetrics(font2)); /********タイトルをうごかす***********/ for (int i = 0; i < title_num; i++){ double ra2 = ra + ((Math.PI*2)/title_num)*i; t[i].setXY(ra2); } for (int i = 0; i < s.length(); i++){ double char_ra2 = char_ra + ((Math.PI/16)*i); t_char[i].setXY(char_ra2,color); if (Math.sin(char_ra2) >= 0){ if (count_f <= 29) fast_draw[count_f++] = i; } else { if (count_l <= 29) last_draw[count_l++] = i; } } off_g.setFont(font1); for (int i = 0; i < count_f; i++) t_char[fast_draw[i]].draw(off_g); off_g.drawImage(star,(getSize().width/2)-90, (getSize().height/2)-69,this); /********タイトルを書く************/ off_g.setFont(font2); for (int i = 0; i < title_num; i++) t[i].draw(off_g,off_g.getFontMetrics()); off_g.setFont(font1); for (int i = 0; i < count_l; i++) t_char[last_draw[i]].draw(off_g); // 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 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 < title_num; i++) t[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; } } }