com.inet.html.views
Class RenderContext

java.lang.Object
  extended by com.inet.html.views.RenderContext

public class RenderContext
extends java.lang.Object

This class contains all references and objects which are relevant to render the views correctly.


Field Summary
static int BIDI_LTR
           
static int BIDI_MIXED
           
static int BIDI_RTL
           
static int BREAK_MODE_OVERFLOW
           
static int BREAK_MODE_WORDBREAK
           
static int BREAK_MODE_WORDBREAKINLINE
           
 
Constructor Summary
RenderContext(javax.swing.text.Document document, FormRegistry formReg, InetHtmlFontFactory fontFactory)
          Creates the render context for a view tree
 
Method Summary
 boolean allowTabs()
          Returns true, if tabs are activated
 void checkImageLoading()
          Checks the current image load state and blocks the current thread until all images are rendered, if this is required by the current document.
 void clearForms()
          Clears the form registry
 boolean collapseEmptyBlocks()
          Returns true if empty blocks have an inner height of 0 PX by default, if false empty blocks have to get a height of one line.
 boolean collapseTailingBreak()
          If a BR element is the last element in a block it will have no visible effect as defined by HTML.
 int countBlockingImages()
          Returns the number of images which have to be loaded before the layouter can start
 void deregisterControl(ControlView control)
          Deregister a control.
 int getBreakMode()
          Returns the break mode which should be used by the layouter
 IBoxPainter getEmptyBoxPainter()
          Returns an unbound blank box painter.
 java.awt.Font getFont(javax.swing.text.Element elem)
          Returns the font of an element
 java.awt.Font getFont(javax.swing.text.Element elem, float size)
          Returns the font of an element
 java.awt.font.FontRenderContext getFontRenderContext()
          Returns the font render context for this view structure
static float getFontSize(javax.swing.text.Element elem)
          Returns the font size of an element
 java.lang.Object getMedia()
          Returns the media identifier of the document
 int getSelectionEnd()
          Returns the Carets Mark position
 int getSelectionStart()
          Returns the Caret Dot-position
 int getTabSize(int xOffset, int spaceWidth)
          Returns the size for the tab stop space at the current location.
 java.lang.Object getTextAntiAliasHint()
          Returns the currently set text anti alias hint
 javax.swing.JEditorPane getTextContainer()
          Returns the surrounding text component or null, if this view is not embedded in a JEditorPane.
 javax.swing.text.Document getTextContainerDocument()
          Returns the Document instance currently referenced by the text container of this view tree.
 javax.swing.text.EditorKit getTextContainerKit()
          Returns the EditorKit instance currently referenced by the text container of this view tree.
 boolean isBlockOnImageLoad()
          Returns true if the renderer is requested to block the paint operation until all images in all sub-views were loaded
 boolean isFontFallbackAllowed()
          If there are characters which cannot be displayed with a certain font, which has been set to and element, JWebEngine can use a fallback and search all known font for one, which can display the character.
 void notifiyBidi(int bidiConstant, boolean overwrite)
          Notify the bidi state of the current element or content.
 void notifyImageLoad(RemoteImage img)
          Notifies the root that another image is currently loading.
 void notifyImageLoadDone(RemoteImage img)
          Notifies the root that another image has finished loading.
 boolean paintSelection()
          Checks, whether a selection can be painted
 void registerControl(ControlView control)
          Register a control.
 boolean requiresBidiCheck()
          Returns the bidi check flag.
 void setAntiAlias(boolean calculateAntiAlias)
          Enable or disable the calculation of anti aliased text on the first layouting.
 void setFontRenderContext(java.awt.font.FontRenderContext frc)
          Sets the current font render context.
 void setFraction(boolean useFractional)
          Enable or disable the calculation of fractional metrics on the first layouting.
 void setTextAntiAlias(boolean useTextAntiAlias)
          Enables or disables the text anti alias on this view and all descendants.
 void setTextContainer(javax.swing.JEditorPane container)
          Sets the editor container for this view tree, if any.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BIDI_LTR

public static final int BIDI_LTR
See Also:
Constant Field Values

BIDI_RTL

public static final int BIDI_RTL
See Also:
Constant Field Values

BIDI_MIXED

public static final int BIDI_MIXED
See Also:
Constant Field Values

BREAK_MODE_OVERFLOW

public static final int BREAK_MODE_OVERFLOW
See Also:
Constant Field Values

BREAK_MODE_WORDBREAK

public static final int BREAK_MODE_WORDBREAK
See Also:
Constant Field Values

BREAK_MODE_WORDBREAKINLINE

public static final int BREAK_MODE_WORDBREAKINLINE
See Also:
Constant Field Values
Constructor Detail

RenderContext

public RenderContext(javax.swing.text.Document document,
                     FormRegistry formReg,
                     InetHtmlFontFactory fontFactory)
Creates the render context for a view tree

Parameters:
document - the document base of this view tree
formReg - the form registry instance to control the form elements in the current view tree
fontFactory - the font factory to create Font instances, optional
Method Detail

checkImageLoading

public void checkImageLoading()
Checks the current image load state and blocks the current thread until all images are rendered, if this is required by the current document.


isBlockOnImageLoad

public boolean isBlockOnImageLoad()
Returns true if the renderer is requested to block the paint operation until all images in all sub-views were loaded

Returns:
true if the renderer should block, false otherwise

setFraction

public void setFraction(boolean useFractional)
Enable or disable the calculation of fractional metrics on the first layouting.
NOTE: This is only relevant for the layout, it DOES NOT affect the rendering! To do so, please modify the graphics, this view structure is rendered to!

Parameters:
useFractional - true to compute fractional metrics

getFontRenderContext

public java.awt.font.FontRenderContext getFontRenderContext()
Returns the font render context for this view structure

Returns:
the font render context for this view structure

setAntiAlias

public void setAntiAlias(boolean calculateAntiAlias)
Enable or disable the calculation of anti aliased text on the first layouting.
NOTE: This is only relevant for the layout, it DOES NOT affect the rendering! To do so, please modify the graphics, this view structure is rendered to!

Parameters:
calculateAntiAlias - true to compute anti alias

setFontRenderContext

public void setFontRenderContext(java.awt.font.FontRenderContext frc)
Sets the current font render context. It is recommended to call this function if the final font render context as defined by the target Graphics is known.

Parameters:
frc - the font render context to use by all views

registerControl

public void registerControl(ControlView control)
Register a control. This MUST be done for every control view!

Parameters:
control - the control to register

deregisterControl

public void deregisterControl(ControlView control)
Deregister a control. This MUST be done for every control view, which is going to be removed!

Parameters:
control - the control to register

clearForms

public void clearForms()
Clears the form registry


setTextContainer

public void setTextContainer(javax.swing.JEditorPane container)
Sets the editor container for this view tree, if any. This is required to invert colors on selection by the text editor.

Parameters:
container - the container or null if rendered directly

getTextContainerDocument

public javax.swing.text.Document getTextContainerDocument()
Returns the Document instance currently referenced by the text container of this view tree. Will return null, if there is no container.
This function can be used to detect document changes in the editor and to block layout and paint operations in this case.

Returns:
the referenced document or null

getTextContainerKit

public javax.swing.text.EditorKit getTextContainerKit()
Returns the EditorKit instance currently referenced by the text container of this view tree. Will return null, if there is no container.
This function can be used to detect mime type changes in the editor and to block layout and paint operations in this case.

Returns:
the referenced document or null

getSelectionStart

public int getSelectionStart()
Returns the Caret Dot-position

Returns:
the Caret Dot-position

getSelectionEnd

public int getSelectionEnd()
Returns the Carets Mark position

Returns:
the Carets Mark position

getTextContainer

public javax.swing.JEditorPane getTextContainer()
Returns the surrounding text component or null, if this view is not embedded in a JEditorPane.

Returns:
Returns the surrounding text component or null, if this view is not embedded in a JEditorPane.

paintSelection

public boolean paintSelection()
Checks, whether a selection can be painted

Returns:
true, if a potential selection has to be painted

setTextAntiAlias

public void setTextAntiAlias(boolean useTextAntiAlias)
Enables or disables the text anti alias on this view and all descendants. Enabled by default.

Parameters:
useTextAntiAlias - true to enable

getTextAntiAliasHint

public java.lang.Object getTextAntiAliasHint()
Returns the currently set text anti alias hint

Returns:
the currently set text anti alias hint, never null

getFont

public java.awt.Font getFont(javax.swing.text.Element elem)
Returns the font of an element

Parameters:
elem - The element to query
Returns:
The font object for elem

getFont

public java.awt.Font getFont(javax.swing.text.Element elem,
                             float size)
Returns the font of an element

Parameters:
elem - The element to query
size - The font size of this element
Returns:
The font object for elem

getFontSize

public static float getFontSize(javax.swing.text.Element elem)
Returns the font size of an element

Parameters:
elem - The element to query
Returns:
The font size for elem in pixel

collapseEmptyBlocks

public boolean collapseEmptyBlocks()
Returns true if empty blocks have an inner height of 0 PX by default, if false empty blocks have to get a height of one line.

Returns:
true if empty blocks should collapse, false otherwise

collapseTailingBreak

public boolean collapseTailingBreak()
If a BR element is the last element in a block it will have no visible effect as defined by HTML. In case of an editor it MUST have a visible effect to the user.

Returns:
true, if the BR should rendered HTML compliant, false otherwise

notifiyBidi

public void notifiyBidi(int bidiConstant,
                        boolean overwrite)
Notify the bidi state of the current element or content. If any conflicting modes are set during the build of the views, the overall mode is set to BIDI_MIXED.

Parameters:
bidiConstant - the bidi constant
overwrite - if true, the current state will be replaces ignoring any conflict, should only be done by the root view

requiresBidiCheck

public boolean requiresBidiCheck()
Returns the bidi check flag.
This flag will return true, if

Returns:
true, if all inline layouts should check for bidi reorder, false the content ir pure LTR or pure RTL

notifyImageLoad

public void notifyImageLoad(RemoteImage img)
Notifies the root that another image is currently loading. Required to block until all images were loaded for print medias

Parameters:
img - the image which is about to load

notifyImageLoadDone

public void notifyImageLoadDone(RemoteImage img)
Notifies the root that another image has finished loading. Required to block until all images were loaded for print medias

Parameters:
img - the image which was loaded or aborted

countBlockingImages

public int countBlockingImages()
Returns the number of images which have to be loaded before the layouter can start

Returns:
the number of images which have to be loaded before the layouter can start

getMedia

public java.lang.Object getMedia()
Returns the media identifier of the document

Returns:
the media identifier of the document
See Also:
InetHtmlDocument.MEDIA_SCREEN, InetHtmlDocument.MEDIA_PRINT

getEmptyBoxPainter

public IBoxPainter getEmptyBoxPainter()
Returns an unbound blank box painter. This painter can be used to replace non-relevant painter objects to safe memory.

Returns:
an unbound blank box painter

getTabSize

public int getTabSize(int xOffset,
                      int spaceWidth)
Returns the size for the tab stop space at the current location. If there is no tab stop size set, this will return the spaceWidth as a fallback to display tab stops as a normal space.

Parameters:
xOffset - the current line x offset int PX
spaceWidth - the with of a space glyph using the current font
Returns:
the tab size in PX

allowTabs

public boolean allowTabs()
Returns true, if tabs are activated

Returns:
true, if tabs are activated

getBreakMode

public int getBreakMode()
Returns the break mode which should be used by the layouter

Returns:
the break mode which should be used by the layouter
See Also:
BREAK_MODE_OVERFLOW, BREAK_MODE_WORDBREAK, BREAK_MODE_WORDBREAKINLINE

isFontFallbackAllowed

public boolean isFontFallbackAllowed()
If there are characters which cannot be displayed with a certain font, which has been set to and element, JWebEngine can use a fallback and search all known font for one, which can display the character.

Returns:
true, if the fallback is enabled, false if not