Skip to content

Commit 3b47f6b

Browse files
committed
- Review comments resolved.
1 parent bb2f0a6 commit 3b47f6b

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/diagram/AspectModelDiagramGenerator.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.io.OutputStream;
2525
import java.io.UncheckedIOException;
2626
import java.nio.charset.StandardCharsets;
27+
import java.nio.file.Files;
2728
import java.util.Base64;
2829
import java.util.EnumMap;
2930
import java.util.List;
@@ -173,7 +174,7 @@ private void generatePng( final String dotInput, final OutputStream output ) thr
173174
// To make the font available during PNG generation, it needs to be registered
174175
// in Java Runtime's graphics environment
175176
try{
176-
File tmpFontFile = gnererateTmpFontFile();
177+
final File tmpFontFile = generateTmpFontFile();
177178
final Font f = Font.createFont( Font.TRUETYPE_FONT, tmpFontFile );
178179
final GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
179180
ge.registerFont( f );
@@ -185,14 +186,13 @@ private void generatePng( final String dotInput, final OutputStream output ) thr
185186
final Graphviz graphviz = Graphviz.fromGraph( g );
186187
graphviz.render( guru.nidi.graphviz.engine.Format.PNG ).toOutputStream( output );
187188
}
188-
private File gnererateTmpFontFile() throws IOException {
189-
File tempFontFile = new File(TMP_FONT_FILE);
190-
if (!tempFontFile.exists()){
191-
try (InputStream fontStream = getInputStream(FONT_FILE)){
192-
try (OutputStream output = new FileOutputStream(tempFontFile, false)){
193-
fontStream.transferTo(output);
189+
private File generateTmpFontFile() throws IOException {
190+
File tempFontFile = new File( System.getProperty( "java.io.tmpdir" ) + "/aspect-model-diagram.tmp" );
191+
if ( !tempFontFile.exists() ){
192+
try ( final InputStream fontStream = getInputStream( FONT_FILE );
193+
final OutputStream output = new FileOutputStream( tempFontFile, false ) ){
194+
fontStream.transferTo( output );
194195
}
195-
}
196196
}
197197
tempFontFile.deleteOnExit();
198198
return tempFontFile;

0 commit comments

Comments
 (0)