Changeset 9007 for lang/java/NanikaKit

Show
Ignore:
Timestamp:
04/06/08 17:44:30 (5 years ago)
Author:
tarchan
Message:

lang/java/NanikaKit: バルーンサーフェスの表示機能を追加 #85

Location:
lang/java/NanikaKit/trunk
Files:
2 added
1 removed
10 modified

Legend:

Unmodified
Added
Removed
  • lang/java/NanikaKit/trunk/build.xml

    r8673 r9007  
    99        <property name="build.bin" value="bin" /> 
    1010        <property name="build.lib" value="lib" /> 
     11        <property name="build.rsrc" value="rsrc" /> 
    1112        <property name="build.jar" value="${manifest.title}.jar" /> 
    1213        <property name="java.home" value="${env.JAVA_HOME}" /> 
     
    1516        <path id="build.class.path"> 
    1617        </path> 
     18 
     19        <target name="clean"> 
     20                <delete dir="${build.bin}" /> 
     21                <delete file="${build.jar}" /> 
     22        </target> 
     23 
     24        <target name="compile"> 
     25                <mkdir dir="${build.bin}" /> 
     26                <javac srcdir="${build.src}" destdir="${build.bin}" encoding="UTF-8"> 
     27                        <classpath refid="build.class.path" /> 
     28                </javac> 
     29                <copy todir="${build.bin}" overwrite="true"> 
     30                        <fileset dir="${build.rsrc}"> 
     31                                <include name="**/*.properties"/> 
     32                        </fileset> 
     33                </copy> 
     34        </target> 
    1735 
    1836        <target name="jar" depends="compile"> 
     
    2846                        </manifest> 
    2947                </jar> 
    30         </target> 
    31  
    32         <target name="compile"> 
    33                 <mkdir dir="${build.bin}" /> 
    34                 <javac srcdir="${build.src}" destdir="${build.bin}" encoding="UTF-8"> 
    35                         <classpath refid="build.class.path" /> 
    36                 </javac> 
    37                 <copy todir="${build.bin}" overwrite="true"> 
    38                         <fileset dir="${build.src}"> 
     48                <copy todir="." overwrite="true"> 
     49                        <fileset dir="${build.rsrc}"> 
    3950                                <include name="**/*.properties"/> 
    4051                        </fileset> 
    4152                </copy> 
     53        </target> 
     54 
     55        <target name="app" depends="jar"> 
    4256        </target> 
    4357 
     
    5367        </target> 
    5468 
    55         <target name="clean"> 
    56                 <delete dir="${build.bin}" /> 
    57                 <delete file="${build.jar}" /> 
    58         </target> 
    59  
    6069        <target name="download.jars"> 
    6170                <mkdir dir="lib" /> 
  • lang/java/NanikaKit/trunk/src/com/mac/tarchan/image/ChromakeyImageFilter.java

    r8673 r9007  
    1313 * このクラスは、クロマキー合成を実行します。 
    1414 *  
    15  * @version 1.0 
     15 * @since 1.0 
    1616 * @author tarchan 
    1717 */ 
  • lang/java/NanikaKit/trunk/src/com/mac/tarchan/image/ChromakeyOp.java

    r8673 r9007  
    1313 * このクラスは、クロマキー合成を実行します。 
    1414 *  
    15  * @version 1.0 
     15 * @since 1.0 
    1616 * @author tarchan 
    1717 */ 
  • lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/SakuraGhost.java

    r8673 r9007  
    2222 
    2323/** 
    24  * このクラスは、ゴーストを表すために使用します。 
     24 * このクラスは、ゴーストを実装します。 
    2525 *  
    26  * @version 1.0 
     26 * @since 1.0 
    2727 * @author tarchan 
    2828 */ 
     
    3636 
    3737        /** シェル */ 
    38         private LinkedHashMap<String, SakuraShell> shell = new LinkedHashMap<String, SakuraShell>(); 
     38        private LinkedHashMap<Integer, SakuraShell> shell = new LinkedHashMap<Integer, SakuraShell>(); 
    3939 
    4040        /** NAR ファイル */ 
     
    4242 
    4343        /** 現在のシェル */ 
    44         private String currentShell = "0"; 
     44        private SakuraShell currentShell; 
     45 
     46        /** ゴーストの栞 */ 
     47        private SakuraShiori shiori; 
    4548 
    4649        /** 
     
    4851         *  
    4952         * @param name NAR ファイル名 
     53         * @return このゴーストへの参照 
    5054         * @throws IOException インストール中にエラーが発生した場合 
    5155         */ 
    52         public void install(String name) throws IOException 
     56        public SakuraGhost install(String name) throws IOException 
    5357        { 
    5458                NanikaArchive newNar = new NanikaArchive(name); 
     
    5862                Properties props = nar.get(name).getProperties(); 
    5963                log.debug("props=" + props); 
     64 
     65                return this; 
    6066        } 
    6167 
    6268        /** 
    6369         * ゴーストの姿を現します。 
    64          */ 
    65         public void materialize() 
    66         { 
     70         *  
     71         * @return このゴーストへの参照 
     72         */ 
     73        public SakuraGhost materialize() 
     74        { 
     75                // loading 
    6776                log.info("starting up engine"); 
    6877                loadShiori(); 
     
    7079                loadGhost(); 
    7180                loadShell(); 
     81 
     82                // materialize 
     83                setScope(0); 
     84                setSurface(0); 
     85                setBalloonSurface(0); 
     86                setScope(1); 
     87                setSurface(10); 
     88                setBalloonSurface(0); 
    7289                log.info("materialized"); 
     90 
     91                return this; 
    7392        } 
    7493 
     
    81100                String shioriSubsystem = System.getProperty("com.mac.tarchan.nanika.shiori.dll", "DummyShiori"); 
    82101                log.debug("SHIORI=" + shioriSubsystem); 
     102 
     103                shiori = new SakuraShiori(); 
     104                shiori.getTalk(); 
    83105        } 
    84106 
     
    88110        private void loadBalloon() 
    89111        { 
     112                currentNar.getBalloon(); 
    90113                String name="name"; 
    91114                String craftman = "craftman"; 
     
    106129        private void loadShell() 
    107130        { 
    108                 int num = 0; 
    109                 int max = currentNar.list("").length; 
    110                 log.info(String.format("loading surface %d/%d", num, max)); 
    111  
    112                 String name="name"; 
    113                 String craftman = "craftman"; 
    114                 log.info(String.format("loading SHELL elements named as \"%s\" crafted by %s", name, craftman)); 
     131                SakuraShell sakura = new SakuraShell("sakura", currentNar); 
     132                SakuraShell kero = new SakuraShell("kero", sakura); 
     133 
     134//              File shellHome = currentNar.getShellHome(); 
     135//              NanikaEntry[] png = currentNar.list(new File(shellHome, "surface.+\\.png").getPath()); 
     136//              NanikaEntry[] txt = currentNar.list(new File(shellHome, "surface.+\\.txt").getPath()); 
     137//              int num = png.length; 
     138//              int max = txt.length; 
     139                log.info(String.format("loading surface %d", sakura.getSurfaceCount())); 
     140 
     141                String id = sakura.getId(); 
     142                String craftman = sakura.getCraftman(); 
     143                log.info(String.format("loading SHELL elements named as \"%s\" crafted by \"%s\"", id, craftman)); 
    115144 
    116145//              log.debug("currentNar=" + currentNar); 
     
    118147 
    119148                // sakura 
    120                 shell.put("0", new SakuraShell("sakura", currentNar)); 
    121                 shell.get("0").setSurface("0"); 
     149                shell.put(0, sakura); 
     150//              shell.get(0).setSurface(0); 
    122151 
    123152                // kero 
    124                 shell.put("1", new SakuraShell("kero", currentNar)); 
    125                 shell.get("1").setSurface("10"); 
     153                shell.put(1, kero); 
     154//              shell.get(1).setSurface(10); 
    126155        } 
    127156 
    128157        /** 
    129158         * ゴーストの姿を消します。 
    130          */ 
    131         public void vanish() 
     159         *  
     160         * @return このゴーストへの参照 
     161         */ 
     162        public SakuraGhost vanish() 
    132163        { 
    133164                log.info("vanish"); 
     
    136167                currentNar = null; 
    137168                currentShell = null; 
     169 
     170                return this; 
     171        } 
     172 
     173        /** 
     174         * スコープを変更します。 
     175         *  
     176         * @param scope スコープ番号 
     177         * @return このゴーストへの参照 
     178         */ 
     179        public SakuraGhost setScope(int scope) 
     180        { 
     181                currentShell = shell.get(scope); 
     182 
     183                return this; 
     184        } 
     185 
     186        /** 
     187         * 現在のスコープのサーフェスを変更します。 
     188         *  
     189         * @param id サーフェス ID 
     190         * @return このゴーストへの参照 
     191         */ 
     192        public SakuraGhost setSurface(int id) 
     193        { 
     194                if (currentShell != null) currentShell.setSurface(id); 
     195 
     196                return this; 
     197        } 
     198 
     199        /** 
     200         * 現在のスコープのバルーンサーフェスを変更します。 
     201         *  
     202         * @param id バルーンサーフェス ID 
     203         * @return このゴーストへの参照 
     204         */ 
     205        public SakuraGhost setBalloonSurface(int id) 
     206        { 
     207                if (currentShell != null) 
     208                { 
     209                        SakuraBalloon balloon = currentShell.getBalloon(); 
     210                        if (balloon != null) balloon.setSurface(id); 
     211                } 
     212 
     213                return this; 
    138214        } 
    139215 
     
    145221        public void draw(Graphics2D g) 
    146222        { 
    147                 SakuraShell sakura = shell.get("0"); 
    148                 SakuraShell kero = shell.get("1"); 
     223                SakuraShell sakura = shell.get(0); 
     224                SakuraShell kero = shell.get(1); 
    149225 
    150226                Rectangle clip = g.getClipBounds(); 
     
    156232 
    157233                // サクラ 
    158                 if (sakura != null) 
     234                if (sakura != null && sakura.getSurface() != null) 
    159235                { 
    160236                        AffineTransform tx = new AffineTransform(); 
     
    174250 
    175251                // ケロ 
    176                 if (kero != null) 
     252                if (kero != null && kero.getSurface() != null) 
    177253                { 
    178254                        AffineTransform tx = new AffineTransform(); 
  • lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/SakuraScript.java

    r8673 r9007  
    88package com.mac.tarchan.nanika; 
    99 
     10import java.util.Scanner; 
     11 
     12import org.apache.commons.logging.Log; 
     13import org.apache.commons.logging.LogFactory; 
     14 
    1015/** 
    1116 * このクラスは、さくらスクリプトを評価する機能を実装します。 
    1217 *  
    13  * @version 1.0 
     18 * @since 1.0 
    1419 * @author tarchan 
    1520 */ 
    1621public class SakuraScript 
    1722{ 
     23        /** ロガー */ 
     24        private static final Log log = LogFactory.getLog(SakuraScript.class); 
     25 
    1826        /** 
    1927         * さくらスクリプトを評価して、ゴーストを操作します。 
     
    2533        public static Object eval(String script, SakuraGhost ghost) 
    2634        { 
     35                Scanner s = new Scanner(script).useDelimiter("\\\\"); 
     36                while (s.hasNext()) 
     37                { 
     38                        String next = s.next(); 
     39                        log.debug("next=" + next); 
     40                } 
    2741                return null; 
    2842        } 
  • lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/SakuraShell.java

    r8673 r9007  
    99 
    1010import java.awt.Graphics2D; 
    11 import java.awt.Point; 
    12 import java.awt.Rectangle; 
     11import java.io.File; 
     12import java.io.IOException; 
     13import java.util.Arrays; 
     14import java.util.HashMap; 
     15import java.util.Properties; 
     16import java.util.regex.Matcher; 
     17import java.util.regex.Pattern; 
    1318 
    1419import org.apache.commons.logging.Log; 
     
    1621 
    1722import com.mac.tarchan.nanika.nar.NanikaArchive; 
     23import com.mac.tarchan.nanika.nar.NanikaEntry; 
    1824 
    1925/** 
    2026 * このクラスは、シェルを表すために使用します。 
    2127 *  
    22  * @version 1.0 
     28 * @since 1.0 
    2329 * @author tarchan 
    2430 */ 
     
    2834        private static final Log log = LogFactory.getLog(SakuraShell.class); 
    2935 
    30         /** 
    31          * シェル名  
    32          */ 
     36        /** シェル名 */ 
    3337        private String name; 
    3438 
     
    3943        private SakuraSurface surface; 
    4044 
    41         /** バルーンオフセット */ 
    42         private Point balloonOffset = new Point(); 
    43  
    44         /** バルーン位置 */ 
    45         private Balloon balloonAlignment = Balloon.NONE; 
    46  
    47         /** バルーン位置情報 */ 
    48         private enum Balloon 
    49         { 
    50                 /** 自動調整、shell の y軸座標が画面中央より左なら右、右なら左に表示 */ 
    51                 NONE, 
    52                 /** 常に左に表示 */ 
    53                 LEFT, 
    54                 /** 常に右に表示 */ 
    55                 RIGHT, 
    56         }; 
    57  
    58         /** 説明文 */ 
    59         private String readme = "readme.txt"; 
     45        /** サーフェスリスト */ 
     46        private HashMap<Integer, SakuraSurface> surfaces = new HashMap<Integer, SakuraSurface>(); 
     47 
     48//      /** さくら側バルーンオフセット */ 
     49//      private Point sakuraBalloonOffset = new Point(); 
     50// 
     51//      /** ケロ側バルーンオフセット */ 
     52//      private Point keroBalloonOffset = new Point(); 
     53// 
     54//      /** バルーン位置 */ 
     55//      private Balloon balloonAlignment = Balloon.NONE; 
     56// 
     57//      /** バルーン位置情報 */ 
     58//      private enum Balloon 
     59//      { 
     60//              /** 自動調整、shell の y軸座標が画面中央より左なら右、右なら左に表示 */ 
     61//              NONE, 
     62//              /** 常に左に表示 */ 
     63//              LEFT, 
     64//              /** 常に右に表示 */ 
     65//              RIGHT, 
     66//      }; 
     67 
     68        /** 詳細 */ 
     69        private Properties descript; 
     70 
     71        /** バルーン */ 
     72        private SakuraBalloon balloon; 
    6073 
    6174        /** 
     
    6982                this.name = name; 
    7083                this.nar = nar; 
     84 
     85                File shellHome = nar.getShellHome(); 
     86 
     87                // descript 
     88                try 
     89                { 
     90                        descript = nar.getEntry(new File(shellHome, nar.getProperty("nanika.shell.descript"))).readDescript(); 
     91                        log.debug("descript=" + descript); 
     92                } 
     93                catch (IOException e) 
     94                { 
     95                        log.error("read shell descript error", e); 
     96                } 
     97                catch (NumberFormatException e) 
     98                { 
     99                        log.error("parse int error", e); 
     100                } 
     101 
     102                // surface 
     103                loadSurface(); 
     104 
     105                // balloon 
     106                loadBalloon(name); 
     107        } 
     108 
     109        /** 
     110         * シェルを構築します。 
     111         *  
     112         * @param name シェル名 
     113         * @param pair ペアのシェル 
     114         */ 
     115        public SakuraShell(String name, SakuraShell pair) 
     116        { 
     117                this.name = name; 
     118                this.nar = pair.nar; 
     119                this.descript = pair.descript; 
     120                this.surfaces = pair.surfaces; 
     121                loadBalloon(name); 
     122        } 
     123 
     124        /** 
     125         * サーフェスを読み込みます。 
     126         */ 
     127        private void loadSurface() 
     128        { 
     129                File shellHome = nar.getShellHome(); 
     130 
     131                // image 
     132                NanikaEntry[] png = nar.list(new File(shellHome, "surface(.+)\\.png").getPath()); 
     133                log.debug("png=" + png.length + "," + Arrays.toString(png)); 
     134                Pattern p = Pattern.compile("surface(.+)\\.png"); 
     135                for (NanikaEntry entry : png) 
     136                { 
     137                        String n = entry.getName(); 
     138                        Matcher m = p.matcher(n); 
     139                        m.find(); 
     140                        int id = Integer.parseInt(m.group(1)); 
     141                        surfaces.put(id, nar.getSurface(id)); 
     142                        log.debug("entry=" + n + "," + id); 
     143                } 
     144 
     145                // collision 
     146                NanikaEntry[] txt = nar.list(new File(shellHome, "surface.+\\.txt").getPath()); 
     147                log.debug("txt=" + txt.length + "," + Arrays.toString(txt));             
     148        } 
     149 
     150        /** 
     151         * バルーンを読み込みます。 
     152         *  
     153         * @param name 名前 
     154         */ 
     155        private void loadBalloon(String name) 
     156        { 
     157                try 
     158                { 
     159                        // balloon 
     160                        balloon = new SakuraBalloon(name, nar); 
     161 
     162                        // balloon offset 
     163                        int x = Integer.parseInt(descript.getProperty(name + ".balloon.offsetx", "0")); 
     164                        int y = Integer.parseInt(descript.getProperty(name + ".balloon.offsety", "0")); 
     165                        balloon.setOffset(x, y); 
     166 
     167                        // balloon alignment 
     168                        String align = descript.getProperty(name + ".balloon.alignment"); 
     169                        balloon.setAlignment(align); 
     170                } 
     171                catch (IOException e) 
     172                { 
     173                        log.error("read balloon error", e); 
     174                } 
     175                catch (Exception e) 
     176                { 
     177                        log.error("read balloon error", e); 
     178                } 
     179        } 
     180 
     181        /** 
     182         * シェルの ID を返します。 
     183         *  
     184         * @return シェルの ID 
     185         */ 
     186        public String getId() 
     187        { 
     188                return descript.getProperty("id"); 
     189        } 
     190 
     191        /** 
     192         * シェルの名前を返します。 
     193         *  
     194         * @return シェルの名前 
     195         */ 
     196        public String getName() 
     197        { 
     198                return descript.getProperty("name"); 
     199        } 
     200 
     201        /** 
     202         * シェルの作成者名を返します。 
     203         *  
     204         * @return シェルの作成者名 
     205         */ 
     206        public String getCraftman() 
     207        { 
     208                return descript.getProperty("craftmanw", descript.getProperty("craftman")); 
     209        } 
     210 
     211        /** 
     212         * シェルのタイプを返します。 
     213         *  
     214         * @return シェルのタイプ 
     215         */ 
     216        public String getType() 
     217        { 
     218                return descript.getProperty("type"); 
     219        } 
     220 
     221        /** 
     222         * サーフェスの数を返します。 
     223         *  
     224         * @return サーフェスの数 
     225         */ 
     226        public int getSurfaceCount() 
     227        { 
     228                return surfaces.size(); 
    71229        } 
    72230 
     
    76234         * @param id サーフェス ID 
    77235         */ 
    78         public void setSurface(String id) 
    79         { 
    80                 log.debug(String.format("set surface: %s(%s)", name, id)); 
    81                 surface = nar.getSurface(id); 
     236        public void setSurface(int id) 
     237        { 
     238//              surface = nar.getSurface(id); 
     239                if (surfaces.containsKey(id)) surface = surfaces.get(id); 
     240                else surface = null; 
     241                log.debug(String.format("set surface: %s(%s): %s", name, id, surface)); 
    82242        } 
    83243 
     
    93253 
    94254        /** 
     255         * バルーンを返します。 
     256         *  
     257         * @return バルーン 
     258         */ 
     259        public SakuraBalloon getBalloon() 
     260        { 
     261                return balloon; 
     262        } 
     263 
     264        /** 
    95265         * サーフェスを描画します。 
    96266         *  
     
    100270        { 
    101271                if (surface != null) surface.draw(g); 
    102         } 
    103  
    104         /** 
    105          * 吹き出しの位置を返します。 
    106          *  
    107          * @param bounds シェルの表示範囲 
    108          * @return バルーンオフセット 
    109          */ 
    110         public Point getBalloonOffset(Rectangle bounds) 
    111         { 
    112                 switch (balloonAlignment) 
    113                 { 
    114                 case NONE: 
    115                         break; 
    116                 case LEFT: 
    117                         break; 
    118                 case RIGHT: 
    119                         break; 
    120                 default: 
    121                         break; 
    122                 } 
    123                 return new Point(balloonOffset); 
    124         } 
     272                if (balloon != null) balloon.draw(g); 
     273        } 
     274 
     275//      /** 
     276//       * 吹き出しの位置を返します。 
     277//       *  
     278//       * @param bounds シェルの表示範囲 
     279//       * @return バルーンオフセット 
     280//       */ 
     281//      public Point getBalloonOffset(Rectangle bounds) 
     282//      { 
     283//              switch (balloonAlignment) 
     284//              { 
     285//              case NONE: 
     286//                      break; 
     287//              case LEFT: 
     288//                      break; 
     289//              case RIGHT: 
     290//                      break; 
     291//              default: 
     292//                      break; 
     293//              } 
     294// 
     295//              return new Point(sakuraBalloonOffset); 
     296//      } 
    125297 
    126298        /** 
     
    131303        public String toString() 
    132304        { 
    133                 return String.format("nar=%s, readme=%s", nar, readme); 
     305                return String.format("shell: name=%s, %s", name, surface.getBounds()); 
    134306        } 
    135307} 
  • lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/SakuraSurface.java

    r8673 r9007  
    2929 * このクラスは、サーフェスを表すために使用します。 
    3030 *  
    31  * @version 1.0 
     31 * @since 1.0 
    3232 * @author tarchan 
    3333 */ 
     
    3838 
    3939        /** サーフェス ID */ 
    40         private String id; 
     40        private int id; 
    4141 
    4242        /** イメージ */ 
     
    5252         * @param image サーフェスイメージ 
    5353         */ 
    54         public SakuraSurface(String id, BufferedImage image) 
     54        public SakuraSurface(int id, BufferedImage image) 
    5555        { 
    5656                this.id = id; 
  • lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/nar/NanikaArchive.java

    r8673 r9007  
    1212import java.io.FileFilter; 
    1313import java.io.IOException; 
     14import java.util.LinkedList; 
    1415import java.util.Properties; 
    1516import java.util.zip.ZipEntry; 
     
    2627 * このクラスは、NAR ファイルからエントリを読み込むために使用します。 
    2728 *  
    28  * @version 1.0 
     29 * @since 1.0 
    2930 * @author tarchan 
    3031 * @see ZipFile 
     
    4243 
    4344        /** プロパティー */ 
    44         protected Properties properties = new Properties(getDefault()); 
     45        protected Properties properties = new Properties(getDefaults()); 
    4546 
    4647        /** 
     
    8182         * @return プロパティー 
    8283         */ 
    83         private static Properties getDefault() 
     84        private static Properties getDefaults() 
    8485        { 
    8586                Properties defaults = new Properties(); 
     
    102103                defaults.setProperty("nanika.shell.surfaces", "surfaces.txt"); 
    103104 
     105                // balloon 
     106                defaults.setProperty("balloon.directory", "balloon"); 
     107                defaults.setProperty("balloon.descript", "descript.txt"); 
     108 
    104109                // other 
    105                 defaults.setProperty("nanika.balloon", "balloon"); 
    106110                defaults.setProperty("nanika.headline", "headline"); 
    107111                defaults.setProperty("nanika.plugin", "plugin"); 
    108                 defaults.setProperty("balloon.directory", "balloon"); 
    109112 
    110113                return defaults; 
     
    181184        { 
    182185                ZipEntry zipEntry = zip.getEntry(file.getPath()); 
    183                 log.debug("zipEntry=" + zipEntry); 
     186//              log.debug("zipEntry=" + zipEntry); 
    184187                return zipEntry != null ? new NanikaEntry(zip, zipEntry) : null; 
    185188        } 
     
    193196        public NanikaEntry[] list(String regex) 
    194197        { 
    195                 return new NanikaEntry[zip.size()]; 
     198                log.debug("regex=" + regex); 
     199                java.util.Enumeration<? extends ZipEntry> in = zip.entries(); 
     200                LinkedList<NanikaEntry> out = new LinkedList<NanikaEntry>(); 
     201                while (in.hasMoreElements()) 
     202                { 
     203                        ZipEntry entry = in.nextElement(); 
     204                        String name = entry.getName(); 
     205                        if (name.matches(regex)) 
     206                        { 
     207                                log.debug("entry=" + name); 
     208                                out.add(getEntry(name)); 
     209                        } 
     210                } 
     211 
     212                return out.toArray(new NanikaEntry[0]); 
    196213        } 
    197214 
     
    213230         * @return サーフェス 
    214231         */ 
    215         public SakuraSurface getSurface(String id) 
     232        public SakuraSurface getSurface(int id) 
    216233        { 
    217234                File file = new File(getShellHome(), String.format("surface%s.png", id)); 
     
    237254 
    238255        /** 
     256         * バルーンを取得します。 
     257         */ 
     258        public void getBalloon() 
     259        { 
     260                try 
     261                { 
     262                        File home = new File(getProperty("balloon.directory")); 
     263                        log.debug("balloon=" + home); 
     264                        NanikaEntry descript = getEntry(new File(home, getProperty("balloon.descript"))); 
     265                        if (descript == null) return; 
     266                        descript.readDescript(); 
     267                        NanikaEntry balloons0 = getEntry(new File(home, "balloons0.png")); 
     268                        if (balloons0 == null) return; 
     269                        balloons0.readImage(); 
     270                } 
     271                catch (IOException e) 
     272                { 
     273                        log.error("read balloon error", e); 
     274                } 
     275        } 
     276 
     277        /** 
    239278         * サムネールを返します。 
    240279         *  
     
    266305                try 
    267306                { 
    268                         NanikaEntry entry = getEntry(getProperties().getProperty("nanika.readme")); 
     307                        NanikaEntry entry = getEntry(getProperty("nanika.readme")); 
    269308                        return entry != null ? entry.readText() : null; 
    270309                } 
  • lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/nar/NanikaEntry.java

    r8673 r9007  
    2828 * このクラスは、NAR ファイルエントリを表すために使用します。 
    2929 *  
    30  * @version 1.0 
     30 * @since 1.0 
    3131 * @author tarchan 
    3232 * @see ZipFile 
  • lang/java/NanikaKit/trunk/src/test/com/mac/tarchan/nanika/NanikaMini.java

    r8673 r9007  
    1212import java.awt.Graphics; 
    1313import java.awt.Graphics2D; 
     14import java.awt.Rectangle; 
    1415import java.awt.geom.AffineTransform; 
    1516import java.awt.geom.RoundRectangle2D; 
     
    2526 
    2627/** 
    27  * @version 1.0 
     28 * 何か。ミニ劇場を実装します。 
     29 *  
     30 * @since 1.0 
    2831 * @author tarchan 
    2932 */ 
     
    3639        private SakuraGhost ghost; 
    3740 
    38 //      /** サクラ側サーフェス */ 
    39 //      private SakuraSurface sakura; 
    40 // 
    41 //      /** ケロ側サーフェス */ 
    42 //      private SakuraSurface kero; 
    43  
    4441        /** サムネール */ 
    4542        private BufferedImage thumbnail; 
    4643 
    4744        /** 
     45         * 何か。を実体化します。 
     46         *  
    4847         * @param args <nar ファイル名> 
    4948         */ 
     
    5251                if (args.length == 0) 
    5352                { 
    54                         System.out.println("NanikaKit.jar <nar files>"); 
     53                        System.out.println("NanikaKit.jar <ghost nar> <balloon nar> ..."); 
    5554                        System.exit(1); 
    5655                } 
    5756 
    58                 NanikaMini mini = new NanikaMini(); 
     57                final NanikaMini mini = new NanikaMini(); 
    5958                mini.setSize(640, 480); 
     59//              mini.setSize(800, 600); 
    6060                mini.setNanika(args); 
    6161 
     62                Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() 
     63                { 
     64                        public void run() 
     65                        { 
     66                                log.info("えんいー"); 
     67                                mini.ghost.vanish(); 
     68                        } 
     69                })); 
     70 
    6271                JFrame frame = new JFrame("Nanika mini"); 
     72                frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    6373                frame.getContentPane().add(mini); 
    64                 frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); 
    6574//              frame.setBackground(new Color(0, true)); 
    6675                frame.pack(); 
     
    8392//                      name = "nanika/nar/nekoshoRX202.nar"; 
    8493//                      args[0] = "nanika/nar/alto_v110.nar"; 
    85  
    86                         ghost = new SakuraGhost(); 
    87 //                      ghost.install(name); 
     94//                      args = new String[]{"nanika/nar/akane_v118.zip", "nanika/balloon/defnekoko.ZIP"}; 
     95//                      args = new String[]{"nanika/nar/sakura020212.nar"}; 
    8896 
    8997                        // すべての NAR ファイルをインストール 
     98                        ghost = new SakuraGhost(); 
    9099                        for (String name : args) 
    91100                        { 
     
    96105                        ghost.materialize(); 
    97106 
    98 //                      NanikaArchive nar = new NanikaArchive(name); 
    99 //                      log.debug("nar=" + nar); 
    100 //                      Properties props = nar.getProperties(); 
    101 //                      log.debug("props=" + props); 
    102 // 
    103 //                      SakuraSurface surface0 = nar.getSurface("0"); 
    104 ////                    SakuraSurface surface0 = nar.getSurface("surface2053"); 
    105 //                      log.debug("surface0=" + surface0); 
    106 //                      sakura = surface0; 
    107 // 
    108 //                      SakuraSurface surface10 = nar.getSurface("10"); 
    109 //                      log.debug("surface10=" + surface10); 
    110 //                      kero = surface10; 
    111 // 
    112 //                      thumbnail = nar.getThumbnail(); 
     107                        // サムネールを取得 
    113108                        thumbnail = ghost.getThumbnail(); 
    114109 
     
    137132         * @param g Graphics2D コンテキスト 
    138133         */ 
    139         public void paint2d(Graphics2D g) 
     134        private void paint2d(Graphics2D g) 
    140135        { 
    141136                log.debug("Graphics2D=" + g.getClass().getName()); 
     
    145140 
    146141                // 背景 
     142                Rectangle rect = g.getClipBounds(); 
    147143//              g.setColor(Color.white); 
    148144//              g.fill(g.getClipBounds()); 
     
    152148                int x = 8; 
    153149                int y = 8; 
    154                 int w = 640 - 16; 
    155 //              int h = 480 - 16 - 22; 
    156                 int h = 480 - 16; 
     150                int w = rect.width - 16; 
     151//              int h = rect.height - 16 - 22; 
     152                int h = rect.height - 16; 
    157153                int arcW = 16; 
    158154                int arcH = 16; 
    159155//              g.fillRoundRect(x, y, w, h, arcW, arcH); 
    160156                RoundRectangle2D.Float rrect = new RoundRectangle2D.Float(x, y, w, h, arcW, arcH); 
     157                g.fill(rrect); 
    161158                g.clip(rrect); 
    162                 g.fill(rrect); 
    163159//              int right = x + w - 16; 
    164160//              x += 128; 
     
    166162//              int bottom = y + h; 
    167163 
     164                // さくら&ケロを描画 
    168165                if (ghost != null) ghost.draw(g); 
    169166 
    170 //              // サクラ 
    171 //              if (sakura != null) 
    172 //              { 
    173 //                      AffineTransform tx = new AffineTransform(); 
    174 ////                    tx.scale(0.8, 0.8); 
    175 ////                    Rectangle rect = sakura.getBounds(); 
    176 //                      Rectangle rect = tx.createTransformedShape(sakura).getBounds(); 
    177 //                      log.debug("rect=" + rect); 
    178 //                      rect.x = right - rect.width; 
    179 //                      rect.y = bottom - rect.height; 
    180 ////                    tx.shear(-0.5, 0); 
    181 //                      tx.rotate(Math.toRadians(0), right - rect.width / 2, bottom); 
    182 //                      tx.translate(rect.x, rect.y); 
    183 //                      g.setTransform(tx); 
    184 //                      sakura.draw(g); 
    185 //                      right = rect.x; 
    186 //              } 
    187 // 
    188 //              // ケロ 
    189 //              if (kero != null) 
    190 //              { 
    191 //                      AffineTransform tx = new AffineTransform(); 
    192 //                      Rectangle rect = kero.getBounds(); 
    193 //                      rect.x = x + (right - x) / 2 - rect.width / 2; 
    194 //                      rect.y = bottom - rect.height; 
    195 //                      tx.translate(rect.x, rect.y); 
    196 ////                    tx.shear(0.5, 0); 
    197 //                      g.setTransform(tx); 
    198 //                      kero.draw(g); 
    199 //              } 
    200  
    201                 // ロゴ 
     167                // サムネール&ロゴを描画 
    202168                if (thumbnail != null) 
    203169                {