Class EventOutSFImageWrapper
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionEventOutSFImageWrapper
(int fieldID, FieldAndNodeRequestProcessor requestProcessor) EventOutSFImageWrapper
(int fieldID, FieldAndNodeRequestProcessor requestProcessor, DataInputStream source) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Add a listener for changes in this eventOut.boolean
Two fields are equal if they point to the same actual node and fieldint
Get the number of colour components in the image.int
The underlying field IDint
Get the height of the image.int[]
Get the image pixel value in the given eventOut.void
getPixels
(int[] pixels) Write the pixel values to the given array.int
getType()
The type of the underlying field.Get the user data that is associated with this eventOutint
getWidth()
Get the width of the image.int
hashCode()
In order to make the event queueing system easier, and since an equals method is required by the specification, compute the hashcode based on the field number and underlying node hashcode.void
loadFieldValue
(DataInputStream input) void
Remove a listener for changes in this eventOut.void
setUserData
(Object data) Associate user data with this event.void
writeFieldValue
(DataOutputStream output)
-
Constructor Details
-
EventOutSFImageWrapper
- Parameters:
fieldID
- The network field IDrequestProcessor
- Handler for field services
-
EventOutSFImageWrapper
public EventOutSFImageWrapper(int fieldID, FieldAndNodeRequestProcessor requestProcessor, DataInputStream source) throws IOException - Parameters:
fieldID
- The network field IDrequestProcessor
- Handler for field servicessource
- The stream to read field values from- Throws:
IOException
-
-
Method Details
-
equals
-
getFieldID
public int getFieldID()The underlying field ID- See Also:
-
getWidth
public int getWidth()Description copied from class:EventOutSFImage
Get the width of the image.- Specified by:
getWidth
in classEventOutSFImage
- Returns:
- * @see vrml.eai.field.EventOutSFImage#getWidth()
-
getHeight
public int getHeight()Description copied from class:EventOutSFImage
Get the height of the image.- Specified by:
getHeight
in classEventOutSFImage
- Returns:
- * @see vrml.eai.field.EventOutSFImage#getHeight()
-
getComponents
public int getComponents()Description copied from class:EventOutSFImage
Get the number of colour components in the image. The value will always be between 1 and 4 indicating the number of components of the colour specification to be read from the image pixel data.- Specified by:
getComponents
in classEventOutSFImage
- Returns:
- * @see vrml.eai.field.EventOutSFImage#getComponents()
-
getPixels
public int[] getPixels()Description copied from class:EventOutSFImage
Get the image pixel value in the given eventOut.The number of items in the pixels array will be
width * height
. If there are less items than this an ArrayIndexOutOfBoundsException will be generated. The integer values are represented according to the number of components.1 Component Images
The integer has the intensity value stored in the lowest byte and can be obtained:intensity = pixel[i] &0xFF;
2 Component Images
The integer has the intensity value stored in the lowest byte and the transparency in the top byte:intensity = pixel[i] &0xFF; alpha = (pixel[i] >> 24) &0xFF00;
Note that this is different to the VRML representation of the image which would store the values in the text file asalpha = pixel[i] >> 8) &0xFF
. The reason for the difference is to maintain as much compatibility with the java image model as possible. Java does not contain a separate intensity only image model, instead it sets all three colour components to the same value. This way, the user of SFImages can take a full colour image and turn it to black + white by just setting each of the bytes to the same value as the lowest byte.3 Component Images
The three colour components are stored in the integer array as follows:red = (pixel[i] >> 16) &0xFF; green = (pixel[i] >> 8) &0xFF; blue = (pixel[i] ) &0xFF;
4 Component Images
The integer has the value stored in the array as follows:alpha = (pixel >> 24) &0xff; red = (pixel >> 16) &0xff; green = (pixel >> 8) &0xff; blue = (pixel ) &0xff;
The width and height values must be greater than or equal to zero. The number of components is between 1 and 4. Any value outside of these bounds will generate an IllegalArgumentException.
- Specified by:
getPixels
in classEventOutSFImage
- Returns:
- * @see vrml.eai.field.EventOutSFImage#getPixels()
-
getPixels
public void getPixels(int[] pixels) Description copied from class:EventOutSFImage
Write the pixel values to the given array. Returns values in the same format as that used by the no argument version of this method. The length of the array must be at least width * height elements.- Specified by:
getPixels
in classEventOutSFImage
- Parameters:
pixels
- The array to write pixels to.- See Also:
-
hashCode
-
addVrmlEventListener
Description copied from class:EventOut
Add a listener for changes in this eventOut.- Specified by:
addVrmlEventListener
in classEventOut
- Parameters:
l
- The listener to add- See Also:
-
removeVrmlEventListener
Description copied from class:EventOut
Remove a listener for changes in this eventOut.- Specified by:
removeVrmlEventListener
in classEventOut
- Parameters:
l
- The listener to remove- See Also:
-
setUserData
Description copied from class:EventOut
Associate user data with this event. Whenever an event is generated on this eventOut. this data will be available with the Event through its getData method.- Specified by:
setUserData
in classEventOut
- Parameters:
data
- The data to associate with this eventOut instance- See Also:
-
getUserData
Description copied from class:EventOut
Get the user data that is associated with this eventOut- Specified by:
getUserData
in classEventOut
- Returns:
- * @see vrml.eai.field.EventOut#getUserData()
-
loadFieldValue
- Throws:
IOException
- * @see org.web3d.vrml.scripting.external.neteai.EventWrapper#loadFieldValue(java.io.DataInputStream)
-
writeFieldValue
- Throws:
IOException
- * @see org.web3d.vrml.scripting.external.neteai.EventWrapper#writeFieldValue(java.io.DataOutputStream)
-
getType
int getType()The type of the underlying field. Method name chosen to coincide with vrml.eai.field.BaseField.- Returns:
- the type of the underlying field
-