Example #1
0
 private UGraphic2 createUGraphic(
     FileFormatOption fileFormatOption,
     final Dimension2D dim,
     Animation affineTransforms,
     double dx,
     double dy) {
   final FileFormat fileFormat = fileFormatOption.getFileFormat();
   switch (fileFormat) {
     case PNG:
       return createUGraphicPNG(
           colorMapper, dpiFactor, dim, mybackcolor, affineTransforms, dx, dy);
     case SVG:
       return createUGraphicSVG(
           colorMapper, dpiFactor, dim, mybackcolor, fileFormatOption.getSvgLinkTarget());
     case EPS:
       return new UGraphicEps(colorMapper, EpsStrategy.getDefault2());
     case EPS_TEXT:
       return new UGraphicEps(colorMapper, EpsStrategy.WITH_MACRO_AND_TEXT);
     case HTML5:
       return new UGraphicHtml5(colorMapper);
     case VDX:
       return new UGraphicVdx(colorMapper);
     case LATEX:
       return new UGraphicTikz(colorMapper);
     default:
       throw new UnsupportedOperationException(fileFormat.toString());
   }
 }
Example #2
0
 public ImageData writeImageTOBEMOVED(FileFormatOption fileFormatOption, OutputStream os)
     throws IOException {
   final FileFormat fileFormat = fileFormatOption.getFileFormat();
   if (fileFormat == FileFormat.MJPEG) {
     return writeImageMjpeg(os);
   } else if (fileFormat == FileFormat.ANIMATED_GIF) {
     return writeImageAnimatedGif(os);
   }
   return writeImageTOBEMOVED(fileFormatOption, os, affineTransformations);
 }
Example #3
0
 public ImageData exportDiagram(OutputStream os, int num, FileFormatOption fileFormat)
     throws IOException {
   if (fileFormat.getFileFormat() == FileFormat.ATXT) {
     os.write(getSource().getPlainString().getBytes());
     return new ImageDataSimple();
   }
   // ditaa can only export png so file format is mostly ignored
   final ConversionOptions options = new ConversionOptions();
   options.setDropShadows(dropShadows);
   final TextGrid grid = new TextGrid();
   grid.initialiseWithText(data, null);
   final Diagram diagram = new Diagram(grid, options, processingOptions);
   final BufferedImage image =
       (BufferedImage) new BitmapRenderer().renderToImage(diagram, options.renderingOptions);
   ImageIO.write(image, "png", os);
   return new ImageDataSimple(image.getWidth(), image.getHeight());
 }
  private ImageData createFileInternal(
      OutputStream os, List<String> dotStrings, FileFormatOption fileFormatOption)
      throws IOException, InterruptedException {
    if (diagram.getUmlDiagramType() == UmlDiagramType.ACTIVITY) {
      new CucaDiagramSimplifierActivity(diagram, dotStrings);
    } else if (diagram.getUmlDiagramType() == UmlDiagramType.STATE) {
      new CucaDiagramSimplifierState(diagram, dotStrings);
    }

    CucaDiagramFileMakerSvek2 svek2 = buildCucaDiagramFileMakerSvek2(DotMode.NORMAL);
    TextBlockBackcolored result = svek2.createFile(diagram.getDotStringSkek());
    if (result instanceof GraphvizCrash) {
      svek2 = buildCucaDiagramFileMakerSvek2(DotMode.NO_LEFT_RIGHT);
      result = svek2.createFile(diagram.getDotStringSkek());
    }
    result = addLegend(result);
    result = addTitle(result);
    result = addHeaderAndFooter(result);

    final String widthwarning = diagram.getSkinParam().getValue("widthwarning");
    if (widthwarning != null && widthwarning.matches("\\d+")) {
      this.warningOrError =
          svek2.getBibliotekon().getWarningOrError(Integer.parseInt(widthwarning));
    } else {
      this.warningOrError = null;
    }
    final Dimension2D dim = result.calculateDimension(stringBounder);
    final double scale = getScale(fileFormatOption, dim);

    final ImageBuilder imageBuilder =
        new ImageBuilder(
            diagram.getSkinParam().getColorMapper(),
            scale,
            result.getBackcolor(),
            fileFormatOption.isWithMetadata() ? diagram.getMetadata() : null,
            warningOrError,
            0,
            10,
            diagram.getAnimation(),
            diagram.getSkinParam().handwritten());
    imageBuilder.addUDrawable(result);
    return imageBuilder.writeImageTOBEMOVED(fileFormatOption, os);
  }