public class SFImageObject extends X3DConcreteField implements SFImage
MFImageObject| Modifier and Type | Field and Description |
|---|---|
static int[] |
DEFAULT_VALUE
Default value for this field type contains values of 0 0 0.
|
static java.lang.String |
DEFAULT_VALUE_STRING
Default string value for this field type is "0 0 0".
|
static java.lang.String |
NAME
String constant NAME provides name of this element: SFImage
|
static java.util.regex.Pattern |
PATTERN
Precompiled regular expression (regex) pattern for this field type using default REGEX value.
|
static java.lang.String |
REGEX
Default regular expression (regex) pattern for this field type is \s*([+]?
|
static int |
TUPLE_SIZE
Default tuple size for this field type is 1 (i.e. number of component values making up a single-field SF object).
|
validationResult| Constructor and Description |
|---|
SFImageObject()
Constructor for SFImageObject performs value initialization.
|
SFImageObject(int[] newValue)
Constructor for SFImageObject using a corresponding Java primitive int[] array as new initial value.
|
SFImageObject(SFImageObject newValue)
Constructor to copy an SFImageObject value as initial value for this new field object.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getComponents()
Get the number of color components in the image.
|
int |
getHeight()
Get the height of the image.
|
java.awt.image.WritableRenderedImage |
getImage()
Fetch the Java representation of the underlying image from these pixels.
|
int |
getLength()
Compute length of SFImage integer array (including height, width and components values).
|
int |
getNumberOfPixelValues()
Compute number of pixel values in SFImage integer array (not counting height, width and components values).
|
void |
getPixels(int[] destinationPixels)
Get the image pixel value in the given eventOut.
|
int[] |
getPrimitiveValue()
Provides current value of the field as a Java primitive type.
|
int |
getWidth()
Get the width of the image.
|
void |
initialize()
Initialization for SFImageObject applies default initial value.
|
boolean |
isDefaultValue()
Determine whether current value matches DEFAULT_VALUE
|
boolean |
matches()
Test PATTERN match via regular expression (regex) check of current object's toString() value.
|
static boolean |
matches(java.lang.String value)
Test PATTERN match with regular expression (regex) of provided value.
|
void |
setImage(java.awt.image.RenderedImage image)
Set the image value in the given writable field to the new image defined
by a set of pixels.
|
void |
setSubImage(java.awt.image.RenderedImage image,
int sourceWidth,
int sourceHeight,
int sourceXOffset,
int sourceYOffset,
int destinationXOffset,
int destinationYOffset)
Copy a region of the argument RenderedImage to replace a portion of the
current SFimage.
|
void |
setValue(int[] sfImageArray)
Set the image value as a primitive array.
|
void |
setValue(int width,
int height,
int components,
int[] pixels)
Set the image value in the given writable field.
|
SFImageObject |
setValue(SFImageObject newValue)
Apply an SFImageObject value to this field.
|
SFImageObject |
setValueByString(java.lang.String newValue)
Utility accessor for SFImageObject using String value (which must pass parsing validation checks).
|
java.lang.String |
toString()
Provides current value as a String.
|
static java.lang.String |
toString(int[] value)
Static utility method to provide String representation of a correctly typed input value.
|
java.lang.String |
toStringDecimal()
Provide pixel values in decimal format.
|
java.lang.String |
toStringHexadecimal()
Provide pixel values in hexadecimal format.
|
java.lang.String |
validate()
Validate current value via regular expression (regex) check of current object's toString() value, reporting errors only if found.
|
addX3DEventListener, getDefinition, getTupleSize, getValidationResult, isReadable, isWritable, removeX3DEventListener, setReadable, setWritableclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitaddX3DEventListener, getDefinition, isReadable, isWritable, removeX3DEventListenerpublic static final java.lang.String NAME
public static final int[] DEFAULT_VALUE
public static final java.lang.String DEFAULT_VALUE_STRING
public static final int TUPLE_SIZE
public static final java.lang.String REGEX
public static final java.util.regex.Pattern PATTERN
REGEX,
matches(),
matches(String),
validate(),
java.util.regex.Patternpublic SFImageObject()
public SFImageObject(SFImageObject newValue)
newValue - The newValue to applypublic SFImageObject(int[] newValue)
newValue - is new value to assign
setContainerFieldOverride(containerFieldName); // apply checksConcreteField#getTupleSize(String)public void initialize()
initialize in class X3DConcreteFieldDEFAULT_VALUEpublic final java.lang.String validate()
REGEX,
PATTERN,
matches(),
matches(String),
validate(),
java.util.regex.Patternpublic final boolean matches()
REGEX,
PATTERN,
matches(),
matches(String),
validate(),
java.util.regex.Patternpublic static final boolean matches(java.lang.String value)
value - String to check against regex pattern for successful matchREGEX,
PATTERN,
matches(),
matches(String),
validate(),
java.util.regex.Patternpublic SFImageObject setValueByString(java.lang.String newValue) throws InvalidFieldValueException
newValue - is new value to assign, if empty then assign DEFAULT_VALUEMFMatrix4dObject - namely this same object to allow sequential method pipelining (i.e. consecutive
method invocations on the same node object).InvalidFieldValueExceptionX3DLoaderObject.toX3dObjectTree(org.w3c.dom.Node)public static java.lang.String toString(int[] value)
value - The value to convert to a Stringpublic int[] getPrimitiveValue()
public java.lang.String toString()
toString in class java.lang.ObjecttoStringHexadecimal(),
toStringDecimal(),
ConfigurationProperties.SFImagePixelOutputHexadecimal_DEFAULT,
ConfigurationProperties.isSFImagePixelOutputHexadecimal(),
ConfigurationProperties.setSFImagePixelOutputHexadecimal(boolean)public java.lang.String toStringDecimal()
toStringHexadecimal(),
ConfigurationProperties.SFImagePixelOutputHexadecimal_DEFAULT,
ConfigurationProperties.isSFImagePixelOutputHexadecimal(),
ConfigurationProperties.setSFImagePixelOutputHexadecimal(boolean),
X3D Tooltips: type SFImagepublic java.lang.String toStringHexadecimal()
toStringDecimal(),
ConfigurationProperties.SFImagePixelOutputHexadecimal_DEFAULT,
ConfigurationProperties.isSFImagePixelOutputHexadecimal(),
ConfigurationProperties.setSFImagePixelOutputHexadecimal(boolean),
X3D Tooltips: type SFImagepublic int getWidth()
getWidth in interface SFImageInvalidFieldValueException - Invalid SFImage data foundpublic int getHeight()
getHeight in interface SFImageInvalidFieldValueException - Invalid SFImage data foundpublic int getComponents()
getComponents in interface SFImageInvalidFieldValueException - Invalid SFImage data foundpublic int getLength()
public int getNumberOfPixelValues()
public void getPixels(int[] destinationPixels)
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 transparency value stored in the lowest byte and the
intensity in the next byte:
intensity = (pixel[i] >> 8) &0xFF;
alpha = (pixel[i] ) &0xFF;
3 Component Images
The three color 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:
red = (pixel[i] >> 24) &0xFF;
green = (pixel[i] >> 16) &0xFF;
blue = (pixel[i] >> 8) &0xFF;
alpha = (pixel[i] ) &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.
getPixels in interface SFImagedestinationPixels - The array to copy pixel values intoInvalidFieldValueException - Invalid SFImage data foundpublic java.awt.image.WritableRenderedImage getImage()
public void setImage(java.awt.image.RenderedImage image)
public void setSubImage(java.awt.image.RenderedImage image,
int sourceWidth,
int sourceHeight,
int sourceXOffset,
int sourceYOffset,
int destinationXOffset,
int destinationYOffset)
The sub image set shall not resize the base image representation and therefore performs an intersection clip of the provided image. The user provided image shall be of the same format (pixel depth, pixel representation) as the original image obtained through the getImage() method.
RenderedImages are row order from top to bottom. A 4x8 RenderImage is indexed as follows:
X >01234567 ---------- 0 |********| 1 |********| 2 |********| 3 |********| ^ ---------- YSFImages are row order from bottom to top. A 4x8 RenderImage is indexed as follows:
X >01234567 ---------- 3 |********| 2 |********| 1 |********| 0 |********| ^ ---------- Y
Note: The parameter srcYOffset is referenced to the RenderedImage object
(indexed top to bottom).
The parameter destYOffset is referenced to the SFImage object
(indexed bottom to top).
setSubImage in interface SFImageimage - The new image to use as the sourcesourceWidth - The width of the argument sub-image region to copysourceHeight - The height of the argument sub-image region to copysourceXOffset - The initial x dimension (width) offset into the
argument sub-image that begins the region to copysourceYOffset - The initial y dimension (height) offset into the
argument sub-image that begins the region to copydestinationXOffset - The initial x dimension (width) offset in the SFimage
object that begins the region to receive the copydestinationYOffset - The initial y dimension (height) offset in the SFimage
object that begins the region to receive the copypublic void setValue(int width,
int height,
int components,
int[] pixels)
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 transparency value stored in the lowest byte and the
intensity in the next byte:
intensity = (pixel[i] >> 8) &0xFF;
alpha = (pixel[i] ) &0xFF;
3 Component Images
The three color 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:
red = (pixel[i] >> 24) &0xFF;
green = (pixel[i] >> 16) &0xFF;
blue = (pixel[i] >> 8) &0xFF;
alpha = (pixel[i] ) &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.
setValue in interface SFImagewidth - The width of the image in pixelsheight - The height of the image in pixelscomponents - The number of color components [1-4]pixels - The array of pixel values as specified above.java.lang.IllegalArgumentException - The number of components or width/
height are illegal values.java.lang.ArrayIndexOutOfBoundsException - The number of pixels provided by the
caller is not enough for the width * height.java.lang.IllegalArgumentException - Invalid parameter(s) provided, no change was madepublic void setValue(int[] sfImageArray)
sfImageArray - full set of SFImage valuespublic SFImageObject setValue(SFImageObject newValue)
newValue - The newValue to applySFImageObject - namely this same object to allow sequential method pipelining (i.e. consecutive method invocations on the same object).public boolean isDefaultValue()
DEFAULT_VALUECopyright ©2005-2017 Web3D Consortium under an open-source license, free for any use. Feedback is welcome.