Example usage for com.google.gwt.graphics.client Color RED

List of usage examples for com.google.gwt.graphics.client Color RED

Introduction

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

Prototype

Color RED

To view the source code for com.google.gwt.graphics.client Color RED.

Click Source Link

Usage

From source file:com.google.speedtracer.client.view.MainGraph.java

License:Apache License

private void paintGraph(double coordDelta, double leftBound, double rightBound, double domainDelta,
        GraphUiProps graphUiProps, GraphModel model) {
    canvas.setStrokeStyle(graphUiProps.getStrokeColor());
    canvas.setFillStyle(graphUiProps.getGraphColor());

    double maxYValueInWindow = graphUiProps.getYAxisScaleCap();
    double yAdjustment = COORD_Y_HEIGHT / graphUiProps.getActiveMaxYAxisValue();

    canvas.setLineWidth(2);/* w w  w  .  j  a va2  s.c  o m*/

    // Redraw timeline
    canvas.beginPath();
    canvas.moveTo(0, COORD_Y_HEIGHT);

    for (int x = 0, p = getPlotPrecision(); x <= p; x++) {
        double xVal = x * coordDelta;
        double yVal = model.getRangeValue(leftBound + (domainDelta * x), domainDelta);

        // Log the max Y value drawn in this current window.
        // If we ever want a graph to plot negative Y values, we would need to
        // override this paint method anyways, but we should be aware that we
        // would want to log the Abs value here instead.
        maxYValueInWindow = (yVal > maxYValueInWindow) ? yVal : maxYValueInWindow;

        canvas.lineTo(xVal, COORD_Y_HEIGHT - (yVal * yAdjustment));
    }

    canvas.lineTo(COORD_X_WIDTH, COORD_Y_HEIGHT);
    canvas.closePath();

    canvas.fill();

    // Draw Start and End regions
    double now = getTimeLine().getModel().getMostRecentDomainValue();
    double timeToCoordConversion = getCoordsPerTime();

    if (now < rightBound) {
        double end = (now - leftBound) * timeToCoordConversion;
        canvas.setFillStyle(Color.LIGHT_GREY);
        canvas.fillRect(end, 0, COORD_X_WIDTH - end, COORD_Y_HEIGHT);
        if (now > leftBound) {
            canvas.setFillStyle(Color.GREEN);
            canvas.fillRect(end, 0, 2, COORD_Y_HEIGHT);
        }
    }

    if (leftBound < 0) {
        canvas.setFillStyle(Color.RED);

        canvas.fillRect((-leftBound * timeToCoordConversion) - 4, 0, 2, COORD_Y_HEIGHT);
    }

    // Remember the active max value for this graph
    graphUiProps.setActiveMaxYAxisValue(maxYValueInWindow);
}