Flying Saucer Project Release ${app.version}

org.xhtmlrenderer.layout
Class SharedContext

java.lang.Object
  extended by org.xhtmlrenderer.layout.SharedContext

public class SharedContext
extends java.lang.Object

The SharedContext is that which is kept between successive layout and render runs.

Author:
empty

Constructor Summary
SharedContext(UserAgentCallback uac)
          Constructor for the Context object
 
Method Summary
 void addBoxId(java.lang.String id, Box box)
           
 boolean debugDrawBoxes()
          Description of the Method
 boolean debugDrawFontMetrics()
           
 boolean debugDrawInlineBoxes()
          Description of the Method
 boolean debugDrawLineBoxes()
          Description of the Method
 void flushFonts()
           
 java.lang.String getBaseURL()
          Gets the baseURL attribute of the RenderingContext object
 Box getBoxById(java.lang.String id)
           
 RootPanel getCanvas()
           
 StyleReference getCss()
           
 int getDotsPerPixel()
           
 float getDPI()
          Gets the dPI attribute of the RenderingContext object
 java.awt.Rectangle getFixedRectangle()
           
 FSFont getFont(FontSpecification spec)
           
 FontResolver getFontResolver()
          Gets the fontResolver attribute of the Context object
 java.util.Map getIdMap()
           
 java.lang.String getMedia()
          The media for this context
 float getMmPerPx()
          Gets the dPI attribute in a more useful form of the RenderingContext object
 NamespaceHandler getNamespaceHandler()
           
 ReplacedElementFactory getReplacedElementFactory()
           
 CalculatedStyle getStyle(org.w3c.dom.Element e)
           
 CalculatedStyle getStyle(org.w3c.dom.Element e, boolean restyle)
           
 TextRenderer getTextRenderer()
           
 UserAgentCallback getUac()
          Gets the uac attribute of the RenderingContext object
 UserAgentCallback getUserAgentCallback()
           
 float getXHeight(FontContext fontContext, FontSpecification fs)
           
 boolean isInteractive()
           
 boolean isPaged()
          Returns true if the currently set media type is paged.
 boolean isPrint()
           
 LayoutContext newLayoutContextInstance()
           
 RenderingContext newRenderingContextInstance()
           
 void removeBoxId(java.lang.String id)
           
 void removeElementReferences(org.w3c.dom.Element e)
           
 void reset()
           
 void set_TempCanvas(java.awt.Rectangle rect)
           
 void setBaseURL(java.lang.String url)
          Sets the baseURL attribute of the RenderingContext object
 void setCanvas(RootPanel canvas)
           
 void setCss(StyleReference css)
           
 void setDebug_draw_boxes(boolean debug_draw_boxes)
           
 void setDebug_draw_font_metrics(boolean debug_draw_font_metrics)
           
 void setDebug_draw_inline_boxes(boolean debug_draw_inline_boxes)
           
 void setDebug_draw_line_boxes(boolean debug_draw_line_boxes)
           
 void setDotsPerPixel(int pixelsPerDot)
           
 void setDPI(float dpi)
          Sets the effective DPI (Dots Per Inch) of the screen.
 void setFontMapping(java.lang.String name, java.awt.Font font)
          

Adds or overrides a font mapping, meaning you can associate a particular font with a particular string.

 void setFontResolver(FontResolver resolver)
           
 void setFormSubmissionListener(FormSubmissionListener fsl)
           
 void setInteractive(boolean interactive)
           
 void setMedia(java.lang.String media)
          

Set the current media type.

 void setNamespaceHandler(NamespaceHandler nh)
           
 void setPrint(boolean print)
           
 void setReplacedElementFactory(ReplacedElementFactory ref)
           
 void setTextRenderer(TextRenderer text_renderer)
          Sets the textRenderer attribute of the RenderingContext object
 void setUserAgentCallback(UserAgentCallback userAgentCallback)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SharedContext

public SharedContext(UserAgentCallback uac)
Constructor for the Context object

Method Detail

setFormSubmissionListener

public void setFormSubmissionListener(FormSubmissionListener fsl)

newLayoutContextInstance

public LayoutContext newLayoutContextInstance()

newRenderingContextInstance

public RenderingContext newRenderingContextInstance()

getFontResolver

public FontResolver getFontResolver()
Gets the fontResolver attribute of the Context object

Returns:
The fontResolver value

flushFonts

public void flushFonts()

getMedia

public java.lang.String getMedia()
The media for this context


getTextRenderer

public TextRenderer getTextRenderer()

debugDrawBoxes

public boolean debugDrawBoxes()
Description of the Method

Returns:
Returns

debugDrawLineBoxes

public boolean debugDrawLineBoxes()
Description of the Method

Returns:
Returns

debugDrawInlineBoxes

public boolean debugDrawInlineBoxes()
Description of the Method

Returns:
Returns

debugDrawFontMetrics

public boolean debugDrawFontMetrics()

setDebug_draw_boxes

public void setDebug_draw_boxes(boolean debug_draw_boxes)

setDebug_draw_line_boxes

public void setDebug_draw_line_boxes(boolean debug_draw_line_boxes)

setDebug_draw_inline_boxes

public void setDebug_draw_inline_boxes(boolean debug_draw_inline_boxes)

setDebug_draw_font_metrics

public void setDebug_draw_font_metrics(boolean debug_draw_font_metrics)

getCss

public StyleReference getCss()

setCss

public void setCss(StyleReference css)

getCanvas

public RootPanel getCanvas()

setCanvas

public void setCanvas(RootPanel canvas)

set_TempCanvas

public void set_TempCanvas(java.awt.Rectangle rect)

getFixedRectangle

public java.awt.Rectangle getFixedRectangle()

setNamespaceHandler

public void setNamespaceHandler(NamespaceHandler nh)

getNamespaceHandler

public NamespaceHandler getNamespaceHandler()

addBoxId

public void addBoxId(java.lang.String id,
                     Box box)

getBoxById

public Box getBoxById(java.lang.String id)

removeBoxId

public void removeBoxId(java.lang.String id)

getIdMap

public java.util.Map getIdMap()

setTextRenderer

public void setTextRenderer(TextRenderer text_renderer)
Sets the textRenderer attribute of the RenderingContext object

Parameters:
text_renderer - The new textRenderer value

setMedia

public void setMedia(java.lang.String media)

Set the current media type. This is usually something like screen or print . See the media section of the CSS 2.1 spec for more information on media types.

Parameters:
media - The new media value

getUac

public UserAgentCallback getUac()
Gets the uac attribute of the RenderingContext object

Returns:
The uac value

getUserAgentCallback

public UserAgentCallback getUserAgentCallback()

setUserAgentCallback

public void setUserAgentCallback(UserAgentCallback userAgentCallback)

getDPI

public float getDPI()
Gets the dPI attribute of the RenderingContext object

Returns:
The dPI value

setDPI

public void setDPI(float dpi)
Sets the effective DPI (Dots Per Inch) of the screen. You should normally never need to override the dpi, as it is already set to the system default by Toolkit.getDefaultToolkit().getScreenResolution() . You can override the value if you want to scale the fonts for accessibility or printing purposes. Currently the DPI setting only affects font sizing.

Parameters:
dpi - The new dPI value

getMmPerPx

public float getMmPerPx()
Gets the dPI attribute in a more useful form of the RenderingContext object

Returns:
The dPI value

getFont

public FSFont getFont(FontSpecification spec)

getXHeight

public float getXHeight(FontContext fontContext,
                        FontSpecification fs)

getBaseURL

public java.lang.String getBaseURL()
Gets the baseURL attribute of the RenderingContext object

Returns:
The baseURL value

setBaseURL

public void setBaseURL(java.lang.String url)
Sets the baseURL attribute of the RenderingContext object

Parameters:
url - The new baseURL value

isPaged

public boolean isPaged()
Returns true if the currently set media type is paged. Currently returns true only for print , projection , and embossed , handheld , and tv . See the media section of the CSS 2.1 spec for more information on media types.

Returns:
The paged value

isInteractive

public boolean isInteractive()

setInteractive

public void setInteractive(boolean interactive)

isPrint

public boolean isPrint()

setPrint

public void setPrint(boolean print)

setFontMapping

public void setFontMapping(java.lang.String name,
                           java.awt.Font font)

Adds or overrides a font mapping, meaning you can associate a particular font with a particular string. For example, the following would load a font out of the cool.ttf file and associate it with the name CoolFont :

   Font font = Font.createFont(Font.TRUETYPE_FONT,
   new FileInputStream("cool.ttf");
   setFontMapping("CoolFont", font);
 

You could then put the following css in your page

   p { font-family: CoolFont Arial sans-serif; }
 

You can also override existing font mappings, like replacing Arial with Helvetica.

Parameters:
name - The new font name
font - The actual Font to map

setFontResolver

public void setFontResolver(FontResolver resolver)

getDotsPerPixel

public int getDotsPerPixel()

setDotsPerPixel

public void setDotsPerPixel(int pixelsPerDot)

getStyle

public CalculatedStyle getStyle(org.w3c.dom.Element e)

getStyle

public CalculatedStyle getStyle(org.w3c.dom.Element e,
                                boolean restyle)

reset

public void reset()

getReplacedElementFactory

public ReplacedElementFactory getReplacedElementFactory()

setReplacedElementFactory

public void setReplacedElementFactory(ReplacedElementFactory ref)

removeElementReferences

public void removeElementReferences(org.w3c.dom.Element e)

Flying Saucer Project Release ${app.version}

Flying Saucer Project Home