Mercurial > hg > Database > Alice
changeset 146:36dc63d1bdcf working
read image from jar
author | sugi |
---|---|
date | Tue, 25 Sep 2012 14:11:37 +0900 |
parents | 5f37b57ff32d |
children | ae6ed9c35288 |
files | .classpath build.xml src/alice/test/topology/aquarium/CheckLocalIndex.java src/alice/test/topology/aquarium/MakeFrame.java src/alice/test/topology/aquarium/MakeObject.java |
diffstat | 5 files changed, 16 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/.classpath Fri Sep 21 18:32:13 2012 +0900 +++ b/.classpath Tue Sep 25 14:11:37 2012 +0900 @@ -1,12 +1,13 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> - <classpathentry kind="lib" path="lib/javassist.jar"/> - <classpathentry kind="lib" path="lib/log4j-1.2.16.jar"/> - <classpathentry kind="lib" path="lib/slf4j-api-1.6.1.jar"/> - <classpathentry kind="lib" path="lib/slf4j-log4j12-1.6.1.jar"/> - <classpathentry kind="lib" path="lib/com.alexmerz.graphviz.jar"/> + <classpathentry exported="true" kind="lib" path="lib/javassist.jar"/> + <classpathentry exported="true" kind="lib" path="lib/log4j-1.2.16.jar"/> + <classpathentry exported="true" kind="lib" path="lib/slf4j-api-1.6.1.jar"/> + <classpathentry exported="true" kind="lib" path="lib/slf4j-log4j12-1.6.1.jar"/> + <classpathentry exported="true" kind="lib" path="lib/com.alexmerz.graphviz.jar"/> <classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> - <classpathentry exported="true" kind="lib" path="lib/msgpack-0.6.6-201206.jar"/> + <classpathentry kind="lib" path="lib/msgpack-0.6.6-SNAPSHOT-sources.jar"/> + <classpathentry kind="lib" path="lib/msgpack-0.6.6-SNAPSHOT.jar"/> <classpathentry kind="output" path="bin"/> </classpath>
--- a/build.xml Fri Sep 21 18:32:13 2012 +0900 +++ b/build.xml Tue Sep 25 14:11:37 2012 +0900 @@ -21,6 +21,8 @@ <jar jarfile="${jar}" basedir="${classes}"> <zipgroupfileset dir="lib" includes="*.jar" /> <fileset dir="src" includes="log4j.xml" /> + <fileset dir="image" includes="*.jpg" /> + <fileset dir="image" includes="TUNA" /> </jar> </target>
--- a/src/alice/test/topology/aquarium/CheckLocalIndex.java Fri Sep 21 18:32:13 2012 +0900 +++ b/src/alice/test/topology/aquarium/CheckLocalIndex.java Tue Sep 25 14:11:37 2012 +0900 @@ -25,7 +25,7 @@ } } - new CheckLocalIndex(this.key,this.data.index); + new CheckLocalIndex(this.key, this.data.index); }
--- a/src/alice/test/topology/aquarium/MakeFrame.java Fri Sep 21 18:32:13 2012 +0900 +++ b/src/alice/test/topology/aquarium/MakeFrame.java Tue Sep 25 14:11:37 2012 +0900 @@ -2,8 +2,8 @@ import java.awt.GraphicsConfiguration; import java.awt.image.BufferedImage; -import java.io.File; import java.io.IOException; +import java.net.URL; import javax.imageio.ImageIO; import javax.media.j3d.Background; @@ -54,7 +54,8 @@ BranchGroup scene = new BranchGroup(); BufferedImage img = null; try { - img = ImageIO.read(new File("../image/image1.jpg")); + URL url = getClass().getClassLoader().getResource("image1.jpg"); + img = ImageIO.read(url); } catch (IOException e) { e.printStackTrace(); }
--- a/src/alice/test/topology/aquarium/MakeObject.java Fri Sep 21 18:32:13 2012 +0900 +++ b/src/alice/test/topology/aquarium/MakeObject.java Tue Sep 25 14:11:37 2012 +0900 @@ -4,6 +4,7 @@ import java.awt.MediaTracker; import java.awt.Toolkit; import java.io.FileNotFoundException; +import java.net.URL; import javax.media.j3d.Appearance; import javax.media.j3d.BranchGroup; @@ -41,7 +42,8 @@ ObjectFile obj = new ObjectFile(ObjectFile.RESIZE); Scene img = null; try{ - img = obj.load("../image/TUNA"); + URL url=getClass().getClassLoader().getResource("TUNA"); + img = obj.load(url); } catch(FileNotFoundException e){ System.err.println(e); System.exit(1);