|
GF4J 0.9.4 Beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Defines an interface to a graphics engine that can be thought to be a "display device". The graphics engine uses double buffering and offers a few methods for loading a bitmap in Windows BMP (8-bit, 16-bit or 24-bit) format, handling the double buffering, converting text strings to bitmap representations and drawing text strings directly.
Note: The actual implementation is recommended to use double buffering if such is available, if no such feature is available backbuffering can be omitted. In the case double buffering is not available all operations affect the one and only displayed buffer and the flip() method does nothing.
Note2: The graphics engine will not create bitmaps larger than the currently used resolution. If you try to create larger bitmaps they are allways automatically clipped to have the maximum width and/or height. This is due to limitations in some platforms and those limitations must be forced to every implementation to make the library work uniformly in all platforms. Writing code to handle this internally by the GameFrame library (by dividing the bitmaps to smaller ones) is too big of a task (at least for the time being).
Bitmap
,
DrawableBitmap
Field Summary | |
static int[] |
ALL_COLOURDEPTHS
All supported colour depths. |
static int |
COLOURDEPTH_16BITS
Constant for 16-bits colour depth. |
static int |
COLOURDEPTH_24BITS
Constant for 24-bits colour depth. |
static int |
COLOURDEPTH_32BITS
Constant for 32-bits colour depth. |
static int |
DEFAULT_COLOURDEPTH
Constant for default colour depth when none is set by the user. |
static java.lang.String |
DEFAULT_TITLE
Constant that is set as the default title for all graphics engine windows. |
static int |
NO_PREFERRED_REFRESHRATE
Constant for refreshrate when there is no preferred refresh rate. |
Method Summary | |
void |
clearBackbuffer()
Paints the current backbuffer with the current backround color. |
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)
Draws the given string to the screen so that the uppermost and leftmost coordinate of the text is at the given location. |
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. |
java.lang.String |
getName()
Returns the short name (max 8 characters) of the implementation e.g. |
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. |
boolean |
isInFullscreenMode()
Returns true if the engine is in fullscreen mode, false if in windowed mode. |
Bitmap |
loadAlphaBitmap(java.lang.String fileName)
Loads and returns a transparent bitmap (used bitmap format is Windows BMP 8-bit, 16-bit or 24-bit) from the given filename. |
Bitmap |
loadAlphaBitmap(java.lang.String fileName,
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 fileName)
Loads and returns a non-transparent bitmap (used bitmap format is Windows BMP 8-bit, 16-bit or 24-bit) from the given filename. |
void |
loadDefaultFontBitmap()
Loads the default font bitmap that is used when printing text on the screen. |
void |
loadFontBitmap(java.lang.String filename)
Loads and sets the used font set to be loaded from the given filename using a calculated fixed size for every letter. |
void |
setBackgroundColor(java.awt.Color color)
Sets the currently used background color (which defaults to Color.black). |
void |
setDataDirectory(java.lang.String strDirectoryName)
Sets the data directory wherefrom the bitmaps are loaded. |
Field Detail |
public static final java.lang.String DEFAULT_TITLE
public static final int NO_PREFERRED_REFRESHRATE
public static final int COLOURDEPTH_16BITS
public static final int COLOURDEPTH_24BITS
public static final int COLOURDEPTH_32BITS
public static final int[] ALL_COLOURDEPTHS
public static final int DEFAULT_COLOURDEPTH
Method Detail |
public void setDataDirectory(java.lang.String strDirectoryName) throws java.io.FileNotFoundException
strDirectoryName
- The name of the directory that contains the bitmaps.java.io.FileNotFoundException
- Thrown if the given directory doesn't exist.loadBitmap(java.lang.String)
,
loadAlphaBitmap(java.lang.String)
public java.lang.String getDataDirectory()
loadBitmap(java.lang.String)
,
loadAlphaBitmap(java.lang.String)
public Bitmap loadBitmap(java.lang.String fileName) throws java.io.FileNotFoundException, GameFrameException
fileName
- The name of the file to be loaded (without the file extension).java.io.FileNotFoundException
- Thrown if the given file doesn't exist.GameFrameException
- Thrown if other error occur while loading the file.setDataDirectory(java.lang.String)
,
loadAlphaBitmap(java.lang.String)
,
Bitmap
public Bitmap loadAlphaBitmap(java.lang.String fileName) throws java.io.FileNotFoundException, GameFrameException
fileName
- The name of the file to be loaded (without the file extension).java.io.FileNotFoundException
- Thrown if the given file doesn't exist.GameFrameException
- Thrown if other error occur while loading the file.setDataDirectory(java.lang.String)
,
loadBitmap(java.lang.String)
,
loadAlphaBitmap(java.lang.String, byte, byte, byte)
,
Bitmap
public Bitmap loadAlphaBitmap(java.lang.String fileName, byte red, byte green, byte blue) throws java.io.FileNotFoundException, GameFrameException
fileName
- 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).java.io.FileNotFoundException
- Thrown if the given file doesn't exist.GameFrameException
- Thrown if other error occur while loading the file.setDataDirectory(java.lang.String)
,
loadBitmap(java.lang.String)
,
loadAlphaBitmap(java.lang.String)
,
Bitmap
public DrawableBitmap getDrawableBitmap(int width, int height) throws GameFrameException
width
- The width of the created bitmap.height
- The height of the created bitmapGameFrameException
- Thrown if errors occur while creating the bitmap.public void flip()
public void setBackgroundColor(java.awt.Color color)
clearBackbuffer()
public void clearBackbuffer()
setBackgroundColor(java.awt.Color)
public void loadDefaultFontBitmap() throws java.io.FileNotFoundException, GameFrameException
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.loadFontBitmap(java.lang.String)
,
getAsBitmap(java.lang.String)
,
getAsBitmap(byte[])
,
drawTextAt(java.lang.String, int, int)
,
drawTextAt(byte[], int, int)
public void loadFontBitmap(java.lang.String filename) throws java.io.FileNotFoundException, GameFrameException
filename
- Name of the bitmap file that contains the letters.java.io.FileNotFoundException
- Thrown if the given font bitmap can't be found.GameFrameException
- Thrown if other error occur while loading the font bitmap.loadDefaultFontBitmap()
,
getAsBitmap(java.lang.String)
,
getAsBitmap(byte[])
,
drawTextAt(java.lang.String, int, int)
,
drawTextAt(byte[], int, int)
public int getTextWidth(java.lang.String strText)
strText
- The text that is written using the current font.loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public int getTextWidth(byte[] aByteText)
aByteText
- The byte array containing the text to be measured.loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public int getFontWidth()
loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public int getFontHeight()
loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public DrawableBitmap getAsBitmap(java.lang.String strText) throws GameFrameException
strText
- The text that is written using the current font.GameFrameException
- Thrown if errors occur.loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public DrawableBitmap getAsBitmap(byte[] aByteText) throws GameFrameException
aByteText
- The byte array containing the text to be printed.GameFrameException
- Thrown if errors occur.loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public void drawTextAt(java.lang.String strText, int x, int y) throws GameFrameException
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.GameFrameException
- Thrown if the font bitmap is not set correctly or other errors occur.loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public void drawTextAt(byte[] aByteText, int x, int y) throws GameFrameException
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.GameFrameException
- Thrown if the font bitmap is not set correctly or other errors occur.loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public boolean isInFullscreenMode()
public java.awt.Dimension getSize()
public java.lang.String getName()
public java.lang.String getDescription()
|
GF4J 0.9.4 Beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |