SVG asset renderer.

@constructor
@extends BaseRenderer
511083
function SVGRenderer(generator, config, logger, document) {
        BaseRenderer.call(this, generator, config, logger, document);
        
        if (config.hasOwnProperty("svgomg-enabled")) {
            this._useSVGOMG = !!config["svgomg-enabled"];
        }
    }
62590
function SVGLoader(loadItem, preferXHR) {
		this.AbstractLoader_constructor(loadItem, preferXHR, createjs.AbstractLoader.SVG);

		// public properties
		this.resultFormatter = this._formatResult;

		// protected properties
		this._tagSrcAttribute = "data";

		if (preferXHR) {
			this.setTag(document.createElement("svg"));
		} else {
			this.setTag(document.createElement("object"));
			this.getTag().type = "image/svg+xml";
		}
	}
1031337
function Renderer(options) {
  var defaults = {
    headers: {
      included: true,
      downcase: true,
      upcase: true
    },

    delimiter: 'tab',
    decimalSign: 'comma',
    outputDataType: 'json',
    columnDelimiter: "\t",
    rowDelimiter: '\n',

    inputHeader: {},
    outputHeader: {},
    dataSelect: {},

    outputText: '',

    newline: '\n',
    indent: '  ',

    commentLine: '//',
    commentLineEnd: '',
    tableName: 'converter',

    useUnderscores: true,
    includeWhiteSpace: true,
    useTabsForIndent: false
  };

  this.options = merge({}, defaults, options);
  if (this.options.includeWhiteSpace) {
    this.options.newline = '\n';
  } else {
    this.options.indent = '';
    this.options.newline = '';
  }
}
1042395
private void render(SVG.Text obj)
   {
      debug("Text render");

      updateStyleForElement(state, obj);

      if (!display())
         return;

      if (obj.transform != null)
         canvas.concat(obj.transform);

      // Get the first coordinate pair from the lists in the x and y properties.
      float  x = (obj.x == null || obj.x.size() == 0) ? 0f : obj.x.get(0).floatValueX(this);
      float  y = (obj.y == null || obj.y.size() == 0) ? 0f : obj.y.get(0).floatValueY(this);
      float  dx = (obj.dx == null || obj.dx.size() == 0) ? 0f : obj.dx.get(0).floatValueX(this);
      float  dy = (obj.dy == null || obj.dy.size() == 0) ? 0f : obj.dy.get(0).floatValueY(this);

      // Handle text alignment
      Style.TextAnchor  anchor = getAnchorPosition();
      if (anchor != Style.TextAnchor.Start) {
         float  textWidth = calculateTextWidth(obj);
         if (anchor == Style.TextAnchor.Middle) {
            x -= (textWidth / 2);
         } else {
            x -= textWidth;  // 'End' (right justify)
         }
      }

      if (obj.boundingBox == null) {
         TextBoundsCalculator  proc = new TextBoundsCalculator(x, y);
         enumerateTextSpans(obj, proc);
         obj.boundingBox = new Box(proc.bbox.left, proc.bbox.top, proc.bbox.width(), proc.bbox.height());
      }
      updateParentBoundingBox(obj);

      checkForGradientsAndPatterns(obj);
      checkForClipPath(obj);
      
      boolean  compositing = pushLayer();

      enumerateTextSpans(obj, new PlainTextDrawer(x + dx, y + dy));

      if (compositing)
         popLayer(obj);
   }
783018
private void render(SVG.Polygon obj)
   {
      debug("Polygon render");

      updateStyleForElement(state, obj);

      if (!display())
         return;
      if (!visible())
         return;
      if (!state.hasStroke && !state.hasFill)
         return;

      if (obj.transform != null)
         canvas.concat(obj.transform);

      int  numPoints = obj.points.length;
      if (numPoints < 2)
         return;

      Path  path = makePathAndBoundingBox(obj);
      updateParentBoundingBox(obj);

      checkForGradientsAndPatterns(obj);
      checkForClipPath(obj);
      
      boolean  compositing = pushLayer();

      if (state.hasFill)
         doFilledPath(obj, path);
      if (state.hasStroke)
         doStroke(path);

      renderMarkers(obj);

      if (compositing)
         popLayer(obj);
   }
374206
private void render(SVG.Symbol obj, Box viewPort)
   {
      debug("Symbol render");

      if (viewPort.width == 0f || viewPort.height == 0f)
         return;

      // "If attribute 'preserveAspectRatio' is not specified, then the effect is as if a value of xMidYMid meet were specified."
      PreserveAspectRatio  positioning = (obj.preserveAspectRatio != null) ? obj.preserveAspectRatio : PreserveAspectRatio.LETTERBOX;

      updateStyleForElement(state, obj);

      state.viewPort = viewPort;

      if (!state.style.overflow) {
         setClipRect(state.viewPort.minX, state.viewPort.minY, state.viewPort.width, state.viewPort.height);
      }

      if (obj.viewBox != null) {
         canvas.concat(calculateViewBoxTransform(state.viewPort, obj.viewBox, positioning));
         state.viewBox = obj.viewBox;
      } else {
         canvas.translate(state.viewPort.minX, state.viewPort.minY);
      }
      
      boolean  compositing = pushLayer();

      renderChildren(obj, true);

      if (compositing)
         popLayer(obj);

      updateParentBoundingBox(obj);
   }
830303
private IRenderer buildRenderer(
			File outputDirectory,
			ApplicationTemplate applicationTemplate,
			File applicationDirectory,
			Renderer renderer,
			Map<String,String> typeAnnotations ) {

		IRenderer result = null;
		switch( renderer ) {
		case HTML:
			result = new HtmlRenderer( outputDirectory, applicationTemplate, applicationDirectory, typeAnnotations );
			break;

		case MARKDOWN:
			result = new MarkdownRenderer( outputDirectory, applicationTemplate, applicationDirectory, typeAnnotations );
			break;

		case FOP:
			result = new FopRenderer( outputDirectory, applicationTemplate, applicationDirectory, typeAnnotations );
			break;

		case PDF:
			result = new PdfRenderer( outputDirectory, applicationTemplate, applicationDirectory, typeAnnotations );
			break;

		default:
			break;
		}

		return result;
	}
975192
function (params) {
		var pointerEventsSpec = params.pointerEventsSpec || "all", renderer = {};

		_jp.jsPlumbUIComponent.apply(this, params.originalArgs);
		this.canvas = null;
		this.path = null;
		this.svg = null;
		this.bgCanvas = null;

		var clazz = params.cssClass + " " + (params.originalArgs[0].cssClass || ""),
			svgParams = {
				"style": "",
				"width": 0,
				"height": 0,
				"pointer-events": pointerEventsSpec,
				"position": "absolute"
			};

		this.svg = _node("svg", svgParams);

		if (params.useDivWrapper) {
			this.canvas = jsPlumb.createElement("div", { position : "absolute" });
			_ju.sizeElement(this.canvas, 0, 0, 1, 1);
			this.canvas.className = clazz;
		}
		else {
			_attr(this.svg, { "class": clazz });
			this.canvas = this.svg;
		}

		params._jsPlumb.appendElement(this.canvas, params.originalArgs[0].parent);
		if (params.useDivWrapper) this.canvas.appendChild(this.svg);

		var displayElements = [ this.canvas ];
		this.getDisplayElements = function () {
			return displayElements;
		};

		this.appendDisplayElement = function (el) {
			displayElements.push(el);
		};

		this.paint = function (style, anchor, extents) {
			if (style != null) {

				var xy = [ this.x, this.y ], wh = [ this.w, this.h ], p;
				if (extents != null) {
					if (extents.xmin < 0) xy[0] += extents.xmin;
					if (extents.ymin < 0) xy[1] += extents.ymin;
					wh[0] = extents.xmax + ((extents.xmin < 0) ? -extents.xmin : 0);
					wh[1] = extents.ymax + ((extents.ymin < 0) ? -extents.ymin : 0);
				}

				if (params.useDivWrapper) {
					_ju.sizeElement(this.canvas, xy[0], xy[1], wh[0], wh[1]);
					xy[0] = 0;
					xy[1] = 0;
					p = _pos([ 0, 0 ]);
				}
				else
					p = _pos([ xy[0], xy[1] ]);

				renderer.paint.apply(this, arguments);

				_attr(this.svg, {
					"style": p,
					"width": wh[0] || 0,
					"height": wh[1] || 0
				});
			}
		};

		return {
			renderer: renderer
		};
	}
271576
private Renderer createRenderer(T content, ViewGroup parent) {
    int prototypeIndex = getPrototypeIndex(content);
    Renderer renderer = getPrototypeByIndex(prototypeIndex).copy();
    renderer.onCreate(content, layoutInflater, parent);
    return renderer;
  }
676011
def svg(file, svg_args, box, paint, trans)
      Squib.logger.debug {"Rendering: #{file}, id: #{id} @#{x},#{y} #{width}x#{height}, alpha: #{alpha}, blend: #{blend}, angle: #{angle}, mask: #{mask}"}
      Squib.logger.warn 'Both an SVG file and SVG data were specified' unless file.to_s.empty? || svg_args.data.to_s.empty?
      return if (file.nil? or file.eql? '') and svg_args.data.nil? # nothing specified TODO Move this out to arg validator
      svg_args.data = File.read(file) if svg_args.data.to_s.empty?
      begin
        svg = Rsvg::Handle.new_from_data(svg_args.data)
      rescue Rsvg::Error::Failed
        Squib.logger.error "Invalid SVG data. Is '#{file}' a valid svg file?"
        return
      end
      box.width    = svg.width  if box.width == :native
      box.height   = svg.height if box.height == :native
      box.width  = svg.width.to_f * box.height.to_f / svg.height.to_f if box.width == :scale
      box.height = svg.height.to_f * box.width.to_f / svg.width.to_f  if box.height == :scale
      scale_width  = box.width.to_f / svg.width.to_f
      scale_height = box.height.to_f / svg.height.to_f
      use_cairo do |cc|
        cc.translate(box.x, box.y)
        cc.flip(trans.flip_vertical, trans.flip_horizontal, box.width / 2, box.height / 2)
        cc.rotate(trans.angle)
        cc.scale(scale_width, scale_height)

        trans.crop_width  = box.width  if trans.crop_width  == :native
        trans.crop_height = box.height if trans.crop_height == :native
        cc.rounded_rectangle(0, 0, trans.crop_width / scale_width, trans.crop_height / scale_height, trans.crop_corner_x_radius, trans.crop_corner_y_radius)
        cc.clip
        cc.translate(-trans.crop_x, -trans.crop_y)

        cc.operator = paint.blend unless paint.blend == :none
        if paint.mask.to_s.empty?
          cc.render_rsvg_handle(svg, id: svg_args.id)
        else
          tmp = Cairo::ImageSurface.new(box.width / scale_width, box.height / scale_height)
          tmp_cc = Cairo::Context.new(tmp)
          tmp_cc.render_rsvg_handle(svg, id: svg_args.id)
          cc.set_source_squibcolor(paint.mask)
          cc.mask(tmp, 0, 0)
        end
      end
    end
10069
function rawRender (vdom, isSvg) {
  if (Array.isArray(vdom)) return renderArray(vdom, isSvg)
  if (vdom instanceof window.Element) return renderDirectDom(vdom, isSvg)
  if (typeof vdom !== 'object') return renderPrimitive(vdom, isSvg)

  // one-level deep flatten children array
  var props = extend(
    extend({}, vdom.props),
    { children: [].concat.apply([], vdom.children || []) }
  )

  if (vdom.isDom) return renderDom(vdom, props, isSvg)
  if (vdom.isStateless) return renderStateless(vdom, props, isSvg)
  if (vdom.isComponent) return renderClass(vdom, props, isSvg)
}
608425
function(renderer) {
        var root = this.root;
        if(renderer.root.parentNode == this.rendererRoot) {
            root = renderer.root;
        }
        root.parentNode.removeChild(root);
        renderer.rendererRoot.appendChild(root);
    }
287491
protected function render ()
  {
    $prop   = $this->props;
    $assets = $this->context->getAssetsService ();

    if (exists ($prop->var))
      $assets->addInlineScript (sprintf ('var %s=%s;', $prop->var, javascriptLiteral ($prop->export, false)));

    elseif (exists ($prop->src))
      $assets->addScript ($prop->src, $this->props->prepend);

    elseif ($this->hasChildren ())
      $assets->addInlineScript (self::getRenderingOfSet ($this->getChildren ()), $prop->name, $this->props->prepend);
  }
692136
function BaseRenderer(generator, config, logger, document) {
        this._generator = generator;
        this._document = document;
        this._logger = logger;

        if (config.hasOwnProperty("use-jpg-encoding")) {
            this._useJPGEncoding = config["use-jpg-encoding"];
        }

        if (config.hasOwnProperty("use-smart-scaling")) {
            this._useSmartScaling = !!config["use-smart-scaling"];
        }

        if (config.hasOwnProperty("include-ancestor-masks")) {
            this._includeAncestorMasks = !!config["include-ancestor-masks"];
        }

        if (config.hasOwnProperty("convert-color-space")) {
            this._convertColorSpace = !!config["convert-color-space"];
        }
        
        if (config.hasOwnProperty("icc-profile")) {
            this._useICCProfile = config["icc-profile"];
        }
        
        if (config.hasOwnProperty("embed-icc-profile")) {
            this._embedICCProfile = config["embed-icc-profile"];
        }

        if (config.hasOwnProperty("allow-dither")) {
            this._allowDither = !!config["allow-dither"];
        }

        if (config.hasOwnProperty("use-psd-smart-object-pixel-scaling")) {
            this._forceSmartPSDPixelScaling = !!config["use-psd-smart-object-pixel-scaling"];
        }

        if (config.hasOwnProperty("use-pngquant")) {
            this._usePngquant = !!config["use-pngquant"];
        }
        
        if (config.hasOwnProperty("use-flite")) {
            this._useFlite = !!config["use-flite"];
        }

        if (config.hasOwnProperty("webp-lossless")) {
            this._webpLossless = !!config["webp-lossless"];
        }

        if (config.hasOwnProperty("clip-all-images-to-document-bounds")) {
            this._clipAllImagesToDocumentBounds = !!config["clip-all-images-to-document-bounds"];
        }

        if (config.hasOwnProperty("clip-all-images-to-artboard-bounds")) {
            this._clipAllImagesToArtboardBounds = !!config["clip-all-images-to-artboard-bounds"];
        }

        if (config.hasOwnProperty("mask-adds-padding")) {
            this._masksAddPadding = !!config["mask-adds-padding"];
        }
        
        if (config.hasOwnProperty("expand-max-dimensions")) {
            this._expandMaxDimensions = !!config["expand-max-dimensions"];
        }
    }
136100
async function render(node) {
            let renderedValue;
            const isMath = node.type === 'math';

            try {
                renderedValue = katex.renderToString(node.math, {
                    displayMode: isMath
                });
            }
            catch (err) {
                const response = await fetch('//tex.s2cms.ru/svg/' + encodeURIComponent(node.math) );
                renderedValue = await response.text();
            }

            const childAst = parseMathHtml(renderedValue).children[0];
            node.data = node.data || {};
            node.data.hChildren = [childAst];
        }
257983
function (renderer) {
        var _gl = renderer.gl;
        for (var attachment in this._textures) {
            var obj = this._textures[attachment];
            if (obj) {
                var texture = obj.texture;
                // FIXME some texture format can't generate mipmap
                if (!texture.NPOT && texture.useMipmap
                    && texture.minFilter === Texture.LINEAR_MIPMAP_LINEAR) {
                    var target = texture.textureType === 'textureCube' ? glenum.TEXTURE_CUBE_MAP : glenum.TEXTURE_2D;
                    _gl.bindTexture(target, texture.getWebGLTexture(renderer));
                    _gl.generateMipmap(target);
                    _gl.bindTexture(target, null);
                }
            }
        }
    }
488417
function render(renderSettings) {
	    var image = null;
	    var mode = renderSettings.mode;
	    var el = renderSettings.el;
	    var holderSettings = renderSettings.holderSettings;
	    var engineSettings = renderSettings.engineSettings;

	    switch (engineSettings.renderer) {
	        case 'svg':
	            if (!App.setup.supportsSVG) return;
	            break;
	        case 'canvas':
	            if (!App.setup.supportsCanvas) return;
	            break;
	        default:
	            return;
	    }

	    //todo: move generation of scene up to flag generation to reduce extra object creation
	    var scene = {
	        width: holderSettings.dimensions.width,
	        height: holderSettings.dimensions.height,
	        theme: holderSettings.theme,
	        flags: holderSettings.flags
	    };

	    var sceneGraph = buildSceneGraph(scene);

	    function getRenderedImage() {
	        var image = null;
	        switch (engineSettings.renderer) {
	            case 'canvas':
	                image = sgCanvasRenderer(sceneGraph, renderSettings);
	                break;
	            case 'svg':
	                image = svgRenderer(sceneGraph, renderSettings);
	                break;
	            default:
	                throw 'Holder: invalid renderer: ' + engineSettings.renderer;
	        }

	        return image;
	    }

	    image = getRenderedImage();

	    if (image == null) {
	        throw 'Holder: couldn\'t render placeholder';
	    }

	    //todo: add <object> canvas rendering
	    if (mode == 'background') {
	        el.style.backgroundImage = 'url(' + image + ')';

	        if (!engineSettings.noBackgroundSize) {
	            el.style.backgroundSize = scene.width + 'px ' + scene.height + 'px';
	        }
	    } else {
	        if (el.nodeName.toLowerCase() === 'img') {
	            DOM.setAttr(el, {
	                'src': image
	            });
	        } else if (el.nodeName.toLowerCase() === 'object') {
	            DOM.setAttr(el, {
	                'data': image,
	                'type': 'image/svg+xml'
	            });
	        }
	        if (engineSettings.reRender) {
	            global.setTimeout(function () {
	                var image = getRenderedImage();
	                if (image == null) {
	                    throw 'Holder: couldn\'t render placeholder';
	                }
	                //todo: refactor this code into a function
	                if (el.nodeName.toLowerCase() === 'img') {
	                    DOM.setAttr(el, {
	                        'src': image
	                    });
	                } else if (el.nodeName.toLowerCase() === 'object') {
	                    DOM.setAttr(el, {
	                        'data': image,
	                        'type': 'image/svg+xml'
	                    });
	                }
	            }, 150);
	        }
	    }
	    //todo: account for re-rendering
	    DOM.setAttr(el, {
	        'data-holder-rendered': true
	    });
	}