- Timestamp:
- 04/12/08 08:36:17 (5 years ago)
- Location:
- lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika
- Files:
-
- 5 modified
-
SakuraBalloon.java (modified) (6 diffs)
-
SakuraGhost.java (modified) (4 diffs)
-
SakuraShell.java (modified) (2 diffs)
-
nar/NanikaArchive.java (modified) (16 diffs)
-
nar/NanikaEntry.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/SakuraBalloon.java
r9332 r9338 94 94 public SakuraBalloon(String name, NanikaArchive nar) throws IOException 95 95 { 96 log.debug("nar=" + nar); 96 97 this.name = name; 97 98 // this.nar = nar; 98 99 99 File balloonHome = new File(nar.getProperty("balloon.directory")); 100 log.debug("balloon=" + balloonHome); 100 String type = nar.getProperty("type"); 101 File balloonDir = type.equals("balloon") ? new File("") : new File(nar.getProperty("balloon.directory")); 102 log.debug("balloon=" + balloonDir); 103 log.debug("balloon=" + new File(balloonDir, nar.getProperty("balloon.descript"))); 101 104 102 105 // descript 103 descript = nar.getEntry(new File(balloon Home, nar.getProperty("balloon.descript"))).readDescript();106 descript = nar.getEntry(new File(balloonDir, nar.getProperty("balloon.descript"))).readDescript(); 104 107 log.debug("descript=" + descript); 105 108 … … 143 146 int x = Integer.parseInt(descript.getProperty("arrow0.x", "0")); 144 147 int y = Integer.parseInt(descript.getProperty("arrow0.y", "0")); 145 BufferedImage image = nar.getEntry(new File(balloon Home, nar.getProperty("balloon.arrow0"))).readImage();148 BufferedImage image = nar.getEntry(new File(balloonDir, nar.getProperty("balloon.arrow0"))).readImage(); 146 149 arrow0 = new SakuraSurface("arrow0", image); 147 150 arrow0.setLocation(x, y); … … 152 155 int x = Integer.parseInt(descript.getProperty("arrow1.x", "0")); 153 156 int y = Integer.parseInt(descript.getProperty("arrow1.y", "0")); 154 BufferedImage image = nar.getEntry(new File(balloon Home, nar.getProperty("balloon.arrow1"))).readImage();157 BufferedImage image = nar.getEntry(new File(balloonDir, nar.getProperty("balloon.arrow1"))).readImage(); 155 158 arrow1 = new SakuraSurface("arrow1", image); 156 159 arrow1.setLocation(x, y); … … 161 164 int x = Integer.parseInt(descript.getProperty("onlinemarker.x", "0")); 162 165 int y = Integer.parseInt(descript.getProperty("onlinemarker.y", "0")); 163 BufferedImage image = nar.getEntry(new File(balloon Home, nar.getProperty("balloon.onlinemarker"))).readImage();166 BufferedImage image = nar.getEntry(new File(balloonDir, nar.getProperty("balloon.onlinemarker"))).readImage(); 164 167 onlinemarker = new SakuraSurface("onlinemarker", image); 165 168 onlinemarker.setLocation(x, y); … … 170 173 int x = Integer.parseInt(descript.getProperty("sstpmarker.x", "0")); 171 174 int y = Integer.parseInt(descript.getProperty("sstpmarker.y", "0")); 172 BufferedImage image = nar.getEntry(new File(balloon Home, nar.getProperty("balloon.sstpmarker"))).readImage();175 BufferedImage image = nar.getEntry(new File(balloonDir, nar.getProperty("balloon.sstpmarker"))).readImage(); 173 176 sstpmarker = new SakuraSurface("sstpmarker", image); 174 177 sstpmarker.setLocation(x, y); … … 191 194 } 192 195 193 NanikaEntry[] png = nar.list(new File(balloon Home, pat).getPath());196 NanikaEntry[] png = nar.list(new File(balloonDir, pat).getPath()); 194 197 log.debug("png=" + png.length + "," + Arrays.toString(png)); 195 198 Pattern p = Pattern.compile(pat); -
lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/SakuraGhost.java
r9332 r9338 78 78 NanikaArchive newNar = new NanikaArchive(name); 79 79 if (currentNar == null) currentNar = newNar; 80 else currentNar.setNext(newNar); 81 80 82 nar.put(name, newNar); 81 83 log.debug("nar=" + newNar); … … 122 124 final SakuraScript sakura = new SakuraScript(); 123 125 sakura.put("ghost", this); 126 sakura.put("system", this); 124 127 ScheduledExecutorService service = Executors.newScheduledThreadPool(1); 125 128 service.schedule(new Runnable() … … 136 139 137 140 /** 138 * オブザーバーに再描画を依頼します。139 */ 140 pr ivatevoid repaint()141 * 再描画を依頼します。 142 */ 143 protected void repaint() 141 144 { 142 145 if (observer != null) observer.repaint(); … … 191 194 private void loadBalloon() 192 195 { 193 currentNar.getBalloon();196 // currentNar.getBalloon(); 194 197 String name="name"; 195 198 String craftman = "craftman"; -
lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/SakuraShell.java
r9332 r9338 158 158 { 159 159 // balloon 160 balloon = new SakuraBalloon(name, nar); 160 // balloon = new SakuraBalloon(name, nar); 161 balloon = nar.getBalloon(name); 161 162 162 163 // balloon offset … … 169 170 balloon.setAlignment(align); 170 171 } 171 catch (IOException e)172 {173 log.error("read balloon error", e);174 }172 // catch (IOException e) 173 // { 174 // log.error("read balloon error", e); 175 // } 175 176 catch (Exception e) 176 177 { -
lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/nar/NanikaArchive.java
r9332 r9338 11 11 import java.io.File; 12 12 import java.io.FileFilter; 13 import java.io.FileNotFoundException; 13 14 import java.io.IOException; 14 15 import java.util.LinkedList; … … 22 23 import org.apache.commons.logging.LogFactory; 23 24 25 import com.mac.tarchan.nanika.SakuraBalloon; 24 26 import com.mac.tarchan.nanika.SakuraSurface; 25 27 … … 36 38 private static final Log log = LogFactory.getLog(NanikaArchive.class); 37 39 38 /** 親NAR ファイル */39 protected NanikaArchive parent;40 /** 次候補 NAR ファイル */ 41 protected NanikaArchive alt; 40 42 41 43 /** ZIP ファイル */ … … 43 45 44 46 /** プロパティー */ 45 protected Properties properties= new Properties(getDefaults());47 protected Properties descript = new Properties(getDefaults()); 46 48 47 49 /** … … 64 66 65 67 NanikaEntry install = getEntry(getProperty("nanika.install")); 66 if (install != null)67 { 68 Properties installDesc = install.readDescript();69 log.debug("install=" +installDesc);70 properties.putAll(installDesc);71 }68 if (install == null) throw new FileNotFoundException(getProperty("nanika.install")); 69 70 Properties installDesc = install.readDescript(); 71 descript.putAll(installDesc); 72 // descript.setProperty(installDesc.getProperty("type") + ".directory", installDesc.getProperty("directory")); 73 log.debug("install=" + descript); 72 74 73 75 NanikaEntry ghost = getEntry(new File(getGhostHome(), getProperty("ghost.descript"))); … … 78 80 79 81 /** 82 * 次のアーカイブを設定します。 83 * 84 * @param nar 次のアーカイブ 85 * @return このアーカイブへの参照 86 */ 87 public NanikaArchive setNext(NanikaArchive nar) 88 { 89 this.alt = nar; 90 return this; 91 } 92 93 /** 80 94 * デフォルトのプロパティーを返します。 81 95 * … … 97 111 98 112 // shell 99 defaults.setProperty("shell.root", "shell"); 100 defaults.setProperty("shell.home", "master"); 113 defaults.setProperty("shell.directory", new File("shell", "master").getPath()); 101 114 defaults.setProperty("shell.descript", "descript.txt"); 102 115 defaults.setProperty("shell.surfaces", "surfaces.txt"); … … 107 120 defaults.setProperty("balloon.arrow0", "arrow0.png"); 108 121 defaults.setProperty("balloon.arrow1", "arrow1.png"); 109 defaults.setProperty("balloon.onlinemarker", "online .png");122 defaults.setProperty("balloon.onlinemarker", "online0.png"); 110 123 defaults.setProperty("balloon.sstpmarker", "sstp.png"); 111 124 … … 124 137 public Properties getProperties() 125 138 { 126 return properties;139 return descript; 127 140 } 128 141 … … 135 148 public String getProperty(String key) 136 149 { 137 return properties.getProperty(key);150 return descript.getProperty(key); 138 151 } 139 152 … … 151 164 { 152 165 Properties props = getProperties(); 153 File shellHome = new File(props.getProperty("ghost. root"), props.getProperty("ghost.directory"));166 File shellHome = new File(props.getProperty("ghost.directory")); 154 167 return shellHome; 155 168 } … … 163 176 { 164 177 Properties props = getProperties(); 165 File shellHome = new File(props.getProperty("shell. root"), props.getProperty("shell.home"));178 File shellHome = new File(props.getProperty("shell.directory")); 166 179 return shellHome; 167 180 } … … 186 199 public NanikaEntry getEntry(File file) 187 200 { 188 ZipEntry zipEntry = zip.getEntry(file.getPath()); 201 String path = file.getPath(); 202 if (path.startsWith("/")) path = path.substring(1); 203 ZipEntry zipEntry = zip.getEntry(path); 189 204 // log.debug("zipEntry=" + zipEntry); 190 205 return zipEntry != null ? new NanikaEntry(zip, zipEntry) : null; … … 199 214 public NanikaEntry[] list(String regex) 200 215 { 216 if (regex.startsWith("/")) regex = regex.substring(1); 201 217 log.debug("regex=" + regex); 202 218 java.util.Enumeration<? extends ZipEntry> in = zip.entries(); … … 258 274 /** 259 275 * バルーンを取得します。 260 */ 261 public void getBalloon() 276 * 277 * @param name sakura または kero 278 * @return バルーン 279 */ 280 public SakuraBalloon getBalloon(String name) 262 281 { 263 282 try 264 283 { 265 File home = new File(getProperty("balloon.directory")); 266 log.debug("balloon=" + home); 267 NanikaEntry descript = getEntry(new File(home, getProperty("balloon.descript"))); 268 if (descript == null) return; 269 descript.readDescript(); 270 NanikaEntry balloons0 = getEntry(new File(home, "balloons0.png")); 271 if (balloons0 == null) return; 272 balloons0.readImage(); 273 } 274 catch (IOException e) 275 { 284 return new SakuraBalloon(name, this); 285 } 286 catch (Exception e) 287 { 288 if (alt != null) 289 { 290 log.trace("alt=" + alt); 291 return alt.getBalloon(name); 292 } 293 276 294 log.error("read balloon error", e); 295 return null; 277 296 } 278 297 } … … 317 336 } 318 337 } 338 339 /** 340 * NAR ファイルの文字列表現を返します。 341 * 342 * @return NAR ファイルの文字列表現 343 */ 344 public String toString() 345 { 346 return new StringBuilder() 347 .append("type=" + getProperty("type")) 348 .append(", name=" + getProperty("name")) 349 .append(", directory=" + getProperty("directory")) 350 .toString(); 351 } 319 352 } -
lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/nar/NanikaEntry.java
r9091 r9338 102 102 out.println(line); 103 103 } 104 reader.close(); 104 105 105 106 return buf.toString();
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)