Example usage for com.google.gwt.graphics.client Canvas fillRect

List of usage examples for com.google.gwt.graphics.client Canvas fillRect

Introduction

In this page you can find the example usage for com.google.gwt.graphics.client Canvas fillRect.

Prototype

public native void fillRect(double startX, double startY, double width, double height) ;

Source Link

Document

Fills a rectangle of the specified dimensions, at the specified start coords, according to the current fillstyle.

Usage

From source file:com.google.speedtracer.client.visualizations.view.EventTraceBreakdown.java

License:Apache License

private void renderNode(Canvas canvas, UiEvent parent, UiEvent node,
        JsIntegerDoubleMap accumulatedErrorByType) {
    double startX = (node.getTime() - rootEvent.getTime()) * masterDomainToCoords;
    double width = node.getDuration() * masterDomainToCoords;
    final int nodeType = node.getType();
    // Insignificance is tricky. If we have lots of insignificant things, they
    // can add up to a significant thing.
    if (node.getDuration() < insignificanceThreshold) {
        // When the sub-pixel strokes are composited, we get a misleading color
        // blend. We use a unique aliasing scheme here where we suppress short
        // duration events but keep up with the total time we've suppressed for
        // each suppressed type. If the total suppressed time for a type ends up
        // being significant, we will synthesize a single aggregate event to
        // correct our accounting.
        double correctedTime = node.getSelfTime();
        if (accumulatedErrorByType.hasKey(nodeType)) {
            correctedTime += accumulatedErrorByType.get(nodeType);
        }/* w  w  w . j  a  v  a  2s . co m*/

        if (correctedTime < insignificanceThreshold) {
            accumulatedErrorByType.put(nodeType, correctedTime);
            return;
        }

        // We want to draw a discrete bar.
        width = insignificanceThreshold * masterDomainToCoords;
        // Reset the type specific aggregation.
        accumulatedErrorByType.put(nodeType, 0);
    }

    canvas.setFillStyle(presenter.getColor(node));
    canvas.fillRect(startX, 0, width, COORD_HEIGHT);
}