MakeTiles: when generating intermediate images, use a staging directory
git-svn-id: https://micropolis.googlecode.com/svn/trunk/micropolis-java@748 d9718cc8-9f43-0410-858b-315f434eb58c
This commit is contained in:
parent
e3dcff2804
commit
f5b0089abc
3 changed files with 15 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
build
|
||||
*.jar
|
||||
docs/api
|
||||
graphics/generated
|
||||
|
|
|
@ -91,6 +91,7 @@
|
|||
|
||||
<target name="clean">
|
||||
<delete dir="${builddir}" />
|
||||
<delete dir="graphics/generated" />
|
||||
<delete file="${distfile}" />
|
||||
<delete>
|
||||
<fileset dir="." includes="${ant.project.name}*.zip" />
|
||||
|
|
|
@ -158,14 +158,16 @@ public class MakeTiles
|
|||
throw new Error("INKSCAPE not installed (or not found)");
|
||||
}
|
||||
|
||||
static void renderSvg(File svgFile, File pngFile)
|
||||
static File stagingDir = new File("generated");
|
||||
static File renderSvg(String fileName, File svgFile)
|
||||
throws IOException
|
||||
{
|
||||
File pngFile = new File(stagingDir, fileName+"_"+TILE_SIZE+"x"+TILE_SIZE+".png");
|
||||
if (pngFile.exists() &&
|
||||
pngFile.lastModified() > svgFile.lastModified())
|
||||
{
|
||||
// looks like the PNG file is already up-to-date
|
||||
return;
|
||||
return pngFile;
|
||||
}
|
||||
|
||||
File inkscapeBin = findInkscape();
|
||||
|
@ -174,6 +176,9 @@ public class MakeTiles
|
|||
if (pngFile.exists()) {
|
||||
pngFile.delete();
|
||||
}
|
||||
else if (!stagingDir.exists()) {
|
||||
stagingDir.mkdir();
|
||||
}
|
||||
|
||||
String [] cmdline = {
|
||||
inkscapeBin.toString(),
|
||||
|
@ -198,26 +203,28 @@ public class MakeTiles
|
|||
if (!pngFile.exists()) {
|
||||
throw new RuntimeException("File not found: "+pngFile);
|
||||
}
|
||||
|
||||
return pngFile;
|
||||
}
|
||||
|
||||
static SourceImage loadImage(String fileName)
|
||||
throws IOException
|
||||
{
|
||||
File svgFile, pngFile;
|
||||
File svgFile, pngFile = null;
|
||||
|
||||
svgFile = new File(fileName+"_"+TILE_SIZE+"x"+TILE_SIZE+".svg");
|
||||
pngFile = new File(fileName+"_"+TILE_SIZE+"x"+TILE_SIZE+".png");
|
||||
|
||||
if (svgFile.exists()) {
|
||||
renderSvg(svgFile, pngFile);
|
||||
pngFile = renderSvg(fileName, svgFile);
|
||||
}
|
||||
else {
|
||||
svgFile = new File(fileName+".svg");
|
||||
if (svgFile.exists()) {
|
||||
renderSvg(svgFile, pngFile);
|
||||
pngFile = renderSvg(fileName, svgFile);
|
||||
}
|
||||
}
|
||||
|
||||
pngFile = new File(fileName+"_"+TILE_SIZE+"x"+TILE_SIZE+".png");
|
||||
if (pngFile.exists()) {
|
||||
ImageIcon ii = new ImageIcon(pngFile.toString());
|
||||
return new SourceImage(
|
||||
|
|
Reference in a new issue