# autolatex - astah2png.transdef # Copyright (C) 2012-13 Stephane Galland # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; see the file COPYING. If not, write to # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. #-------------------------------------------- # See template.txt for details on the fields #-------------------------------------------- INPUT_EXTENSIONS = .asta .jude .juth OUTPUT_EXTENSIONS = .png TRANSLATOR_FUNCTION =<catfile("$ENV{ASTAH_HOME}", "$library" ) ) { $jarfile = $library; } } if ( ! $jarfile ) { printErr("Unable to find the java library of Astah. Please define the ASTAH_HOME environment variable."); } # Prepare the generation from Astah my $outputDir = File::Spec->rel2abs(dirname("$in")); my $shortBasename = basename("$in",@inexts); my $astahOutputDir = File::Spec->catfile("$outputDir","$shortBasename"); if ( -d "$astahOutputDir" ) { remove_tree("$astahOutputDir") or printErr("$astahOutputDir: $!"); } # Generation of the SVG from Astah runCommandOrFail( 'java', @JAVA_OPTS, '-cp', File::Spec->catfile("$ENV{ASTAH_HOME}","$jarfile"), 'com.change_vision.jude.cmdline.JudeCommandRunner', '-image', 'all', '-f', "$in", '-t', 'png', '-o', "$outputDir"); # Move the files my @generatedFiles = (); local *OUTDIR; opendir(*OUTDIR, "$astahOutputDir") or printErr("$astahOutputDir: $!"); while (my $fn = readdir(*OUTDIR)) { if ($fn ne File::Spec->updir() && $fn ne File::Spec->curdir() && $fn =~ /$outext$/s) { my $sourceFile = File::Spec->catfile("$astahOutputDir", "$fn"); push @generatedFiles, "$sourceFile"; } } closedir(*OUTDIR); # Move the generated files if (@generatedFiles>1) { my $template = File::Spec->catfile( dirname($out), basename($out,$outext)).'_'; foreach my $file (@generatedFiles) { my $bn = basename($file,$outext); $bn =~ s/\s+/_/sg; move("$file", "$template$bn$outext") or printErr("$file -> $template$bn$outext: $!"); } if (@generatedFiles) { touch("$out"); } } elsif (@generatedFiles) { my $file = shift @generatedFiles; move("$file", "$out"); } else { printErr("No file generated."); } if ( -d "$astahOutputDir" ) { remove_tree("$astahOutputDir") or printErr("$astahOutputDir: $!"); } 1; } EOL FILES_TO_CLEAN = $out_*.png $out