|
GF4J 0.9.4 Beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--java.awt.Component | +--java.awt.Canvas | +--gameframe.engines.jdk12x.CComponentGraphicsEngine
Java 2 AWT implementation of the graphics engine. For some odd reason this works only if the component is Canvas object.
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 |
private static CComponentGraphicsEngine mStatic_graphicsEngine
private java.awt.Dimension mStatic_size
private java.util.Vector m_createdBitmaps
private java.util.Vector m_createdDrawableBitmaps
private java.lang.String m_strDataDirectory
private java.awt.Color m_backgroundColor
private java.awt.Image m_backBuffer
private java.awt.Graphics2D m_backBufferGraphics
private java.awt.Image m_frontBuffer
private java.awt.Graphics2D m_frontBufferGraphics
private java.awt.Graphics2D m_componentGraphics
private boolean m_fIsNotified
private int m_width
private int m_height
private Bitmap m_fontBitmap
private int m_letterWidth
private int m_letterHeight
private Bitmap[] m_aFonts
private static java.util.Hashtable mStatic_graphicsSettings
Constructor Detail |
private CComponentGraphicsEngine(GameFrameSettings settings)
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()
static CComponentGraphicsEngine getInstance(GameFrameSettings settings)
settings
- The settings object that contains settings for this
graphics engine.public java.lang.String getName()
getName
in interface GraphicsEngine
getName
in class java.awt.Component
public java.lang.String getDescription()
getDescription
in interface GraphicsEngine
boolean isAddNotified()
public Bitmap loadBitmap(java.lang.String strFileName) throws java.io.FileNotFoundException, GameFrameException
loadBitmap
in interface GraphicsEngine
strFileName
- The name of the file to be loaded (without the file extension).public Bitmap loadAlphaBitmap(java.lang.String strFileName) throws java.io.FileNotFoundException, GameFrameException
loadAlphaBitmap
in interface GraphicsEngine
strFileName
- The name of the file to be loaded (without the file extension).public Bitmap loadAlphaBitmap(java.lang.String strFileName, byte red, byte green, byte blue) throws java.io.FileNotFoundException, GameFrameException
loadAlphaBitmap
in interface GraphicsEngine
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).java.io.FileNotFoundException
- Thrown if the given file doesn't exist.GameFrameException
- Thrown if other error occur while loading the file.public DrawableBitmap getDrawableBitmap(int width, int height) throws GameFrameException
getDrawableBitmap
in interface GraphicsEngine
width
- The width of the bitmap.height
- The height of the bitmapprivate CComponentGraphicsEngine.CBitmap createAlphaBitmap(int width, int height) throws GameFrameException
width
- The width of the alpha bitmap.height
- The height of the alpha bitmap.public void copyArea(int x, int y, int width, int height, int dx, int dy)
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.public void flip()
flip
in interface GraphicsEngine
public void clearBackbuffer()
clearBackbuffer
in interface GraphicsEngine
gameframe.graphics.GraphicsEngine
GraphicsEngine.setBackgroundColor(java.awt.Color)
public void setDataDirectory(java.lang.String strDirectoryName) throws java.io.FileNotFoundException
setDataDirectory
in interface GraphicsEngine
strDirectoryName
- The name of the directory that contains the bitmaps.java.io.FileNotFoundException
- Thrown if the data directory doesn't exist.public java.lang.String getDataDirectory()
getDataDirectory
in interface GraphicsEngine
loadBitmap(java.lang.String)
,
loadAlphaBitmap(java.lang.String)
public boolean isInFullscreenMode()
isInFullscreenMode
in interface GraphicsEngine
public void update(java.awt.Graphics grfx)
update
in class java.awt.Component
grfx
- The graphics context used in drawing.public void paint(java.awt.Graphics grfx)
paint
in class java.awt.Canvas
grfx
- The graphics context used in drawing.public void setBackgroundColor(java.awt.Color color)
setBackgroundColor
in interface GraphicsEngine
gameframe.graphics.GraphicsEngine
GraphicsEngine.clearBackbuffer()
public java.awt.Dimension getSize()
getSize
in interface GraphicsEngine
getSize
in class java.awt.Component
public java.awt.Dimension getMaximumSize()
getMaximumSize
in class java.awt.Component
public java.awt.Dimension getMinimumSize()
getMinimumSize
in class java.awt.Component
public java.awt.Dimension getPreferredSize()
getPreferredSize
in class java.awt.Component
public boolean isFocusTraversable()
isFocusTraversable
in class java.awt.Component
public boolean isOpaque()
isOpaque
in class java.awt.Component
public void finalize()
finalize
in interface Finalizable
finalize
in class java.lang.Object
public void setTitle(java.lang.String title)
title
- The title of the window.public void loadDefaultFontBitmap() throws java.io.FileNotFoundException, GameFrameException
loadDefaultFontBitmap
in interface GraphicsEngine
gameframe.graphics.GraphicsEngine
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.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)
public void loadFontBitmap(java.lang.String strFileName) throws java.io.FileNotFoundException, GameFrameException
loadFontBitmap
in interface GraphicsEngine
strFileName
- Name of the bitmap file that contains the letters.public int getTextWidth(java.lang.String strText)
getTextWidth
in interface GraphicsEngine
strText
- The text that is written using the current font.loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public int getTextWidth(byte[] aByteText)
getTextWidth
in interface GraphicsEngine
aByteText
- The byte array containing the text to be measured.loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public int getFontWidth()
getFontWidth
in interface GraphicsEngine
loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public int getFontHeight()
getFontHeight
in interface GraphicsEngine
loadDefaultFontBitmap()
,
loadFontBitmap(java.lang.String)
public DrawableBitmap getAsBitmap(java.lang.String strText) throws GameFrameException
getAsBitmap
in interface GraphicsEngine
strText
- The text that is written using the current font.public DrawableBitmap getAsBitmap(byte[] aByteText) throws GameFrameException
getAsBitmap
in interface GraphicsEngine
aByteText
- The byte array containing the text to be printed.public void drawTextAt(java.lang.String strText, int x, int y) throws GameFrameException
drawTextAt
in interface GraphicsEngine
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.public void drawTextAt(byte[] aByteText, int x, int y) throws GameFrameException
drawTextAt
in interface GraphicsEngine
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.public void addNotify()
addNotify
in class java.awt.Canvas
|
GF4J 0.9.4 Beta | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |