Aviatrix3D
2.1.0

org.j3d.aviatrix3d
Class BitmapRaster

java.lang.Object
  extended by org.j3d.aviatrix3d.SceneGraphObject
      extended by org.j3d.aviatrix3d.NodeComponent
          extended by org.j3d.aviatrix3d.Raster
              extended by org.j3d.aviatrix3d.BitmapRaster
All Implemented Interfaces:
java.lang.Comparable, LeafPickTarget, PickableObject, PickTarget, GeometryRenderable, Renderable

public class BitmapRaster
extends Raster

Raster object that represents a single drawn object using individual bits.

Bitmaps describe what should be seen on screen, but not the colour. Colour information is derived from the Pixmap's appearance information. A bitmap also has a local offset field. A user may set explicit bounds for this object, but in doing so may or may not truncate the bits themselves.

When providing byte data, each bit represents the state of a single pixel as either on or off. The bitmap width does not need to be a power of 2 or eight to handle this. An image that is 2 pixels high and 10 pixels wide would be represented by 4 bytes. The first byte is the first 8 bits of the input for the first row. The second byte uses the first 2 bits for the remaining part of the first row. The other 6 bits are ignored. The third byte starts the next row, and finally the first 2 bits of the the fourth byte provide the last two pixels of the second row.

Internationalisation Resource Names

Version:
$Revision: 2.6 $
Author:
Justin Couch

Field Summary
 
Fields inherited from class org.j3d.aviatrix3d.Raster
bounds, implicitBounds, internalUpdater, INVALID_BOUNDS, lastParentList, parentList, pickFlags, validAlpha
 
Fields inherited from class org.j3d.aviatrix3d.NodeComponent
lastParent, liveCount
 
Fields inherited from class org.j3d.aviatrix3d.SceneGraphObject
alive, LISTENER_SET_TIMING_ERR_PROP, updateHandler
 
Fields inherited from interface org.j3d.aviatrix3d.picking.PickableObject
COLLIDABLE_OBJECT, GENERAL_OBJECT, PROXIMITY_OBJECT, VISIBLE_OBJECT
 
Fields inherited from interface org.j3d.aviatrix3d.picking.PickTarget
CUSTOM_PICK_TYPE, GROUP_PICK_TYPE, LEAF_PICK_TYPE, SINGLE_PICK_TYPE
 
Constructor Summary
BitmapRaster(int width, int height)
          Create a new empty raster with the given width and height.
 
Method Summary
 int compareTo(BitmapRaster br)
          Compares this object with the specified object for order.
 int compareTo(java.lang.Object o)
          Compares this object with the specified object for order.
 boolean equals(BitmapRaster br)
          Compares this object with the specified object to check for equivalence.
 boolean equals(java.lang.Object o)
          Compare this object for equality to the given object.
 void getBits(byte[] bitmask)
          Retrieve the vertices that are currently set.
 int getHeight()
          Get the height of this bitmap.
 void getOrigin(float[] origin)
          Get the current origin of the bitmap.
 int getWidth()
          Get the width of this bitmap.
 boolean pickLineRay(float[] origin, float[] direction, boolean findAny, float[] dataOut, int dataOutFlags)
          Check for all intersections against this geometry using a line ray and return the exact distance away of the closest picking point.
 boolean pickLineSegment(float[] start, float[] end, boolean findAny, float[] dataOut, int dataOutFlags)
          Check for all intersections against this geometry using a line segment and return the exact distance away of the closest picking point.
protected  void recomputeBounds()
          Internal method to recalculate the implicit bounds of this Node.
 void render(javax.media.opengl.GL gl)
          Render the geometry now.
 void setBits(byte[] bitmask)
          Set the pixel data for the bitmap contents.
 void setBits(byte[] bitmask, int width, int height)
          Set the pixel data for the bitmap contents and change the size of the raster at the same time.
protected  void setLive(boolean state)
          Notification that this object is live now.
 void setOrigin(float x, float y)
          Set the origin offset of the bitmap to be used when rendering.
protected  void updateBounds()
          Update this node's bounds and then call the parent to update it's bounds.
 
Methods inherited from class org.j3d.aviatrix3d.Raster
addParent, boundsChanged, checkPickMask, getBounds, getPickableBounds, getPickMask, getPickTargetType, hasTransparency, isVisible, markBoundsDirty, pickBatch, pickSingle, removeParent, setBounds, setPickMask
 
Methods inherited from class org.j3d.aviatrix3d.NodeComponent
addParent, getParents, numParents, removeParent
 
Methods inherited from class org.j3d.aviatrix3d.SceneGraphObject
checkForCyclicChild, checkForCyclicParent, dataChanged, getAppUpdateWriteTimingMessage, getBoundsWriteTimingMessage, getDataWriteTimingMessage, getUserData, isLive, setUpdateHandler, setUserData
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BitmapRaster

public BitmapRaster(int width,
                    int height)
Create a new empty raster with the given width and height.

Parameters:
width - The width of the raster in pixels
height - The height of the raster in pixels
Throws:
java.lang.IllegalArgumentException - The width or height are not positive
Method Detail

render

public void render(javax.media.opengl.GL gl)
Render the geometry now.

Parameters:
gl - The GL context to render with

pickLineSegment

public boolean pickLineSegment(float[] start,
                               float[] end,
                               boolean findAny,
                               float[] dataOut,
                               int dataOutFlags)
                        throws NotPickableException
Check for all intersections against this geometry using a line segment and return the exact distance away of the closest picking point. Default implementation always returns false indicating that nothing was found. Derived classes should override and provide a real implementation.

Specified by:
pickLineSegment in interface LeafPickTarget
Overrides:
pickLineSegment in class Raster
Parameters:
start - The start point of the segment
end - The end point of the segment
findAny - True if it only has to find a single intersection and can exit as soon as it finds the first intersection. False if it must find the closest polygon
dataOut - An array to put the data in for the intersection. Exact format is described by the flags
dataOutFlags - A set of derived-class specific flags describing what data should be included in the output array
Returns:
True if an intersection was found according to the input request
Throws:
NotPickableException - This object has been marked as non pickable, but you decided to try to call the method anyway

pickLineRay

public boolean pickLineRay(float[] origin,
                           float[] direction,
                           boolean findAny,
                           float[] dataOut,
                           int dataOutFlags)
                    throws NotPickableException
Check for all intersections against this geometry using a line ray and return the exact distance away of the closest picking point. Default implementation always returns false indicating that nothing was found. Derived classes should override and provide a real implementation.

Specified by:
pickLineRay in interface LeafPickTarget
Overrides:
pickLineRay in class Raster
Parameters:
origin - The start point of the ray
direction - The direction vector of the ray
findAny - True if it only has to find a single intersection and can exit as soon as it finds the first intersection. False if it must find the closest polygon
dataOut - An array to put the data in for the intersection. Exact format is described by the flags
dataOutFlags - A set of derived-class specific flags describing what data should be included in the output array
Returns:
True if an intersection was found according to the input request
Throws:
NotPickableException - This object has been marked as non pickable, but you decided to try to call the method anyway

updateBounds

protected void updateBounds()
Update this node's bounds and then call the parent to update it's bounds. Used to propogate bounds changes from the leaves of the tree to the root. A node implementation may decide when and where to tell the parent(s)s that updates are ready.

Overrides:
updateBounds in class Raster

recomputeBounds

protected void recomputeBounds()
Internal method to recalculate the implicit bounds of this Node. By default the bounds are a point sphere, so derived classes should override this method with something better.

Specified by:
recomputeBounds in class Raster

setLive

protected void setLive(boolean state)
Notification that this object is live now. Overridden to make sure that the live state of the nodes represents the same state as the parent scene graph.

Overrides:
setLive in class SceneGraphObject
Parameters:
state - true if this should be marked as live now

compareTo

public int compareTo(java.lang.Object o)
              throws java.lang.ClassCastException
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
o - The objec to be compared
Returns:
-1, 0 or 1 depending on order
Throws:
java.lang.ClassCastException - The specified object's type prevents it from being compared to this Object

equals

public boolean equals(java.lang.Object o)
Compare this object for equality to the given object.

Specified by:
equals in interface Renderable
Overrides:
equals in class java.lang.Object
Parameters:
o - The object to be compared
Returns:
True if these represent the same values

getHeight

public int getHeight()
Get the height of this bitmap.

Returns:
the height.

getWidth

public int getWidth()
Get the width of this bitmap.

Returns:
the width.

setBits

public void setBits(byte[] bitmask)
             throws InvalidWriteTimingException,
                    java.lang.IllegalArgumentException
Set the pixel data for the bitmap contents. Each byte represents 8 pixels of the image. See class documentation for more information. A null reference can be used to clear the bitmap and not have anything appear on screen.

Parameters:
bitmask - The bits to use for the raster or null to clear
Throws:
java.lang.IllegalArgumentException - The number of bytes is not sufficient to fulfill the previously set width and height of the bitmap
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener data callback method

setBits

public void setBits(byte[] bitmask,
                    int width,
                    int height)
             throws InvalidWriteTimingException,
                    java.lang.IllegalArgumentException
Set the pixel data for the bitmap contents and change the size of the raster at the same time. Each byte represents 8 pixels of the image. See class documentation for more information. A null reference can be used to clear the bitmap and not have anything appear on screen. Because this is also changing the bounds of the image, it needs to be called during the bounds callback, not the data callback like the other setBits method.

Parameters:
bitmask - The bits to use for the raster or null to clear
width - The width of the raster in pixels
height - The height of the raster in pixels
Throws:
java.lang.IllegalArgumentException - The width or height are not positive
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds callback method

getBits

public void getBits(byte[] bitmask)
Retrieve the vertices that are currently set. The array must be at least as long as the valid vertex count, times 3. If none are set currently or have been cleared, the provided array is untouched.

Parameters:
bitmask - The array to copy the bit mask values into
Throws:
java.lang.ArrayIndexOutOfBoundsException - The provided array is too short

setOrigin

public void setOrigin(float x,
                      float y)
               throws InvalidWriteTimingException
Set the origin offset of the bitmap to be used when rendering. The origin allows an offset to be defined relative to the raster position. Raster position is generated from the parent pixel transforms, and this allows for bitmaps to be offset from that.

Parameters:
x - The X coordinate of the origin
y - The Y coordinate of the origin
Throws:
InvalidWriteTimingException - An attempt was made to write outside of the NodeUpdateListener bounds callback method

getOrigin

public void getOrigin(float[] origin)
Get the current origin of the bitmap. The default origin is (0,0).

Parameters:
origin - An array of length 2 to copy the values into

compareTo

public int compareTo(BitmapRaster br)
Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.

Parameters:
br - The argument instance to be compared
Returns:
-1, 0 or 1 depending on order

equals

public boolean equals(BitmapRaster br)
Compares this object with the specified object to check for equivalence.

Parameters:
br - The shape instance to be compared
Returns:
true if the objects represent identical values

Aviatrix3D
2.1.0

Latest Info from http://aviatrix3d.j3d.org/
Copyright © 2003 - 2009 j3d.org