GF4J 0.9.4 Beta

gameframe.engines.msjava4x
Class CFullscreenGraphicsEngine

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--gameframe.engines.msjava4x.CFullscreenGraphicsEngine
All Implemented Interfaces:
javax.accessibility.Accessible, Finalizable, GraphicsEngine, IBitmapStorage, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class CFullscreenGraphicsEngine
extends java.awt.Window
implements GraphicsEngine, IBitmapStorage, Finalizable

Microsoft DirectDraw (from DirectX 3) implementation of the graphics engine. Uses Microsoft Java 3.x specific DirectX classes and Direct/J API.

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

Inner classes inherited from class java.awt.Window
java.awt.Window.AccessibleAWTWindow
 
Inner classes inherited from class java.awt.Container
java.awt.Container.AccessibleAWTContainer
 
Inner classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.AWTTreeLock
 
Field Summary
private  java.awt.Color m_backgroundColor
          The color that is used when painting the backbuffer in the clear operation.
private  int m_backgroundFillValue
          The actual pixel value that is used to fill the backbuffer with background color.
private  gameframe.engines.msjava4x.DirectDrawClipper m_ddclipper
          The DirectDrawClipper for front and back surfaces.
private  gameframe.engines.msjava4x.DirectDrawPalette m_ddPalette
          DirectDraw palette.
private  gameframe.engines.msjava4x.DirectDrawSurface m_ddsBack
          DirectDraw backbuffer surface.
private  gameframe.engines.msjava4x.DirectDrawSurface m_ddsFontBitmap
          DirectDraw surface that contains the letter for the current font.
private  gameframe.engines.msjava4x.DirectDrawSurface m_ddsPrimary
          DirectDraw primary surface.
private  gameframe.engines.msjava4x.DirectDraw m_directDraw
          DirectDraw object.
private  boolean m_fFocused
          Flag that indicates if we have at the moment focus or not.
private  boolean m_fInfullscreenMode
          Flag that indicates if we are at the moment in fullscreen mode or not.
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.util.Vector m_loadedBitmaps
          Every bitmap that has been loaded since last finalize method call.
private  int m_modeBpp
          The bits per pixel value of the display.
private  int m_modeRefresh
          The refresh rate of the display.
private  gameframe.engines.msjava4x.Rect m_screenRectangle
          The rectangle object that holds the size of this screen.
private  java.lang.String m_strDataDirectory
          Name of the directory that contains loaded bitmaps.
private  int m_width
          Width of this frame.
(package private) static gameframe.engines.msjava4x.Rect mStatic_dstRectangle
          The rectangle that covers the destination are of the blit.
private static java.awt.Frame mStatic_parentFrame
          Frame that acts as a parent to the window.
(package private) static gameframe.engines.msjava4x.Rect mStatic_srcRectangle
          The rectangle that covers the DirectDraw surface this bitmap class represents.
 
Fields inherited from class java.awt.Window
active, base, dbg, focusMgr, inputContext, inputContextLock, nameCounter, OPENED, ownedWindowList, serialVersionUID, state, warningString, weakThis, windowListener, windowSerializedDataVersion
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, listeningBoundsChildren, listeningChildren, maxSize, ncomponents, printing, printingThreads
 
Fields inherited from class java.awt.Component
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, 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 CFullscreenGraphicsEngine(java.awt.Frame parentFrame, GameFrameSettings settings)
          Private constructor for this singleton instance.
private CFullscreenGraphicsEngine(java.awt.Frame parentFrame, int width, int height, int bpp, int refresh)
          Private constructor for this singleton instance.
 
Method Summary
 void addBitmap(CBitmapBase bitmap)
          Adds a bitmap to the group of created bitmaps (that is used when finalizing all objects).
 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  CDDAlphaBitmap createAlphaBitmap(int width, int height)
          Creates an alpha bitmap of the given size.
(package private)  gameframe.engines.msjava4x.DirectDrawSurface createSurface(int width, int height)
          First tries to create a plain DD surface that has the given size to the video memory.
 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.
(package private)  boolean enumerate(CModeEnumerator enumerator)
          Enumerates all available resolutions and all different refresh rates.
 void finalize()
          Invoked when the program is exiting or user wants to get rid of this engine.
 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 CFullscreenGraphicsEngine getInstance(GameFrameSettings settings)
          Returns an instance of this class.
 java.lang.String getName()
          Returns the short name (max 8 characters) of the implementation "DDraw".
 java.awt.Dimension getSize()
          Returns the size of the display area that this engine uses.
(package private)  java.util.Vector getSupportedModes()
          Returns a vector filled with the supported modes.
 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)  void init()
          Initializes this graphics engine to fullscreen mode with doublebuffering.
 boolean isInFullscreenMode()
          Returns true as this engine is allways in fullscreen mode.
 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.
(package private)  Bitmap loadAlphaBitmapInternal(java.lang.String strFileName, byte red, byte green, byte blue)
          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 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.
(package private)  Bitmap loadBitmapInternal(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.
(package private)  gameframe.engines.msjava4x.DirectDrawBitmap loadDDBitmap(java.lang.String strFileName)
          Loads the given bitmap file as a surface.
 void loadDefaultFontBitmap()
          Loads the default font bitmap that is used when printing text on the screen.
 void loadFontBitmap(java.lang.String strFileName)
          Loads and sets the used font set to be loaded from the given strFileName using the specified fixed size for every letter.
(package private)  int mapToPixelFormat(java.awt.Color color, gameframe.engines.msjava4x.DirectDrawSurface surface)
          Maps the given color object to a pixel value that has the same pixel format as the given DirectDraw surface.
 void paint(java.awt.Graphics g)
          Overrides the java.awt.Component's method to do nothing.
private  void paintSurfaceWithBackgroundColor(gameframe.engines.msjava4x.DirectDrawSurface surface)
          Paints the given surface with the current background color.
 void removeBitmap(CBitmapBase bitmap)
          Removes a bitmap from the group of created bitmaps (that is used when finalizing all objects).
 void setBackgroundColor(java.awt.Color color)
          Sets the currently used background color (defaults to Color.black).
 void setBmpKeyColor(gameframe.engines.msjava4x.DirectDrawSurface ddSurface, byte red, byte green, byte blue)
          Sets the bitmap key color to the surface.
 void setDataDirectory(java.lang.String strDirectoryName)
          Sets the data directory wherefrom the bitmaps are loaded.
 void setVisible(boolean fVisibility)
          Overrides the java.awt.Window's setVisible() method to also set the visibility of the frame that is the parent of this window.
 void show()
          Overrides the java.awt.Window's show() method to also show the frame that is the parent of this window.
 void update(java.awt.Graphics g)
          Overrides the java.awt.Component's method to do nothing.
 
Methods inherited from class java.awt.Window
, addNotify, addOwnedWindow, addWindowListener, adjustListeningChildren, applyResourceBundle, applyResourceBundle, connectOwnedWindow, constructComponentName, dispatchEventImpl, dispose, eventEnabled, getAccessibleContext, getFocusOwner, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, hide, initIDs, isActive, isShowing, nextFocus, ownedInit, pack, postEvent, postProcessKeyEvent, postWindowEvent, preProcessKeyEvent, processEvent, processWindowEvent, readObject, removeOwnedWindow, removeWindowListener, resetGC, setCursor, setFocusOwner, setWarningString, toBack, toFront, transferFocus, writeObject
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, checkGD, countComponents, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventToSelf, doLayout, findComponentAt, findComponentAt, findComponentAt, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, numListening, paintComponents, paintHeavyweightComponents, paramString, postsOldMouseEvents, preferredSize, print, printComponents, printHeavyweightComponents, processContainerEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isRecursivelyVisible, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

mStatic_parentFrame

private static java.awt.Frame mStatic_parentFrame
Frame that acts as a parent to the window.

mStatic_srcRectangle

static gameframe.engines.msjava4x.Rect mStatic_srcRectangle
The rectangle that covers the DirectDraw surface this bitmap class represents.

mStatic_dstRectangle

static gameframe.engines.msjava4x.Rect mStatic_dstRectangle
The rectangle that covers the destination are of the blit.

m_modeBpp

private int m_modeBpp
The bits per pixel value of the display. If value is NO_PREFERRED_BPP it is set to be the same as system BPP value.

m_modeRefresh

private int m_modeRefresh
The refresh rate of the display. Initially set to NO_PREFERRED_REFRESHRATE which means that all refresh modes are enumerated.

m_directDraw

private gameframe.engines.msjava4x.DirectDraw m_directDraw
DirectDraw object.

m_ddsPrimary

private gameframe.engines.msjava4x.DirectDrawSurface m_ddsPrimary
DirectDraw primary surface.

m_ddsBack

private gameframe.engines.msjava4x.DirectDrawSurface m_ddsBack
DirectDraw backbuffer surface.

m_ddPalette

private gameframe.engines.msjava4x.DirectDrawPalette m_ddPalette
DirectDraw palette.

m_ddclipper

private gameframe.engines.msjava4x.DirectDrawClipper m_ddclipper
The DirectDrawClipper for front and back surfaces.

m_fInfullscreenMode

private boolean m_fInfullscreenMode
Flag that indicates if we are at the moment in fullscreen mode or not.

m_fFocused

private boolean m_fFocused
Flag that indicates if we have at the moment focus or not.

m_backgroundColor

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

m_backgroundFillValue

private int m_backgroundFillValue
The actual pixel value that is used to fill the backbuffer with background color.

m_width

private int m_width
Width of this frame.

m_height

private int m_height
Height of this frame.

m_loadedBitmaps

private java.util.Vector m_loadedBitmaps
Every bitmap that has been loaded since last finalize method call.

m_screenRectangle

private gameframe.engines.msjava4x.Rect m_screenRectangle
The rectangle object that holds the size of this screen.

m_strDataDirectory

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

m_ddsFontBitmap

private gameframe.engines.msjava4x.DirectDrawSurface m_ddsFontBitmap
DirectDraw surface that contains the letter for 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.
Constructor Detail

CFullscreenGraphicsEngine

private CFullscreenGraphicsEngine(java.awt.Frame parentFrame,
                                  GameFrameSettings settings)
Private constructor for this singleton instance.
Parameters:
parentFrame - The parent frame of this window
settings - The settings used to create this graphics engine.

CFullscreenGraphicsEngine

private CFullscreenGraphicsEngine(java.awt.Frame parentFrame,
                                  int width,
                                  int height,
                                  int bpp,
                                  int refresh)
Private constructor for this singleton instance.
Parameters:
parentFrame - The parent frame of this window
settings - The settings used to create this graphics engine.
Method Detail

getInstance

static CFullscreenGraphicsEngine getInstance(GameFrameSettings settings)
                                      throws GameFrameException
Returns an instance of this class. The instance is a window that has the given title and size. Note: This class is not a singleton!
Parameters:
settings - The settings used to create this graphics engine.

init

void init()
    throws GameFrameException
Initializes this graphics engine to fullscreen mode with doublebuffering.

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.

loadBitmapInternal

Bitmap loadBitmapInternal(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.
Parameters:
strFileName - The exact name of the file to be loaded.
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.

loadAlphaBitmapInternal

Bitmap loadAlphaBitmapInternal(java.lang.String strFileName,
                               byte red,
                               byte green,
                               byte blue)
                         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.
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:
An unique Bitmap object that represents the loaded bitmap image.

loadDDBitmap

gameframe.engines.msjava4x.DirectDrawBitmap loadDDBitmap(java.lang.String strFileName)
                                                   throws java.io.FileNotFoundException,
                                                          GameFrameException
Loads the given bitmap file as a surface.
Parameters:
strFileName - The filename of the bitmap.
Returns:
The DirectDrawSurface that contains the bitmaps.

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 CDDAlphaBitmap 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.
Returns:
The created alpha bitmap.

createSurface

gameframe.engines.msjava4x.DirectDrawSurface createSurface(int width,
                                                           int height)
                                                     throws GameFrameException
First tries to create a plain DD surface that has the given size to the video memory. If that is not successfull, creates the DD surface to other memory (system or AGP).
Parameters:
width - Width of the surface to be created.
height - Height of the surface to be created.
Returns:
DirectDraw surface that has the given size.

addBitmap

public void addBitmap(CBitmapBase bitmap)
Adds a bitmap to the group of created bitmaps (that is used when finalizing all objects).
Specified by:
addBitmap in interface IBitmapStorage
Following copied from interface: gameframe.engines.msjava4x.IBitmapStorage
Parameters:
bitmap - The bitmap to be added to the storage.

removeBitmap

public void removeBitmap(CBitmapBase bitmap)
Removes a bitmap from the group of created bitmaps (that is used when finalizing all objects).
Specified by:
removeBitmap in interface IBitmapStorage
Following copied from interface: gameframe.engines.msjava4x.IBitmapStorage
Parameters:
bitmap - The bitmap to be removed from the storage.

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

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.
Specified by:
setDataDirectory in interface GraphicsEngine
Parameters:
strDirectoryName - The name of the directory that contains the bitmaps.

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)

paintSurfaceWithBackgroundColor

private void paintSurfaceWithBackgroundColor(gameframe.engines.msjava4x.DirectDrawSurface surface)
Paints the given surface with the current background color.
Parameters:
surface - The surface to be painted with background color.

clearBackbuffer

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

isInFullscreenMode

public boolean isInFullscreenMode()
Returns true as this engine is allways in fullscreen mode.
Specified by:
isInFullscreenMode in interface GraphicsEngine
Returns:
True as the engine is in fullscreen mode.

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
Loads and 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.
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.
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.

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()

getName

public java.lang.String getName()
Returns the short name (max 8 characters) of the implementation "DDraw".
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

getSupportedModes

java.util.Vector getSupportedModes()
Returns a vector filled with the supported modes.
Returns:
The supported modes.

enumerate

boolean enumerate(CModeEnumerator enumerator)
Enumerates all available resolutions and all different refresh rates.

finalize

public void finalize()
Invoked when the program is exiting or user wants to get rid of this engine. Frees all COM stuff that needs to be freed.
Specified by:
finalize in interface Finalizable
Overrides:
finalize in class java.awt.Window

paint

public void paint(java.awt.Graphics g)
Overrides the java.awt.Component's method to do nothing.
Overrides:
paint in class java.awt.Container

update

public void update(java.awt.Graphics g)
Overrides the java.awt.Component's method to do nothing.
Overrides:
update in class java.awt.Container

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.
Since:
GameFrame for Java 0.9.2

setVisible

public void setVisible(boolean fVisibility)
Overrides the java.awt.Window's setVisible() method to also set the visibility of the frame that is the parent of this window.
Overrides:
setVisible in class java.awt.Component
Parameters:
fVisibility - True if the window is to be visible, false if not.

show

public void show()
Overrides the java.awt.Window's show() method to also show the frame that is the parent of this window.
Overrides:
show in class java.awt.Window

setBmpKeyColor

public void setBmpKeyColor(gameframe.engines.msjava4x.DirectDrawSurface ddSurface,
                           byte red,
                           byte green,
                           byte blue)
                    throws GameFrameException
Sets the bitmap key color to the surface.
Parameters:
ddSurface - The DirectDraw surface whose key color is to be set.
red - The red key color component.
green - The green key color component.
blue - The blue key color component.

mapToPixelFormat

int mapToPixelFormat(java.awt.Color color,
                     gameframe.engines.msjava4x.DirectDrawSurface surface)
               throws GameFrameException
Maps the given color object to a pixel value that has the same pixel format as the given DirectDraw surface. Returns 0xFFFFFFFF in case of failure, but also when user wants to map a color to such a value. User should note when errors occur...
Parameters:
color - The color that is mapped.
surface - The DirectDraw surface whose pixel format is used.
Returns:
The given color mapped to a pixel value.

GF4J 0.9.4 Beta