/** * Updates the bounds of the component and updates the camera accordingly. * * @param x left of bounds * @param y top of bounds * @param width width of bounds * @param height height of bounds */ public void setBounds(final int x, final int y, final int width, final int height) { camera.setBounds(camera.getX(), camera.getY(), width, height); super.setBounds(x, y, width, height); }
/** * Set the camera associated with this canvas. All input events from this * canvas go through this camera. And this is the camera that paints this * canvas. * * @param newCamera camera to attach to this canvas */ public void setCamera(final PCamera newCamera) { if (camera != null) { camera.setComponent(null); } camera = newCamera; if (camera != null) { camera.setComponent(this); final Rectangle swtRect = getBounds(); camera.setBounds(new Rectangle2D.Double(swtRect.x, swtRect.y, swtRect.width, swtRect.height)); } }
/** * Set the camera for this offscreen canvas to <code>camera</code>. * * @param camera camera for this offscreen canvas */ public void setCamera(final PCamera camera) { if (this.camera != null) { this.camera.setComponent(null); } this.camera = camera; if (camera != null) { camera.setComponent(this); camera.setBounds((PBounds) bounds.clone()); } }
/** * Set the camera associated with this canvas. All input events from this * canvas go through this camera. And this is the camera that paints this * canvas. * * @param newCamera the camera which this PCanvas should view the scene */ public void setCamera(final PCamera newCamera) { if (camera != null) { camera.setComponent(null); } camera = newCamera; if (camera != null) { camera.setComponent(this); camera.setBounds(0, 0, getWidth(), getHeight()); } }
/** * Changes the bounds of this PSWTCanvas. Updating the camera and the double * buffered image appropriately. * * @param x left of the new bounds * @param y top of the new bounds * @param newWidth new width of the bounds * @param newHeight new height of the bounds */ public void setBounds(final int x, final int y, final int newWidth, final int newHeight) { camera.setBounds(camera.getX(), camera.getY(), newWidth, newHeight); if (backBufferNeedsResizing(newWidth, newHeight)) { resizeBackBuffer(newWidth, newHeight); } super.setBounds(x, y, newWidth, newHeight); }