/** * Retrieves the buffer from canvas, if possible, and * calls/notifies component to be repainted, if necessary. */ @Override synchronized public void postSwap() { if (true == isRendererRunning()) { // as weird as it can look, there can be postswaps without rendered running. (?!!) Anyway, in that case we should not refresh. bi = getOffScreenBuffer().getImage(); imageReadyBis = true; if (false == waitingForSwap) { // System.err.println("repaint " + System.currentTimeMillis()); this.lwCanvas.repaint(); } else { notify(); } } else { // System.err.println("SWAP WITHOUT RENDERER RUNNING"); } }
throw new IllegalArgumentException(J3dI18N.getString("GraphicsContext3D33")); if (image.isByReference() && (image.getImage() == null)) { throw new IllegalArgumentException(J3dI18N.getString("GraphicsContext3D34"));
@Override public void writeConstructorParams( DataOutput out ) throws IOException { super.writeConstructorParams( out ); ImageComponent2D ic = ((ImageComponent2D)node); // If the BufferedImage is associated with the ImageComponent2D by // reference then we don't know much about it, so it'd be hard to // save. So we copy it into an ImageComponent2D and then copy it // out. It comes out in a known format so it's easier to save. if ( ic.isByReference() ) { ImageComponent2D noByRef = new ImageComponent2D( ic.getFormat(), ic.getRenderedImage(), false, ic.isYUp() ); bufferedImage = noByRef.getImage(); } else bufferedImage = ic.getImage(); writeBufferedImage( out, bufferedImage ); }
/** * Creates a heavyweight canvas and initializes it, or changes the * size of the current one if present. Current heavyweight canvas is * changed only if size is different from the actual one. No canvas is * created if this component has no parent, that is, was not added to a * container. * * @param width the width of the canvas to create. * @param height the height of the canvas to create. */ void createCanvas(int width, int height) { if (getParent() == null) { return; } if (null != canvas) { // i had a canvas, i need to check if i really need to change it if ((width != canvas.getWidth()) || (height != canvas.getHeight())) { if ((null != canvas.getOffScreenBuffer()) && (null != canvas.getOffScreenBuffer().getImage())) { canvas.getOffScreenBuffer().getImage().flush(); // flushing so that eventual resources are freed. } } else { return; } } else { // no canvas, i have to create it. canvas = new InternalCanvas3D(this.graphicsConfig, this); } createOffScreenBuffer(width, height); // whatever happened right above, i need to create the offscreen buffer. }
offCanvas.renderOffScreenBuffer(); offCanvas.waitForOffScreenRendering(); bImage = offCanvas.getOffScreenBuffer().getImage();
offScreenCanvas3D.renderOffScreenBuffer(); offScreenCanvas3D.waitForOffScreenRendering(); bImage = offScreenCanvas3D.getOffScreenBuffer().getImage();