|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.ctdp.rfdynhud.render.TextureImage2D
public class TextureImage2D
This class provides a direct interface to draw on a Texture. Most of the code is borrowed from TextureImage2D from the Xith3D project. (http://xith.org/)
Nested Class Summary | |
---|---|
static class |
TextureImage2D.TextDirection
|
Method Summary | ||
---|---|---|
|
clampToClipRect(Rect2i_ rect)
Clamps the given rect to the current effective clip rect. |
|
void |
clear(boolean markDirty,
Rect2i dirtyRect)
Clears the whole (used part of the) texture with a black-transparent color. |
|
void |
clear(java.awt.Color color,
boolean markDirty,
Rect2i dirtyRect)
Clears the whole (used part of the) texture with the specified color. |
|
void |
clear(java.awt.Color color,
int offsetX,
int offsetY,
int width,
int height,
boolean markDirty,
Rect2i dirtyRect)
Clears the given rectangle with the specified color. |
|
void |
clear(int offsetX,
int offsetY,
int width,
int height,
boolean markDirty,
Rect2i dirtyRect)
Clears the given rectangle with a black-transparent color. |
|
void |
clear(TextureImage2D srcTI,
boolean markDirty,
Rect2i dirtyRect)
Draws the given TextureImage2D onto this one and simply overwrites anything. |
|
void |
clear(TextureImage2D srcTI,
int trgX,
int trgY,
boolean markDirty,
Rect2i dirtyRect)
Draws the given TextureImage2D onto this one and simply overwrites anything. |
|
void |
clear(TextureImage2D srcTI,
int trgX,
int trgY,
int trgWidth,
int trgHeight,
boolean markDirty,
Rect2i dirtyRect)
Draws the given TextureImage2D onto this one and simply overwrites anything. |
|
void |
clear(TextureImage2D srcTI,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
int trgX,
int trgY,
boolean markDirty,
Rect2i dirtyRect)
Draws the given TextureImage2D onto this one and simply overwrites anything. |
|
void |
clear(TextureImage2D srcTI,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
int trgX,
int trgY,
int trgWidth,
int trgHeight,
boolean markDirty,
Rect2i dirtyRect)
Draws the given TextureImage2D onto this one and simply overwrites anything. |
|
void |
clear(TextureImage2D srcTI,
Rect2i srcRect,
int trgX,
int trgY,
boolean markDirty,
Rect2i dirtyRect)
Draws the given TextureImage2D onto this one and simply overwrites anything. |
|
void |
clearOutline(java.awt.Color color,
int offsetX,
int offsetY,
int width,
int height,
int lineWidth,
boolean markDirty,
Rect2i dirtyRect)
Clears the given rectangle's outline with the specified color. |
|
void |
clearPixelLine(byte[] pixels,
int startX,
int startY,
int length,
boolean markDirty,
Rect2i dirtyRect)
Clears a horizontal line of pixels. |
|
void |
copyImageDataFrom(java.awt.image.BufferedImage srcImage,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
int trgX,
int trgY,
int trgWidth,
int trgHeight,
boolean overwrite,
boolean markDirty,
Rect2i dirtyRect)
|
|
static TextureImage2D |
createDrawTexture(int width,
int height,
boolean alpha)
|
|
static TextureImage2D |
createDrawTexture(int maxWidth,
int maxHeight,
int usedWidth,
int usedHeight,
boolean alpha)
|
|
protected java.awt.Graphics2D |
createGraphics2D()
|
|
void |
drawImage(TextureImage2D srcTI,
int trgX,
int trgY,
boolean markDirty,
Rect2i dirtyRect)
Draws the given TextureImage2D onto this one and honors the alpha channels (if any). |
|
void |
drawImage(TextureImage2D srcTI,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
int trgX,
int trgY,
boolean markDirty,
Rect2i dirtyRect)
Draws the given TextureImage2D onto this one and honors the alpha channels (if any). |
|
void |
drawImage(TextureImage2D srcTI,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
int trgX,
int trgY,
int trgWidth,
int trgHeight,
boolean markDirty,
Rect2i dirtyRect)
Draws the given TextureImage2D onto this one and honors the alpha channels (if any). |
|
void |
drawImage(TextureImage2D srcTI,
Rect2i srcRect,
int trgX,
int trgY,
boolean markDirty,
Rect2i dirtyRect)
Draws the given TextureImage2D onto this one and honors the alpha channels (if any). |
|
void |
drawPixelLine(byte[] pixels,
int startX,
int startY,
int length,
boolean markDirty,
Rect2i dirtyRect)
Draws a horizontal line of pixels and combines alpha channels if necessary. |
|
void |
drawString(java.lang.String s,
int x,
int y,
java.awt.geom.Rectangle2D bounds,
java.awt.Font font,
boolean antiAliased,
java.awt.Color color,
boolean markDirty,
Rect2i dirtyRect)
Draws a String at the specified location. |
|
void |
drawString(java.lang.String s,
int x,
int y,
java.awt.geom.Rectangle2D bounds,
java.awt.Font font,
boolean antiAliased,
java.awt.Color color,
TextureImage2D.TextDirection direction,
boolean markDirty,
Rect2i dirtyRect)
Draws a String at the specified location. |
|
void |
fillFullRectangle(java.awt.Color color,
boolean markDirty,
Rect2i dirtyRect)
Fills the complete (used part of the) texture with the specified color and combines alpha channels if necessary. |
|
void |
fillRectangle(java.awt.Color color,
int offsetX,
int offsetY,
int width,
int height,
boolean markDirty,
Rect2i dirtyRect)
Fills the given rectangle with the specified color and combines alpha channels if necessary. |
|
java.awt.image.BufferedImage |
getBufferedImage()
Gets a BufferedImagebacked by this texture's data. |
|
|
getClipRect(Rect2i_ rect)
Gets the currently used clip-rect. |
|
byte[] |
getData()
Gets the backing byte array. |
|
static int |
getFontAscent(java.awt.Font font)
|
|
static int |
getFontDescent(java.awt.Font font)
|
|
int |
getHeight()
Gets the height-part of the texture, that is actually used by the application. |
|
int |
getMaxHeight()
Gets the physical height of the texture. |
|
int |
getMaxWidth()
Gets the physical width of the texture. |
|
java.lang.String |
getName()
|
|
static TextureImage2D |
getOrCreateDrawTexture(int width,
int height,
boolean alpha,
TextureImage2D possibleResult,
boolean usePowerOfTwoSizes)
|
|
byte[] |
getPixel(int x,
int y,
byte[] data)
Gets one pixel. |
|
int |
getPixelBytes()
Gets the number of bytes per pixel (3 or 4). |
|
byte[] |
getPixelLine(int x,
int y,
byte[] data,
int length)
Gets one (part of a) pixel line. |
|
int |
getPixelSize()
Gets the number of bits per pixel (24 or 32). |
|
static java.awt.geom.Rectangle2D |
getStringBounds(java.lang.String s,
java.awt.Font font,
boolean antiAliased)
|
|
static java.awt.geom.Rectangle2D |
getStringBounds(java.lang.String s,
FontProperty font)
|
|
static int |
getStringHeight(java.lang.String s,
java.awt.Font font,
boolean antiAliased)
|
|
static int |
getStringHeight(java.lang.String s,
FontProperty font)
|
|
static int |
getStringWidth(java.lang.String s,
java.awt.Font font,
boolean antiAliased)
|
|
static int |
getStringWidth(java.lang.String s,
FontProperty font)
|
|
Texture2DCanvas |
getTextureCanvas()
Gets the attached Texture2DCanvas. |
|
int |
getWidth()
Gets the width-part of the texture, that is actually used by the application. |
|
boolean |
hasAlphaChannel()
Gets whether this texture has an alpha channel. |
|
boolean |
hasTextureCanvas()
Gets whether this texture has an attached Texture2DCanvas instance. |
|
protected void |
markDirty(int x,
int y,
int width,
int height,
boolean clampClip,
boolean validate,
Rect2i dirtyRect)
|
|
|
markDirty(int x,
int y,
int width,
int height,
Rect2i_ dirtyRect)
Marks a portion of the image component as dirty. |
|
|
markDirty(Rect2i r,
Rect2i_ dirtyRect)
Marks a portion of the image component as dirty. |
|
void |
resize(int width,
int height)
Resizes this texture to a size in range [1,getMaxWidth()],[1,getMaxHeight()]. |
|
void |
setClipRect(int x,
int y,
int width,
int height)
Sets the clip-rect, that will be clipping the drawn pixels. |
|
void |
setClipRect(Rect2i clipRect)
Sets the clip-rect, that will be clipping the drawn pixels. |
|
void |
setName(java.lang.String name)
|
|
protected void |
setPixel(int offset,
byte[] data)
|
|
void |
setPixel(int x,
int y,
byte[] data,
boolean markDirty,
Rect2i dirtyRect)
Sets one pixel. |
|
void |
setPixelLine(int x,
int y,
int length,
byte[] data,
int srcOffset,
boolean markDirty,
Rect2i dirtyRect)
Sets one (part of a) pixel line. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public void setName(java.lang.String name)
public final java.lang.String getName()
public final int getMaxWidth()
public final int getMaxHeight()
public final int getWidth()
public final int getHeight()
public void resize(int width, int height)
width
- the width to resize toheight
- the height to resize topublic final int getPixelBytes()
public final int getPixelSize()
public final boolean hasAlphaChannel()
public final byte[] getData()
public final boolean hasTextureCanvas()
public Texture2DCanvas getTextureCanvas()
protected void markDirty(int x, int y, int width, int height, boolean clampClip, boolean validate, Rect2i dirtyRect)
public final <Rect2i_ extends Rect2i> Rect2i_ markDirty(int x, int y, int width, int height, Rect2i_ dirtyRect)
Rect2i_
- parameter type restrictionx
- the left coordinatey
- the top coordinatewidth
- the widthheight
- the heightdirtyRect
- the dirtyRect to fill, if non null
public final <Rect2i_ extends Rect2i> Rect2i_ markDirty(Rect2i r, Rect2i_ dirtyRect)
Rect2i_
- parameter type restrictionr
- the rectangledirtyRect
- the dirtyRect to fill, if non null
public java.awt.image.BufferedImage getBufferedImage()
protected java.awt.Graphics2D createGraphics2D()
public void setClipRect(int x, int y, int width, int height)
x
- the left coordinatey
- the top coordinatewidth
- the widthheight
- the heightpublic final void setClipRect(Rect2i clipRect)
clipRect
- the clip rectanglepublic final <Rect2i_ extends Rect2i> Rect2i_ getClipRect(Rect2i_ rect)
Rect2i_
- the return and parameter type restrictionrect
- where the rectangle data will be written to.
public final <Rect2i_ extends Rect2i> Rect2i_ clampToClipRect(Rect2i_ rect)
Rect2i_
- the return and parameter type restrictionrect
- the rectangle
protected final void setPixel(int offset, byte[] data)
public final void setPixel(int x, int y, byte[] data, boolean markDirty, Rect2i dirtyRect)
x
- the x-coordinatey
- the y-coordinatedata
- the source pixel datamarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final byte[] getPixel(int x, int y, byte[] data)
x
- the x-coordinatey
- the y-coordinatedata
- the target pixel data
public final void setPixelLine(int x, int y, int length, byte[] data, int srcOffset, boolean markDirty, Rect2i dirtyRect)
x
- the x-cordinate of the starting locationy
- the y-cordinate of the starting locationlength
- the number of pixels to writedata
- the source pixel datasrcOffset
- the offset in the source arraymarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final byte[] getPixelLine(int x, int y, byte[] data, int length)
x
- the x-cordinate of the starting locationy
- the y-cordinate of the starting locationdata
- the target pixel datalength
- the number of pixels to read
public void copyImageDataFrom(java.awt.image.BufferedImage srcImage, int srcX, int srcY, int srcWidth, int srcHeight, int trgX, int trgY, int trgWidth, int trgHeight, boolean overwrite, boolean markDirty, Rect2i dirtyRect)
public final void drawImage(TextureImage2D srcTI, int srcX, int srcY, int srcWidth, int srcHeight, int trgX, int trgY, int trgWidth, int trgHeight, boolean markDirty, Rect2i dirtyRect)
TextureImage2D
onto this one and honors the alpha channels (if any).
srcTI
- source imagesrcX
- the rectangle's left to copy from the source TextureImage2D
.srcY
- the rectangle's top to copy from the source TextureImage2D
.srcWidth
- the rectangle's width to copy from the source TextureImage2D
.srcHeight
- the rectangle's height to copy from the source TextureImage2D
.trgX
- target x-coordinatetrgY
- target y-coordinatetrgWidth
- the targetWidth (tiled or clipped if necessary)trgHeight
- the targetHeight (tiled or clipped if necessary)markDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void drawImage(TextureImage2D srcTI, int srcX, int srcY, int srcWidth, int srcHeight, int trgX, int trgY, boolean markDirty, Rect2i dirtyRect)
TextureImage2D
onto this one and honors the alpha channels (if any).
srcTI
- source imagesrcX
- the rectangle's left to copy from the source TextureImage2D
.srcY
- the rectangle's top to copy from the source TextureImage2D
.srcWidth
- the rectangle's width to copy from the source TextureImage2D
.srcHeight
- the rectangle's height to copy from the source TextureImage2D
.trgX
- target x-coordinatetrgY
- target y-coordinatemarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void drawImage(TextureImage2D srcTI, Rect2i srcRect, int trgX, int trgY, boolean markDirty, Rect2i dirtyRect)
TextureImage2D
onto this one and honors the alpha channels (if any).
srcTI
- source imagesrcRect
- the rectangle to copy from the source TextureImage2D
.trgX
- target x-coordinatetrgY
- target y-coordinatemarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void drawImage(TextureImage2D srcTI, int trgX, int trgY, boolean markDirty, Rect2i dirtyRect)
TextureImage2D
onto this one and honors the alpha channels (if any).
srcTI
- source imagetrgX
- target x-coordinatetrgY
- target y-coordinatemarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic void fillRectangle(java.awt.Color color, int offsetX, int offsetY, int width, int height, boolean markDirty, Rect2i dirtyRect)
color
- the color to fill withoffsetX
- the destination x coordinateoffsetY
- the destination y coordinatewidth
- the destination area widthheight
- the destination area heightmarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void fillFullRectangle(java.awt.Color color, boolean markDirty, Rect2i dirtyRect)
color
- the color to fill withmarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic void drawPixelLine(byte[] pixels, int startX, int startY, int length, boolean markDirty, Rect2i dirtyRect)
pixels
- the pixel data arraystartX
- the x-coordinate of the starting locationstartY
- the y-coordinate of the starting locationlength
- the number of pixels to drawmarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void clear(TextureImage2D srcTI, int srcX, int srcY, int srcWidth, int srcHeight, int trgX, int trgY, int trgWidth, int trgHeight, boolean markDirty, Rect2i dirtyRect)
TextureImage2D
onto this one and simply overwrites anything.
srcTI
- source imagesrcX
- the rectangle's left to copy from the source TextureImage2D
.srcY
- the rectangle's top to copy from the source TextureImage2D
.srcWidth
- the rectangle's width to copy from the source TextureImage2D
.srcHeight
- the rectangle's height to copy from the source TextureImage2D
.trgX
- target x-coordinatetrgY
- target y-coordinatetrgWidth
- the targetWidth (tiled or clipped if necessary)trgHeight
- the targetHeight (tiled or clipped if necessary)markDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void clear(TextureImage2D srcTI, int trgX, int trgY, int trgWidth, int trgHeight, boolean markDirty, Rect2i dirtyRect)
TextureImage2D
onto this one and simply overwrites anything.
srcTI
- source imagetrgX
- target x-coordinatetrgY
- target y-coordinatetrgWidth
- the targetWidth (tiled or clipped if necessary)trgHeight
- the targetHeight (tiled or clipped if necessary)markDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void clear(TextureImage2D srcTI, int srcX, int srcY, int srcWidth, int srcHeight, int trgX, int trgY, boolean markDirty, Rect2i dirtyRect)
TextureImage2D
onto this one and simply overwrites anything.
srcTI
- source imagesrcX
- the rectangle's left to copy from the source TextureImage2D
.srcY
- the rectangle's top to copy from the source TextureImage2D
.srcWidth
- the rectangle's width to copy from the source TextureImage2D
.srcHeight
- the rectangle's height to copy from the source TextureImage2D
.trgX
- target x-coordinatetrgY
- target y-coordinatemarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void clear(TextureImage2D srcTI, Rect2i srcRect, int trgX, int trgY, boolean markDirty, Rect2i dirtyRect)
TextureImage2D
onto this one and simply overwrites anything.
srcTI
- source imagesrcRect
- the rectangle to copy from the source TextureImage2D
.trgX
- target x-coordinatetrgY
- target y-coordinatemarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void clear(TextureImage2D srcTI, int trgX, int trgY, boolean markDirty, Rect2i dirtyRect)
TextureImage2D
onto this one and simply overwrites anything.
srcTI
- source imagetrgX
- target x-coordinatetrgY
- target y-coordinatemarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void clear(TextureImage2D srcTI, boolean markDirty, Rect2i dirtyRect)
TextureImage2D
onto this one and simply overwrites anything.
srcTI
- source imagemarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic void clearOutline(java.awt.Color color, int offsetX, int offsetY, int width, int height, int lineWidth, boolean markDirty, Rect2i dirtyRect)
color
- the color to draw withoffsetX
- the destination x coordinateoffsetY
- the destination y coordinatewidth
- the destination area widthheight
- the destination area heightlineWidth
- the width of the outlinemarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic void clear(java.awt.Color color, int offsetX, int offsetY, int width, int height, boolean markDirty, Rect2i dirtyRect)
color
- the color to clear withoffsetX
- the destination x coordinateoffsetY
- the destination y coordinatewidth
- the destination area widthheight
- the destination area heightmarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void clear(java.awt.Color color, boolean markDirty, Rect2i dirtyRect)
color
- the color to clear withmarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void clear(int offsetX, int offsetY, int width, int height, boolean markDirty, Rect2i dirtyRect)
offsetX
- the destination x coordinateoffsetY
- the destination y coordinatewidth
- the destination area widthheight
- the destination area heightmarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic final void clear(boolean markDirty, Rect2i dirtyRect)
markDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic void clearPixelLine(byte[] pixels, int startX, int startY, int length, boolean markDirty, Rect2i dirtyRect)
pixels
- the pixel datastartX
- the x-coordinate of the starting locationstartY
- the y-coordinate of the starting locationlength
- the number of pixels to clearmarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic static final java.awt.geom.Rectangle2D getStringBounds(java.lang.String s, java.awt.Font font, boolean antiAliased)
public static final java.awt.geom.Rectangle2D getStringBounds(java.lang.String s, FontProperty font)
public static final int getStringWidth(java.lang.String s, java.awt.Font font, boolean antiAliased)
public static final int getStringWidth(java.lang.String s, FontProperty font)
public static final int getStringHeight(java.lang.String s, java.awt.Font font, boolean antiAliased)
public static final int getStringHeight(java.lang.String s, FontProperty font)
public static final int getFontAscent(java.awt.Font font)
public static final int getFontDescent(java.awt.Font font)
public void drawString(java.lang.String s, int x, int y, java.awt.geom.Rectangle2D bounds, java.awt.Font font, boolean antiAliased, java.awt.Color color, boolean markDirty, Rect2i dirtyRect)
s
- the String to drawx
- the x-positiony
- the y-position of the String's baselinebounds
- the String's bounds. If null, bounds will be created temporarilyfont
- the Font to useantiAliased
- anti aliased font?color
- the Color to usemarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic void drawString(java.lang.String s, int x, int y, java.awt.geom.Rectangle2D bounds, java.awt.Font font, boolean antiAliased, java.awt.Color color, TextureImage2D.TextDirection direction, boolean markDirty, Rect2i dirtyRect)
s
- the String to drawx
- the x-positiony
- the y-position of the String's baselinebounds
- the String's bounds. If null, bounds will be created temporarilyfont
- the Font to useantiAliased
- anti aliased font?color
- the Color to usedirection
- the text directionmarkDirty
- if true, the pixel is marked dirtydirtyRect
- if non null, the dirty rect is written to this instancepublic static TextureImage2D createDrawTexture(int maxWidth, int maxHeight, int usedWidth, int usedHeight, boolean alpha)
public static TextureImage2D createDrawTexture(int width, int height, boolean alpha)
public static TextureImage2D getOrCreateDrawTexture(int width, int height, boolean alpha, TextureImage2D possibleResult, boolean usePowerOfTwoSizes)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |