home *** CD-ROM | disk | FTP | other *** search
Java Source | 2017-09-21 | 19.4 KB | 691 lines |
- /*----------------------------------------------------------------------------
- *
- * ImageLoop.java 1.00 96/01/23 S.Nakagawa
- *
- * Copyright (c) 1996 KOTOBUKI SYSTEM CO.,LTD. All Rights Reserved.
- *
- * ï@ö\ : âCâüü[âWâtâ@âCâïé╠ÿAæ▒ò\Īé≡ìséñü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
- * bgm âTâEâôâhâtâ@âCâïé≡âpâXû╝òté½é┼ÄwÆΦé╖éΘüB
- * cycle ò\Īé╖éΘâCâüü[âWé╠éPâTâCâNâïò¬é╠ö╘ìåé≡ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═ first ü` last é≡îJéΦò╘é╖üB
- * speed âCâüü[âWò\Īè╘é╠æ╥ï@Ä₧è╘é≡ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═ "100" é╞é╚éΘüB
- * sleep âCâüü[âWò\ĪéPâïü[âvé╠æ╥ï@Ä₧è╘é≡ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═ "100" é╞é╚éΘüB
- * loop âCâüü[âWò\Īé≡îJéΦò╘é╖ë±Éöé≡ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═ëiïvâïü[âvé╞é╚éΘüB
- * skip âXâLâbâvé╖éΘâCâüü[âWûçÉöé≡ÄwÆΦé╖éΘüB
- * backcolor öwîié╠ÉFé≡ÄwÆΦé╖éΘüB
- * "r,g,b"é╠Åçé┼ÄwÆΦé╖éΘüB
- * Å╚ù¬Ä₧é═üA"128,128,128" é╞é╖éΘüB
- * mode éPâïü[âvûêé╔ò\Īé╖éΘâtâîü[âÇé╔özÆué╖éΘâ{â^âôé≡ÄwÆΦé╖éΘüB
- * 1 -> REPLAY(éαéñêΩôx)
- * "0" é▄é╜é═ ÄwÆΦé│éΩé─éóé╚éóÅΩìçüAò\Īé╡é╚éóüB
- * button â{â^âôâCâüü[âWé╠èiö[âpâXé≡ÄwÆΦé╖éΘüBüiâüâCâôüj
- * buttons â{â^âôâCâüü[âWé╠èiö[âpâXé≡ÄwÆΦé╖éΘüBüiâTâuüj
- *
- * Ägùpùß : <APPLET CODES="ImageLoop.class" WIDTH=300 HEIGHT=300>
- * <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=LOOP VALUE=10>
- * <PARAM NAME=LEGAL VALUE=4>
- * <PARAM NAME=SPEED VALUE=0>
- * <PARAM NAME=SLEEP VALUE=0>
- * <PARAM NAME=LOAD VALUE=0>
- * <PARAM NAME=BGM VALUE="KEMCO.AU">
- * <PARAM NAME=CYCLE VALUE="1,2,3,2,4,5,"
- * <PARAM NAME=LOOP VALUE=10>
- * <PARAM NAME=SKIP VALUE=4>
- * <PARAM NAME=BACKCOLOR VALUE="255,255,255">
- * <PARAM NAME=MODE VALUE=0>
- * <PARAM NAME=BUTTON VALUE="BUTTON">
- * </APPLET>
- ---------------------------------------------------------------------------*/
- import java.applet.Applet;
- import java.awt.Font;
- import java.awt.Panel;
- import java.awt.Frame;
- import java.awt.Image;
- import java.awt.Color;
- import java.awt.Event;
- import java.awt.Button;
- import java.awt.Canvas;
- import java.awt.Graphics;
- import java.awt.Dimension;
- import java.awt.Component;
- import java.awt.FontMetrics;
- import java.awt.MediaTracker;
- import java.awt.BorderLayout;
- import java.util.Vector;
- import java.util.Enumeration;
- import java.util.StringTokenizer;
- import java.applet.AudioClip;
- import java.net.URL;
- import java.net.MalformedURLException;
- import java.lang.Runtime;
-
-
- /*----------------------------------------------------------------------------
- * ImageLoop Class.
- *
- * ì∞ɼÄ╥ : S.Nakagawa
- * Version : 1.00 96/01/23
- ---------------------------------------------------------------------------*/
- public
- class ImageLoop extends Applet implements Runnable
- {
- /* âfâoâbâOùp */
- boolean DEBUG = false; /* âfâoâbâOâtâëâO */
- // boolean DEBUG = true; /* â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 = false; /* âìü[âhâtâëâO */
- int playerLoop = 0; /* âïü[âvë±Éö */
- boolean judgeFlag = false; /* âåü[âUü[ö╗ÆfÆåâtâëâO */
-
- /* âIâtâXâNâèü[âôù╠êµ */
- Graphics offScrGraph = null; /* âCâüü[âWüEâRâôâeâLâXâg */
- Image offScrImage = null; /* âCâüü[âWÅεò± */
-
- /* âCâüü[âWè╓ÿA */
- int maxSlot = 0; /* âCâüü[âWâtâ@âCâïÉö */
- int imgSlot = 0; /* î╗ì▌é╠âCâüü[âWâtâ@âCâïö╘ìå */
- int preSlot = 0; /* Æ╝æOé╠âCâüü[âWâtâ@âCâïö╘ìå */
- Image imgs[] = null; /* âCâüü[âWÅεò±âeü[âuâï */
- MediaTracker mt = null; /* âüâfâBâAüEâgâëâbâJü[ */
-
- /* â{â^âôè╓ÿA */
- ImageButton replayButton = null; /* REPLAY â{â^âô */
- ImageButton replayButtonS = null; /* REPLAY â{â^âô */
-
- /* â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âïö╘ìå */
- int speed = 0; /* âXâèü[âvÄ₧è╘ */
- int sleep = 0; /* âXâèü[âvÄ₧è╘ */
- AudioClip bgm = null; /* BGM */
- int skip = 0; /* âCâüü[âWâXâLâbâvûçÉö */
- int cycle[] = null; /* âCâüü[âWò\Īâeü[âuâï */
- int cycles = 0; /* âCâüü[âWò\ĪÉö */
- int loop = 0; /* âïü[âvë±Éö */
- Color backColor = null; /* öwîiÉF */
- int mode = 0; /* özÆuâ{â^âô */
- String buttonPath = null; /* â{â^âôâCâüü[âWèiö[âpâX */
- String buttonPathS = null; /* â{â^âôâCâüü[âWèiö[âpâX */
-
-
- /*----------------------------------------------------------------------
- * Åëè·Åêù¥
- * <PARAM NAME=....>éµéΦôné│éΩé╜âpâëâüü[â^é≡ĵô╛é╖éΘ
- ---------------------------------------------------------------------*/
- public void init()
- {
- StringTokenizer st; /* âtâHü[â}âbâgòté½ò╢ÄÜù± */
-
- if ( DEBUG ) nowMemory( "init" );
-
- /* â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;
-
- /* ò\ĪéPûçôûé╜éΦâXâèü[âvÄ₧è╘ */
- at = getParameter( "speed" );
- speed = ( at != null ) ? Integer.valueOf(at).intValue() : 100;
-
- /* ò\ĪéPâïü[âvôûé╜éΦâXâèü[âvÄ₧è╘ */
- at = getParameter( "sleep" );
- sleep = ( at != null ) ? Integer.valueOf(at).intValue() : 100;
-
- /* âCâüü[âWò\ĪÅç */
- at = getParameter( "cycle" );
- if ( at != null )
- {
- /* âtâHü[â}âbâgòté½é╠ò╢ÄÜù±é≡ì∞ɼé╖éΘ */
- st = new StringTokenizer( at, "," );
-
- /* ò\Īâeü[âuâïÉöé≡ĵô╛é╖éΘ */
- cycles = st.countTokens();
-
- /* ò\Īâeü[âuâïù╠êµé≡ì∞ɼé╖éΘ */
- cycle = new int[cycles];
-
- /* ò╢ÄÜù±é≡ë≡É═é╡üAò\Īâeü[âuâïé╔ò█è╟é╖éΘ */
- for ( int i = 0; i < cycles; i++ )
- {
- cycle[i] = Integer.valueOf( st.nextToken() ).intValue() - first;
- }
- }
- else
- {
- /* ò\Īâeü[âuâïÉöé≡ĵô╛é╖éΘ */
- cycles = ( last - first ) + 1;
-
- /* ò\Īâeü[âuâïù╠êµé≡ì∞ɼé╖éΘ */
- cycle = new int[cycles];
-
- /* ò╢ÄÜù±é≡ë≡É═é╡üAò\Īâeü[âuâïé╔ò█è╟é╖éΘ */
- for ( int i = 0; i < cycles; i++ )
- {
- cycle[i] = i;
- }
- }
-
- /* âCâüü[âWâXâLâbâvûçÉö */
- at = getParameter( "skip" );
- skip = ( at != null ) ? Integer.valueOf(at).intValue() : 1;
- if ( skip == 0 ) skip = 1;
-
- /* âïü[âvë±Éö */
- at = getParameter( "loop" );
- loop = ( at != null ) ? Integer.valueOf(at).intValue() : 0;
-
- /* öwîiÉF */
- at = getParameter( "backcolor" );
- if ( at == null )
- {
- backColor = new Color( 198, 198, 198 );
- }
- else
- {
- int keyEnd = at.indexOf( "," );
- int red = Integer.valueOf( at.substring( 0, keyEnd ) ).intValue();
- st = new StringTokenizer( at.substring( keyEnd + 1 ), "," );
- int green = Integer.valueOf( st.nextToken() ).intValue();
- int blue = Integer.valueOf( st.nextToken() ).intValue();
- backColor = new Color( red, green, blue );
- }
-
- /* â{â^âôâéü[âh */
- at = getParameter( "mode" );
- mode = ( at != null ) ? Integer.valueOf(at).intValue() : 0;
-
- /* â{â^âôèiö[âpâX */
- buttonPath = getParameter( "button" );
- buttonPathS = getParameter( "buttons" );
- }
-
-
- /*------------------------------------------------------------------------
- * â{â^âôâCâüü[âWé≡âìü[âhé╖éΘüB
- -----------------------------------------------------------------------*/
- ImageButton loadButton( String imgName, String evtMsg )
- {
- /* âüâfâBâAüEâgâëâbâJü[é≡ì∞ɼé╖éΘ */
- MediaTracker m = new MediaTracker( this );
-
- /* âCâüü[âWé≡âìü[âhé╖éΘ */
- Image img = getImage( getDocumentBase(), imgName );
- m.addImage( img, 0 );
- try {
- showStatus( "loading : " + imgName );
- m.waitForID( 0 );
- } catch ( InterruptedException e ) {
- return null;
- }
-
- /* âCâüü[âWâ{â^âôé≡ì∞ɼé╖éΘ */
- return ( new ImageButton( img, evtMsg ) );
- }
-
-
- /*------------------------------------------------------------------------
- * â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 );
-
- /* ò╧Éöé≡Åëè·ë╗é╖éΘ */
- judgeFlag = false;
-
- /* âCâüü[âWé≡âìü[âhé╖éΘ */
- nowLoading = true;
- if ( loadImage() == false ) return;
- nowLoading = false;
-
- if ( DEBUG ) nowMemory( "load" );
-
- /* ò\Īé╖éΘâCâüü[âWâtâ@âCâïé¬éáéΩé╬Åêù¥é≡é╖éΘ */
- if ( maxSlot != 0 )
- {
- /* âCâôâfâbâNâXé≡Åëè·ë╗é╖éΘ */
- imgSlot = 0;
- preSlot = -1;
-
- /* ò`ëµâXâîâbâhÅIù╣âgâèâKü[é¬É▌ÆΦé│éΩé─éóé╚éóÅΩìçé╔âïü[âvé╖éΘ */
- while ( engine != null )
- {
- /* âïü[âvÅIù╣é≡ö╗Æfé╖éΘ */
- if ( loop != 0 && imgSlot == 0 )
- {
- if ( playerLoop++ == loop ) break;
- }
-
- /* âCâüü[âWé≡ò`ëµé╖éΘ */
- if ( preSlot != imgSlot ) repaint();
-
- /* âXâîâbâhé≡ïxÄ~é╖éΘ */
- try {
- Thread.sleep( speed );
- } catch ( InterruptedException e ) {
- break;
- }
-
- /* âåü[âUü[ö╗ÆfÆåé═Åêù¥é╡é╚éó */
- if ( judgeFlag == false )
- {
- if ( preSlot == imgSlot )
- {
- if ( ++imgSlot == cycles )
- {
- /* âåü[âUü[ö╗Æfé≡ï▓é▄é╚éóÅΩìç */
- if ( mode == 0 )
- {
- /* Åêù¥ì╧é▌âCâüü[âWÉöé≡â[âìé╔é╖éΘ */
- imgSlot = 0;
-
- /* âXâîâbâhé≡ïxÄ~é╖éΘ */
- if ( sleep != 0 )
- {
- try {
- Thread.sleep( sleep );
- } catch ( InterruptedException e ) {
- break;
- }
- }
- }
- else
- {
- /* BGMé≡ÆΓÄ~é╖éΘ */
- if ( bgm != null ) bgm.stop();
-
- /* ö╗ÆfÆåé╠âtâëâOé≡É▌ÆΦé╖éΘ */
- imgSlot--;
- judgeFlag = true;
-
- /* â{â^âôé≡ùLî°é╔é╖éΘ */
- replayButton.enable();
- if ( buttonPathS != null ) replayButtonS.enable();
- }
- }
- }
- }
- }
- }
- }
-
-
- /*------------------------------------------------------------------------
- * âCâüü[âWé≡âìü[âhé╖éΘ
- -----------------------------------------------------------------------*/
- boolean loadImage()
- {
- /* âCâüü[âWÉöé≡É▌ÆΦé╖éΘ */
- maxSlot = ( last - first ) + 1;
-
- /* âCâüü[âWâeü[âuâïé╠ù╠êµé≡âCâüü[âWÉöò¬èmò█é╖éΘ */
- imgs = new Image[maxSlot];
-
- /* âCâüü[âWâeü[âuâïö╘ìåé≡Åëè·ë╗é╖éΘ */
- imgSlot = 0;
-
- /* âCâüü[âWé≡âìü[âhé╖éΘé╜é▀é╠âïü[âv */
- for ( int i = first; i <= last; i+=skip )
- {
- /* âCâüü[âWâtâ@âCâïé≡âCâüü[âWâeü[âuâïé╔âìü[âhé╖éΘ */
- 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 {
- showStatus( "loading : " + path + "/" + file + i + "." + ext );
- repaint();
- mt.waitForID( imgSlot );
- } catch ( InterruptedException e ) {
- return false;
- }
-
- /* âCâôâfâbâNâXé≡ìXÉVé╖éΘ */
- imgSlot++;
- }
-
- return true;
- }
-
-
- /*------------------------------------------------------------------------
- * âåü[âUü[ö╗Æfâtâîü[âÇé╠èeâ{â^âôé╔æ╬ë₧é╖éΘÅêù¥é≡ìséñüB
- -----------------------------------------------------------------------*/
- public boolean action( Event ev, Object arg )
- {
- if ( ev.target instanceof Button )
- {
- String label = (String)arg;
-
- /* éαéñêΩôx */
- if ( label.equals( "REPLAY" ) )
- {
- imgSlot = 0;
- judgeFlag = false;
- if ( bgm != null ) bgm.loop();
- }
- }
-
- /* â{â^âôé≡û│î°é╔é╖éΘ */
- if ( judgeFlag == false )
- {
- replayButton.disable();
- if ( buttonPathS != null ) replayButtonS.disable();
- }
-
- return false;
- }
-
-
- /*------------------------------------------------------------------------
- * î╗â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( backColor );
- offScrGraph.fillRect( 0, 0, size().width, size().height );
-
- /* âüâfâBâAâgâëâbâJü[ûóÆΦï`é╠ÅΩìçÅêù¥é╡é╚éó */
- if ( mt != null && cycle[imgSlot] < maxSlot )
- {
- /* cycle é≡ì╠ùpé╡é╜è╓îWÅπüAâìü[âhÆåé╞é╗éñé┼é╚éóÅΩìçüAÅêù¥é¬ê┘é╚éΘ */
- if ( nowLoading == true )
- {
- /* â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 / 2 ) + ( font.getSize() / 2 );
- offScrGraph.drawString( word, x, y );
- }
- /* âìü[âhì╧é▌é╠ÅΩìç */
- else if ( mt.checkID( 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 / 2 ) + ( font.getSize() / 2 );
- offScrGraph.setColor( Color.black );
- offScrGraph.drawString( word, x, y );
- offScrGraph.setColor( backColor );
- }
- }
- else
- {
- /* âGâëü[é╠ÅΩìç */
- if ( mt.isErrorID( cycle[imgSlot] ) )
- {
- /* âüâbâZü[âWé≡ò\Īé╖éΘ */
- int now = cycle[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 / 2 ) + ( font.getSize() / 2 );
- offScrGraph.drawString( word, x, y );
- }
- /* âìü[âhì╧é▌é╠ÅΩìç */
- else if ( mt.checkID( cycle[imgSlot] ) )
- {
- if ( imgs[cycle[imgSlot]] != null ) offScrGraph.drawImage( imgs[cycle[imgSlot]], 0, 0, this );
- preSlot = imgSlot;
- }
- }
- }
-
- /* Ä└ëµû╩é╔â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()
- {
- 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() );
-
- /* âpâlâïé≡ì∞ɼé╖éΘ */
- Panel p = new Panel();
-
- /* â{â^âôé≡ì∞ɼé╖éΘ */
- if ( mode != 0 )
- {
- replayButton = loadButton( buttonPath + "/b-more.gif", "REPLAY" );
- replayButton.disable();
- p.add( replayButton );
-
- if ( buttonPathS != null )
- {
- replayButtonS = loadButton( buttonPathS + "/b-more.gif", "REPLAY" );
- replayButtonS.disable();
- p.add( replayButtonS );
- }
-
- add( "South", p );
- }
-
- /* 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;
-
- if ( mode != 0 )
- {
- replayButton = null;
- replayButtonS = null;
- }
-
- /* âKâxü[âWâRâîâNâVâçâôé≡ïNô«é╖éΘ */
- System.gc();
- if ( DEBUG ) nowMemory( "gc" );
- }
-
-
- public void destroy()
- {
- if ( DEBUG ) nowMemory( "destroy() : " );
- }
-
-
- /*------------------------------------------------------------------------
- * â}âEâXé≡âNâèâbâNé│éΩé╜ÅΩìçé╔âXâîâbâhé≡Ä└ìsü^ïxÄ~é╖éΘ
- -----------------------------------------------------------------------*/
- public boolean mouseUp( Event evt, int x, int y )
- {
- /* â{â^âôé¬éáéΘÅΩìçé═ë╜éαé╡é╚éó */
- if ( mode != 0 ) return false;
-
- /* Ä└ìsÆåé╠ÅΩìçé╔ïxÄ~é╖éΘ */
- if ( threadSuspended == false )
- {
- if ( engine != null ) engine.suspend();
- if ( bgm != null ) bgm.stop();
- threadSuspended = true;
- }
- /* ïxÄ~Æåé╠ÅΩìçé╔Ä└ìsé╖éΘ */
- else
- {
- if ( engine != null ) engine.resume();
- if ( bgm != null ) bgm.loop();
- threadSuspended = false;
- }
-
- return threadSuspended;
- }
-
-
- /*------------------------------------------------------------------------
- * âüâéâèò\Ī
- -----------------------------------------------------------------------*/
- void nowMemory( String title )
- {
- System.out.println( title + " : " + Runtime.getRuntime().freeMemory() + "/" + Runtime.getRuntime().totalMemory() );
- }
- }
-