GF4J 0.9.4 Beta

gameframe.engines.msjava4x
Class CEngineFactory

java.lang.Object
  |
  +--gameframe.engines.msjava4x.CEngineFactory
All Implemented Interfaces:
EngineFactory

public class CEngineFactory
extends java.lang.Object
implements EngineFactory

Implementation of an engine factory for Microsoft Java JVM's that support DirectX interfacing from Java. Uses the emulated fullscreen graphics engine (if needed), component graphics engine (if needed), windowed graphics engine (if needed) and the input engine (allways) from the gameframe.engines.jdk11x package.

Since:
GameFrame for Java 0.9
Version:
GameFrame for Java 0.9.4

Field Summary
private  java.lang.String[] m_aFullscreenGraphicsModes
          The valid fullscreen modes this engine factory can handle.
private  java.util.Vector m_finalizableObjects
          All objects that must be finalized upon engine factory finalization.
private  java.awt.Component m_focusComponent
          Reference to the java.awt.Component for the DirectSound sound engine
private  GraphicsEngine m_graphicsEngine
          Reference to the singleton graphics engine implementation.
private  InputEngine m_inputEngine
          Reference to the singleton input engine implementation.
private  GameFrameSettings m_settings
          The main factory settings used for this engine factory.
private  SoundEngine m_soundEngine
          Reference to the singleton sound engine implementation.
private static CEngineFactory mStatic_engineFactory
          Reference to the singleton instance of this engine factory.
 
Fields inherited from interface gameframe.engines.EngineFactory
SUITABILITY_GOOD, SUITABILITY_NOT_SUITED, SUITABILITY_POOR, SUITABILITY_ULTIMATE
 
Constructor Summary
private CEngineFactory(GameFrameSettings settings)
          Constructs the engine factory.
 
Method Summary
 <>Timer createTimer()
          Returns a new timer instance.
 void finalizationNotify(<>Timer timer)
          Notifies that the given timer has been finalized.
 void finalize()
          Invoked before application exits.
private  CComponentGraphicsEngine getComponentGraphicsEngine()
          Creates and returns the component graphics engine.
 java.lang.String getDescription()
          Returns the description of the engine factory implementation.
 GraphicsEngine getGraphicsEngine()
          Returns the most suitable graphics engine implementation for the current platform.
 InputEngine getInputEngine()
          Returns the input engine implementation for the current platform.
static CEngineFactory getInstance(GameFrameSettings settings)
          Returns the singleton instance of this engine factory (the instace will be created upon the first call to this method).
 java.lang.String getName()
          Returns the short name (max 8 characters) of this engine factory implementation which is "MSJ4DX".
 SoundEngine getSoundEngine()
          Returns the sound engine implementation for the current platform.
 int getSuitabilityForPlatform()
          Returns the suitability of this engine implementation for the current platform as one of the enumerated values.
 java.lang.String[] getSupportedResolutions()
          Returns the fullscreen graphics modes supported by graphics engines that are created by this factory.
static boolean isRunnableOnPlatform()
          Returns true if this engine factory is runnable on the platform.
 
Methods inherited from class java.lang.Object
, clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 
Methods inherited from interface gameframe.engines.EngineFactory
finalizationNotify
 

Field Detail

mStatic_engineFactory

private static CEngineFactory mStatic_engineFactory
Reference to the singleton instance of this engine factory.

m_finalizableObjects

private java.util.Vector m_finalizableObjects
All objects that must be finalized upon engine factory finalization.

m_focusComponent

private java.awt.Component m_focusComponent
Reference to the java.awt.Component for the DirectSound sound engine

m_soundEngine

private SoundEngine m_soundEngine
Reference to the singleton sound engine implementation.

m_graphicsEngine

private GraphicsEngine m_graphicsEngine
Reference to the singleton graphics engine implementation.

m_inputEngine

private InputEngine m_inputEngine
Reference to the singleton input engine implementation.

m_aFullscreenGraphicsModes

private java.lang.String[] m_aFullscreenGraphicsModes
The valid fullscreen modes this engine factory can handle.

m_settings

private GameFrameSettings m_settings
The main factory settings used for this engine factory.
Constructor Detail

CEngineFactory

private CEngineFactory(GameFrameSettings settings)
Constructs the engine factory.
Parameters:
settings - The settings to be used in this engine factory.
Method Detail

getInstance

public static CEngineFactory getInstance(GameFrameSettings settings)
Returns the singleton instance of this engine factory (the instace will be created upon the first call to this method).
Parameters:
settings - The settings to be used in this engine factory.
Returns:
The singleton instance of this engine factory.

getName

public java.lang.String getName()
Returns the short name (max 8 characters) of this engine factory implementation which is "MSJ4DX".
Specified by:
getName in interface EngineFactory
Returns:
The short name of the engine factory.

getDescription

public java.lang.String getDescription()
Returns the description of the engine factory implementation.
Specified by:
getDescription in interface EngineFactory
Returns:
A description of the engine factory.

getSuitabilityForPlatform

public int getSuitabilityForPlatform()
Returns the suitability of this engine implementation for the current platform as one of the enumerated values. Currently return POOR so that any better implementation will override this implementation.
Specified by:
getSuitabilityForPlatform in interface EngineFactory
Returns:
Suitability of the engine factory for this platform.

isRunnableOnPlatform

public static boolean isRunnableOnPlatform()
Returns true if this engine factory is runnable on the platform.

getSupportedResolutions

public java.lang.String[] getSupportedResolutions()
Returns the fullscreen graphics modes supported by graphics engines that are created by this factory. If the factory created graphics engines support only windowed modes, this method returns null. Note: This method should always do a full cleanup after it has been run!
Specified by:
getSupportedResolutions in interface EngineFactory
Returns:
Supported fullscreen modes or null.

getSoundEngine

public SoundEngine getSoundEngine()
                           throws GameFrameException
Returns the sound engine implementation for the current platform. If not successfull returns the do-nothing implementation of a sound engine.
Specified by:
getSoundEngine in interface EngineFactory
Returns:
The sound engine for this platform.

getGraphicsEngine

public GraphicsEngine getGraphicsEngine()
                                 throws GameFrameException
Returns the most suitable graphics engine implementation for the current platform. Only the fullscreen graphics engine differs from the JDK 1.1.x versions so other engines are used from the gameframe.engines.jdk11x package.
Specified by:
getGraphicsEngine in interface EngineFactory
Returns:
The graphics engine for this platform.
See Also:
CFullscreenGraphicsEngine, CEmulatedFullscreenGraphicsEngine, CWindowedGraphicsEngine, CComponentGraphicsEngine

getComponentGraphicsEngine

private CComponentGraphicsEngine getComponentGraphicsEngine()
                                                     throws GameFrameException
Creates and returns the component graphics engine.
Returns:
The used component graphics engine.

getInputEngine

public InputEngine getInputEngine()
                           throws GameFrameException
Returns the input engine implementation for the current platform. If not successfull returns null.
Specified by:
getInputEngine in interface EngineFactory
Returns:
The input engine for this platform.
See Also:
CInputEngine

createTimer

public <>Timer createTimer()
                               throws GameFrameException
Returns a new timer instance. Several timers can be created with this method. If a native timer can't be for some reason created, this method returns the basic implementation CTimer from the GameFrame.Java11 package.
Specified by:
createTimer in interface EngineFactory
Returns:
Timer instance.

finalizationNotify

public void finalizationNotify(<>Timer timer)
Notifies that the given timer has been finalized.

finalize

public void finalize()
Invoked before application exits. Should do all the cleanup that is necessary to exit cleanly (close window, stop playing sounds, release any objects referenced etc.).
Specified by:
finalize in interface EngineFactory
Overrides:
finalize in class java.lang.Object

GF4J 0.9.4 Beta