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

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

Introduction

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

Prototype

public int getCoordinateSpaceWidth() 

Source Link

Document

Gets the width of the internal canvas coordinate space.

Usage

From source file:com.gambo.web.client.WebDisplay.java

License:Open Source License

public WebDisplay(Mmu mmu, Canvas canvas) {
    super(mmu);/*w  w w. j a  va  2s . com*/

    this.canvas = canvas;

    width = canvas.getCoordinateSpaceWidth();
    height = canvas.getCoordinateSpaceHeight();

    this.bufferImage = canvas.getContext2d().createImageData(width, height);
    this.cpa = bufferImage.getData();
}

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

public void setDrawingAreaSize(int width, int height) {
    Canvas c = panel.getCanvas();
    if (cElement.getWidth() != width || cElement.getHeight() != height || c.getCoordinateSpaceWidth() != width
            || c.getCoordinateSpaceHeight() != height) {

        panel.setPixelSize(width, height);
        cElement.setWidth(width);//ww w .j ava2  s . c  o m
        cElement.setHeight(height);

    }
}

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

public void copyAsImage(AdvancedGraphics g) {
    Canvas sourceCanvas = g.getCanvasPanel().getCanvas();
    int w = sourceCanvas.getCoordinateSpaceWidth();
    int h = sourceCanvas.getCoordinateSpaceHeight();
    ctx.drawImage(sourceCanvas.getCanvasElement(), 0, 0, w, h, 0, 0, w, h);
}

From source file:eu.maxschuster.vaadin.signaturefield.client.SignatureFieldConnector.java

License:Apache License

public boolean updateCanvasSize() {
    VSignatureField field = getWidget();
    Canvas canvas = field.getCanvas();
    int oldWidth = canvas.getCoordinateSpaceWidth();
    int newWidth = field.getElement().getClientWidth();
    int oldHeight = canvas.getCoordinateSpaceHeight();
    int newHeight = field.getElement().getClientHeight();
    boolean empty = field.isEmpty();
    boolean sizeChanged = false;
    if (oldWidth != newWidth || oldHeight != newHeight) {
        canvas.setCoordinateSpaceWidth(newWidth);
        canvas.setCoordinateSpaceHeight(newHeight);
        if (!empty) {
            field.getSignaturePad().fromDataURL(value);
        }/* www .  j  a  va 2 s.com*/
        sizeChanged = true;
    }
    return sizeChanged;
}

From source file:examples.geometry.containment.AbstractPolygonContainmentExample.java

License:Open Source License

@Override
protected AbstractControllableShape createControllableShape1(final Canvas canvas) {
    return new AbstractControllableShape(canvas) {
        @Override/*from   w w w  . j a  v  a2 s .  com*/
        public void createControlPoints() {
            // no control points => user cannot change it
        }

        @Override
        public Polygon createGeometry() {
            double w = canvas.getCoordinateSpaceWidth(), wg = w / 6, h = canvas.getCoordinateSpaceHeight(),
                    hg = h / 6;

            return new Polygon(new Point[] { new Point(wg, hg), new Point(w - wg, h - hg),
                    new Point(wg, h - hg), new Point(w - wg, hg) });
        }

        @Override
        public void drawShape() {
            Context2d context2d = canvas.getContext2d();
            Polygon polygon = createGeometry();
            context2d.setStrokeStyle("black");

            for (Line segment : polygon.getOutlineSegments()) {
                context2d.beginPath();
                context2d.moveTo(segment.getX1(), segment.getY1());
                context2d.lineTo(segment.getX2(), segment.getY2());
                context2d.stroke();
            }
        }
    };
}

From source file:nl.mpi.tg.eg.experiment.client.view.ColourPickerCanvasView.java

License:Open Source License

private void setColour(int x, int y, Canvas targetCanvas, VerticalPanel targetPanel) {
    x = (x >= targetCanvas.getCoordinateSpaceWidth()) ? targetCanvas.getCoordinateSpaceWidth() - 1 : x;
    y = (y >= targetCanvas.getCoordinateSpaceHeight()) ? targetCanvas.getCoordinateSpaceHeight() - 1 : y;
    final ImageData imageData = targetCanvas.getContext2d().getImageData(x, y, 1, 1);
    final int blue = imageData.getBlueAt(0, 0);
    final int green = imageData.getGreenAt(0, 0);
    final int red = imageData.getRedAt(0, 0);
    if (targetPanel.equals(selectedColourPanel)) {
        selectedColourData = new ColourData(red, green, blue);
    }/*from   ww w  . j  ava2 s .  c  om*/
    targetPanel.getElement().setAttribute("style", "background:rgb(" + red + "," + green + "," + blue + ")");
}

From source file:nl.mpi.tg.eg.experiment.client.view.ColourPickerCanvasView.java

License:Open Source License

private void setHue(int x, int y, Canvas targetCanvas) {
    x = (x >= targetCanvas.getCoordinateSpaceWidth()) ? targetCanvas.getCoordinateSpaceWidth() - 1 : x;
    y = (y >= targetCanvas.getCoordinateSpaceHeight()) ? targetCanvas.getCoordinateSpaceHeight() - 1 : y;
    final ImageData imageData = targetCanvas.getContext2d().getImageData(x, y, 1, 1);
    final int blue = imageData.getBlueAt(0, 0);
    final int green = imageData.getGreenAt(0, 0);
    final int red = imageData.getRedAt(0, 0);
    setHue(red, green, blue);/*from   w w w  .j a  v a  2s  . com*/
}

From source file:org.cesiumjs.cs.scene.interaction.MarkerGroup.java

License:Apache License

public static BillboardOptions createBillboard(DrawInteractionOptions options) {
    Canvas canvas = Canvas.createIfSupported();
    Context2d context = canvas.getContext2d();

    context.setFillStyle(options.color.toCssColorString());
    context.setStrokeStyle(options.outlineColor.toCssColorString());
    context.setLineWidth(options.outlineWidth);

    context.translate(canvas.getCoordinateSpaceWidth() / 2, canvas.getCoordinateSpaceHeight() / 2);
    context.beginPath();/*from w  w w  .  j  av  a2  s.  co  m*/
    context.arc(0, 0, options.pixelSize, 0, Math.PI * 2, true);
    context.closePath();
    context.stroke();
    context.fill();

    BillboardOptions billboard = new BillboardOptions();
    billboard.horizontalOrigin = HorizontalOrigin.CENTER();
    billboard.verticalOrigin = VerticalOrigin.CENTER();
    billboard.imageCanvas = canvas.getCanvasElement();
    return billboard;
}

From source file:org.geomajas.gwt2.client.gfx.CanvasContainerImpl.java

License:Open Source License

private void clearCanvas(Canvas canvas) {
    canvas.getContext2d().save();/*from  w  ww. jav  a 2 s  .  co  m*/
    canvas.getContext2d().setTransform(1, 0, 0, 1, 0, 0);
    canvas.getContext2d().clearRect(0, 0, canvas.getCoordinateSpaceWidth(), canvas.getCoordinateSpaceHeight());
    canvas.getContext2d().restore();
}

From source file:org.plyrenderer.client.Renderer.java

License:Open Source License

public Renderer(Canvas canvas) {
    this.canvas = canvas;
    ctx = canvas.getContext2d();/*from w w w.j  a  v a 2  s  .c  o  m*/
    camera = new Camera();
    // Set the camera parameters
    camera.setWindow(canvas.getCoordinateSpaceWidth(), canvas.getCoordinateSpaceHeight());

    zBuffer = new double[canvas.getCoordinateSpaceHeight() * canvas.getCoordinateSpaceWidth()];

    listeners = new ArrayList<RendererListener>();

    useNormal = false;

    enabled = false;
    lastCount = 0;
}