/** * Set the image value in the given writable field to the new image defined by a set of pixels. * * <p> * * @param imgIndex The index of the image in the array * @param img The new image to use as the source */ public void setImage(int imgIndex, RenderedImage img) throws InvalidOperationTimingException, InvalidFieldValueException, InvalidWritableFieldException, InvalidFieldException { if (imgIndex < 0) throw new ArrayIndexOutOfBoundsException(); checkWriteAccess(); synchronized (theEventQueue.eventLock) { MFImageWrapper queuedElement = (MFImageWrapper) theEventQueue.getLast(this); if (queuedElement == null || !queuedElement.isSetOneValue) { // Input and output buffers do not mix if (!storedInput && !storedOutput) { // Avoid clogging this buffer if // index out of bounds if (imgIndex < 0) throw new ArrayIndexOutOfBoundsException(); loadInputValue(); if (imgIndex >= storedInputValue.length) throw new ArrayIndexOutOfBoundsException(); queuedElement = this; loadInputValue(); isSetOneValue = true; } else { // If this generates an ArrayIndexOutOfBounds its okay, // the element will be garbage. queuedElement = new MFImageWrapper(theNode, fieldIndex, theEventQueue, theEventAdapterFactory, true); queuedElement.isSetOneValue = true; } queuedElement.rewriteImageToSize(imgIndex, img.getWidth(), img.getHeight()); SFImageUtils.convertRenderedImageToData( img, queuedElement.storedInputValue, queuedElement.findStartOfInputImage(imgIndex)); theEventQueue.processEvent(queuedElement); } else { checkDataSanity(); queuedElement.rewriteImageToSize(imgIndex, img.getWidth(), img.getHeight()); SFImageUtils.convertRenderedImageToData( img, queuedElement.storedInputValue, queuedElement.findStartOfInputImage(imgIndex)); queuedElement.getSize(); } } }