Note that this class intentionally does not use PooledClass. DrawingUtils manages <canvas> pooling for more fine-grained control.
425324
function Canvas (width, height, scale) {
  // Re-purposing an existing canvas element.
  if (!this._canvas) {
    this._canvas = document.createElement('canvas');
  }

  this.width = width;
  this.height = height;
  this.scale = scale || window.devicePixelRatio;

  this._canvas.width = this.width * this.scale;
  this._canvas.height = this.height * this.scale;
  this._canvas.getContext('2d').scale(this.scale, this.scale);
}
19959
function Graphics()
{
    Container.call(this);

    /**
     * The alpha value used when filling the Graphics object.
     *
     * @member {number}
     * @default 1
     */
    this.fillAlpha = 1;

    /**
     * The width (thickness) of any lines drawn.
     *
     * @member {number}
     * @default 0
     */
    this.lineWidth = 0;

    /**
     * The color of any lines drawn.
     *
     * @member {string}
     * @default 0
     */
    this.lineColor = 0;

    /**
     * Graphics data
     *
     * @member {GraphicsData[]}
     * @private
     */
    this.graphicsData = [];

    /**
     * The tint applied to the graphic shape. This is a hex value. Apply a value of 0xFFFFFF to reset the tint.
     *
     * @member {number}
     * @default 0xFFFFFF
     */
    this.tint = 0xFFFFFF;

    /**
     * The previous tint applied to the graphic shape. Used to compare to the current tint and check if theres change.
     *
     * @member {number}
     * @private
     * @default 0xFFFFFF
     */
    this._prevTint = 0xFFFFFF;

    /**
     * The blend mode to be applied to the graphic shape. Apply a value of blendModes.NORMAL to reset the blend mode.
     *
     * @member {number}
     * @default CONST.BLEND_MODES.NORMAL;
     */
    this.blendMode = CONST.BLEND_MODES.NORMAL;

    /**
     * Current path
     *
     * @member {GraphicsData}
     * @private
     */
    this.currentPath = null;

    /**
     * Array containing some WebGL-related properties used by the WebGL renderer.
     *
     * @member {object<number, object>}
     * @private
     */
    // TODO - _webgl should use a prototype object, not a random undocumented object...
    this._webGL = {};

    /**
     * Whether this shape is being used as a mask.
     *
     * @member {boolean}
     */
    this.isMask = false;

    /**
     * The bounds' padding used for bounds calculation.
     *
     * @member {number}
     */
    this.boundsPadding = 0;

    /**
     * A cache of the local bounds to prevent recalculation.
     *
     * @member {Rectangle}
     * @private
     */
    this._localBounds = new math.Rectangle(0,0,1,1);

    /**
     * Used to detect if the graphics object has changed. If this is set to true then the graphics
     * object will be recalculated.
     *
     * @member {boolean}
     * @private
     */
    this.dirty = true;

    /**
     * Used to detect if the WebGL graphics object has changed. If this is set to true then the
     * graphics object will be recalculated.
     *
     * @member {boolean}
     * @private
     */
    this.glDirty = false;

    this.boundsDirty = true;

    /**
     * Used to detect if the cached sprite object needs to be updated.
     *
     * @member {boolean}
     * @private
     */
    this.cachedSpriteDirty = false;
}
875760
@Override
    protected void paintComponent(Graphics g) {
        final Graphics2D G2 = (Graphics2D) g.create();

        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
        G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        G2.translate(INNER_BOUNDS.x, INNER_BOUNDS.y);

        if (backgroundVisible) {
            // Draw SparkLineBackground
            G2.drawImage(sparkLineBackgroundImage, 0, 0, null);

            // Set the clip
            G2.setClip(CLIP_SHAPE);
        }

        // Draw info label text
        if (infoLabelsVisible && INNER_BOUNDS.height > 40) {
            G2.setColor(sparkLineColor.TEXT_COLOR);
            G2.setFont(INFO_LABEL_FONT.deriveFont(0.12f * INNER_BOUNDS.height));
            G2.drawString("hi: " + DF.format(hi), (int) (INNER_BOUNDS.width * 0.0277777778), 2 + G2.getFont().getSize());
            G2.drawString("lo: " + DF.format(lo), (int) (INNER_BOUNDS.width * 0.0277777778), (INNER_BOUNDS.height - 4));
        }

        // Draw the sparkline
        G2.drawImage(sparkLineImage, 0, 0, null);

        // Draw baseline
        if (baseLineVisible) {
            G2.setColor(Color.BLACK);
            G2.drawLine(INNER_BOUNDS.x, (int) baseLineY, INNER_BOUNDS.x + INNER_BOUNDS.width, (int) baseLineY);
        }

        // Draw normal area
        if (normalAreaVisible) {
            G2.setColor(normalAreaColor);
            G2.fill(NORMAL_AREA);
        }

        // Draw average
        if (averageVisible) {
            G2.setColor(averageColor);
            G2.draw(AVERAGE_LINE);
        }

        // Draw disabled image if needed
        if (!isEnabled()) {
            G2.setColor(DISABLED_COLOR);
            G2.fill(disabledShape);
        }

        G2.translate(-INNER_BOUNDS.x, -INNER_BOUNDS.y);

        G2.dispose();
    }
1174184
function() {
      WireIt.CanvasContainer.superclass.render.call(this);

		this.canvasEl = new WireIt.CanvasElement(this.bodyEl);
		this.canvasEl.SetCanvasRegion(0,0, this.width, this.height );
		this.canvasWidth = this.width;
		this.canvasHeight = this.height;
		this.drawCanvas();
   }
997912
@SuppressWarnings("unchecked")
  static <T> void processFullBaseBuffer(final ItemsSketch<T> sketch) {
    final int bbCount = sketch.getBaseBufferCount();
    final long n = sketch.getN();
    assert bbCount == (2 * sketch.getK()); // internal consistency check

    // make sure there will be enough levels for the propagation
    ItemsUpdateImpl.maybeGrowLevels(sketch, n); // important: n_ was incremented by update before we got here

    // this aliasing is a bit dangerous; notice that we did it after the possible resizing
    final Object[] baseBuffer = sketch.getCombinedBuffer();

    Arrays.sort((T[]) baseBuffer, 0, bbCount, sketch.getComparator());
    ItemsUpdateImpl.inPlacePropagateCarry(
        0,
        null, 0,  // this null is okay
        (T[]) baseBuffer, 0,
        true, sketch);
    sketch.baseBufferCount_ = 0;
    Arrays.fill(baseBuffer, 0, 2 * sketch.getK(), null); // to release the discarded objects
    assert (n / (2L * sketch.getK())) == sketch.getBitPattern();  // internal consistency check
  }
920717
@Override
    protected void onGraphDraw(Canvas _Canvas) {
        super.onGraphDraw(_Canvas);
        if(mUseOverlapFill) {
            mLinePaint.setStyle(Paint.Style.FILL);
        }
        else {
            mLinePaint.setStrokeWidth(mLineStroke);
            mLinePaint.setStyle(Paint.Style.STROKE);
        }

        _Canvas.concat(mDrawMatrix);
        if(mHasNegativeValues) {
            _Canvas.translate(0, -mNegativeOffset);
        }

        // drawing of lines
        for (ValueLineSeries series : mSeries) {
            mLinePaint.setColor(series.getColor());
            _Canvas.drawPath(series.getPath(), mLinePaint);
        }
    }
891019
private WsByteBufferPoolManager createBufferManager(Map<String, Object> config) {
        WsBBConfigException configError = null;
        Object oClass = config.get("class");
        if (null != oClass && oClass instanceof String) {
            // bundle is specifying a custom class
            String className = (String) oClass;
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Pool class: " + className);
            }
            config.remove("class");
            Class<?> clazz = null;
            try {
                // ClassLoader cl = Thread.currentThread().getContextClassLoader();
                ClassLoader cl = ByteBufferConfiguration.class.getClassLoader();
                if (null != cl) {
                    clazz = cl.loadClass(className);
                }
            } catch (Exception e) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                    Tr.debug(this, tc, "Class load failed using loader: " + e);
                }
                try {
                    clazz = Class.forName(className,
                                          true,
                                          Thread.currentThread().getContextClassLoader());
                } catch (Exception e2) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(this, tc, "Class load failed using Class.forName: " + e2);
                    }
                }
            }

            if (null != clazz) {
                try {
                    Constructor<?> c = clazz.getConstructor(new Class[] { Map.class });
                    return (WsByteBufferPoolManager) c.newInstance(new Object[] { config });
                } catch (Exception e) {
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(this, tc, "New instance of class " + clazz + " failed: " + e.getCause());
                    }
                    if (e.getCause() instanceof WsBBConfigException) {
                        configError = (WsBBConfigException) e.getCause();
                    }
                }
            }
        }

        // try the default class with the configuration (assuming that
        // config did not previously fail)
        if (null == configError) {
            try {
                return new WsByteBufferPoolManagerImpl(directByteBufferHelper, config);
            } catch (WsBBConfigException e) {
                if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                    Tr.event(this, tc, "Error in configuration: " + e);
                }
            }
        }
        // if we failed to create the manager by now, it was due to bad
        // configuration
        if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
            Tr.debug(this, tc, "Using default pool class with default config");
        }
        try {
            return new WsByteBufferPoolManagerImpl(directByteBufferHelper);
        } catch (WsBBConfigException e) {
            // shouldn't be possible with default config...
            FFDCFilter.processException(e, getClass().getName() + ".createBufferManager", "2");
            if (TraceComponent.isAnyTracingEnabled() && tc.isEventEnabled()) {
                Tr.event(this, tc, "Failure to create buffer manager: " + e);
            }
            return null;
        }
    }
546821
@Override
    public void paint(Graphics g, Shape allocation)
    {
        if (view != null)
        {
            view.paint(g, allocation);
        }
    }
166692
def makedraw(self):
        
        if self.draw == None:
            self.draw = imdw.Draw(self.pilimage)
1055909
@ Override
	public void paint(Graphics g) {
		super.paint(g);
		boolean change = indeterminate;
		Graphics2D g2 = (Graphics2D) g.create();
		updateComponentMiddelpoint(g2);

		for (int animationPointID = animationPointCount - 1; animationPointID >= 0; animationPointID--) {
			if (indeterminate) {
				indeterminateAnimation(g2, animationPointID);
			} else {
				progressAnimation(g2, animationPoint[animationPointID], animationPointID);
				if (!(animationPoint[animationPointID] == 0 || animationPoint[animationPointID] == 255)) {
					change = true;
				}
			}
            Thread.yield();
		}

		if (!change) {
			synchronized (animationTimer) {
				animationTimer.stop();
				animationTimer.notifyAll();
			}
		}
		//Rectangle rec = g2.getClipBounds();
		//((GroupLayout) this.getLayout()).
		//stateTextLabel.setPreferredSize(new Dimension((int) stateTextLabel.getWidth(), ));
		//debugPaint(g2);
		g2.dispose();
	}
702624
function (d, context) {
                    dimple._drawMarkers(d, chart, series, duration, className, graded, onEnter(d), onLeave(d), context);
                }
541512
function(cancel) {
        this.control.layer.events.unregister(
            "sketchcomplete", this, this.finalizeInteriorRing
        );
        this.control.layer.events.unregister(
            "sketchmodified", this, this.enforceTopology
        );
        this.layer.removeFeatures([this.polygon], {silent: true});
        this.control.layer.addFeatures([this.polygon], {silent: true});
        this.drawingHole = false;
        if (!cancel) {
            // Re-trigger "sketchcomplete" so other listeners can do their
            // business.  While this is somewhat sloppy (if a listener is 
            // registered with registerPriority - not common - between the start
            // and end of a single ring drawing - very uncommon - it will be 
            // called twice).
            // TODO: In 3.0, collapse sketch handlers into geometry specific
            // drawing controls.
            this.control.layer.events.triggerEvent(
                "sketchcomplete", {feature : this.polygon}
            );
        }
    }
369112
@Override
    protected void paintComponent(Graphics g) {
        final Graphics2D G2 = (Graphics2D) g.create();

        G2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
        G2.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY);
        G2.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_NORMALIZE);
        G2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);

        // Translate the coordinate system related to insets
        G2.translate(getInnerBounds().x, getInnerBounds().y);

        // Draw combined background image
        G2.drawImage(bImage, 0, 0, null);

        // Draw LCD display
        if (isLcdVisible() && bImage != null) {
            // Draw lcd text
            if (getLcdColor() == LcdColor.CUSTOM) {
                G2.setColor(getCustomLcdForeground());
            } else {
                G2.setColor(getLcdColor().TEXT_COLOR);
            }
            G2.setFont(getLcdUnitFont());
            final double UNIT_STRING_WIDTH;
            if (isLcdUnitStringVisible() && !getLcdUnitString().isEmpty()) {
                unitLayout = new TextLayout(getLcdUnitString(), G2.getFont(), RENDER_CONTEXT);
                UNIT_BOUNDARY.setFrame(unitLayout.getBounds());
                //G2.drawString(getLcdUnitString(), (int) ((LCD.getWidth() - UNIT_BOUNDARY.getWidth()) - LCD.getWidth() * 0.03 + (getGaugeBounds().width - LCD.getWidth()) / 2.0), (int) (LCD.getHeight() * 0.6 + (getGaugeBounds().height - LCD.getHeight()) / 2.0));
                G2.drawString(getLcdUnitString(), (int) ((LCD.getWidth() - UNIT_BOUNDARY.getWidth()) - LCD.getWidth() * 0.03 + (getGaugeBounds().width - LCD.getWidth()) / 2.0), (int) (LCD.getHeight() * lcdTextYPositionFactor + getGaugeBounds().height * 0.425));
                UNIT_STRING_WIDTH = UNIT_BOUNDARY.getWidth();
            } else {
                UNIT_STRING_WIDTH = 0;
            }

            // Draw value
            G2.setFont(getLcdValueFont());
            switch (getLcdNumberSystem()) {
                case HEX:
                    valueLayout = new TextLayout(Integer.toHexString((int) getLcdValue()).toUpperCase(), G2.getFont(), RENDER_CONTEXT);
                    VALUE_BOUNDARY.setFrame(valueLayout.getBounds());
                    G2.drawString(Integer.toHexString((int) getLcdValue()).toUpperCase(), (int) ((LCD.getWidth() - UNIT_STRING_WIDTH - VALUE_BOUNDARY.getWidth()) - LCD.getWidth() * 0.09 + ((getGaugeBounds().width - LCD.getWidth()) / 2.0)), (int) (LCD.getHeight() * lcdTextYPositionFactor + getGaugeBounds().height * 0.425));
                    break;

                case OCT:
                    valueLayout = new TextLayout(Integer.toOctalString((int) getLcdValue()), G2.getFont(), RENDER_CONTEXT);
                    VALUE_BOUNDARY.setFrame(valueLayout.getBounds());
                    G2.drawString(Integer.toOctalString((int) getLcdValue()), (int) ((LCD.getWidth() - UNIT_STRING_WIDTH - VALUE_BOUNDARY.getWidth()) - LCD.getWidth() * 0.09 + ((getGaugeBounds().width - LCD.getWidth()) / 2.0)), (int) (LCD.getHeight() * lcdTextYPositionFactor + getGaugeBounds().height * 0.425));
                    break;

                case DEC:

                default:
                    valueLayout = new TextLayout(formatLcdValue(getLcdValue()), G2.getFont(), RENDER_CONTEXT);
                    VALUE_BOUNDARY.setFrame(valueLayout.getBounds());
                    G2.drawString(formatLcdValue(getLcdValue()), (int) ((LCD.getWidth() - UNIT_STRING_WIDTH - VALUE_BOUNDARY.getWidth()) - LCD.getWidth() * 0.09 + ((getGaugeBounds().width - LCD.getWidth()) / 2.0)), (int) (LCD.getHeight() * lcdTextYPositionFactor + getGaugeBounds().height * 0.425));
                    break;
            }

            // Draw lcd info string
            if (!getLcdInfoString().isEmpty() && !displayMulti) {
                G2.setFont(getLcdInfoFont());
                infoLayout = new TextLayout(getLcdInfoString(), G2.getFont(), RENDER_CONTEXT);
                INFO_BOUNDARY.setFrame(infoLayout.getBounds());
                G2.drawString(getLcdInfoString(), LCD.getBounds().x + 5, LCD.getBounds().y + (float) INFO_BOUNDARY.getHeight() + 5f);
            }

            if (displayMulti) {
                // Draw oldValue
                G2.setFont(lcdFormerValueFont);
                oldValueLayout = new TextLayout(formatLcdValue(oldValue), G2.getFont(), RENDER_CONTEXT);
                OLD_VALUE_BOUNDARY.setFrame(oldValueLayout.getBounds());
                //G2.drawString(formatLcdValue(oldValue), (int) ((LCD.getWidth() - OLD_VALUE_BOUNDARY.getWidth()) / 2.0 + (getGaugeBounds().width - LCD.getWidth()) / 2.0), (int) (LCD.getHeight() * 0.9 + (getGaugeBounds().height - LCD.getHeight()) / 2.0));
                G2.drawString(formatLcdValue(oldValue), (int) ((LCD.getWidth() - OLD_VALUE_BOUNDARY.getWidth()) / 2.0 + (getGaugeBounds().width - LCD.getWidth()) / 2.0), (int) (LCD.getHeight() * 0.9 + getGaugeBounds().height * 0.425));
            }

            // Draw lcd threshold indicator
            if (getLcdNumberSystem() == NumberSystem.DEC && isLcdThresholdVisible() && getLcdValue() >= getLcdThreshold()) {
                G2.drawImage(lcdThresholdImage, (int) (LCD.getX() + LCD.getHeight() * 0.0568181818), (int) (LCD.getY() + LCD.getHeight() - lcdThresholdImage.getHeight() - LCD.getHeight() * 0.0568181818), null);
            }
        }

        // Draw user LED if enabled
        if (isUserLedVisible()) {
            G2.drawImage(getCurrentUserLedImage(), (int) (getGaugeBounds().width * getUserLedPosition().getX()), (int) (getGaugeBounds().height * getUserLedPosition().getY()), null);
        }

        // Draw combined foreground image
        G2.drawImage(fImage, 0, 0, null);

        if (!isEnabled()) {
            G2.drawImage(disabledImage, 0, 0, null);
        }

        // Translate the coordinate system back to original
        G2.translate(-getInnerBounds().x, -getInnerBounds().y);

        G2.dispose();
    }
789473
public void accept(PainterVisitor visitor, Object group, Bbox bounds, boolean recursive) {
		// First place the image at the correct location:
		image.setBounds(new Bbox(getUpperLeftCorner().getX(), getUpperLeftCorner().getY(), getWidth(), getHeight()));

		// Then draw:
		if (parent != null) {
			map.getVectorContext().drawImage(parent, getId(), image.getHref(), image.getBounds(),
					(PictureStyle) image.getStyle());
		} else {
			map.getVectorContext().drawImage(group, getId(), image.getHref(), image.getBounds(),
					(PictureStyle) image.getStyle());
		}
		map.getVectorContext().setCursor(parent, getId(), Cursor.POINTER.getValue());
	}
937796
public void accept(PainterVisitor visitor, Object group, Bbox bounds, boolean recursive) {
		map.getVectorContext().drawGroup(group, this);

		Coordinate c = getUpperLeftCorner();
		PictureStyle pictureStyle = new PictureStyle(1);
		pictureStyle.setClassName("gm-ZoomStepControl");
		map.getVectorContext().drawImage(this, "bg", Geomajas.getIsomorphicDir() + "geomajas/mapaddon/zoombg.png",
				new Bbox(c.getX(), c.getY(), 20, 60), pictureStyle);

		pictureStyle = new PictureStyle(1);
		pictureStyle.setClassName("gm-ZoomStepControl-zoomIn");
		map.getVectorContext().drawImage(this, "plus", Geomajas.getIsomorphicDir() + "geomajas/mapaddon/zoomPlus.png",
				new Bbox(c.getX(), c.getY(), 20, 20), pictureStyle);
		map.getVectorContext().setCursor(this, "plus", Cursor.POINTER.getValue());

		pictureStyle = new PictureStyle(1);
		pictureStyle.setClassName("gm-ZoomStepControl-zoomOut");
		map.getVectorContext().drawImage(this, "minus",
				Geomajas.getIsomorphicDir() + "geomajas/mapaddon/zoomMinus.png",
				new Bbox(c.getX(), c.getY() + 40, 20, 20), pictureStyle);
		map.getVectorContext().setCursor(this, "minus", Cursor.POINTER.getValue());

		pictureStyle = new PictureStyle(1);
		pictureStyle.setClassName("gm-ZoomStepControl-zoomMax");
		map.getVectorContext().drawImage(this, "max", Geomajas.getIsomorphicDir() + "geomajas/mapaddon/maxextent.png",
				new Bbox(c.getX(), c.getY() + 20, 20, 20), pictureStyle);
		map.getVectorContext().setCursor(this, "max", Cursor.POINTER.getValue());

		if (firstTime) {
			map.getVectorContext().setController(this, "plus", new ZoomController(map, 2), Event.MOUSEEVENTS);
			map.getVectorContext().setCursor(this, "plus", Cursor.POINTER.getValue());

			map.getVectorContext().setController(this, "minus", new ZoomController(map, 0.5), Event.MOUSEEVENTS);
			map.getVectorContext().setCursor(this, "minus", Cursor.POINTER.getValue());

			map.getVectorContext().setController(this, "max", new MaxExtentController(map), Event.MOUSEEVENTS);
			map.getVectorContext().setCursor(this, "max", Cursor.POINTER.getValue());
		}
		firstTime = false;
	}
374093
@Override
    public void draw(@NonNull Canvas canvas) {
        if (mCurrDrawable != null) {
            mCurrDrawable.draw(canvas);
        }
        if (mLastDrawable != null) {
            mLastDrawable.draw(canvas);
        }
    }
138373
def draw
      drawns = []
      @options[:include].each { |n| drawns << n } unless @options[:include].nil?
      count = @options[:include] ? @options[:pick] - @options[:include].count : @options[:pick]
      count.times { drawns << pick(drawns) }
      drawns
    end