Utility function to setup a canvas element for the visualization.

@param svgp Plot element
@param proj Projection to use
@param width Width
@param height Height
@return wrapper element with appropriate view box.
439809
public Element setupCanvas(SVGPlot svgp, ProjectionParallel proj, double width, double height) {
    Element layer = SVGUtil.svgElement(svgp.getDocument(), SVGConstants.SVG_G_TAG);
    final String transform = SVGUtil.makeMarginTransform(width, height, size[0], size[1], margins[0], margins[1], margins[2], margins[3]);
    SVGUtil.setAtt(layer, SVGConstants.SVG_TRANSFORM_ATTRIBUTE, transform);
    return layer;
  }
140481
public void setPixelSize(int width, int height) {
		layerHtmlContainer.setPixelSize(width, height);
		drawingArea.setWidth(width);
		drawingArea.setHeight(height);
		canvasPanel.setPixelSize(width, height);
		for (CanvasContainer container : worldCanvases) {
			container.setPixelSize(width, height);
		}
		super.setPixelSize(width, height);
	}
976128
private PVPanel createVisualization(final ProtovisWidget graphWidget) {

        final PVPanel vis = graphWidget.getPVPanel()
                .width(400)
                .height(30)
                .margin(20)
                .left(100)  // translate(_,y)
                .top(
                        new JsDoubleFunction() {
                            public double f(JsArgs args) {
                                PVMark _this = args.getThis();
                                return 10 + _this.index() * 60; // translate(x,_)
                            }
                        }
                );

        PVBulletLayout bullet = vis.add(PV.Layout.Bullet()).orient(LEFT)
                .ranges(new JsFunction<JsArrayNumber>() {
                    public JsArrayNumber f(JsArgs args) {
                        Bullet d = args.getObject();
                        return JsUtils.toJsArrayNumber(d.ranges);
                    }
                }).measures(new JsFunction<JsArrayNumber>() {
                    public JsArrayNumber f(JsArgs args) {
                        Bullet d = args.getObject();
                        return JsUtils.toJsArrayNumber(d.measures);
                    }
                }).markers(new JsFunction<JsArrayNumber>() {
                    public JsArrayNumber f(JsArgs args) {
                        Bullet d = args.getObject();
                        return JsUtils.toJsArrayNumber(d.markers);
                    }
                });


        // workaround for right hand side labels
        graphWidget.addAttachHandler(new AttachEvent.Handler() {
            @Override
            public void onAttachOrDetach(AttachEvent event) {
                if(event.isAttached()) {
                    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
                        @Override
                        public void execute() {
                            Element svg = graphWidget.getElement().getFirstChildElement();
                            if (svg != null) {
                                svg.setAttribute("overflow", "visible");
                            }
                        }
                    });
                }
            }
        });

        bullet.strokeStyle("#CFCFCF");
        bullet.lineWidth(0.9);

        bullet.range().add(PV.Bar).fillStyle("#ffffff");
        bullet.measure().add(PV.Bar).fillStyle("#666666");

        bullet.marker().add(PV.Dot).shape(PVShape.TRIANGLE).fillStyle("white");
        bullet.tick().add(PV.Rule)
                .strokeStyle("#CFCFCF")
                .anchor(BOTTOM)
                .add(PV.Label)
                .text(bullet.x().tickFormat());

        // title
        bullet.anchor(LEFT).add(PV.Label).font("12px sans-serif")
                .textAlign(RIGHT).textBaseline(BOTTOM)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        Bullet d = args.getObject(0);
                        return d.title;
                    }
                });

        // subtitle
        bullet.anchor(LEFT).add(PV.Label).textStyle("#616161").textAlign(RIGHT)
                .textBaseline(TOP).text(new JsStringFunction() {
            public String f(JsArgs args) {
                Bullet d = args.getObject(0);
                return d.subtitle;
            }
        });

        // scale
        bullet.anchor(RIGHT)
                .add(PV.Label)
                .textStyle("#616161")
                .textAlign(LEFT)
                .textBaseline(MIDDLE)
                .text(new JsStringFunction() {
                    public String f(JsArgs args) {
                        Bullet d = args.getObject(0);
                        double measures = d.measures[0];
                        return measures > 0.00 ? String.valueOf(Double.valueOf(d.ranges[0]).longValue()) : "";
                    }
                });


        return vis;
    }
1297426
function (x, y, width, height) {
    return new BVG('rect', x.constructor.name === 'Object' ? x : {
      x: x,
      y: y,
      width: width,
      height: height
    });
  }
760052
public static Widget newShim (int width, int height)
    {
        Image shim = new Image(_rsrc.blank());
        shim.setWidth(width + "px");
        shim.setHeight(height + "px");
        return shim;
    }
199314
public java.awt.Graphics2D createGraphicsShapes(float width, float height, boolean convertImagesToJPEG, float quality) {
        return new PdfGraphics2D(this, width, height, null, true, convertImagesToJPEG, quality);
    }
588869
public void setSize(int width, int height) {
    rootElement.getStyle().setWidth(width, Unit.PX);
    rootElement.getStyle().setHeight(height, Unit.PX);
  }
248385
function (el, width, height) {
        // FIXME Text element not consider textAlign and textVerticalAlign.

        // TODO, inner text, shadow
        var rect = el.getBoundingRect();

        // FIXME aspect ratio
        if (width == null) {
            width = rect.width;
        }
        if (height == null) {
            height = rect.height;
        }
        width *= this.dpr;
        height *= this.dpr;

        this._fitElement(el, width, height);

        // var aspect = el.scale[1] / el.scale[0];
        // Adjust aspect ratio to make the text more clearly
        // FIXME If height > width, width is useless ?
        // width = height * aspect;
        // el.position[0] *= aspect;
        // el.scale[0] = el.scale[1];

        var x = this._x;
        var y = this._y;

        var canvasWidth = this.width * this.dpr;
        var canvasHeight = this.height * this.dpr;
        var gap = this.gap;

        if (x + width + gap > canvasWidth) {
            // Change a new row
            x = this._x = 0;
            y += this._rowHeight + gap;
            this._y = y;
            // Reset row height
            this._rowHeight = 0;
        }

        this._x += width + gap;

        this._rowHeight = Math.max(this._rowHeight, height);

        if (y + height + gap > canvasHeight) {
            // There is no space anymore
            return null;
        }

        // Shift the el
        el.position[0] += this.offsetX * this.dpr + x;
        el.position[1] += this.offsetY * this.dpr + y;

        this._zr.add(el);

        var coordsOffset = [
            this.offsetX / this.width,
            this.offsetY / this.height
        ];
        var coords = [
            [x / canvasWidth + coordsOffset[0], y / canvasHeight + coordsOffset[1]],
            [(x + width) / canvasWidth + coordsOffset[0], (y + height) / canvasHeight + coordsOffset[1]]
        ];

        return coords;
    }
197177
protected Element setupCanvas() {
    final double margin = context.getStyleLibrary().getSize(StyleLibrary.MARGIN);
    this.layer = setupCanvas(svgp, this.proj, margin, getWidth(), getHeight());
    return layer;
  }
1137647
protected void resizeForLayer( int width , int height ) {
		deriv1X.reshape(width,height);
		deriv1Y.reshape(width,height);
		deriv2X.reshape(width,height);
		deriv2Y.reshape(width,height);
		deriv2XX.reshape(width,height);
		deriv2YY.reshape(width,height);
		deriv2XY.reshape(width,height);

		warpImage2.reshape(width,height);
		warpDeriv2X.reshape(width,height);
		warpDeriv2Y.reshape(width,height);
		warpDeriv2XX.reshape(width,height);
		warpDeriv2YY.reshape(width,height);
		warpDeriv2XY.reshape(width,height);

		derivFlowUX.reshape(width,height);
		derivFlowUY.reshape(width,height);
		derivFlowVX.reshape(width,height);
		derivFlowVY.reshape(width,height);

		psiData.reshape(width,height);
		psiGradient.reshape(width,height);
		psiSmooth.reshape(width,height);

		divU.reshape(width,height);
		divV.reshape(width,height);
		divD.reshape(width,height);

		du.reshape(width,height);
		dv.reshape(width,height);
	}
967923
function (x, y, width, height) {
            var glPoints = this._glPoints;
            glPoints[0].x = x + width;
            glPoints[0].y = y;
            glPoints[1].x = x;
            glPoints[1].y = y;
            glPoints[2].x = x + width;
            glPoints[2].y = y + height;
            glPoints[3].x = x;
            glPoints[3].y = y + height;
            this.compositor.drawTriangle(glPoints, 4, true);
        }
442642
function viewBox(details) {
    svg.viewBox = `${details.x || 0} ${details.y || 0} ${details.width} ${details.height}`;

    fn(null, svg);
  }
26362
function( width, height ){

            var layer;
            proto.resize.call( this, width, height );

            for ( var id in this._layers ){

                layer = this._layers[ id ];
                if ( layer.options.autoResize ){
                    layer.el.width = this.width;
                    layer.el.height = this.height;
                }
            }

            return this;
        }
453665
function (container, width, height, style) {
                var renderer = this,
                  boxWrapper,
                  box,
                  css;

                renderer.alignedObjects = [];

                boxWrapper = renderer.createElement(DIV)
                  .css(extend(this.getStyle(style), { position: RELATIVE}));
                box = boxWrapper.element;
                container.appendChild(boxWrapper.element);


                // generate the containing box
                renderer.isVML = true;
                renderer.box = box;
                renderer.boxWrapper = boxWrapper;
                renderer.cache = {};


                renderer.setSize(width, height, false);

                // The only way to make IE6 and IE7 print is to use a global namespace. However,
                // with IE8 the only way to make the dynamic shapes visible in screen and print mode
                // seems to be to add the xmlns attribute and the behaviour style inline.
                if (!doc.namespaces.hcv) {

                    doc.namespaces.add('hcv', 'urn:schemas-microsoft-com:vml');

                    // Setup default CSS (#2153, #2368, #2384)
                    css = 'hcv\\:fill, hcv\\:path, hcv\\:shape, hcv\\:stroke' +
                      '{ behavior:url(#default#VML); display: inline-block; } ';
                    try {
                        doc.createStyleSheet().cssText = css;
                    } catch (e) {
                        doc.styleSheets[0].cssText += css;
                    }

                }
            }
1228032
public static SVGGraphics2D createSvgGraphics(final Dimension size)
            throws ParserConfigurationException {
        DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
        DocumentBuilder db = dbf.newDocumentBuilder();
        Document document = db.getDOMImplementation().createDocument(null, "svg", null);

        SVGGeneratorContext ctx = SVGGeneratorContext.createDefault(document);
        ctx.setStyleHandler(new OpacityAdjustingStyleHandler());
        ctx.setComment("Generated by GeoTools2 with Batik SVG Generator");

        SVGGraphics2D g2d = new SVGGraphics2D(ctx, true);
        g2d.setSVGCanvasSize(size);

        return g2d;
    }
874568
func SVG(width, height int) (Renderer, error) {
	buffer := bytes.NewBuffer([]byte{})
	canvas := newCanvas(buffer)
	canvas.Start(width, height)
	return &vectorRenderer{
		b:   buffer,
		c:   canvas,
		s:   &Style{},
		p:   []string{},
		dpi: DefaultDPI,
	}, nil
}
520473
public static Element drawManhattan(SVGPlot svgp, Projection2D proj, NumberVector mid, double radius) {
    final double[] v_mid = mid.toArray(); // a copy
    final long[] dims = proj.getVisibleDimensions2D();

    SVGPath path = new SVGPath();
    for(int dim = BitsUtil.nextSetBit(dims, 0); dim >= 0; dim = BitsUtil.nextSetBit(dims, dim + 1)) {
      v_mid[dim] += radius;
      double[] p1 = proj.fastProjectDataToRenderSpace(v_mid);
      v_mid[dim] -= radius * 2;
      double[] p2 = proj.fastProjectDataToRenderSpace(v_mid);
      v_mid[dim] += radius;
      for(int dim2 = BitsUtil.nextSetBit(dims, 0); dim2 >= 0; dim2 = BitsUtil.nextSetBit(dims, dim2 + 1)) {
        if(dim < dim2) {
          v_mid[dim2] += radius;
          double[] p3 = proj.fastProjectDataToRenderSpace(v_mid);
          v_mid[dim2] -= radius * 2;
          double[] p4 = proj.fastProjectDataToRenderSpace(v_mid);
          v_mid[dim2] += radius;

          path.moveTo(p1[0], p1[1]).drawTo(p3[0], p3[1]) //
              .moveTo(p1[0], p1[1]).drawTo(p4[0], p4[1]) //
              .moveTo(p2[0], p2[1]).drawTo(p3[0], p3[1]) //
              .moveTo(p2[0], p2[1]).drawTo(p4[0], p4[1]) //
              .close();
        }
      }
    }
    return path.makeElement(svgp);
  }