Example usage for com.google.gwt.canvas.dom.client CssColor make

List of usage examples for com.google.gwt.canvas.dom.client CssColor make

Introduction

In this page you can find the example usage for com.google.gwt.canvas.dom.client CssColor make.

Prototype

public static final CssColor make(int r, int g, int b) 

Source Link

Document

Sets the RGB color value.

Usage

From source file:com.google.gwt.sample.guestbook.client.CanvasCustom.java

protected void randomIncrementColour() {
    colour = CssColor.make(red = randomIncrementColourComponent(red),
            green = randomIncrementColourComponent(green), blue = randomIncrementColourComponent(blue));
}

From source file:com.google.gwt.sample.mobilewebapp.presenter.taskchart.TaskChartPresenter.java

License:Apache License

/**
 * Update the pie chart with the list of tasks.
 * /*from   w w  w.  jav  a  2  s .  c om*/
 * @param tasks the list of tasks
 */
@SuppressWarnings("deprecation")
private void updatePieChart(List<TaskProxy> tasks) {
    if (pieChart == null) {
        return;
    }

    // Calculate the slices based on the due date.
    double pastDue = 0;
    double dueSoon = 0;
    double onTime = 0;
    double noDate = 0;
    final Date now = new Date();
    final Date tomorrow = new Date(now.getYear(), now.getMonth(), now.getDate() + 1, 23, 59, 59);
    for (TaskProxy task : tasks) {
        Date dueDate = task.getDueDate();
        if (dueDate == null) {
            noDate++;
        } else if (dueDate.before(now)) {
            pastDue++;
        } else if (dueDate.before(tomorrow)) {
            dueSoon++;
        } else {
            onTime++;
        }
    }

    // Update the pie chart.
    pieChart.clearSlices();
    if (pastDue > 0) {
        pieChart.addSlice(pastDue, CssColor.make(255, 100, 100));
    }
    if (dueSoon > 0) {
        pieChart.addSlice(dueSoon, CssColor.make(255, 200, 100));
    }
    if (onTime > 0) {
        pieChart.addSlice(onTime, CssColor.make(100, 255, 100));
    }
    if (noDate > 0) {
        pieChart.addSlice(noDate, CssColor.make(200, 200, 200));
    }
    pieChart.redraw();
}

From source file:com.himamis.retex.renderer.web.graphics.ColorW.java

License:Open Source License

public ColorW(int r, int g, int b) {
    cssColor = CssColor.make(r, g, b);
}

From source file:gwtquery.plugins.gwtcaptcha.client.Captcha.java

License:Apache License

private void computeBgFgColors() {
    int r = rnd(255);
    int g = rnd(255);
    int b = rnd(255);
    bg = CssColor.make(r, g, b);
    double i = (r << 16 | g << 8 | b);
    fg = CssColor.make((0xffffff / 2) < i ? "#111111" : "#ffffff");
}

From source file:gwtquery.plugins.gwtcaptcha.client.Captcha.java

License:Apache License

private CssColor getRandomColor() {
    return CssColor.make(rnd(255), rnd(255), rnd(255));
}

From source file:org.primaresearch.web.gwt.client.ui.page.renderer.ContentSelectionRendererPlugin.java

License:Apache License

private void drawSelection() {
    if (renderer.getSelectionManager() == null || renderer.getSelectionManager().isEmpty())
        return;//  w  ww .  j a  v a 2s .c  o  m

    Set<ContentObjectC> selection = renderer.getSelectionManager().getSelection();
    ContentObjectC obj;
    context.setStrokeStyle(CssColor.make(0, 162, 232));
    context.setLineWidth(2.0 / renderer.getZoomFactor());
    for (Iterator<ContentObjectC> it = selection.iterator(); it.hasNext();) {
        obj = it.next();
        //drawPolygon(obj.getCoords());
        drawRectangle(obj.getCoords().getBoundingBox());
    }
}

From source file:org.primaresearch.web.gwt.client.ui.page.renderer.PageRenderer.java

License:Apache License

/**
 * Draws grey background//from   w  w w. j  ava  2  s .  c  o m
 */
private void drawBackground() {
    CssColor liteGrey = CssColor.make(200, 200, 200);
    CssColor darkGrey = CssColor.make(100, 100, 100);

    boolean dark;
    boolean startLineDark = false;
    final int rectSize = 200;
    for (int x = 0; x < canvas.getCoordinateSpaceWidth(); x += rectSize) {
        dark = startLineDark;
        for (int y = 0; y < canvas.getCoordinateSpaceWidth(); y += rectSize) {
            context.setFillStyle(dark ? darkGrey : liteGrey);
            context.fillRect(x, y, x + rectSize, y + rectSize);
            context.fill();
            dark = !dark;
        }
        startLineDark = !startLineDark;
    }
}

From source file:org.primaresearch.web.gwt.client.ui.page.tool.drawing.RectangleTool.java

License:Apache License

@Override
public void render(PageRenderer renderer) {
    if (p1 == null || !isEnabled())
        return;//from  w  ww. j a  v  a2s .c om
    Context2d context = renderer.getContext();

    //Blue rectangle
    context.setStrokeStyle(CssColor.make(0, 128, 255));
    context.setLineWidth(1.0 / renderer.getZoomFactor());

    int x1 = Math.min(p1.x, p2.x);
    int x2 = Math.max(p1.x, p2.x);
    int y1 = Math.min(p1.y, p2.y);
    int y2 = Math.max(p1.y, p2.y);

    context.beginPath();
    context.rect(x1, y1, x2 - x1 + 1, y2 - y1 + 1);
    context.stroke();
}

From source file:org.rstudio.studio.client.workbench.views.vcs.dialog.graph.GraphTheme.java

License:Open Source License

public CssColor getColorForId(int id) {
    if (!colors_.containsKey(id)) {
        colors_.put(id, CssColor.make(randomColorValue(), randomColorValue(), randomColorValue()).value());
    }/*from ww  w. ja  va  2  s . co  m*/
    return CssColor.make(colors_.get(id));
}

From source file:org.thole.hendrik.mandelbrot.gwt.client.impl.MandelBrotImpl.java

License:Open Source License

/**
 * get the color./*  www.  jav a 2  s  .c  o m*/
 * @param it
 * @return Color
 */
private final CssColor it2C(final int it) {
    if (it < itmax13) {
        return CssColor.make(it * 255 / itmax13, 0, 0);
    }
    if (it < itmax23) {
        return CssColor.make(0, (it - itmax13) * 255 / itmax13, 0);
    }
    return CssColor.make(0, 0, (it - itmax23) * 255 / itmax13);
}