GF4J 0.9.4 Beta

gameframe.engines.jdk12x
Class CComponentGraphicsEngine

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Canvas
              |
              +--gameframe.engines.jdk12x.CComponentGraphicsEngine
All Implemented Interfaces:
javax.accessibility.Accessible, Finalizable, GraphicsEngine, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class CComponentGraphicsEngine
extends java.awt.Canvas
implements GraphicsEngine, java.awt.image.ImageObserver, Finalizable

Java 2 AWT implementation of the graphics engine. For some odd reason this works only if the component is Canvas object.

Since:
GameFrame for Java 0.9
Version:
GameFrame for Java 0.9.3
See Also:
Serialized Form

Inner Class Summary
(package private)  class CComponentGraphicsEngine.CBitmap
          Implementation of the bitmap image for plain Java 2 graphics engine.
(package private)  class CComponentGraphicsEngine.CClippedBitmap
          Implementation of the bitmap image for plain Java 2 graphics engine.
(package private)  class CComponentGraphicsEngine.CDrawableBitmap
          Implementation of the drawable bitmap image for plain Java 2 graphics engine.
 
Inner classes inherited from class java.awt.Canvas
java.awt.Canvas.AccessibleAWTCanvas
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
private  Bitmap[] m_aFonts
          Bitmaps of the fonts.
private  java.awt.Image m_backBuffer
          The offscreen image used for double buffering.
private  java.awt.Graphics2D m_backBufferGraphics
          The graphics context of the current offscreen buffer.
private  java.awt.Color m_backgroundColor
          The color that is used when painting the backbuffer in the clear operation.
private  java.awt.Graphics2D m_componentGraphics
          The graphics context of the component.
private  java.util.Vector m_createdBitmaps
          All the bitmaps created through this graphics engine.
private  java.util.Vector m_createdDrawableBitmaps
          All the drawable bitmaps created through this graphics engine.
private  boolean m_fIsNotified
          Indicates if this frame has been addNotified.
private  Bitmap m_fontBitmap
          The bitmap that contains all the letters in the current font.
private  java.awt.Image m_frontBuffer
          The image that is shown on the screen upon repaint.
private  java.awt.Graphics2D m_frontBufferGraphics
          The graphics context of the image shown on the screen.
private  int m_height
          Height of this frame.
private  int m_letterHeight
          Height of all the letters in the font bitmap.
private  int m_letterWidth
          Width of all the letters in the font bitmap.
private  java.lang.String m_strDataDirectory
          Name of the directory that contains loaded bitmaps.
private  int m_width
          Width of this frame.
private static CComponentGraphicsEngine mStatic_graphicsEngine
          The singleton instance of this graphics engine.
private static java.util.Hashtable mStatic_graphicsSettings
          The graphics settings that are set to every graphics object.
private  java.awt.Dimension mStatic_size
          The size of this component.
 
Fields inherited from class java.awt.Canvas
base, nameCounter, serialVersionUID
 
Fields inherited from class java.awt.Component
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dbg, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, graphicsConfig, hasFocus, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, privateKey, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, width, windowClosingException, windowListenerK, visible, x, y
 
Fields inherited from interface gameframe.graphics.GraphicsEngine
ALL_COLOURDEPTHS, COLOURDEPTH_16BITS, COLOURDEPTH_24BITS, COLOURDEPTH_32BITS, DEFAULT_COLOURDEPTH, DEFAULT_TITLE, NO_PREFERRED_REFRESHRATE
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
private CComponentGraphicsEngine(GameFrameSettings settings)
          The default constructor that calls the superclass constructor that sets the title of the frame to "GameFrame" and sets the created frame to be non-resizable.
 
Method Summary
(package private) static void ()
           
 void addNotify()
          Invoked when the peer has been created for this frame.
 void clearBackbuffer()
          Clears the backbuffer with the current backround color.
 void copyArea(int x, int y, int width, int height, int dx, int dy)
          Moves by copying a rectangular area of the backbuffer by a distance specified by dx and dy.
private  CComponentGraphicsEngine.CBitmap createAlphaBitmap(int width, int height)
          Creates an alpha bitmap of the given size.
 void drawTextAt(byte[] aByteText, int x, int y)
          Prints the given string to the screen so that the uppermost and leftmost coordinate of the text is at the given location.
 void drawTextAt(java.lang.String strText, int x, int y)
          Prints the given one line of text to the screen so that the uppermost and leftmost coordinate of the text is at the given location.
 void finalize()
          Invoked when the program exiting.
 void flip()
          Switches the backbuffer and the currently displayed buffer.
 DrawableBitmap getAsBitmap(byte[] aByteText)
          Returns the given one line of text as an bitmap that is painted using the current font.
 DrawableBitmap getAsBitmap(java.lang.String strText)
          Returns the given one line of text as an bitmap that is painted using the current font.
 java.lang.String getDataDirectory()
          Returns the data directory wherefrom the bitmaps are loaded.
 java.lang.String getDescription()
          Returns the (possibly multiline) description of the implementation.
 DrawableBitmap getDrawableBitmap(int width, int height)
          Creates a non-transparent bitmap (the color is set to the current background color) that can be drawn into with other bitmaps.
 int getFontHeight()
          Returns the current font height.
 int getFontWidth()
          Returns the current font width.
(package private) static CComponentGraphicsEngine getInstance(GameFrameSettings settings)
          Returns an instance of this class.
 java.awt.Dimension getMaximumSize()
          Returns the maximum size of this component graphics engine.
 java.awt.Dimension getMinimumSize()
          Returns the minimum size of this component graphics engine.
 java.lang.String getName()
          Returns the short name (max 8 characters) of the implementation "Java2".
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of this component graphics engine.
 java.awt.Dimension getSize()
          Returns the size of the display area that this engine uses.
 int getTextWidth(byte[] aByteText)
          Returns the given one line of text's width when we are using the current font bitmap.
 int getTextWidth(java.lang.String strText)
          Returns the given one line of text's width when we are using the current font bitmap.
(package private)  boolean isAddNotified()
          This method is used by the graphics engine to wait until this frame has been add notified.
 boolean isFocusTraversable()
          Returns true, which means this component is focus traversable with TAB and SHIFT-TAB keys.
 boolean isInFullscreenMode()
          Returns false as this engine is allways in windowed mode.
 boolean isOpaque()
          Overridden to allways return true.
 Bitmap loadAlphaBitmap(java.lang.String strFileName)
          Load a bitmap (used bitmap format is Windows BMP, alpha keycolor is set to the pixel color at bitmap location 0,0 which is the pixel at upper left corner of the bitmap)from the given file and return an abstract reference for the loaded bitmap.
 Bitmap loadAlphaBitmap(java.lang.String strFileName, byte red, byte green, byte blue)
          Loads and returns a transparent bitmap (used bitmap format is Windows BMP 8-bit, 16-bit or 24-bit) from the given filename.
 Bitmap loadBitmap(java.lang.String strFileName)
          Load a bitmap (used bitmap format is Windows BMP, no alpha values are loaded) from the given file and return an abstract reference for the loaded bitmap.
 void loadDefaultFontBitmap()
          Loads the default font bitmap that is used when printing text on the screen.
 void loadFontBitmap(java.lang.String strFileName)
          Sets the used font set to be loaded from the given strFileName using the specified fixed size for every letter.
 void paint(java.awt.Graphics grfx)
          Overrides the java.awt.Component's method to just draw the current frontbuffer to the screen.
 void setBackgroundColor(java.awt.Color color)
          Sets the currently used background color (defaults to Color.black).
 void setDataDirectory(java.lang.String strDirectoryName)
          Sets the data directory wherefrom the bitmaps are loaded.
 void setTitle(java.lang.String title)
          Sets the title of the window (if in windowed mode).
 void update(java.awt.Graphics grfx)
          Overrides the java.awt.Component's method to just draw the current frontbuffer to the screen.
 
Methods inherited from class java.awt.Canvas
constructComponentName, getAccessibleContext, postsOldMouseEvents
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkGD, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createChildHierarchyEvents, createHierarchyEvents, createImage, createImage, deliverEvent, disable, disableEvents, dispatchEvent, dispatchEventImpl, doLayout, enable, enable, enableEvents, enableInputMethods, eventEnabled, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getInputContext, getInputMethodRequests, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getToolkit, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, initIDs, inside, invalidate, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isLightweight, isRecursivelyVisible, isShowing, isValid, isVisible, keyDown, keyUp, layout, lightweightPaint, lightweightPrint, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, numListening, paintAll, paintHeavyweightComponents, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, printHeavyweightComponents, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, readObject, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, resetGC, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFont, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, validate, writeObject
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 
Methods inherited from interface java.awt.image.ImageObserver
imageUpdate
 

Field Detail

mStatic_graphicsEngine

private static CComponentGraphicsEngine mStatic_graphicsEngine
The singleton instance of this graphics engine.

mStatic_size

private java.awt.Dimension mStatic_size
The size of this component.

m_createdBitmaps

private java.util.Vector m_createdBitmaps
All the bitmaps created through this graphics engine.

m_createdDrawableBitmaps

private java.util.Vector m_createdDrawableBitmaps
All the drawable bitmaps created through this graphics engine.

m_strDataDirectory

private java.lang.String m_strDataDirectory
Name of the directory that contains loaded bitmaps.

m_backgroundColor

private java.awt.Color m_backgroundColor
The color that is used when painting the backbuffer in the clear operation.

m_backBuffer

private java.awt.Image m_backBuffer
The offscreen image used for double buffering.

m_backBufferGraphics

private java.awt.Graphics2D m_backBufferGraphics
The graphics context of the current offscreen buffer.

m_frontBuffer

private java.awt.Image m_frontBuffer
The image that is shown on the screen upon repaint.

m_frontBufferGraphics

private java.awt.Graphics2D m_frontBufferGraphics
The graphics context of the image shown on the screen.

m_componentGraphics

private java.awt.Graphics2D m_componentGraphics
The graphics context of the component.

m_fIsNotified

private boolean m_fIsNotified
Indicates if this frame has been addNotified.

m_width

private int m_width
Width of this frame.

m_height

private int m_height
Height of this frame.

m_fontBitmap

private Bitmap m_fontBitmap
The bitmap that contains all the letters in the current font.

m_letterWidth

private int m_letterWidth
Width of all the letters in the font bitmap.

m_letterHeight

private int m_letterHeight
Height of all the letters in the font bitmap.

m_aFonts

private Bitmap[] m_aFonts
Bitmaps of the fonts.

mStatic_graphicsSettings

private static java.util.Hashtable mStatic_graphicsSettings
The graphics settings that are set to every graphics object.
Constructor Detail

CComponentGraphicsEngine

private CComponentGraphicsEngine(GameFrameSettings settings)
The default constructor that calls the superclass constructor that sets the title of the frame to "GameFrame" and sets the created frame to be non-resizable.
Parameters:
parentFrame - The frame to be used as the parent for the game window.
settings - The settings object that contains settings for this graphics engine.
Method Detail

static void ()

getInstance

static CComponentGraphicsEngine getInstance(GameFrameSettings settings)
Returns an instance of this class. The instance is a window that has the given title and size.
Parameters:
settings - The settings object that contains settings for this graphics engine.

getName

public java.lang.String getName()
Returns the short name (max 8 characters) of the implementation "Java2".
Specified by:
getName in interface GraphicsEngine
Overrides:
getName in class java.awt.Component
Returns:
The short name of the graphics engine.
Since:
GameFrame for Java 0.9.3

getDescription

public java.lang.String getDescription()
Returns the (possibly multiline) description of the implementation.
Specified by:
getDescription in interface GraphicsEngine
Returns:
A description of the graphics engine.
Since:
GameFrame for Java 0.9.3

isAddNotified

boolean isAddNotified()
This method is used by the graphics engine to wait until this frame has been add notified.
Returns:
True if the frames peer is created.

loadBitmap

public Bitmap loadBitmap(java.lang.String strFileName)
                  throws java.io.FileNotFoundException,
                         GameFrameException
Load a bitmap (used bitmap format is Windows BMP, no alpha values are loaded) from the given file and return an abstract reference for the loaded bitmap. Bitmap is loaded from the bitmap resource directory specified by MainFactory.
Specified by:
loadBitmap in interface GraphicsEngine
Parameters:
strFileName - The name of the file to be loaded (without the file extension).
Returns:
An unique Bitmap object that represents the loaded bitmap image.

loadAlphaBitmap

public Bitmap loadAlphaBitmap(java.lang.String strFileName)
                       throws java.io.FileNotFoundException,
                              GameFrameException
Load a bitmap (used bitmap format is Windows BMP, alpha keycolor is set to the pixel color at bitmap location 0,0 which is the pixel at upper left corner of the bitmap)from the given file and return an abstract reference for the loaded bitmap. Bitmap is loaded from the bitmap resource directory specified by MainFactory.
Specified by:
loadAlphaBitmap in interface GraphicsEngine
Parameters:
strFileName - The name of the file to be loaded (without the file extension).
Returns:
An unique Bitmap object that represents the loaded bitmap image.

loadAlphaBitmap

public Bitmap loadAlphaBitmap(java.lang.String strFileName,
                              byte red,
                              byte green,
                              byte blue)
                       throws java.io.FileNotFoundException,
                              GameFrameException
Loads and returns a transparent bitmap (used bitmap format is Windows BMP 8-bit, 16-bit or 24-bit) from the given filename. Bitmap is loaded by default from the current data directory, the directory that is used to load the bitmaps can be set with the setDataDirectory() method. Alpha keycolor (the color that is interpreted as the transparent color) is taken from the given red, green and blue values. If the bitmap is larger than current resolution it will be clipped to the dimensions of the current resolution.
Specified by:
loadAlphaBitmap in interface GraphicsEngine
Parameters:
strFileName - The name of the file to be loaded (without the file extension).
red - The red intensity value of the key color (in range 0x00-0xFF).
green - The green intensity value of the key color (in range 0x00-0xFF).
blue - The blue intensity value of the key color (in range 0x00-0xFF).
Returns:
Bitmap object that represents the loaded bitmap image or null if the loading failed.
Throws:
java.io.FileNotFoundException - Thrown if the given file doesn't exist.
GameFrameException - Thrown if other error occur while loading the file.
Since:
GameFrame for Java 0.9

getDrawableBitmap

public DrawableBitmap getDrawableBitmap(int width,
                                        int height)
                                 throws GameFrameException
Creates a non-transparent bitmap (the color is set to the current background color) that can be drawn into with other bitmaps. If the creation of the bitmap fails this method returns null.
Specified by:
getDrawableBitmap in interface GraphicsEngine
Parameters:
width - The width of the bitmap.
height - The height of the bitmap
Returns:
The created bitmap or null if failed to create.

createAlphaBitmap

private CComponentGraphicsEngine.CBitmap createAlphaBitmap(int width,
                                                           int height)
                                                    throws GameFrameException
Creates an alpha bitmap of the given size.
Parameters:
width - The width of the alpha bitmap.
height - The height of the alpha bitmap.

copyArea

public void copyArea(int x,
                     int y,
                     int width,
                     int height,
                     int dx,
                     int dy)
Moves by copying a rectangular area of the backbuffer by a distance specified by dx and dy. From the point specified by x and y, this method moves downwards and to the right. To move an area of the component to the left or upwards, specify a negative value for dx or dy. If a portion of the source rectangle lies outside the bounds of the component moveArea will be unable to move the associated pixels.
Parameters:
x - The x-coordinate of the source rectangle.
y - The y-coordinate of the source rectangle.
width - The width of the source rectangle.
height - The height of the source rectangle.
dx - The horizontal distance to copy the pixels.
dy - The vertical distance to copy the pixels.

flip

public void flip()
Switches the backbuffer and the currently displayed buffer.
Specified by:
flip in interface GraphicsEngine

clearBackbuffer

public void clearBackbuffer()
Clears the backbuffer with the current backround color. All exceptions are held inside this method.
Specified by:
clearBackbuffer in interface GraphicsEngine
Following copied from interface: gameframe.graphics.GraphicsEngine
See Also:
GraphicsEngine.setBackgroundColor(java.awt.Color)

setDataDirectory

public void setDataDirectory(java.lang.String strDirectoryName)
                      throws java.io.FileNotFoundException
Sets the data directory wherefrom the bitmaps are loaded. Defaults to the current directory. Do not add the last directory separator.
Specified by:
setDataDirectory in interface GraphicsEngine
Parameters:
strDirectoryName - The name of the directory that contains the bitmaps.
Throws:
java.io.FileNotFoundException - Thrown if the data directory doesn't exist.

getDataDirectory

public java.lang.String getDataDirectory()
Returns the data directory wherefrom the bitmaps are loaded. The source directory defaults to the current directory. Note: The returned path will have the path separator as the last character.
Specified by:
getDataDirectory in interface GraphicsEngine
Returns:
The name of the directory that wherefrom the bitmaps are loaded.
Since:
GameFrame for Java 0.9.3
See Also:
loadBitmap(java.lang.String), loadAlphaBitmap(java.lang.String)

isInFullscreenMode

public boolean isInFullscreenMode()
Returns false as this engine is allways in windowed mode.
Specified by:
isInFullscreenMode in interface GraphicsEngine
Returns:
False as the engine is allways in windowed mode.

update

public void update(java.awt.Graphics grfx)
Overrides the java.awt.Component's method to just draw the current frontbuffer to the screen.
Overrides:
update in class java.awt.Component
Parameters:
grfx - The graphics context used in drawing.

paint

public void paint(java.awt.Graphics grfx)
Overrides the java.awt.Component's method to just draw the current frontbuffer to the screen.
Overrides:
paint in class java.awt.Canvas
Parameters:
grfx - The graphics context used in drawing.

setBackgroundColor

public void setBackgroundColor(java.awt.Color color)
Sets the currently used background color (defaults to Color.black).
Specified by:
setBackgroundColor in interface GraphicsEngine
Following copied from interface: gameframe.graphics.GraphicsEngine
See Also:
GraphicsEngine.clearBackbuffer()

getSize

public java.awt.Dimension getSize()
Returns the size of the display area that this engine uses. For fullscreen modes it is the size of the fullscreen mode. For windowed modes the size is size of the window.
Specified by:
getSize in interface GraphicsEngine
Overrides:
getSize in class java.awt.Component
Returns:
The size of the display area.

getMaximumSize

public java.awt.Dimension getMaximumSize()
Returns the maximum size of this component graphics engine. The values are gotten from the GameFrameSettings object.
Overrides:
getMaximumSize in class java.awt.Component
Returns:
The user set width and height of this component.

getMinimumSize

public java.awt.Dimension getMinimumSize()
Returns the minimum size of this component graphics engine. The values are gotten from the GameFrameSettings object.
Overrides:
getMinimumSize in class java.awt.Component
Returns:
The user set width and height of this component.

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of this component graphics engine. The values are gotten from the GameFrameSettings object.
Overrides:
getPreferredSize in class java.awt.Component
Returns:
The user set width and height of this component.

isFocusTraversable

public boolean isFocusTraversable()
Returns true, which means this component is focus traversable with TAB and SHIFT-TAB keys.
Overrides:
isFocusTraversable in class java.awt.Component
Returns:
True.

isOpaque

public boolean isOpaque()
Overridden to allways return true.
Overrides:
isOpaque in class java.awt.Component
Returns:
True.

finalize

public void finalize()
Invoked when the program exiting. Should do any necessary clean up, switch back to desktop etc.
Specified by:
finalize in interface Finalizable
Overrides:
finalize in class java.lang.Object

setTitle

public void setTitle(java.lang.String title)
Sets the title of the window (if in windowed mode).
Parameters:
title - The title of the window.

loadDefaultFontBitmap

public void loadDefaultFontBitmap()
                           throws java.io.FileNotFoundException,
                                  GameFrameException
Loads the default font bitmap that is used when printing text on the screen. Either this method or the setFontBitmap method must be called before using any of the getAsString() or drawTextAt() methods.
Specified by:
loadDefaultFontBitmap in interface GraphicsEngine
Following copied from interface: gameframe.graphics.GraphicsEngine
Throws:
java.io.FileNotFoundException - Thrown if the default font bitmap can't be found.
GameFrameException - Thrown if other errors occur while loading the default font bitmap.
See Also:
GraphicsEngine.loadFontBitmap(java.lang.String), GraphicsEngine.getAsBitmap(java.lang.String), GraphicsEngine.getAsBitmap(byte[]), GraphicsEngine.drawTextAt(java.lang.String, int, int), GraphicsEngine.drawTextAt(byte[], int, int)

loadFontBitmap

public void loadFontBitmap(java.lang.String strFileName)
                    throws java.io.FileNotFoundException,
                           GameFrameException
Sets the used font set to be loaded from the given strFileName using the specified fixed size for every letter. The strFileName must specify a window BMP formatted bitmap that is then loaded as transparent (alpha) bitmap and is then divided in pieces that represent one letter each piece. The order in the bitmap must use the standard ASCII letter order (can be obtained by running the PrintFontOrder class in the GameFrame.Util package) and it must contain 16 columns of letters in 16 rows (that is a 16x16 matrix of letters = 256 letters in whole). If a nonexisting bitmap or fontbitmap of invalid size is used, the method will do nothing. Either this method or the setDefaultFontBitmap method must be called before using any of the getAsString() or drawTextAt() methods.
Specified by:
loadFontBitmap in interface GraphicsEngine
Parameters:
strFileName - Name of the bitmap file that contains the letters.

getTextWidth

public int getTextWidth(java.lang.String strText)
Returns the given one line of text's width when we are using the current font bitmap. The method doesn't take into account possible clipping to current screen size.
Specified by:
getTextWidth in interface GraphicsEngine
Parameters:
strText - The text that is written using the current font.
Returns:
The width of the given text.
Since:
GameFrame for Java 0.9.3
See Also:
loadDefaultFontBitmap(), loadFontBitmap(java.lang.String)

getTextWidth

public int getTextWidth(byte[] aByteText)
Returns the given one line of text's width when we are using the current font bitmap.
Specified by:
getTextWidth in interface GraphicsEngine
Parameters:
aByteText - The byte array containing the text to be measured.
Returns:
The width of the given text.
Since:
GameFrame for Java 0.9.3
See Also:
loadDefaultFontBitmap(), loadFontBitmap(java.lang.String)

getFontWidth

public int getFontWidth()
Returns the current font width.
Specified by:
getFontWidth in interface GraphicsEngine
Since:
GameFrame for Java 0.9.3
See Also:
loadDefaultFontBitmap(), loadFontBitmap(java.lang.String)

getFontHeight

public int getFontHeight()
Returns the current font height.
Specified by:
getFontHeight in interface GraphicsEngine
Since:
GameFrame for Java 0.9.3
See Also:
loadDefaultFontBitmap(), loadFontBitmap(java.lang.String)

getAsBitmap

public DrawableBitmap getAsBitmap(java.lang.String strText)
                           throws GameFrameException
Returns the given one line of text as an bitmap that is painted using the current font. The returned bitmap will have the background color set to the current background color of the graphics engine. This means also that the returned bitmap is never transparent (due to limitations on some platforms).
Specified by:
getAsBitmap in interface GraphicsEngine
Parameters:
strText - The text that is written using the current font.
Returns:
The text as bitmap or null if not successfull.

getAsBitmap

public DrawableBitmap getAsBitmap(byte[] aByteText)
                           throws GameFrameException
Returns the given one line of text as an bitmap that is painted using the current font.
Specified by:
getAsBitmap in interface GraphicsEngine
Parameters:
aByteText - The byte array containing the text to be printed.
Returns:
The text as bitmap or null if not successfull.

drawTextAt

public void drawTextAt(java.lang.String strText,
                       int x,
                       int y)
                throws GameFrameException
Prints the given one line of text to the screen so that the uppermost and leftmost coordinate of the text is at the given location.
Specified by:
drawTextAt in interface GraphicsEngine
Parameters:
strText - The text that is written using the current font.
x - The leftmost x-coordinate for the text.
y - The topmost y-coordinate for the text.

drawTextAt

public void drawTextAt(byte[] aByteText,
                       int x,
                       int y)
                throws GameFrameException
Prints the given string to the screen so that the uppermost and leftmost coordinate of the text is at the given location.
Specified by:
drawTextAt in interface GraphicsEngine
Parameters:
aByteText - The byte array containing the text to be printed.
x - The leftmost x-coordinate for the text.
y - The topmost y-coordinate for the text.

addNotify

public void addNotify()
Invoked when the peer has been created for this frame.
Overrides:
addNotify in class java.awt.Canvas

GF4J 0.9.4 Beta