home *** CD-ROM | disk | FTP | other *** search
/ Internet 1996 World Exposition / park.org.s3.amazonaws.com.7z / park.org.s3.amazonaws.com / Japan / Public / Hiroshima / java / ImageLoop.java < prev    next >
Encoding:
Java Source  |  2017-09-21  |  19.4 KB  |  691 lines

  1. /*----------------------------------------------------------------------------
  2.  *
  3.  *    ImageLoop.java        1.00    96/01/23    S.Nakagawa
  4.  *
  5.  *    Copyright (c) 1996 KOTOBUKI SYSTEM CO.,LTD. All Rights Reserved.
  6.  *
  7.  *    ï@ö\        :    âCâüü[âWâtâ@âCâïé╠ÿAæ▒ò\Īé≡ìséñüB
  8.  *
  9.  *    âpâëâüü[â^    :    path        âCâüü[âWâtâ@âCâïé¬èiö[é│éΩé─éóéΘâpâXé≡ÄwÆΦé╖éΘüB
  10.  *                                "/IMAGES"é▄é╜é═"/IMAGES/"é╠î`Ä«é┼ÄwÆΦé╖éΘüB
  11.  *                                Å╚ù¬Ä₧é═âJâîâôâg(HTMLé¬éáéΘ)âfâBâîâNâgâèé╞é╚éΘüB
  12.  *                    file        âCâüü[âWâtâ@âCâïé╠ö╘ìåòöò¬é≡Å£éóé╜û╝æOé≡ÄwÆΦé╖éΘüB
  13.  *                                "IMG1.GIF"ü`"IMG10.GIF"é≡ò\Īé╡é╜éóÅΩìçé═"IMG"é≡ÄwÆΦé╖éΘüB
  14.  *                                Å╚ù¬Ä₧é═ "IMG" é╞é╚éΘüB
  15.  *                    ext            âCâüü[âWâtâ@âCâïègÆúÄq
  16.  *                                "IMG1.GIF"é≡ò\Īé╖éΘÅΩìçé═"GIF"é▄é╜é═".GIF"é≡ÄwÆΦé╖éΘüB
  17.  *                                Å╚ù¬Ä₧é═ "GIF" é╞é╚éΘüB
  18.  *                    first        ò\Īé╖éΘɵô¬âtâ@âCâïö╘ìåé≡ÄwÆΦé╖éΘüB
  19.  *                                "IMG1.GIF"ü`"IMG10.GIF"é≡ò\Īé╖éΘÅΩìçé═"1"é≡ÄwÆΦé╖éΘüB
  20.  *                                Å╚ù¬Ä₧é═ "1" é╞é╚éΘüB
  21.  *                    last        ì┼ÅIâtâ@âCâïö╘ìå
  22.  *                                "IMG1.GIF"ü`"IMG10.GIF"é≡ò\Īé╖éΘÅΩìçé═"10"é≡ÄwÆΦé╖éΘüB
  23.  *                                Å╚ù¬Ä₧é═ "1" é╞é╚éΘüB
  24.  *                    bgm            âTâEâôâhâtâ@âCâïé≡âpâXû╝òté½é┼ÄwÆΦé╖éΘüB
  25.  *                    cycle        ò\Īé╖éΘâCâüü[âWé╠éPâTâCâNâïò¬é╠ö╘ìåé≡ÄwÆΦé╖éΘüB
  26.  *                                Å╚ù¬Ä₧é═ first ü` last é≡îJéΦò╘é╖üB
  27.  *                    speed        âCâüü[âWò\Īè╘é╠æ╥ï@Ä₧è╘é≡ÄwÆΦé╖éΘüB
  28.  *                                Å╚ù¬Ä₧é═ "100" é╞é╚éΘüB
  29.  *                    sleep        âCâüü[âWò\ĪéPâïü[âvé╠æ╥ï@Ä₧è╘é≡ÄwÆΦé╖éΘüB
  30.  *                                Å╚ù¬Ä₧é═ "100" é╞é╚éΘüB
  31.  *                    loop        âCâüü[âWò\Īé≡îJéΦò╘é╖ë±Éöé≡ÄwÆΦé╖éΘüB
  32.  *                                Å╚ù¬Ä₧é═ëiïvâïü[âvé╞é╚éΘüB
  33.  *                    skip        âXâLâbâvé╖éΘâCâüü[âWûçÉöé≡ÄwÆΦé╖éΘüB
  34.  *                    backcolor    öwîié╠ÉFé≡ÄwÆΦé╖éΘüB
  35.  *                                "r,g,b"é╠Åçé┼ÄwÆΦé╖éΘüB
  36.  *                                Å╚ù¬Ä₧é═üA"128,128,128" é╞é╖éΘüB
  37.  *                    mode        éPâïü[âvûêé╔ò\Īé╖éΘâtâîü[âÇé╔özÆué╖éΘâ{â^âôé≡ÄwÆΦé╖éΘüB
  38.  *                                1 -> REPLAY(éαéñêΩôx)
  39.  *                                "0" é▄é╜é═ ÄwÆΦé│éΩé─éóé╚éóÅΩìçüAò\Īé╡é╚éóüB
  40.  *                    button        â{â^âôâCâüü[âWé╠èiö[âpâXé≡ÄwÆΦé╖éΘüBüiâüâCâôüj
  41.  *                    buttons        â{â^âôâCâüü[âWé╠èiö[âpâXé≡ÄwÆΦé╖éΘüBüiâTâuüj
  42.  *
  43.  *    Ägùpùß        :    <APPLET CODES="ImageLoop.class" WIDTH=300 HEIGHT=300>
  44.  *                    <PARAM NAME=PATH       VALUE="/KEMCO">
  45.  *                    <PARAM NAME=FILE       VALUE="IMG">
  46.  *                    <PARAM NAME=EXT        VALUE="GIF">
  47.  *                    <PARAM NAME=FIRST      VALUE=1>
  48.  *                    <PARAM NAME=LAST       VALUE=999>
  49.  *                    <PARAM NAME=LOOP       VALUE=10>
  50.  *                    <PARAM NAME=LEGAL      VALUE=4>
  51.  *                    <PARAM NAME=SPEED      VALUE=0>
  52.  *                    <PARAM NAME=SLEEP      VALUE=0>
  53.  *                    <PARAM NAME=LOAD       VALUE=0>
  54.  *                    <PARAM NAME=BGM        VALUE="KEMCO.AU">
  55.  *                    <PARAM NAME=CYCLE      VALUE="1,2,3,2,4,5,"
  56.  *                    <PARAM NAME=LOOP       VALUE=10>
  57.  *                    <PARAM NAME=SKIP       VALUE=4>
  58.  *                    <PARAM NAME=BACKCOLOR  VALUE="255,255,255">
  59.  *                    <PARAM NAME=MODE       VALUE=0>
  60.  *                    <PARAM NAME=BUTTON     VALUE="BUTTON">
  61.  *                    </APPLET>
  62.  ---------------------------------------------------------------------------*/
  63. import    java.applet.Applet;
  64. import    java.awt.Font;
  65. import    java.awt.Panel;
  66. import    java.awt.Frame;
  67. import    java.awt.Image;
  68. import    java.awt.Color;
  69. import    java.awt.Event;
  70. import    java.awt.Button;
  71. import    java.awt.Canvas;
  72. import    java.awt.Graphics;
  73. import    java.awt.Dimension;
  74. import    java.awt.Component;
  75. import    java.awt.FontMetrics;
  76. import    java.awt.MediaTracker;
  77. import    java.awt.BorderLayout;
  78. import    java.util.Vector;
  79. import    java.util.Enumeration;
  80. import    java.util.StringTokenizer;
  81. import    java.applet.AudioClip;
  82. import    java.net.URL;
  83. import    java.net.MalformedURLException;
  84. import    java.lang.Runtime;
  85.  
  86.  
  87. /*----------------------------------------------------------------------------
  88.  *    ImageLoop Class.
  89.  *
  90.  *    ì∞ɼÄ╥        :    S.Nakagawa
  91.  *    Version        :    1.00    96/01/23
  92.  ---------------------------------------------------------------------------*/
  93. public
  94. class    ImageLoop    extends    Applet    implements Runnable
  95. {
  96.     /*    âfâoâbâOùp    */
  97.     boolean        DEBUG            =    false;    /*    âfâoâbâOâtâëâO                */
  98. //    boolean        DEBUG            =    true;    /*    âfâoâbâOâtâëâO                */
  99.  
  100.     /*    âvâìâZâXüAâXâîâbâhè╓ÿA    */
  101.     Thread        engine            =    null;    /*    âXâîâbâhÅεò±                */
  102.     boolean        threadSuspended    =    false;    /*    âXâîâbâhÆΓÄ~âtâëâO            */
  103.     boolean        nowLoading        =    false;    /*    âìü[âhâtâëâO                */
  104.     int            playerLoop        =    0;        /*    âïü[âvë±Éö                    */
  105.     boolean        judgeFlag        =    false;    /*    âåü[âUü[ö╗ÆfÆåâtâëâO        */
  106.  
  107.     /*    âIâtâXâNâèü[âôù╠êµ    */
  108.     Graphics    offScrGraph        =    null;    /*    âCâüü[âWüEâRâôâeâLâXâg        */
  109.     Image        offScrImage        =    null;    /*    âCâüü[âWÅεò±                */
  110.  
  111.     /*    âCâüü[âWè╓ÿA    */
  112.     int                maxSlot        =    0;        /*    âCâüü[âWâtâ@âCâïÉö            */
  113.     int                imgSlot        =    0;        /*    î╗ì▌é╠âCâüü[âWâtâ@âCâïö╘ìå    */
  114.     int                preSlot        =    0;        /*    Æ╝æOé╠âCâüü[âWâtâ@âCâïö╘ìå    */
  115.     Image            imgs[]        =    null;    /*    âCâüü[âWÅεò±âeü[âuâï        */
  116.     MediaTracker    mt            =    null;    /*    âüâfâBâAüEâgâëâbâJü[        */
  117.  
  118.     /*    â{â^âôè╓ÿA    */
  119.     ImageButton    replayButton    =    null;    /*    REPLAY â{â^âô                */
  120.     ImageButton    replayButtonS    =    null;    /*    REPLAY â{â^âô                */
  121.  
  122.     /*    âpâëâüü[â^è╓ÿA    */
  123.     String        path            =    null;    /*    âCâüü[âWâtâ@âCâïèiö[âpâX    */
  124.     String        file            =    null;    /*    âCâüü[âWâtâ@âCâïû╝            */
  125.     String        ext                =    null;    /*    âCâüü[âWâtâ@âCâïègÆúÄq        */
  126.     int            first            =    0;        /*    Éµô¬âtâ@âCâïö╘ìå            */
  127.     int            last            =    0;        /*    ì┼ÅIâtâ@âCâïö╘ìå            */
  128.     int            speed            =    0;        /*    âXâèü[âvÄ₧è╘                */
  129.     int            sleep            =    0;        /*    âXâèü[âvÄ₧è╘                */
  130.     AudioClip    bgm                =    null;    /*    BGM                            */
  131.     int            skip            =    0;        /*    âCâüü[âWâXâLâbâvûçÉö        */
  132.     int            cycle[]            =    null;    /*    âCâüü[âWò\Īâeü[âuâï        */
  133.     int            cycles            =    0;        /*    âCâüü[âWò\ĪÉö                */
  134.     int            loop            =    0;        /*    âïü[âvë±Éö                    */
  135.     Color        backColor        =    null;    /*    öwîiÉF                        */
  136.     int            mode            =    0;        /*    özÆuâ{â^âô                    */
  137.     String        buttonPath        =    null;    /*    â{â^âôâCâüü[âWèiö[âpâX        */
  138.     String        buttonPathS        =    null;    /*    â{â^âôâCâüü[âWèiö[âpâX        */
  139.  
  140.  
  141.     /*----------------------------------------------------------------------
  142.      *    Åëè·Åêù¥
  143.      *    <PARAM NAME=....>éµéΦôné│éΩé╜âpâëâüü[â^é≡ĵô╛é╖éΘ
  144.      ---------------------------------------------------------------------*/
  145.     public    void    init()
  146.     {
  147.         StringTokenizer    st;                    /*    âtâHü[â}âbâgòté½ò╢ÄÜù±        */
  148.  
  149.         if ( DEBUG )    nowMemory( "init" );
  150.  
  151.         /*    âpâXû╝    */
  152.         String    at    =    getParameter( "path" );
  153.         if ( at != null )
  154.         {
  155.             path    =    ( at.charAt(at.length()-1) != '/' )    ?
  156.                         new    String( at ) : at.substring( 0, at.length() - 1 );
  157.         }
  158.         else
  159.         {
  160.             path    =    "./";
  161.         }
  162.  
  163.         /*    âtâ@âCâïû╝    */
  164.         at        =    getParameter( "file" );
  165.         file    =    ( at != null ) ? at : "SpinGlobe";
  166.  
  167.         /*    ègÆúÄq    */
  168.         at        =    getParameter( "ext" );
  169.         if ( at != null )
  170.         {
  171.             ext    =    ( at.charAt(0) != '.' )    ?
  172.                     new    String( at ) : at.substring( 1, at.length() );
  173.         }
  174.         else
  175.         {
  176.             ext    =    "gif";
  177.         }
  178.  
  179.         /*    Éµô¬âtâ@âCâïö╘ìå    */
  180.         at        =    getParameter( "first" );
  181.         first    =    ( at != null ) ? Integer.valueOf(at).intValue() : 1;
  182.  
  183.         /*    ì┼ÅIâtâ@âCâïö╘ìå    */
  184.         at        =    getParameter( "last" );
  185.         last    =    ( at != null ) ? Integer.valueOf(at).intValue() : 1;
  186.  
  187.         /*    ò\ĪéPûçôûé╜éΦâXâèü[âvÄ₧è╘    */
  188.         at        =    getParameter( "speed" );
  189.         speed    =    ( at != null ) ? Integer.valueOf(at).intValue() : 100;
  190.  
  191.         /*    ò\ĪéPâïü[âvôûé╜éΦâXâèü[âvÄ₧è╘    */
  192.         at        =    getParameter( "sleep" );
  193.         sleep    =    ( at != null ) ? Integer.valueOf(at).intValue() : 100;
  194.  
  195.         /*    âCâüü[âWò\ĪÅç    */
  196.         at        =    getParameter( "cycle" );
  197.         if ( at != null )
  198.         {
  199.             /*    âtâHü[â}âbâgòté½é╠ò╢ÄÜù±é≡ì∞ɼé╖éΘ    */
  200.             st        =    new    StringTokenizer( at, "," );
  201.  
  202.             /*    ò\Īâeü[âuâïÉöé≡ĵô╛é╖éΘ    */
  203.             cycles    =    st.countTokens();
  204.  
  205.             /*    ò\Īâeü[âuâïù╠êµé≡ì∞ɼé╖éΘ    */
  206.             cycle    =    new    int[cycles];
  207.  
  208.             /*    ò╢ÄÜù±é≡ë≡É═é╡üAò\Īâeü[âuâïé╔ò█è╟é╖éΘ    */
  209.             for ( int i = 0; i < cycles; i++ )
  210.             {
  211.                 cycle[i]    =    Integer.valueOf( st.nextToken() ).intValue() - first;
  212.             }
  213.         }
  214.         else
  215.         {
  216.             /*    ò\Īâeü[âuâïÉöé≡ĵô╛é╖éΘ    */
  217.             cycles    =    ( last - first ) + 1;
  218.  
  219.             /*    ò\Īâeü[âuâïù╠êµé≡ì∞ɼé╖éΘ    */
  220.             cycle    =    new    int[cycles];
  221.  
  222.             /*    ò╢ÄÜù±é≡ë≡É═é╡üAò\Īâeü[âuâïé╔ò█è╟é╖éΘ    */
  223.             for ( int i = 0; i < cycles; i++ )
  224.             {
  225.                 cycle[i]    =    i;
  226.             }
  227.         }
  228.  
  229.         /*    âCâüü[âWâXâLâbâvûçÉö    */
  230.         at        =    getParameter( "skip" );
  231.         skip    =    ( at != null ) ? Integer.valueOf(at).intValue() : 1;
  232.         if ( skip == 0 )    skip    =    1;
  233.  
  234.         /*    âïü[âvë±Éö    */
  235.         at        =    getParameter( "loop" );
  236.         loop    =    ( at != null ) ? Integer.valueOf(at).intValue() : 0;
  237.  
  238.         /*    öwîiÉF    */
  239.         at    =    getParameter( "backcolor" );
  240.         if ( at == null )
  241.         {
  242.             backColor    =    new    Color( 198, 198, 198 );
  243.         }
  244.         else
  245.         {
  246.             int    keyEnd    =    at.indexOf( "," );
  247.             int    red        =    Integer.valueOf( at.substring( 0, keyEnd ) ).intValue();
  248.             st            =    new    StringTokenizer( at.substring( keyEnd + 1 ), "," );
  249.             int    green    =    Integer.valueOf( st.nextToken() ).intValue();
  250.             int    blue    =    Integer.valueOf( st.nextToken() ).intValue();
  251.             backColor    =    new    Color( red, green, blue );
  252.         }
  253.  
  254.         /*    â{â^âôâéü[âh    */
  255.         at        =    getParameter( "mode" );
  256.         mode    =    ( at != null ) ? Integer.valueOf(at).intValue() : 0;
  257.  
  258.         /*    â{â^âôèiö[âpâX    */
  259.         buttonPath    =    getParameter( "button" );
  260.         buttonPathS    =    getParameter( "buttons" );
  261.     }
  262.  
  263.  
  264.     /*------------------------------------------------------------------------
  265.      *    â{â^âôâCâüü[âWé≡âìü[âhé╖éΘüB
  266.      -----------------------------------------------------------------------*/
  267.     ImageButton        loadButton( String imgName, String evtMsg )
  268.     {
  269.         /*    âüâfâBâAüEâgâëâbâJü[é≡ì∞ɼé╖éΘ    */
  270.         MediaTracker    m    =    new    MediaTracker( this );
  271.  
  272.         /*    âCâüü[âWé≡âìü[âhé╖éΘ    */
  273.         Image    img    =    getImage( getDocumentBase(), imgName );
  274.         m.addImage( img, 0 );
  275.         try    {
  276.             showStatus( "loading : " + imgName );
  277.             m.waitForID( 0 );
  278.         }    catch    ( InterruptedException e )    {
  279.             return    null;
  280.         }
  281.  
  282.         /*    âCâüü[âWâ{â^âôé≡ì∞ɼé╖éΘ    */
  283.         return ( new ImageButton( img, evtMsg ) );
  284.     }
  285.  
  286.  
  287.     /*------------------------------------------------------------------------
  288.      *    âCâüü[âWé≡âCâüü[âWâeü[âuâïé╔âìü[âhé╡é╜îπüAò\Īé≡èJÄné╖éΘüB
  289.      -----------------------------------------------------------------------*/
  290.     public    void    run()
  291.     {
  292.         if ( DEBUG )    nowMemory( "run" );
  293.  
  294.         /*    î╗âXâîâbâhé╠ùDɵÅçê╩é≡É▌ÆΦé╖éΘ    */
  295.         Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
  296.  
  297.         /*    âüâfâBâAüEâgâëâbâJü[é≡ì∞ɼé╖éΘ    */
  298.         mt    =    new    MediaTracker( this );
  299.  
  300.         /*    ò╧Éöé≡Åëè·ë╗é╖éΘ    */
  301.         judgeFlag    =    false;
  302.  
  303.         /*    âCâüü[âWé≡âìü[âhé╖éΘ    */
  304.         nowLoading    =    true;
  305.         if ( loadImage() == false )    return;
  306.         nowLoading    =    false;
  307.  
  308.         if ( DEBUG )    nowMemory( "load" );
  309.  
  310.         /*    ò\Īé╖éΘâCâüü[âWâtâ@âCâïé¬éáéΩé╬Åêù¥é≡é╖éΘ    */
  311.         if ( maxSlot != 0 )
  312.         {
  313.             /*    âCâôâfâbâNâXé≡Åëè·ë╗é╖éΘ    */
  314.             imgSlot    =    0;
  315.             preSlot    =    -1;
  316.  
  317.             /*    ò`ëµâXâîâbâhÅIù╣âgâèâKü[é¬É▌ÆΦé│éΩé─éóé╚éóÅΩìçé╔âïü[âvé╖éΘ    */
  318.             while ( engine != null )
  319.             {
  320.                 /*    âïü[âvÅIù╣é≡ö╗Æfé╖éΘ    */
  321.                 if ( loop != 0 && imgSlot == 0 )
  322.                 {
  323.                     if ( playerLoop++ == loop )    break;
  324.                 }
  325.  
  326.                 /*    âCâüü[âWé≡ò`ëµé╖éΘ    */
  327.                 if ( preSlot != imgSlot )    repaint();
  328.  
  329.                 /*    âXâîâbâhé≡ïxÄ~é╖éΘ    */
  330.                 try    {
  331.                     Thread.sleep( speed );
  332.                 }    catch    ( InterruptedException e )    {
  333.                     break;
  334.                 }
  335.  
  336.                 /*    âåü[âUü[ö╗ÆfÆåé═Åêù¥é╡é╚éó    */
  337.                 if ( judgeFlag == false )
  338.                 {
  339.                     if ( preSlot == imgSlot )
  340.                     {
  341.                         if ( ++imgSlot == cycles )
  342.                         {
  343.                             /*    âåü[âUü[ö╗Æfé≡ï▓é▄é╚éóÅΩìç    */
  344.                             if ( mode == 0 )
  345.                             {
  346.                                 /*    Åêù¥ì╧é▌âCâüü[âWÉöé≡â[âìé╔é╖éΘ    */
  347.                                 imgSlot = 0;
  348.  
  349.                                 /*    âXâîâbâhé≡ïxÄ~é╖éΘ    */
  350.                                 if ( sleep != 0 )
  351.                                 {
  352.                                     try    {
  353.                                     Thread.sleep( sleep );
  354.                                     }    catch    ( InterruptedException e )    {
  355.                                         break;
  356.                                     }
  357.                                 }
  358.                             }
  359.                             else
  360.                             {
  361.                                 /*    BGMé≡ÆΓÄ~é╖éΘ    */
  362.                                 if ( bgm != null )        bgm.stop();
  363.  
  364.                                 /*    ö╗ÆfÆåé╠âtâëâOé≡É▌ÆΦé╖éΘ    */
  365.                                 imgSlot--;
  366.                                 judgeFlag    =    true;
  367.     
  368.                                 /*    â{â^âôé≡ùLî°é╔é╖éΘ    */
  369.                                 replayButton.enable();
  370.                                 if ( buttonPathS != null )    replayButtonS.enable();
  371.                             }
  372.                         }
  373.                     }
  374.                 }
  375.             }
  376.         }
  377.     }
  378.  
  379.  
  380.     /*------------------------------------------------------------------------
  381.      *    âCâüü[âWé≡âìü[âhé╖éΘ
  382.      -----------------------------------------------------------------------*/
  383.     boolean        loadImage()
  384.     {
  385.         /*    âCâüü[âWÉöé≡É▌ÆΦé╖éΘ    */
  386.         maxSlot    =    ( last - first ) + 1;
  387.  
  388.         /*    âCâüü[âWâeü[âuâïé╠ù╠êµé≡âCâüü[âWÉöò¬èmò█é╖éΘ    */
  389.         imgs    =    new    Image[maxSlot];
  390.  
  391.         /*    âCâüü[âWâeü[âuâïö╘ìåé≡Åëè·ë╗é╖éΘ    */
  392.         imgSlot    =    0;
  393.  
  394.         /*    âCâüü[âWé≡âìü[âhé╖éΘé╜é▀é╠âïü[âv    */
  395.         for ( int i = first; i <= last; i+=skip )
  396.         {
  397.             /*    âCâüü[âWâtâ@âCâïé≡âCâüü[âWâeü[âuâïé╔âìü[âhé╖éΘ    */
  398.             imgs[ imgSlot ]    =    getImage( getDocumentBase(), path + "/" + file + i + "." + ext );
  399.  
  400.             /*    âüâfâBâAüEâgâëâbâJü[é╔âCâüü[âWé≡ôoÿ^é╖éΘ    */
  401.             mt.addImage( imgs[ imgSlot ], imgSlot );
  402.  
  403.             /*    âCâüü[âWé╠âìü[âhé≡æ╥é┬    */
  404.             try    {
  405.                 showStatus( "loading : " + path + "/" + file + i + "." + ext );
  406.                 repaint();
  407.                 mt.waitForID( imgSlot );
  408.             }    catch    ( InterruptedException e )    {
  409.                 return    false;
  410.             }
  411.  
  412.             /*    âCâôâfâbâNâXé≡ìXÉVé╖éΘ    */
  413.             imgSlot++;
  414.         }
  415.  
  416.         return    true;
  417.     }
  418.  
  419.  
  420.     /*------------------------------------------------------------------------
  421.      *    âåü[âUü[ö╗Æfâtâîü[âÇé╠èeâ{â^âôé╔æ╬ë₧é╖éΘÅêù¥é≡ìséñüB
  422.      -----------------------------------------------------------------------*/
  423.     public    boolean    action( Event ev, Object arg )
  424.     {
  425.         if ( ev.target instanceof Button )
  426.         {
  427.             String    label    =    (String)arg;
  428.  
  429.             /*    éαéñêΩôx    */
  430.             if ( label.equals( "REPLAY" ) )
  431.             {
  432.                 imgSlot        =    0;
  433.                 judgeFlag    =    false;
  434.                 if ( bgm != null )    bgm.loop();
  435.             }
  436.         }
  437.  
  438.         /*    â{â^âôé≡û│î°é╔é╖éΘ    */
  439.         if ( judgeFlag == false )
  440.         {
  441.             replayButton.disable();
  442.             if ( buttonPathS != null )    replayButtonS.disable();
  443.         }
  444.  
  445.         return    false;
  446.     }
  447.  
  448.  
  449.     /*------------------------------------------------------------------------
  450.      *    î╗âtâîü[âÇé≡ò\Īé╖éΘ
  451.      -----------------------------------------------------------------------*/
  452.     public    void    paint( Graphics g )
  453.     {
  454.         /*    âIâtâXâNâèü[âôûóì∞ɼé╠ÅΩìçé═ì∞ɼé╖éΘ    */
  455.         if ( offScrImage == null )
  456.         {
  457.             offScrImage    =    createImage( size().width, size().height );
  458.             offScrGraph    =    offScrImage.getGraphics();
  459.         }
  460.  
  461.         /*    öwîié≡ôhéΦé┬é╘é╖    */
  462.         offScrGraph.setColor( backColor );
  463.         offScrGraph.fillRect( 0, 0, size().width, size().height );
  464.  
  465.         /*    âüâfâBâAâgâëâbâJü[ûóÆΦï`é╠ÅΩìçÅêù¥é╡é╚éó    */
  466.         if ( mt != null && cycle[imgSlot] < maxSlot )
  467.         {
  468.             /*    cycle é≡ì╠ùpé╡é╜è╓îWÅπüAâìü[âhÆåé╞é╗éñé┼é╚éóÅΩìçüAÅêù¥é¬ê┘é╚éΘ    */
  469.             if ( nowLoading == true )
  470.             {
  471.                 /*    âGâëü[é╠ÅΩìç    */
  472.                 if ( mt.isErrorID( imgSlot ) )
  473.                 {
  474.                     /*    âüâbâZü[âWé≡ò\Īé╖éΘ    */
  475.                     int        now        =    imgSlot    +    1;
  476.                     String    word    =    "Error!!  " + now + " / " + maxSlot;
  477.                     Font    font    =    new    Font( "TimesRoman", Font.PLAIN, ( size().width / word.length() ) );
  478.                     offScrGraph.setFont( font );
  479.                     FontMetrics    fm    =    offScrGraph.getFontMetrics();
  480.                     offScrGraph.setColor( Color.red );
  481.                     offScrGraph.fillRect( 0, 0, size().width, size().height );
  482.                     offScrGraph.setColor( Color.yellow );
  483.                     int        x        =    ( size().width / 2 ) - ( fm.stringWidth( word ) / 2 );
  484.                     int        y        =    ( size().height / 2 ) + ( font.getSize() / 2 );
  485.                     offScrGraph.drawString( word, x, y );
  486.                 }
  487.                 /*    âìü[âhì╧é▌é╠ÅΩìç    */
  488.                 else    if ( mt.checkID( imgSlot ) )
  489.                 {
  490.                     ;
  491.                 }
  492.                 /*    âìü[âhÆåé╠ÅΩìç    */
  493.                 else
  494.                 {
  495.                     /*    âìü[âhì╧é▌âtâ@âCâïÉöé≡ò\Īé╖éΘ    */
  496.                     int        now        =    imgSlot    +    1;
  497.                     String    word    =    "Loading Now!!  " + now + " / " + maxSlot;
  498.                     Font    font    =    new    Font( "TimesRoman", Font.PLAIN, ( size().width / word.length() ) );
  499.                     offScrGraph.setFont( font );
  500.                     FontMetrics    fm    =    offScrGraph.getFontMetrics();
  501.                     int        x        =    ( size().width / 2 ) - ( fm.stringWidth( word ) / 2 );
  502.                     int        y        =    ( size().height / 2 ) + ( font.getSize() / 2 );
  503.                     offScrGraph.setColor( Color.black );
  504.                     offScrGraph.drawString( word, x, y );
  505.                     offScrGraph.setColor( backColor );
  506.                 }
  507.             }
  508.             else
  509.             {
  510.                 /*    âGâëü[é╠ÅΩìç    */
  511.                 if ( mt.isErrorID( cycle[imgSlot] ) )
  512.                 {
  513.                     /*    âüâbâZü[âWé≡ò\Īé╖éΘ    */
  514.                     int        now        =    cycle[imgSlot]    +    1;
  515.                     String    word    =    "Error!!  " + now + " / " + maxSlot;
  516.                     Font    font    =    new    Font( "TimesRoman", Font.PLAIN, ( size().width / word.length() ) );
  517.                     offScrGraph.setFont( font );
  518.                     FontMetrics    fm    =    offScrGraph.getFontMetrics();
  519.                     offScrGraph.setColor( Color.red );
  520.                     offScrGraph.fillRect( 0, 0, size().width, size().height );
  521.                     offScrGraph.setColor( Color.yellow );
  522.                     int        x        =    ( size().width / 2 ) - ( fm.stringWidth( word ) / 2 );
  523.                     int        y        =    ( size().height / 2 ) + ( font.getSize() / 2 );
  524.                     offScrGraph.drawString( word, x, y );
  525.                 }
  526.                 /*    âìü[âhì╧é▌é╠ÅΩìç    */
  527.                 else    if ( mt.checkID( cycle[imgSlot] ) )
  528.                 {
  529.                     if ( imgs[cycle[imgSlot]] != null )    offScrGraph.drawImage( imgs[cycle[imgSlot]], 0, 0, this );
  530.                     preSlot    =    imgSlot;
  531.                 }
  532.             }
  533.         }
  534.  
  535.         /*    Ä└ëµû╩é╔âCâüü[âWé≡ò`ëµé╖éΘ    */
  536.         g.drawImage( offScrImage, 0, 0, this );
  537.     }
  538.     public    void    update( Graphics g )
  539.     {
  540.         paint( g );
  541.     }
  542.  
  543.  
  544.     /*------------------------------------------------------------------------
  545.      *    âAâjâüü[âVâçâôüEâXâîâbâhé≡èJÄné╖éΘüB
  546.      -----------------------------------------------------------------------*/
  547.     public    void    start()
  548.     {
  549.         if ( DEBUG )    nowMemory( "start" );
  550.  
  551.         /*    âXâîâbâhé≡èJÄné╖éΘ    */
  552.         if ( engine == null )
  553.         {
  554.             engine    =    new Thread( this );
  555.             engine.start();
  556.         }
  557.  
  558.         /*    âîâCâAâEâgé≡É▌ÆΦé╖éΘ    */
  559.         setLayout( new BorderLayout() );
  560.  
  561.         /*    âpâlâïé≡ì∞ɼé╖éΘ    */
  562.         Panel    p    =    new    Panel();
  563.  
  564.         /*    â{â^âôé≡ì∞ɼé╖éΘ    */
  565.         if ( mode != 0 )
  566.         {
  567.             replayButton    =    loadButton( buttonPath + "/b-more.gif", "REPLAY" );
  568.             replayButton.disable();
  569.             p.add( replayButton );
  570.  
  571.             if ( buttonPathS != null )
  572.             {
  573.                 replayButtonS    =    loadButton( buttonPathS + "/b-more.gif", "REPLAY" );
  574.                 replayButtonS.disable();
  575.                 p.add( replayButtonS );
  576.             }
  577.  
  578.             add( "South",  p );
  579.         }
  580.  
  581.         /*    BGM    */
  582.         String    at    =    getParameter( "bgm" );
  583.         if ( at != null )
  584.         {
  585.             try    {
  586.                 bgm    =    getAudioClip( getCodeBase(), at );
  587.             }    catch ( OutOfMemoryError e )    {
  588.                 System.out.println( "ImageLoop.class : catch OutOfMemoryError" );
  589.                 showStatus( "ImageLoop.class : catch OutOfMemoryError" );
  590.                 bgm    =    null;
  591.             }
  592.         }
  593.         else
  594.         {
  595.             bgm    =    null;
  596.         }
  597.  
  598.         /*    BGMé≡èJÄné╖éΘ    */
  599.         if ( bgm != null )    bgm.loop();
  600.     }
  601.  
  602.  
  603.     /*------------------------------------------------------------------------
  604.      *    âAâjâüü[âVâçâôüEâXâîâbâhé≡ÆΓÄ~é╖éΘüB
  605.      -----------------------------------------------------------------------*/
  606.     public    void    stop()
  607.     {
  608.         if ( DEBUG )    nowMemory( "stop" );
  609.  
  610.         /*    BGMé≡ÆΓÄ~é╖éΘ    */
  611.         if ( bgm != null )    bgm.stop();
  612.         bgm    =    null;
  613.  
  614.         /*    âXâîâbâhé≡ÆΓÄ~é╖éΘ    */
  615.         if ( engine != null )
  616.         {
  617.             engine.stop();
  618.             try    {
  619.                 engine.destroy();
  620.             }    catch ( NoSuchMethodError e )    {
  621.                 ;
  622.             }
  623.         }
  624.         engine    =    null;
  625.  
  626.         /*    âCâüü[âWé≡Åëè·ë╗é╖éΘ    */
  627.         if ( imgs != null )
  628.         {
  629.             for ( int i = 0; i < maxSlot; i++ )
  630.             {
  631.                 imgs[i]    =    null;
  632.             }
  633.         }
  634.         imgs    =    null;
  635.         mt        =    null;
  636.         imgSlot    =    0;
  637.  
  638.         if ( mode != 0 )
  639.         {
  640.             replayButton    =    null;
  641.             replayButtonS    =    null;
  642.         }
  643.  
  644.         /*    âKâxü[âWâRâîâNâVâçâôé≡ïNô«é╖éΘ    */
  645.         System.gc();
  646.         if ( DEBUG )    nowMemory( "gc" );
  647.     }
  648.  
  649.  
  650.     public    void    destroy()
  651.     {
  652.         if ( DEBUG )    nowMemory( "destroy() : " );
  653.     }
  654.  
  655.  
  656.     /*------------------------------------------------------------------------
  657.      *    â}âEâXé≡âNâèâbâNé│éΩé╜ÅΩìçé╔âXâîâbâhé≡Ä└ìsü^ïxÄ~é╖éΘ
  658.      -----------------------------------------------------------------------*/
  659.     public    boolean    mouseUp( Event evt, int x, int y )
  660.     {
  661.         /*    â{â^âôé¬éáéΘÅΩìçé═ë╜éαé╡é╚éó    */
  662.         if ( mode != 0 )    return    false;
  663.  
  664.         /*    Ä└ìsÆåé╠ÅΩìçé╔ïxÄ~é╖éΘ    */
  665.         if ( threadSuspended == false )
  666.         {
  667.             if ( engine != null )    engine.suspend();
  668.             if ( bgm != null )        bgm.stop();
  669.             threadSuspended    =    true;
  670.         }
  671.         /*    ïxÄ~Æåé╠ÅΩìçé╔Ä└ìsé╖éΘ    */
  672.         else
  673.         {
  674.             if ( engine != null )    engine.resume();
  675.             if ( bgm != null )        bgm.loop();
  676.             threadSuspended    =    false;
  677.         }
  678.  
  679.         return    threadSuspended;
  680.     }
  681.  
  682.  
  683.     /*------------------------------------------------------------------------
  684.      *    âüâéâèò\Ī
  685.      -----------------------------------------------------------------------*/
  686.     void    nowMemory( String title )
  687.     {
  688.         System.out.println( title + " : " + Runtime.getRuntime().freeMemory() + "/" + Runtime.getRuntime().totalMemory() );
  689.     }
  690. }
  691.