Beispiel #1
0
 private OutputStream createOutputStream(CommandLineArguments cmd) throws FileNotFoundException {
   if (cmd.isAutogenOutputFile() && cmd.getInputFile() != null) {
     String inputFile = cmd.getInputFile();
     int index = inputFile.lastIndexOf('.');
     String filename = (index != -1 ? inputFile.substring(0, index) : inputFile);
     filename += "." + cmd.getOutputFormat();
     return new FileOutputStream(filename);
   } else {
     return cmd.getOutputFile() != null ? new FileOutputStream(cmd.getOutputFile()) : System.out;
   }
 }
Beispiel #2
0
  private void visualize(
      WordGraph wordGraph, LayoutResult layout, ColorScheme colorScheme, CommandLineArguments cmd)
      throws FileNotFoundException {
    List<UIWord> uiWords = UIWord.prepareUIWords(wordGraph.getWords(), layout, colorScheme);
    WordCloudRenderer renderer =
        new WordCloudRenderer(uiWords, cmd.getMaxWidth(), cmd.getMaxHeight());
    byte[] content = RenderUtils.createCloud(renderer, cmd.getOutputFormat());

    OutputStream out = createOutputStream(cmd);

    try {
      out.write(content);
      out.close();
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }