Example usage for com.google.gwt.canvas.client Canvas isSupported

List of usage examples for com.google.gwt.canvas.client Canvas isSupported

Introduction

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

Prototype

public static boolean isSupported() 

Source Link

Document

Runtime check for whether the canvas element is supported in this browser.

Usage

From source file:co.fxl.gui.canvas.gwt.GWTCanvasWidgetProvider.java

License:Open Source License

public static void setUp() {
    if (Canvas.isSupported())
        Display.instance().register(new GWTCanvasWidgetProvider());
    else/*from   www.  j a v  a2  s  . c o m*/
        Log.instance().warn("Browser doesn't support canvas element");
}

From source file:com.google.gwt.sample.mobilewebapp.client.desktop.PieChart.java

License:Apache License

/**
 * Runtime check for whether the canvas element is supported in this browser.
 * /*  ww  w  .  j a va  2  s  . c  o m*/
 * @return whether the canvas element is supported
 */
public static boolean isSupported() {
    return Canvas.isSupported();
}

From source file:edu.caltech.ipac.firefly.visualize.draw.CanvasPanel.java

public static boolean isSupported() {
    return Canvas.isSupported();
}

From source file:edu.caltech.ipac.firefly.visualize.graph.ChartingFactory.java

public GChartCanvasLite create() {
    //        GwtUtil.showDebugMsg("create");
    GChartCanvasLite canvas;/*from www  .  j a  va  2 s  .c o  m*/
    if (Canvas.isSupported()) {
        canvas = new GChartGraphicsCanvasImpl();
    } else {
        canvas = new GChartLightCanvasImpl();
    }
    return canvas;
}

From source file:org.rstudio.core.client.widget.FontDetector.java

License:Open Source License

public static boolean isFontSupported(String fontName) {
    SimplePanel panel = null;/*from w w  w.jav  a2 s. c  om*/
    try {
        // default font name as a reference point
        final String defaultFontName = "Arial";
        if (defaultFontName.equals(fontName))
            return true;

        // make sure canvas is supported
        if (!Canvas.isSupported())
            return false;

        // add a temporary div to the dom
        panel = new SimplePanel();
        panel.setHeight("200px");
        panel.getElement().getStyle().setVisibility(Visibility.HIDDEN);
        panel.getElement().getStyle().setOverflow(Overflow.SCROLL);
        RootPanel.get().add(panel, -2000, -2000);

        // add a canvas element to the div and get the 2d drawing context
        final Canvas canvas = Canvas.createIfSupported();
        canvas.setWidth("512px");
        canvas.setHeight("64px");
        canvas.getElement().getStyle().setLeft(400, Unit.PX);
        canvas.getElement().getStyle().setBackgroundColor("#ffe");
        panel.add(canvas);
        final Context2d ctx = canvas.getContext2d();
        ctx.setFillStyle("#000000");

        // closure to generate a hash for a font
        class HashGenerator {
            public String getHash(String fontName) {
                ctx.setFont("57px " + fontName + ", " + defaultFontName);
                int width = canvas.getOffsetWidth();
                int height = canvas.getOffsetHeight();
                ctx.clearRect(0, 0, width, height);
                ctx.fillText("TheQuickBrownFox", 2, 50);
                return canvas.toDataUrl();
            }
        }
        ;

        // get hashes and compare them
        HashGenerator hashGenerator = new HashGenerator();
        String defaultHash = hashGenerator.getHash(defaultFontName);
        String fontHash = hashGenerator.getHash(fontName);
        return !defaultHash.equals(fontHash);
    } catch (Exception ex) {
        Debug.log(ex.toString());
        return false;
    } finally {
        if (panel != null)
            RootPanel.get().remove(panel);
    }
}

From source file:stroom.widget.htree.client.LayeredCanvas.java

License:Apache License

public static LayeredCanvas createIfSupported() {
    if (Canvas.isSupported()) {
        return new LayeredCanvas();
    }/*from   w w  w.ja  v  a  2 s  . c o  m*/
    return null;
}