2019년 2월 1일 금요일

[Markdown] How to embed PlantUML


1. Process File


1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
public static int processFile(File inFile, File outDir, String outFilePrefix, FileFormat outFormat) 
        throws IOException, InterruptedException {

    final Option option = new Option(); 
    if (inFile.exists() == false) {
            throw new IllegalArgumentException();
    }
    FileSystem.getInstance().setCurrentDir(inFile.getAbsoluteFile().getParentFile());
    BlockUmlBuilder builder = new BlockUmlBuilder(
            new ArrayList<String>(), //option.getConfig(),  
            "UTF-8", //option.getCharset(), 
            createEmpty(), //option.getDefaultDefines(file), 
            new InputStreamReader(new FileInputStream(inFile), "UTF-8"),
            inFile.getAbsoluteFile().getParentFile(), 
            inFile.getName());      

    //final List<GeneratedImage> result = new ArrayList<>();
    int count = 0;
    for (BlockUml blockUml : builder.getBlockUmls()) {    
        final Diagram system;
        try {
            system = blockUml.getDiagram();
            final List<FileImageData> exportDiagrams = PSystemUtils.exportDiagrams(system, 
                SuggestedFile.fromOutputFile(new File(outDir, outFilePrefix  + count) , outFormat, 0),
                new FileFormatOption(outFormat),
                false);
            if (exportDiagrams.size() > 1) {
                    exportDiagrams.size();
            }    
            count++;
        } catch (Throwable t) {
            return 0;
        }
    }     
    return count;
}



댓글 없음:

댓글 쓰기