コード例 #1
0
 /**
  * Set one pixel value at the correct index in this field. Basically a single pixel set, but it
  * could also be width, height, number of components. This must be used with great care as it
  * could well corrupt the user data.
  *
  * @param index The position in the array to set
  * @param value The value to use at that position
  */
 public void set1Value(int index, int value) throws ArrayIndexOutOfBoundsException {
   checkReadAccess();
   checkWriteAccess();
   if (value < 0) throw new IllegalArgumentException("Pixels may not be negative.");
   if (index < 0) throw new ArrayIndexOutOfBoundsException();
   synchronized (theEventQueue.eventLock) {
     MFImageWrapper queuedElement = (MFImageWrapper) theEventQueue.getLast(this);
     boolean newEvent = false;
     if (queuedElement == null || !queuedElement.isSetOneValue) {
       // Input and output buffers do not mix
       if (!storedInput && !storedOutput) {
         queuedElement = this;
         loadInputValue();
         isSetOneValue = true;
       } else {
         queuedElement =
             new MFImageWrapper(theNode, fieldIndex, theEventQueue, theEventAdapterFactory, true);
         queuedElement.isSetOneValue = true;
       }
       newEvent = true;
     }
     queuedElement.storedInputValue[index] = value;
     queuedElement.rogueInputData = true;
     if (newEvent) theEventQueue.processEvent(queuedElement);
   }
 }
コード例 #2
0
 /**
  * Inserts a value into an existing index of the field. Current field values from the index to the
  * end of the field are shifted down and the field length is increased by one to accomodate the
  * new element.
  *
  * <p>This method modifies the integer array rather than the conceptual image array.
  *
  * <p>If the index is out of the bounds of the current field an ArrayIndexOutofBoundsException
  * will be generated.
  *
  * @param index The position at which to insert
  * @param value The new element to insert
  * @exception ArrayIndexOutOfBoundsException The index was outside the current field size.
  */
 public void insertValue(int index, int value) throws ArrayIndexOutOfBoundsException {
   checkReadAccess();
   checkWriteAccess();
   synchronized (theEventQueue.eventLock) {
     MFImageWrapper queuedElement = (MFImageWrapper) theEventQueue.getLast(this);
     boolean newEvent = false;
     if (queuedElement == null || !queuedElement.isSetOneValue) {
       // Input and output buffers do not mix
       if (!storedInput && !storedOutput) {
         queuedElement = this;
         loadInputValue();
         isSetOneValue = true;
       } else {
         queuedElement =
             new MFImageWrapper(theNode, fieldIndex, theEventQueue, theEventAdapterFactory, true);
         queuedElement.isSetOneValue = true;
       }
       newEvent = true;
     }
     queuedElement.ensureArraySize(queuedElement.storedInputLength + 1);
     System.arraycopy(
         queuedElement.storedInputValue,
         index,
         queuedElement.storedInputValue,
         index + 1,
         queuedElement.storedInputLength - index);
     queuedElement.storedInputValue[index] = value;
     queuedElement.storedInputLength++;
     queuedElement.rogueInputData = true;
     if (newEvent) theEventQueue.processEvent(queuedElement);
   }
 }
コード例 #3
0
 /** @see org.web3d.x3d.sai.MFImage#removeValue(int) */
 public void removeValue(int index) throws ArrayIndexOutOfBoundsException {
   checkReadAccess();
   checkWriteAccess();
   synchronized (theEventQueue.eventLock) {
     MFImageWrapper queuedElement = (MFImageWrapper) theEventQueue.getLast(this);
     boolean newEvent = false;
     if (queuedElement == null || !queuedElement.isSetOneValue) {
       // Input and output buffers do not mix
       if (!storedInput && !storedOutput) {
         queuedElement = this;
         loadInputValue();
         isSetOneValue = true;
       } else {
         queuedElement =
             new MFImageWrapper(theNode, fieldIndex, theEventQueue, theEventAdapterFactory, true);
         queuedElement.isSetOneValue = true;
       }
       newEvent = true;
     }
     // Removing a raw byte, rather than an image value.
     if (queuedElement.storedInputLength > 0) {
       if (index + 1 < queuedElement.storedInputLength)
         System.arraycopy(
             queuedElement.storedInputValue,
             index + 1,
             queuedElement.storedInputValue,
             index,
             queuedElement.storedInputLength - index - 1);
       queuedElement.storedInputLength--;
       queuedElement.rogueInputData = true;
       if (newEvent) theEventQueue.processEvent(queuedElement);
     } else {
       // Free up the buffer before throwing the exception
       if (newEvent) queuedElement.isSetOneValue = false;
       throw new ArrayIndexOutOfBoundsException();
     }
   }
 }