Esempio n. 1
0
  private UGraphic2 createUGraphicPNG(
      ColorMapper colorMapper,
      double dpiFactor,
      final Dimension2D dim,
      HtmlColor mybackcolor,
      Animation affineTransforms,
      double dx,
      double dy) {
    Color backColor = Color.WHITE;
    if (mybackcolor instanceof HtmlColorSimple) {
      backColor = colorMapper.getMappedColor(mybackcolor);
    } else if (mybackcolor instanceof HtmlColorTransparent) {
      backColor = null;
    }

    /*
     * if (rotation) { builder = new EmptyImageBuilder((int) (dim.getHeight() * dpiFactor), (int) (dim.getWidth() *
     * dpiFactor), backColor); graphics2D = builder.getGraphics2D(); graphics2D.rotate(-Math.PI / 2);
     * graphics2D.translate(-builder.getBufferedImage().getHeight(), 0); } else {
     */
    final EmptyImageBuilder builder =
        new EmptyImageBuilder(
            (int) (dim.getWidth() * dpiFactor), (int) (dim.getHeight() * dpiFactor), backColor);
    final Graphics2D graphics2D = builder.getGraphics2D();

    // }
    final UGraphicG2d ug =
        new UGraphicG2d(
            colorMapper,
            graphics2D,
            dpiFactor,
            affineTransforms == null ? null : affineTransforms.getFirst(),
            dx,
            dy);
    ug.setBufferedImage(builder.getBufferedImage());
    final BufferedImage im = ((UGraphicG2d) ug).getBufferedImage();
    if (mybackcolor instanceof HtmlColorGradient) {
      ug.apply(new UChangeBackColor(mybackcolor))
          .draw(new URectangle(im.getWidth(), im.getHeight()));
    }

    return ug;
  }
 static {
   final EmptyImageBuilder builder = new EmptyImageBuilder(10, 10, Color.WHITE);
   stringBounder = StringBounderUtils.asStringBounder(builder.getGraphics2D());
 }