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

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

Introduction

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

Prototype

public int getCoordinateSpaceHeight() 

Source Link

Document

Gets the height 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);/*from   w  ww . ja va2s.  c  om*/

    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);/*from w ww  . ja  va2 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  .ja v a2  s . co m
        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// w  w  w.  java2  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 .java2s  .c  o  m
    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 ww .  ja  va  2s  . c  om*/
}

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  ww  w .j  a v  a 2s .c  o 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();//  w w w .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  ww.ja  v  a2  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;
}