org.ogre4j
Class Font

java.lang.Object
  extended by org.xbig.base.NativeObject
      extended by org.ogre4j.Font
All Implemented Interfaces:
IAllocatedObject<IResourceAllocPolicy>, IFont, IManualResourceLoader, IResource, IResourceAllocatedObject, IStringInterface, INativeObject

public class Font
extends NativeObject
implements IFont


Nested Class Summary
protected static class Font.CmdCodePoints
           
protected static class Font.CmdResolution
           
protected static class Font.CmdSize
           
protected static class Font.CmdSource
           
protected static class Font.CmdType
           
protected static class Font.CodePointMap
           
static class Font.CodePointRange
           
static class Font.CodePointRangeList
           
static class Font.GlyphInfo
           
 
Nested classes/interfaces inherited from interface org.ogre4j.IFont
IFont.ICmdCodePoints, IFont.ICmdResolution, IFont.ICmdSize, IFont.ICmdSource, IFont.ICmdType, IFont.ICodePointMap, IFont.ICodePointRange, IFont.ICodePointRangeList, IFont.IGlyphInfo
 
Nested classes/interfaces inherited from interface org.ogre4j.IResource
IResource.IListener, IResource.IListenerList
 
Field Summary
 
Fields inherited from class org.xbig.base.NativeObject
deleted, object, remote
 
Constructor Summary
  Font(InstancePointer p)
          This constructor is public for internal useage only!
protected Font(InstancePointer p, boolean remote)
          Creates a Java wrapper object for an existing C++ object.
  Font(IResourceManager creator, java.lang.String name, long handle, java.lang.String group, boolean isManual, IManualResourceLoader loader)
          Constructor.
  Font(WithoutNativeObject val)
          Allows creation of Java objects without C++ objects.
 
Method Summary
 void _dirtyState()
          Manually mark the state of this resource as having been changed.
 void _fireBackgroundLoadingComplete()
          Firing of background loading complete event
 void _fireBackgroundPreparingComplete()
          Firing of background preparing complete event
 void _notifyOrigin(java.lang.String origin)
           
 void addCodePointRange(IFont.ICodePointRange range)
          Adds a range of code points to the list of code point ranges to generate glyphs for, if this is a truetype based font.
 void addListener(IResource.IListener lis)
          Register a listener on this resource.
 void changeGroupOwnership(java.lang.String newGroup)
          Change the resource group ownership of a .
static void cleanupDictionary()
          Cleans up the static 'msDictionary' required to reset , otherwise the containers are left with invalid pointers, which will lead to a crash as soon as one of the implementers (e.g. ) initializes.
 void clearCodePointRanges()
          Clear the list of code point ranges.
 void copyParametersTo(IStringInterface dest)
          Method for copying this object's parameters to another object.
 void delete()
          Deletes the corresponding C++ object.
 void escalateLoading()
          Escalates the loading of a background loaded resource.
 void finalize()
           
 boolean getAntialiasColour()
          Gets whether or not the colour of this font is antialiased as it is generated from a true type font.
 IFont.ICodePointRangeList getCodePointRangeList()
          Get a const reference to the list of code point ranges to be used to generate glyphs from a truetype font.
 IResourceManager getCreator()
           
 float getGlyphAspectRatio(long id)
          Gets the aspect ratio (width / height) of this character.
 IFont.IGlyphInfo getGlyphInfo(long id)
          Gets the information available for a glyph corresponding to a given code point, or throws an exception if it doesn't exist;
 IFloatRect getGlyphTexCoords(long id)
          Returns the texture coordinates of the associated glyph.
 java.lang.String getGroup()
           
 long getHandle()
           
 Resource.LoadingState getLoadingState()
          Returns the current loading state.
 IMaterialPtr getMaterial_const()
           
 IMaterialPtr getMaterial()
          Gets the material generated for this font, as a weak reference.
 java.lang.String getName()
          Gets resource name.
 java.lang.String getOrigin()
          Get the origin of this resource, e.g. a script file name.
 IParamDictionary getParamDictionary_const()
           
 IParamDictionary getParamDictionary()
          Retrieves the parameter dictionary for this class.
 java.lang.String getParameter(java.lang.String name)
          Generic parameter retrieval method.
 IParameterList getParameters()
          Retrieves a list of parameters valid for this object.
 int getSize()
          Retrieves info about the size of the resource.
 java.lang.String getSource()
          Gets the source this font (either an image or a truetype font).
 int getStateCount()
          Returns the number of times this resource has changed state, which generally means the number of times it has been loaded.
 int getTrueTypeMaxBearingY()
          Gets the maximum baseline distance of all glyphs used in the texture.
 long getTrueTypeResolution()
          Gets the resolution (dpi) of the font used to generate the texture.
 float getTrueTypeSize()
          Gets the point size of the font used to generate the texture.
 FontType getType()
          Gets the type of font.
 boolean isBackgroundLoaded()
          Returns whether this has been earmarked for background loading.
 boolean isLoaded()
          Returns true if the has been loaded, false otherwise.
 boolean isLoading()
          Returns whether the resource is currently in the process of background loading.
 boolean isManuallyLoaded()
          Is this resource manually loaded?
 boolean isPrepared()
          Returns true if the has been prepared, false otherwise.
 boolean isReloadable()
          Returns true if the is reloadable, false otherwise.
 void load(boolean backgroundThread)
          Loads the resource, if it is not already.
 void loadResource(IResource resource)
          Implementation of , called when the that this font creates needs to (re)load.
 void prepare()
          Prepares the resource for load, if it is not already.
 void prepareResource(IResource resource)
          Called when a resource wishes to load.
 void reload()
          Reloads the resource, if it is already loaded.
 void removeListener(IResource.IListener lis)
          Remove a listener on this resource.
 void setAntialiasColour(boolean enabled)
          Sets whether or not the colour of this font is antialiased as it is generated from a true type font.
 void setBackgroundLoaded(boolean bl)
          Tells the resource whether it is background loaded or not.
 void setGlyphAspectRatio(long id, float ratio)
          Sets the aspect ratio (width / height) of this character.
 void setGlyphTexCoords(long id, float u1, float v1, float u2, float v2, float textureAspect)
          Sets the texture coordinates of a glyph.
 boolean setParameter(java.lang.String name, java.lang.String value)
          Generic parameter setting method.
 void setParameterList(INameValuePairList paramList)
          Generic multiple parameter setting method.
 void setSource(java.lang.String source)
          Sets the source of the font.
 void setTrueTypeResolution(long ttfResolution)
          Gets the resolution (dpi) of the font used to generate the texture (only required for FT_TRUETYPE).
 void setTrueTypeSize(float ttfSize)
          Sets the size of a truetype font (only required for FT_TRUETYPE).
 void setType(FontType ftype)
          Sets the type of font.
 void touch()
          'Touches' the resource to indicate it has been used.
 void unload()
          Unloads the resource; this is not permanent, the resource can be reloaded later if required.
 
Methods inherited from class org.xbig.base.NativeObject
disconnectFromNativeObject, equals, getInstancePointer, hashCode, setInstancePointer, setInstancePointer, setInstancePointer, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.xbig.base.INativeObject
disconnectFromNativeObject, getInstancePointer, setInstancePointer, setInstancePointer, setInstancePointer
 

Constructor Detail

Font

public Font(InstancePointer p)
This constructor is public for internal useage only! Do not use it!


Font

protected Font(InstancePointer p,
               boolean remote)
Creates a Java wrapper object for an existing C++ object. If remote is set to 'true' this object cannot be deleted in Java.


Font

public Font(WithoutNativeObject val)
Allows creation of Java objects without C++ objects.

See Also:
WithoutNativeObject, INativeObject.disconnectFromNativeObject()

Font

public Font(IResourceManager creator,
            java.lang.String name,
            long handle,
            java.lang.String group,
            boolean isManual,
            IManualResourceLoader loader)
Constructor.

Method Detail

delete

public void delete()
Description copied from interface: INativeObject
Deletes the corresponding C++ object.

Subclasses must implement this but if the native instance was created by the underlying library the native call to dispose must not happen!

Specified by:
delete in interface INativeObject
Specified by:
delete in class NativeObject
See Also:
#remote

finalize

public void finalize()
Overrides:
finalize in class NativeObject

setType

public void setType(FontType ftype)
Sets the type of font. Must be set before loading.

Specified by:
setType in interface IFont

getType

public FontType getType()
Gets the type of font.

Specified by:
getType in interface IFont

setSource

public void setSource(java.lang.String source)
Sets the source of the font.

Specified by:
setSource in interface IFont

getSource

public java.lang.String getSource()
Gets the source this font (either an image or a truetype font).

Specified by:
getSource in interface IFont

setTrueTypeSize

public void setTrueTypeSize(float ttfSize)
Sets the size of a truetype font (only required for FT_TRUETYPE).

Specified by:
setTrueTypeSize in interface IFont

setTrueTypeResolution

public void setTrueTypeResolution(long ttfResolution)
Gets the resolution (dpi) of the font used to generate the texture (only required for FT_TRUETYPE).

Specified by:
setTrueTypeResolution in interface IFont

getTrueTypeSize

public float getTrueTypeSize()
Gets the point size of the font used to generate the texture.

Specified by:
getTrueTypeSize in interface IFont

getTrueTypeResolution

public long getTrueTypeResolution()
Gets the resolution (dpi) of the font used to generate the texture.

Specified by:
getTrueTypeResolution in interface IFont

getTrueTypeMaxBearingY

public int getTrueTypeMaxBearingY()
Gets the maximum baseline distance of all glyphs used in the texture.

Specified by:
getTrueTypeMaxBearingY in interface IFont

getGlyphTexCoords

public IFloatRect getGlyphTexCoords(long id)
Returns the texture coordinates of the associated glyph.

Specified by:
getGlyphTexCoords in interface IFont

setGlyphTexCoords

public void setGlyphTexCoords(long id,
                              float u1,
                              float v1,
                              float u2,
                              float v2,
                              float textureAspect)
Sets the texture coordinates of a glyph.

Specified by:
setGlyphTexCoords in interface IFont

getGlyphAspectRatio

public float getGlyphAspectRatio(long id)
Gets the aspect ratio (width / height) of this character.

Specified by:
getGlyphAspectRatio in interface IFont

setGlyphAspectRatio

public void setGlyphAspectRatio(long id,
                                float ratio)
Sets the aspect ratio (width / height) of this character.

Specified by:
setGlyphAspectRatio in interface IFont

getGlyphInfo

public IFont.IGlyphInfo getGlyphInfo(long id)
Gets the information available for a glyph corresponding to a given code point, or throws an exception if it doesn't exist;

Specified by:
getGlyphInfo in interface IFont

addCodePointRange

public void addCodePointRange(IFont.ICodePointRange range)
Adds a range of code points to the list of code point ranges to generate glyphs for, if this is a truetype based font.

Specified by:
addCodePointRange in interface IFont

clearCodePointRanges

public void clearCodePointRanges()
Clear the list of code point ranges.

Specified by:
clearCodePointRanges in interface IFont

getCodePointRangeList

public IFont.ICodePointRangeList getCodePointRangeList()
Get a const reference to the list of code point ranges to be used to generate glyphs from a truetype font.

Specified by:
getCodePointRangeList in interface IFont

getMaterial_const

public IMaterialPtr getMaterial_const()
Specified by:
getMaterial_const in interface IFont

getMaterial

public IMaterialPtr getMaterial()
Gets the material generated for this font, as a weak reference.

Specified by:
getMaterial in interface IFont

setAntialiasColour

public void setAntialiasColour(boolean enabled)
Sets whether or not the colour of this font is antialiased as it is generated from a true type font.

Specified by:
setAntialiasColour in interface IFont

getAntialiasColour

public boolean getAntialiasColour()
Gets whether or not the colour of this font is antialiased as it is generated from a true type font.

Specified by:
getAntialiasColour in interface IFont

loadResource

public void loadResource(IResource resource)
Implementation of , called when the that this font creates needs to (re)load.

Specified by:
loadResource in interface IFont
Specified by:
loadResource in interface IManualResourceLoader

prepare

public void prepare()
Prepares the resource for load, if it is not already. One can call before , but this is not required as will call itself, if needed. When OGRE_THREAD_SUPPORT==1 both and are thread-safe. When OGRE_THREAD_SUPPORT==2 however, only is thread-safe. The reason for this function is to allow a background thread to do some of the loading work, without requiring the whole render system to be thread-safe. The background thread would call while the main render loop would later call . So long as remains thread-safe, subclasses can arbitrarily split the work of loading a resource between and . It is best to try and do as much work in , however, since this will leave less work for the main render thread to do and thus increase FPS.

Specified by:
prepare in interface IResource

load

public void load(boolean backgroundThread)
Loads the resource, if it is not already.

Specified by:
load in interface IResource

reload

public void reload()
Reloads the resource, if it is already loaded.

Specified by:
reload in interface IResource

isReloadable

public boolean isReloadable()
Returns true if the is reloadable, false otherwise.

Specified by:
isReloadable in interface IResource

isManuallyLoaded

public boolean isManuallyLoaded()
Is this resource manually loaded?

Specified by:
isManuallyLoaded in interface IResource

unload

public void unload()
Unloads the resource; this is not permanent, the resource can be reloaded later if required.

Specified by:
unload in interface IResource

getSize

public int getSize()
Retrieves info about the size of the resource.

Specified by:
getSize in interface IResource

touch

public void touch()
'Touches' the resource to indicate it has been used.

Specified by:
touch in interface IResource

getName

public java.lang.String getName()
Gets resource name.

Specified by:
getName in interface IResource

getHandle

public long getHandle()
Specified by:
getHandle in interface IResource

isPrepared

public boolean isPrepared()
Returns true if the has been prepared, false otherwise.

Specified by:
isPrepared in interface IResource

isLoaded

public boolean isLoaded()
Returns true if the has been loaded, false otherwise.

Specified by:
isLoaded in interface IResource

isLoading

public boolean isLoading()
Returns whether the resource is currently in the process of background loading.

Specified by:
isLoading in interface IResource

getLoadingState

public Resource.LoadingState getLoadingState()
Returns the current loading state.

Specified by:
getLoadingState in interface IResource

isBackgroundLoaded

public boolean isBackgroundLoaded()
Returns whether this has been earmarked for background loading.

Specified by:
isBackgroundLoaded in interface IResource

setBackgroundLoaded

public void setBackgroundLoaded(boolean bl)
Tells the resource whether it is background loaded or not.

Specified by:
setBackgroundLoaded in interface IResource

escalateLoading

public void escalateLoading()
Escalates the loading of a background loaded resource.

Specified by:
escalateLoading in interface IResource

addListener

public void addListener(IResource.IListener lis)
Register a listener on this resource.

Specified by:
addListener in interface IResource

removeListener

public void removeListener(IResource.IListener lis)
Remove a listener on this resource.

Specified by:
removeListener in interface IResource

getGroup

public java.lang.String getGroup()
Specified by:
getGroup in interface IResource

changeGroupOwnership

public void changeGroupOwnership(java.lang.String newGroup)
Change the resource group ownership of a .

Specified by:
changeGroupOwnership in interface IResource

getCreator

public IResourceManager getCreator()
Specified by:
getCreator in interface IResource

getOrigin

public java.lang.String getOrigin()
Get the origin of this resource, e.g. a script file name.

Specified by:
getOrigin in interface IResource

_notifyOrigin

public void _notifyOrigin(java.lang.String origin)
Specified by:
_notifyOrigin in interface IResource

getStateCount

public int getStateCount()
Returns the number of times this resource has changed state, which generally means the number of times it has been loaded. Objects that build derived data based on the resource can check this value against a copy they kept last time they built this derived data, in order to know whether it needs rebuilding. This is a nice way of monitoring changes without having a tightly-bound callback.

Specified by:
getStateCount in interface IResource

_dirtyState

public void _dirtyState()
Manually mark the state of this resource as having been changed.

Specified by:
_dirtyState in interface IResource

_fireBackgroundLoadingComplete

public void _fireBackgroundLoadingComplete()
Firing of background loading complete event

Specified by:
_fireBackgroundLoadingComplete in interface IResource

_fireBackgroundPreparingComplete

public void _fireBackgroundPreparingComplete()
Firing of background preparing complete event

Specified by:
_fireBackgroundPreparingComplete in interface IResource

getParamDictionary

public IParamDictionary getParamDictionary()
Retrieves the parameter dictionary for this class.

Specified by:
getParamDictionary in interface IStringInterface

getParamDictionary_const

public IParamDictionary getParamDictionary_const()
Specified by:
getParamDictionary_const in interface IStringInterface

getParameters

public IParameterList getParameters()
Retrieves a list of parameters valid for this object.

Specified by:
getParameters in interface IStringInterface

setParameter

public boolean setParameter(java.lang.String name,
                            java.lang.String value)
Generic parameter setting method.

Specified by:
setParameter in interface IStringInterface

setParameterList

public void setParameterList(INameValuePairList paramList)
Generic multiple parameter setting method.

Specified by:
setParameterList in interface IStringInterface

getParameter

public java.lang.String getParameter(java.lang.String name)
Generic parameter retrieval method.

Specified by:
getParameter in interface IStringInterface

copyParametersTo

public void copyParametersTo(IStringInterface dest)
Method for copying this object's parameters to another object.

Specified by:
copyParametersTo in interface IStringInterface

cleanupDictionary

public static void cleanupDictionary()
Cleans up the static 'msDictionary' required to reset , otherwise the containers are left with invalid pointers, which will lead to a crash as soon as one of the implementers (e.g. ) initializes.


prepareResource

public void prepareResource(IResource resource)
Called when a resource wishes to load. Note that this could get called in a background thread even in just a semithreaded ogre (OGRE_THREAD_SUPPORT==2). Thus, you must not access the rendersystem from this callback. Do that stuff in loadResource.

Specified by:
prepareResource in interface IManualResourceLoader


Copyright © 2007 netAllied GmbH. All Rights Reserved.