home *** CD-ROM | disk | FTP | other *** search
Java Source | 2017-09-21 | 20.9 KB | 715 lines |
- /*----------------------------------------------------------------------------
- *
- * AbombDome.java 1.00 96/02/08 S.Nakagawa
- *
- * Copyright (c) 1996 KOTOBUKI SYSTEM CO.,LTD. All Rights Reserved.
- *
- * ï@ö\ : î┤öÜâhü[âÇé≡ò\Īé╖éΘüB
- * ì╢ëEâ{â^âôò\Īé╡üAé╗éΩé╝éΩé╠â{â^âôâNâèâbâNé╔éµéΦâCâüü[âWò\Īò√îⁿé≡îêÆΦé╖éΘüB
- *
- * âpâëâüü[â^ : path âCâüü[âWâtâ@âCâïé¬èiö[é│éΩé─éóéΘâpâXé≡ÄwÆΦé╖éΘüB
- * "/IMAGES"é▄é╜é═"/IMAGES/"é╠î`Ä«é┼ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═âJâîâôâg(HTMLé¬éáéΘ)âfâBâîâNâgâèé╞é╚éΘüB
- * file âCâüü[âWâtâ@âCâïé╠ö╘ìåòöò¬é≡Å£éóé╜û╝æOé≡ÄwÆΦé╖éΘüB
- * "IMG1.GIF"ü`"IMG10.GIF"é≡ò\Īé╡é╜éóÅΩìçé═"IMG"é≡ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═ "IMG" é╞é╚éΘüB
- * ext âCâüü[âWâtâ@âCâïègÆúÄq
- * "IMG1.GIF"é≡ò\Īé╖éΘÅΩìçé═"GIF"é▄é╜é═".GIF"é≡ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═ "GIF" é╞é╚éΘüB
- * first ò\Īé╖éΘɵô¬âtâ@âCâïö╘ìåé≡ÄwÆΦé╖éΘüB
- * "IMG1.GIF"ü`"IMG10.GIF"é≡ò\Īé╖éΘÅΩìçé═"1"é≡ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═ "1" é╞é╚éΘüB
- * last ì┼ÅIâtâ@âCâïö╘ìå
- * "IMG1.GIF"ü`"IMG10.GIF"é≡ò\Īé╖éΘÅΩìçé═"10"é≡ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═ "1" é╞é╚éΘüB
- * speed âCâüü[âWò\Īè╘é╠æ╥ï@Ä₧è╘é≡ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═ "100" é╞é╚éΘüB
- * bgm âTâEâôâhâtâ@âCâïé≡âpâXû╝òté½é┼ÄwÆΦé╖éΘüB
- * mode ì─É╢âéü[âh
- * 0 : ì─É╢üAïtô]ì─É╢üAÆΓÄ~â{â^âô
- * else : é▄é½û▀é╡üAì─É╢üAÆΓÄ~üAâRâ}æùéΦüAâRâ}û▀é╡â{â^âô
- * button â{â^âôâCâüü[âWé╠èiö[âpâXé≡ÄwÆΦé╖éΘüB
- *
- * Ägùpùß : <APPLET CODES="Sample.class" WIDTH=320 HEIGHT=240>
- * <PARAM NAME=PATH VALUE="/KEMCO">
- * <PARAM NAME=FILE VALUE="IMG">
- * <PARAM NAME=EXT VALUE="GIF">
- * <PARAM NAME=FIRST VALUE=1>
- * <PARAM NAME=LAST VALUE=999>
- * <PARAM NAME=SPEED VALUE=100>
- * <PARAM NAME=BGM VALUE="AUDIO/KEMCO.AU">
- * <PARAM NAME=MODE VALUE=0>
- * <PARAM NAME=BUTTON VALUE="BUTTON">
- * </APPLET>
- ---------------------------------------------------------------------------*/
- import java.applet.Applet;
- import java.applet.AppletContext;
- import java.awt.Font;
- import java.awt.Image;
- import java.awt.Color;
- import java.awt.Event;
- import java.awt.Panel;
- import java.awt.Frame;
- import java.awt.Button;
- import java.awt.Polygon;
- import java.awt.Graphics;
- import java.awt.Dimension;
- import java.awt.Component;
- import java.awt.FontMetrics;
- import java.awt.BorderLayout;
- import java.awt.MediaTracker;
- import java.applet.AudioClip;
- import java.util.StringTokenizer;
- import java.util.Enumeration;
-
-
- /*----------------------------------------------------------------------------
- * AbombDome Class.
- *
- * ì∞ɼÄ╥ : S.nakagawa
- * Version : 1.00 96/01/23
- ---------------------------------------------------------------------------*/
- public
- class AbombDome extends Applet implements Runnable
- {
- /* âfâoâbâOùp */
- boolean DEBUG = false; /* âfâoâbâOâtâëâO */
-
- /* âvâìâZâXüAâXâîâbâhè╓ÿA */
- Thread engine = null; /* âXâîâbâhÅεò± */
- boolean threadSuspended = false; /* âXâîâbâhÆΓÄ~âtâëâO */
- boolean nowLoading = true; /* âìü[âhâtâëâO */
-
- /* âIâtâXâNâèü[âôù╠êµ */
- Graphics offScrGraph = null; /* âCâüü[âWüEâRâôâeâLâXâg */
- Image offScrImage = null; /* âCâüü[âWÅεò± */
- Graphics btnGraph = null; /* âCâüü[âWüEâRâôâeâLâXâg */
- Image btnImage = null; /* âCâüü[âWÅεò± */
-
- /* âCâüü[âWè╓ÿA */
- int maxSlot = 0; /* âCâüü[âWâtâ@âCâïÉö */
- int imgSlot = 0; /* î╗ì▌é╠âCâüü[âWö╘ìå */
- int preSlot = 0; /* Æ╝æOé╠âCâüü[âWö╘ìå */
- Image imgs[] = null; /* âCâüü[âWÅεò±âeü[âuâï */
- MediaTracker mt = null; /* âüâfâBâAüEâgâëâbâJü[ */
-
- /* âpâëâüü[â^è╓ÿA */
- String path = null; /* âCâüü[âWâtâ@âCâïèiö[âpâX */
- String file = null; /* âCâüü[âWâtâ@âCâïû╝ */
- String ext = null; /* âCâüü[âWâtâ@âCâïègÆúÄq */
- int first = 0; /* ɵô¬âtâ@âCâïö╘ìå */
- int last = 0; /* ì┼ÅIâtâ@âCâïö╘ìå */
- String buttonPath = null; /* â{â^âôèiö[âpâX */
- int speed = 0; /* âCâüü[âWò\Īè╘é╠æ╥ï@Ä₧è╘ */
- int mode = 0; /* ì─É╢âéü[âh */
- AudioClip bgm = null; /* BGM */
-
- /* â{â^âôè╓ÿA */
- Image rplayButton = null; /* ïtì─É╢â{â^âô */
- Image playButton = null; /* ì─É╢â{â^âô */
- Image stopButton = null; /* ÆΓÄ~â{â^âô */
- Image prevButton = null; /* é▄é½û▀é╡â{â^âô */
- Image scButton = null; /* âRâ}æùéΦâ{â^âô */
- Image rscButton = null; /* âRâ}û▀é╡â{â^âô */
- Panel buttonPanel = null; /* â{â^âôözÆuâpâlâï */
- int xButton[] = null; /* â{â^âôê╩Æu(X) */
- int yButton[] = null; /* â{â^âôê╩Æu(Y) */
- int buttonWidth[] = null; /* â{â^âôìéé│ */
- int buttonHeight[] = null; /* â{â^âôò¥ */
- String buttonMsg[] = null; /* â{â^âôâüâbâZü[âW */
- int buttonCount = 0; /* â{â^âôî┬Éö */
- ImageCanvas imgCanvas = null; /* âCâüü[âWâLâââôâpâX */
-
- /* ì─É╢Å≤æ╘ */
- boolean rplayStatus = false; /* ïtì─É╢â{â^âôëƒë║ */
- boolean playStatus = false; /* "RIGHT"â{â^âôëƒë║ */
-
- /*----------------------------------------------------------------------
- * Åëè·Åêù¥
- * <PARAM NAME=....>éµéΦôné│éΩé╜âpâëâüü[â^é≡ĵô╛é╖éΘ
- ---------------------------------------------------------------------*/
- public void init()
- {
- if ( DEBUG ) nowMemory( "init" );
-
- /* <PARAM NAME=...>é┼ÄwÆΦé│éΩé╜âpâëâüü[â^é≡ĵô╛é╖éΘ */
- /* âpâXû╝ */
- String at = getParameter( "path" );
- if ( at != null )
- {
- path = ( at.charAt(at.length()-1) != '/' ) ?
- new String( at ) : at.substring( 0, at.length() - 1 );
- }
- else
- {
- path = "./";
- }
-
- /* âtâ@âCâïû╝ */
- at = getParameter( "file" );
- file = ( at != null ) ? at : "SpinGlobe";
-
- /* ègÆúÄq */
- at = getParameter( "ext" );
- if ( at != null )
- {
- ext = ( at.charAt(0) != '.' ) ?
- new String( at ) : at.substring( 1, at.length() );
- }
- else
- {
- ext = "gif";
- }
-
- /* ɵô¬âtâ@âCâïö╘ìå */
- at = getParameter( "first" );
- first = ( at != null ) ? Integer.valueOf(at).intValue() : 1;
-
- /* ì┼ÅIâtâ@âCâïö╘ìå */
- at = getParameter( "last" );
- last = ( at != null ) ? Integer.valueOf(at).intValue() : 1;
-
- /* âCâüü[âWò\Īè╘é╠æ╥ï@Ä₧è╘ */
- at = getParameter( "speed" );
- speed = ( at != null ) ? Integer.valueOf(at).intValue() : 100;
-
- /* â{â^âôèiö[âpâX */
- buttonPath = getParameter( "button" );
-
- /* ì─É╢âéü[âh */
- at = getParameter( "mode" );
- mode = ( at != null ) ? Integer.valueOf(at).intValue() : 0;
- }
-
-
- /*------------------------------------------------------------------------
- * â{â^âôâCâüü[âWé≡âìü[âhé╖éΘüB
- -----------------------------------------------------------------------*/
- Image loadButton( String imgName )
- {
- /* âüâfâBâAüEâgâëâbâJü[é≡ì∞ɼé╖éΘ */
- MediaTracker m = new MediaTracker( this );
-
- /* âCâüü[âWé≡âìü[âhé╖éΘ */
- Image img = getImage( getDocumentBase(), buttonPath + "/" + imgName );
- m.addImage( img, 0 );
- try {
- showStatus( "loading : " + buttonPath + "/" + imgName );
- m.waitForID( 0 );
- } catch ( InterruptedException e ) {
- return null;
- }
-
- /* âCâüü[âWâ{â^âôé≡ì∞ɼé╖éΘ */
- return ( img );
- }
-
-
- /*------------------------------------------------------------------------
- * âCâüü[âWé≡âCâüü[âWâeü[âuâïé╔âìü[âhé╡é╜îπüAò\Īé≡èJÄné╖éΘüB
- -----------------------------------------------------------------------*/
- public void run()
- {
- if ( DEBUG ) nowMemory( "run" );
-
- /* î╗âXâîâbâhé╠ùDɵÅçê╩é≡É▌ÆΦé╖éΘ */
- Thread.currentThread().setPriority( Thread.MIN_PRIORITY );
-
- /* âüâfâBâAüEâgâëâbâJü[é≡ì∞ɼé╖éΘ */
- mt = new MediaTracker( this );
-
- /* âCâüü[âWé≡âìü[âhé╖éΘ */
- nowLoading = true;
- if ( loadImage() == false ) return;
- nowLoading = false;
-
- if ( DEBUG ) nowMemory( "load" );
-
- /* ò\Īé╖éΘâCâüü[âWâtâ@âCâïé¬éáéΩé╬Åêù¥é≡é╖éΘ */
- if ( maxSlot != 0 )
- {
- /* Åëè·ò\Īé≡é╖éΘ */
- imgSlot = 0;
- preSlot = -1;
-
- /* ò`ëµâXâîâbâhÅIù╣âgâèâKü[é¬É▌ÆΦé│éΩé─éóé╚éóÅΩìçé╔âïü[âvé╖éΘ */
- while ( engine != null )
- {
- /* âCâüü[âWé≡ò\Īé╖éΘ */
- if ( preSlot != imgSlot ) repaint();
-
- /* ì─É╢âéü[âh "0" é╠ÅΩìç */
- if ( mode == 0 )
- {
- if ( rplayStatus == true && preSlot == imgSlot )
- {
- if ( ++imgSlot == maxSlot )
- {
- imgSlot = 0;
- rplayStatus = false;
- }
- }
- else if ( playStatus == true && preSlot == imgSlot )
- {
- if ( --imgSlot < 0 )
- {
- imgSlot = 0;
- playStatus = false;
- }
- }
- }
- /* ì─É╢âéü[âh "0" ê╚èOé╠ÅΩìç */
- else
- {
- if ( playStatus == true && preSlot == imgSlot )
- {
- if ( ++imgSlot == maxSlot )
- {
- imgSlot = 0;
- playStatus = false;
- try {
- Thread.sleep( speed );
- } catch ( InterruptedException e ) {
- break;
- }
- }
- }
- }
-
- /* âXâîâbâhé≡ïxÄ~é╖éΘ */
- try {
- Thread.sleep( speed );
- } catch ( InterruptedException e ) {
- break;
- }
- }
- }
- }
-
-
- /*------------------------------------------------------------------------
- * âCâüü[âWé≡âìü[âhé╖éΘ
- -----------------------------------------------------------------------*/
- boolean loadImage()
- {
- /* âCâüü[âWÉöé≡É▌ÆΦé╖éΘ */
- maxSlot = ( last - first ) + 1;
-
- /* âCâüü[âWâeü[âuâïé╠ù╠êµé≡èmò█é╖éΘ */
- imgs = new Image[ maxSlot ];
-
- /* âCâüü[âWâtâ@âCâïé≡âìü[âhé╖éΘé╜é▀é╠âïü[âv */
- imgSlot = 0;
- for ( int i = first; i <= last; i++ )
- {
- /* âCâüü[âWâtâ@âCâïé≡ĵô╛é╖éΘ */
- imgs[ imgSlot ] = getImage( getDocumentBase(), path + "/" + file + i + "." + ext );
-
- /* âüâfâBâAüEâgâëâbâJü[é╔âCâüü[âWé≡ôoÿ^é╖éΘ */
- mt.addImage( imgs[ imgSlot ], imgSlot );
-
- /* âCâüü[âWé╠âìü[âhé≡æ╥é┬ */
- try {
- repaint();
- showStatus( "loading : " + path + "/" + file + i + "." + ext );
- mt.waitForID( imgSlot );
- } catch ( InterruptedException e ) {
- return false;
- }
-
- /* âCâôâfâbâNâXé≡ìXÉVé╖éΘ */
- imgSlot++;
- }
-
- return true;
- }
-
-
- /*------------------------------------------------------------------------
- * î╗âtâîü[âÇé≡ò\Īé╖éΘ
- -----------------------------------------------------------------------*/
- public void paint( Graphics g )
- {
- /* âIâtâXâNâèü[âôûóì∞ɼé╠ÅΩìçé═ì∞ɼé╖éΘ */
- if ( offScrImage == null )
- {
- offScrImage = createImage( size().width, size().height );
- offScrGraph = offScrImage.getGraphics();
- }
-
- /* öwîié≡ôhéΦé┬é╘é╖ */
- offScrGraph.setColor( Color.gray );
- offScrGraph.fillRect( 0, 0, size().width, size().height );
-
- /* âüâfâBâAâgâëâbâJü[ûóÆΦï`é╠ÅΩìçÅêù¥é╡é╚éó */
- if ( mt != null && imgSlot < maxSlot )
- {
- /* âGâëü[é╠ÅΩìç */
- if ( mt.isErrorID( imgSlot ) )
- {
- /* âüâbâZü[âWé≡ò\Īé╖éΘ */
- int now = imgSlot + 1;
- String word = "Error!! " + now + " / " + maxSlot;
- Font font = new Font( "TimesRoman", Font.PLAIN, ( size().width / word.length() ) );
- offScrGraph.setFont( font );
- FontMetrics fm = offScrGraph.getFontMetrics();
- offScrGraph.setColor( Color.red );
- offScrGraph.fillRect( 0, 0, size().width, size().height );
- offScrGraph.setColor( Color.yellow );
- int x = ( size().width / 2 ) - ( fm.stringWidth( word ) / 2 );
- int y = ( ( size().height - 25 ) / 2 ) + ( font.getSize() / 2 );
- offScrGraph.drawString( word, x, y );
- }
- /* âìü[âhì╧é▌é╠ÅΩìç */
- else if ( mt.checkID( imgSlot ) && nowLoading == false )
- {
- /* âCâüü[âWé≡ò\Īé╖éΘ */
- if ( imgs[imgSlot] != null ) offScrGraph.drawImage( imgs[imgSlot], 0, 0, this );
- preSlot = imgSlot;
- }
- /* âìü[âhÆåé╠ÅΩìç */
- else
- {
- /* âìü[âhì╧é▌âtâ@âCâïÉöé≡ò\Īé╖éΘ */
- int now = imgSlot + 1;
- String word = "Loading Now!! " + now + " / " + maxSlot;
- Font font = new Font( "TimesRoman", Font.PLAIN, ( size().width / word.length() ) );
- offScrGraph.setFont( font );
- FontMetrics fm = offScrGraph.getFontMetrics();
- int x = ( size().width / 2 ) - ( fm.stringWidth( word ) / 2 );
- int y = ( ( size().height - 25 ) / 2 ) + ( font.getSize() / 2 );
- offScrGraph.setColor( Color.black );
- offScrGraph.drawString( word, x, y );
- offScrGraph.setColor( Color.gray );
- }
- }
-
- /* Ä└ëµû╩é╔âCâüü[âWé≡ò`ëµé╖éΘ */
- g.drawImage( offScrImage, 0, 0, this );
- }
- public void update( Graphics g )
- {
- paint( g );
- }
-
-
- /*------------------------------------------------------------------------
- * âAâjâüü[âVâçâôüEâXâîâbâhé≡èJÄné╖éΘüB
- -----------------------------------------------------------------------*/
- public void start()
- {
- /* â{â^âôâTâCâY */
- int btnWidth = 0; /* â{â^âôâCâüü[âWò¥ */
- int btnHeight = 0; /* â{â^âôâCâüü[âWìéé│ */
-
- /* ì└òW */
- int xPos = 0; /* ì└òW(X) */
- int yPos = 0; /* ì└òW(Y) */
-
-
- if ( DEBUG ) nowMemory( "start" );
-
- /* âXâîâbâhé≡èJÄné╖éΘ */
- if ( engine == null )
- {
- engine = new Thread( this );
- engine.start();
- }
-
- /* âîâCâAâEâgé≡É▌ÆΦé╖éΘ */
- setLayout( new BorderLayout() );
-
- /* âeâôâ|âëâèâCâüü[âWé≡èmò█é╖éΘ */
- btnImage = createImage( size().width, 35 );
- btnGraph = btnImage.getGraphics();
-
- /* âeâôâ|âëâèâCâüü[âWé╠öwîié≡öûéóâOâîü[é╔é╖éΘ */
- btnGraph.setColor( Color.lightGray );
- btnGraph.fillRect( 0, 0, btnImage.getWidth( this ), btnImage.getHeight( this ) );
-
- /* â{â^âôé≡ì∞ɼé╡üAâeâôâ|âëâèé╔ô\éΦòté»éΘ */
- btnWidth = btnHeight = 0;
- buttonCount = 0;
- if ( mode == 0 )
- {
- rplayButton = loadButton( "b-rplay.gif" );
- stopButton = loadButton( "b-stop.gif" );
- playButton = loadButton( "b-play.gif" );
- btnWidth += rplayButton.getWidth( this );
- btnWidth += stopButton.getWidth( this );
- btnWidth += playButton.getWidth( this );
- buttonCount = 3;
- }
- else
- {
- prevButton = loadButton( "b-prev.gif" );
- playButton = loadButton( "b-play.gif" );
- stopButton = loadButton( "b-stop.gif" );
- rscButton = loadButton( "b-rsc.gif" );
- scButton = loadButton( "b-sc.gif" );
- btnWidth += prevButton.getWidth( this );
- btnWidth += playButton.getWidth( this );
- btnWidth += stopButton.getWidth( this );
- btnWidth += rscButton.getWidth( this );
- btnWidth += scButton.getWidth( this );
- buttonCount = 5;
- }
-
- /* ì└òWÅεò±é≡É▌ÆΦé╖éΘ */
- xButton = new int[buttonCount];
- yButton = new int[buttonCount];
- buttonWidth = new int[buttonCount];
- buttonHeight = new int[buttonCount];
- buttonMsg = new String[buttonCount];
-
- /* âCâüü[âWì└òWé≡Åëè·ë╗é╖éΘ */
- xPos = ( size().width - ( btnWidth + ( ( buttonCount - 1 ) * 5 ) ) ) / 2;
- yPos = 5;
- buttonCount = 0;
-
- /* âeâôâ|âëâèâCâüü[âWé╔â{â^âôé╔ô\éΦòté»éΘ */
- if ( mode == 0 )
- {
- btnGraph.drawImage( rplayButton, xPos, yPos, this );
- xButton[buttonCount] = xPos;
- yButton[buttonCount] = yPos + ( size().height - 35 );
- buttonWidth[buttonCount] = rplayButton.getWidth( this );
- buttonHeight[buttonCount] = rplayButton.getHeight( this );
- buttonMsg[buttonCount] = "RPLAY";
- xPos += ( buttonWidth[buttonCount] + 5 );
- buttonCount++;
-
- btnGraph.drawImage( stopButton, xPos, yPos, this );
- xButton[buttonCount] = xPos;
- yButton[buttonCount] = yPos + ( size().height - 35 );
- buttonWidth[buttonCount] = stopButton.getWidth( this );
- buttonHeight[buttonCount] = stopButton.getHeight( this );
- buttonMsg[buttonCount] = "STOP";
- xPos += ( buttonWidth[buttonCount] + 5 );
- buttonCount++;
-
- btnGraph.drawImage( playButton, xPos, yPos, this );
- xButton[buttonCount] = xPos;
- yButton[buttonCount] = yPos + ( size().height - 35 );
- buttonWidth[buttonCount] = playButton.getWidth( this );
- buttonHeight[buttonCount] = playButton.getHeight( this );
- buttonMsg[buttonCount] = "PLAY";
- buttonCount++;
- }
- else
- {
- btnGraph.drawImage( prevButton, xPos, yPos, this );
- xButton[buttonCount] = xPos;
- yButton[buttonCount] = yPos + ( size().height - 35 );
- buttonWidth[buttonCount] = prevButton.getWidth( this );
- buttonHeight[buttonCount] = prevButton.getHeight( this );
- buttonMsg[buttonCount] = "PREV";
- xPos += ( buttonWidth[buttonCount] + 5 );
- buttonCount++;
-
- btnGraph.drawImage( playButton, xPos, yPos, this );
- xButton[buttonCount] = xPos;
- yButton[buttonCount] = yPos + ( size().height - 35 );
- buttonWidth[buttonCount] = playButton.getWidth( this );
- buttonHeight[buttonCount] = playButton.getHeight( this );
- buttonMsg[buttonCount] = "PLAY";
- xPos += ( buttonWidth[buttonCount] + 5 );
- buttonCount++;
-
- btnGraph.drawImage( stopButton, xPos, yPos, this );
- xButton[buttonCount] = xPos;
- yButton[buttonCount] = yPos + ( size().height - 35 );
- buttonWidth[buttonCount] = stopButton.getWidth( this );
- buttonHeight[buttonCount] = stopButton.getHeight( this );
- buttonMsg[buttonCount] = "STOP";
- xPos += ( buttonWidth[buttonCount] + 5 );
- buttonCount++;
-
- btnGraph.drawImage( rscButton, xPos, yPos, this );
- xButton[buttonCount] = xPos;
- yButton[buttonCount] = yPos + ( size().height - 35 );
- buttonWidth[buttonCount] = rscButton.getWidth( this );
- buttonHeight[buttonCount] = rscButton.getHeight( this );
- buttonMsg[buttonCount] = "RSC";
- xPos += ( buttonWidth[buttonCount] + 5 );
- buttonCount++;
-
- btnGraph.drawImage( scButton, xPos, yPos, this );
- xButton[buttonCount] = xPos;
- yButton[buttonCount] = yPos + ( size().height - 35 );
- buttonWidth[buttonCount] = scButton.getWidth( this );
- buttonHeight[buttonCount] = scButton.getHeight( this );
- buttonMsg[buttonCount] = "SC";
- buttonCount++;
- }
-
- /* âLâââôâpâXé≡ì∞ɼé╖éΘ */
- imgCanvas = new ImageCanvas( btnImage );
-
- /* âLâââôâpâXé≡ô\éΦòté»éΘ */
- add( "South", imgCanvas );
-
- /* BGM */
- String at = getParameter( "bgm" );
- if ( at != null )
- {
- try {
- bgm = getAudioClip( getCodeBase(), at );
- } catch ( OutOfMemoryError e ) {
- System.out.println( "ImageLoop.class : catch OutOfMemoryError" );
- showStatus( "ImageLoop.class : catch OutOfMemoryError" );
- bgm = null;
- }
- }
- else
- {
- bgm = null;
- }
-
- /* BGMé≡èJÄné╖éΘ */
- if ( bgm != null ) bgm.loop();
- }
-
-
- /*------------------------------------------------------------------------
- * âAâjâüü[âVâçâôüEâXâîâbâhé≡ÆΓÄ~é╖éΘüB
- -----------------------------------------------------------------------*/
- public void stop()
- {
- if ( DEBUG ) nowMemory( "stop" );
-
- /* BGMé≡ÆΓÄ~é╖éΘ */
- if ( bgm != null ) bgm.stop();
- bgm = null;
-
- /* âXâîâbâhé≡ÆΓÄ~é╖éΘ */
- if ( engine != null )
- {
- engine.stop();
- try {
- engine.destroy();
- } catch ( NoSuchMethodError e ) {
- ;
- }
- }
- engine = null;
-
- /* âCâüü[âWé≡Åëè·ë╗é╖éΘ */
- if ( imgs != null )
- {
- for ( int i = 0; i < maxSlot; i++ )
- {
- imgs[i] = null;
- }
- }
- imgs = null;
- mt = null;
- imgSlot = 0;
-
- /* âKâxü[âWâRâîâNâVâçâôé≡ïNô«é╖éΘ */
- System.gc();
- if ( DEBUG ) nowMemory( "gc" );
- }
-
-
- /*------------------------------------------------------------------------
- * èeâ{â^âôé╔æ╬ë₧é╖éΘÅêù¥é≡ìséñüB
- -----------------------------------------------------------------------*/
- public boolean action( Event ev, Object arg )
- {
- if ( ev.target instanceof Button )
- {
- String label = (String)arg;
-
- /* ì─É╢âéü[âh "0" é╠ÅΩìç */
- if ( mode == 0 )
- {
- if ( label.equals( "RPLAY" ) )
- {
- rplayStatus = true;
- }
- else if ( label.equals( "PLAY" ) )
- {
- if ( imgSlot == 0 ) imgSlot = maxSlot - 1;
- playStatus = true;
- }
- else if ( label.equals( "STOP" ) )
- {
- playStatus = false;
- rplayStatus = false;
- }
- }
- /* ì─É╢âéü[âh "0" ê╚èOé╠ÅΩìç */
- else
- {
- if ( label.equals( "PREV" ) )
- {
- playStatus = false;
- imgSlot = 0;
- }
- else if ( label.equals( "PLAY" ) )
- {
- playStatus = true;
- }
- else if ( label.equals( "STOP" ) )
- {
- playStatus = false;
- }
- else if ( label.equals( "SC" ) )
- {
- playStatus = false;
- imgSlot++;
- if ( imgSlot == maxSlot ) imgSlot = 0;
- }
- else if ( label.equals( "RSC" ) )
- {
- playStatus = false;
- imgSlot--;
- if ( imgSlot == -1 ) imgSlot = maxSlot - 1;;
- }
- }
- }
-
- return false;
- }
-
- /*------------------------------------------------------------------------
- * â}âEâXëƒë║Åêù¥é≡é╖éΘ
- -----------------------------------------------------------------------*/
- public boolean mouseUp( Event evt, int x, int y )
- {
- /* âìü[âhÆåé═û│Äïé╖éΘ */
- if ( nowLoading == true ) return false;
-
- /* â{â^âôö╗ÆΦ */
- for ( int i = 0; i < buttonCount; i++ )
- {
- if ( ( x >= xButton[i] ) && ( x <= ( xButton[i] + buttonWidth[i] ) ) &&
- ( y >= yButton[i] ) && ( y <= ( yButton[i] + buttonHeight[i] ) ) )
- {
- if ( mode == 0 )
- {
- if ( rplayStatus == true || playStatus == true )
- {
- if ( buttonMsg[i].equals( "STOP" ) == false ) break;
- }
- }
- Event e = new Event( new Button(), 0, buttonMsg[i] );
- e.id = e.ACTION_EVENT;
- postEvent( e );
- break;
- }
- }
- return false;
- }
-
-
- /*------------------------------------------------------------------------
- * âüâéâèò\Ī
- -----------------------------------------------------------------------*/
- void nowMemory( String title )
- {
- System.out.println( title + " : " + Runtime.getRuntime().freeMemory() + "/" + Runtime.getRuntime().totalMemory() );
- }
- }
-