public class TextImageStore
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
TextImageStore.Glyph
A Glyph, with an associated GlyphVector from which it came.
|
static class |
TextImageStore.GlyphLoc |
static class |
TextImageStore.GlyphStore
Glyph with storage location in backed image
|
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG |
Constructor and Description |
---|
TextImageStore(RectanglePacker packer,
boolean antialiasing) |
Modifier and Type | Method and Description |
---|---|
void |
clear()
Clears the backing image, increments the storage Id so that any existing
external storage glyphs become invalid
|
static javax.swing.JFrame |
createDisplayFrame(TextImageStore store) |
TextImageStore.Glyph[] |
createGlyphs(java.awt.font.GlyphVector glyphvec,
TextImageStore.Glyph[] out)
Creates an array of Glyphs, each containing identifying information, as
well as location information, so they can be processed glyph by glyph.
|
TextImageStore.Glyph[] |
createGlyphs(java.lang.String str,
TextImageStore.Glyph[] out)
Creates an array of Glyphs, each containing identifying information, as
well as location information, so they can be processed glyph by glyph.
|
java.awt.font.GlyphVector |
createGlyphVector(java.awt.Font font,
java.lang.String str)
Creates a glyph vector using the current font and image context
|
java.awt.font.GlyphVector |
createGlyphVector(java.lang.String str)
Creates a glyph vector using the current font and image context
|
TextImageStore.GlyphStore |
get(TextImageStore.Glyph glyph)
Checks to see if the glyph is already in the backing image, returning the
storage information if present, or null otherwise.
|
void |
getData(java.nio.ByteBuffer out)
Retrieves image data for the entire backing array, rasterized row-major
with pixels starting at bottom-left of image
|
void |
getData(Rectangle region,
java.nio.ByteBuffer out)
Retrieves all bytes for the given region in a rasterized way, row-major,
starting with bottom left.
|
Rectangle |
getDirty()
Get the region marked as dirty
|
Rectangle |
getDirtyData(java.nio.ByteBuffer out)
Get bytes from the dirty region in a rasterized way, row-major, starting
with bottom-left;
|
java.awt.Font |
getFont() |
java.awt.FontMetrics |
getFontMetrics() |
java.awt.FontMetrics |
getFontMetrics(java.awt.Font font) |
java.awt.Graphics2D |
getGraphics() |
int |
getHeight()
Height of image
|
java.awt.image.BufferedImage |
getImage()
The backing image
|
int |
getImageType()
Type of image
|
int |
getPixelSize()
Size of a pixel in bytes
|
int |
getStorageId()
ID for identifying valid glyph stores.
|
int |
getStorageVersion()
Version number for checking if backing image has been updated
|
int |
getWidth()
Width of image
|
boolean |
isValid(TextImageStore.GlyphStore storage)
Checks whether glyph storage is still valid
|
static void |
main(java.lang.String[] args) |
void |
markClean()
Mark the dirty region as now cleaned
|
void |
markDirty(Rectangle rect)
Mark a region of the backing image as "dirty" (i.e.
|
void |
saveImage(java.lang.String type,
java.io.File dest)
Save backing image to a file (convenience method)
|
void |
setAntialiasing(boolean set)
Enable or disable antialiasing in the graphics pipeline
|
void |
setFont(java.awt.Font font) |
boolean |
upload(java.awt.font.GlyphVector vec)
Attempts to upload glyphs for an entire string.
|
boolean |
upload(java.lang.String str)
Attempts to upload glyphs for an entire string.
|
TextImageStore.GlyphStore |
upload(TextImageStore.Glyph glyph)
Attempts to store a glyph into the backing image store, returning the
storage information.
|
public TextImageStore(RectanglePacker packer, boolean antialiasing)
public void setFont(java.awt.Font font)
public java.awt.Font getFont()
public java.awt.FontMetrics getFontMetrics(java.awt.Font font)
public java.awt.FontMetrics getFontMetrics()
public void setAntialiasing(boolean set)
public TextImageStore.Glyph[] createGlyphs(java.lang.String str, TextImageStore.Glyph[] out)
str
- input stringout
- array to populate, or null to create a new arraypublic java.awt.font.GlyphVector createGlyphVector(java.lang.String str)
public java.awt.font.GlyphVector createGlyphVector(java.awt.Font font, java.lang.String str)
public TextImageStore.Glyph[] createGlyphs(java.awt.font.GlyphVector glyphvec, TextImageStore.Glyph[] out)
glyphvec
- glyph vectorout
- array to populate, or null to create a new arraypublic TextImageStore.GlyphStore get(TextImageStore.Glyph glyph)
public boolean upload(java.lang.String str)
public java.awt.Graphics2D getGraphics()
public boolean upload(java.awt.font.GlyphVector vec)
public void markDirty(Rectangle rect)
public Rectangle getDirtyData(java.nio.ByteBuffer out)
out
- buffer to fill with RGBA bytespublic void getData(Rectangle region, java.nio.ByteBuffer out)
region
- pixel region from which to obtain bytesout
- buffer to fill with RGBA bytespublic void getData(java.nio.ByteBuffer out)
out
- buffer to fill with contentpublic int getPixelSize()
public int getImageType()
BufferedImage.getType()
public int getWidth()
public int getHeight()
public Rectangle getDirty()
public void markClean()
public TextImageStore.GlyphStore upload(TextImageStore.Glyph glyph)
RectanglePacker
will
attempt to place the glyph in the backing store.glyph
- glyph to try to upload to the backing store (if not already present)public void saveImage(java.lang.String type, java.io.File dest)
public java.awt.image.BufferedImage getImage()
public void clear()
public int getStorageId()
public boolean isValid(TextImageStore.GlyphStore storage)
public int getStorageVersion()
public static javax.swing.JFrame createDisplayFrame(TextImageStore store)
public static void main(java.lang.String[] args) throws java.lang.Exception
java.lang.Exception