Class EventInSFImageWrapper
- All Implemented Interfaces:
ExternalEvent
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionEventInSFImageWrapper
(int fieldID, FieldAndNodeRequestProcessor requestProcessor, NetworkEventQueue eventQueue) -
Method Summary
Modifier and TypeMethodDescriptionvoid
doEvent()
The EventIn*Wrapper classes implement doEvent by posting their stored values to the underlying implementation.boolean
Two eventIn's are equal if they point to the same actual node and fieldint
The underlying field IDint
getType()
The type of the underlying field.Get the user data that is associated with this eventInint
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.boolean
Is the event conglomerating or non-conglomerating.void
loadFieldValue
(DataInputStream input) void
setUserData
(Object data) Associate user data with this event.void
setValue
(int width, int height, int components, int[] pixels) Set the image value in the given eventIn.void
writeFieldValue
(DataOutputStream output)
-
Constructor Details
-
EventInSFImageWrapper
public EventInSFImageWrapper(int fieldID, FieldAndNodeRequestProcessor requestProcessor, NetworkEventQueue eventQueue) - Parameters:
fieldID
- The network field IDrequestProcessor
- Handler for field serviceseventQueue
- The queue to send events to
-
-
Method Details
-
doEvent
public void doEvent()The EventIn*Wrapper classes implement doEvent by posting their stored values to the underlying implementation.- Specified by:
doEvent
in interfaceExternalEvent
- See Also:
-
equals
-
getFieldID
public int getFieldID()The underlying field ID- See Also:
-
hashCode
-
isConglomerating
public boolean isConglomerating()Description copied from interface:ExternalEvent
Is the event conglomerating or non-conglomerating. Conglomerating events such as the set1Value calls build up in the event buffer.- Specified by:
isConglomerating
in interfaceExternalEvent
- Returns:
- whether event is conglomerating or not
- See Also:
-
setValue
public void setValue(int width, int height, int components, int[] pixels) Description copied from class:EventInSFImage
Set the image value in the given eventIn.Image values are specified using a width, height and the number of components. The number of items in the pixels array must be at least
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. If the integer contains values in bytes that are not used by the number of components for that image, the values are ignored.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 the number of components to 2 - particularly if the three colour components are the same (which they are for an intensity only image) which will result in the correct intepretation of the image.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:
setValue
in classEventInSFImage
- Parameters:
width
- The width of the image in pixelsheight
- The height of the image in pixelscomponents
- The number of colour components [1-4]pixels
- The array of pixel values as specified above.- See Also:
-
setUserData
Description copied from class:EventIn
Associate user data with this event. Whenever an event is generated on this eventIn. this data will be available with the Event through its getData method.- Specified by:
setUserData
in classEventIn
- Parameters:
data
- The data to associate with this eventIn instance- See Also:
-
getUserData
Description copied from class:EventIn
Get the user data that is associated with this eventIn- Specified by:
getUserData
in classEventIn
- Returns:
- * @see vrml.eai.field.EventIn#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
-