Example #1
0
 public String generateImage(OutputStream os, int numImage, FileFormatOption fileFormatOption)
     throws IOException {
   if (blocks.size() == 0) {
     final GraphicStrings error = new GraphicStrings(Arrays.asList("No @startuml found"));
     error.writeImage(os, fileFormatOption);
     return null;
   }
   try {
     for (BlockUml b : blocks) {
       final PSystem system = b.getSystem();
       final int nbInSystem = system.getNbImages();
       if (numImage < nbInSystem) {
         final CMapData cmap = new CMapData();
         system.exportDiagram(os, cmap, numImage, fileFormatOption);
         if (cmap.containsData()) {
           return system.getDescription() + "\n" + cmap.asString("plantuml");
         }
         return system.getDescription();
       }
       numImage -= nbInSystem;
     }
   } catch (InterruptedException e) {
     return null;
   }
   Log.error("numImage is too big = " + numImage);
   return null;
 }
Example #2
0
  public void logData(File file, PSystem system) {
    final String warnOrError = system.getWarningOrError();
    if (warnOrError == null) {
      return;
    }
    synchronized (logDataInitized) {
      if (logData == null && logDataInitized.get() == false) {
        final String s = GraphvizUtils.getenvLogData();
        if (s != null) {
          setLogData(new File(s));
        }
        logDataInitized.set(true);
      }

      if (logData == null) {
        return;
      }
      // final PSystemError systemError = (PSystemError) system;
      PrintStream ps = null;
      try {
        ps = new PrintStream(new FileOutputStream(logData, true));
        ps.println("Start of " + file.getName());
        ps.println(warnOrError);
        ps.println("End of " + file.getName());
        ps.println();
      } catch (FileNotFoundException e) {
        Log.error("Cannot open " + logData);
        e.printStackTrace();
      } finally {
        if (ps != null) {
          ps.close();
        }
      }
    }
  }