com.inet.html.views
Class HtmlRootView

java.lang.Object
  extended by javax.swing.text.View
      extended by com.inet.html.views.BoxView
          extended by com.inet.html.views.BlockView
              extended by com.inet.html.views.HtmlRootView
All Implemented Interfaces:
ILayouted, java.lang.Cloneable, javax.swing.SwingConstants

public class HtmlRootView
extends BlockView
implements java.lang.Cloneable

HTML root view. This class is the interface between the the Editor Pane and the HTML content(JWebEngine views). It controls the layout/update process initiated by the surrounding view and the z-order in case of a repaint.


Field Summary
static int IMAGE_LOAD_TIMEOUT
          The time in ms this view will wait for all images to be loaded.
 
Fields inherited from class com.inet.html.views.BoxView
BASELINE, STATUS_REQ_LAYOUT, STATUS_REQ_PRELAYOUT, STATUS_UPTODATE
 
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
 
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
 
Constructor Summary
HtmlRootView(javax.swing.text.Element elem)
          Create a new View object
HtmlRootView(javax.swing.text.Element elem, ViewPainter painter, InetHtmlFontFactory fontFactory)
          Creates a new RootView with a custom painter and a custom font factory
 
Method Summary
 void blockOnLayoutRunning()
          Blocks the current thread until the current layout-run has finished.
 void changedUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
          
 void forceLayout()
          Forces a perform-layout and repaints the whole document.
 void forceLayout(long timeout)
          Forces a COMPLETE re-layout of the whole document!
 HtmlRootView getHTMLRoot()
          Returns the HTML root view or null, if this view was disposed
 float getMinimumSpan(int axis)
          
 int getNextVisualPositionFrom(int pos, javax.swing.text.Position.Bias b, java.awt.Shape a, int direction, javax.swing.text.Position.Bias[] biasRet)
          
 float getPreferredSpan(int axis)
          
 RenderContext getRenderContext()
          Returns the current render context, which defines render specific settings for this view tree
 void insertUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
          
 boolean isPositionRoot()
          Returns whether this block is a root for positioned or floated elements
 java.awt.Shape modelToView(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b)
          
 java.awt.Shape nativeModelToView(int pos, java.awt.Shape a, javax.swing.text.Position.Bias b)
          The same like modelToView but it cannot be ovveridden.
 void paint(java.awt.Graphics g, java.awt.Shape allocation)
          
 java.awt.Rectangle performLayout(boolean hard)
          Causes this view to update its layout.
 void performLayoutWidth()
          Layout what is required to determin the width of this view. In most cases this method only requires the CSS width setting, the parent's width and the minumum and preferred span. ATTENTION: This method mus be called before layouting the children of a view. Otherwise the children don't get a corrent parent's size.
 void performPreLayout()
          Causes this view to update its preLayout data. In case of print media this operation will wait for all images to be loaded.
 void removeUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)
          
 void setAntiAlias(boolean calculateAntiAlias)
          Enable or disable the calculation of anti aliased text on the first layouting.
 void setFraction(boolean useFractional)
          Enable or disable the calculation of fractional metrics on the first layouting.
 void setParent(javax.swing.text.View parent)
          
 void setSize(float newWidth, float newHeight)
          This method changes the OUTER box size, which is the box around the border of this box.
 int viewToModel(float x, float y, java.awt.Shape a, javax.swing.text.Position.Bias[] biasReturn)
          
 
Methods inherited from class com.inet.html.views.BlockView
createFragment, getChildAllocation, getChildViews, getCompleteHight, getContentHeight, getLayout, getLeftUpperCorner, getListValue, getMargins, getOriginalMargins, getOuterHeight, getPositionManager, getSpan, getTextIndent, getView, getViewCount, performLayoutVAlign, predictWidth, replace, replace, toExternalBox, toString, updateListMarkers
 
Methods inherited from class com.inet.html.views.BoxView
addBoxPainter, factoryPreset, getAlignment, getAutoMarginJustify, getBackgroundValue, getBorderBottomColor, getBorderLeftColor, getBorderRightColor, getBorderTopColor, getBottomInset, getBox, getBoxPainter, getClear, getContentVerticalOffset, getContentWidth, getDirection, getDisplay, getEndOffset, getFirstLineBaseLine, getFloat, getFontSize, getHeightUnit, getJustification, getLeftInset, getLineHeight, getOuterWidth, getOverflow, getPainter, getPosition, getResizeWeight, getRightInset, getStartOffset, getStatus, getSwingAlign, getTopInset, getUnicodeBidi, getViewForPosition, getViewIndex, getViewIndex, getVisibility, getWhiteSpace, getWidthUnit, isAbsolutePositioned, isBlock, isBreak, isBreakable, isFloating, isInFlow, isListItemWithMarker, isLTR, isMarker, isNativeLTR, isTableCell, isWidthSet, setBackgroundValue, setBorderBottomColor, setBorderLeftColor, setBorderRightColor, setBorderTopColor, setContentVerticalOffset, setContentWidth, setFirstLineBaseLine, setIsNativeLTR, setJustification, setMarker, setPainter, setRoot, setSizeContent, setStartAndEndOffset, setStatus, setStatusLocal
 
Methods inherited from class javax.swing.text.View
append, breakView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getGraphics, getMaximumSpan, getParent, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, viewToModel
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

IMAGE_LOAD_TIMEOUT

public static final int IMAGE_LOAD_TIMEOUT
The time in ms this view will wait for all images to be loaded. Only relevant for print media

See Also:
Constant Field Values
Constructor Detail

HtmlRootView

public HtmlRootView(javax.swing.text.Element elem)
Create a new View object

Parameters:
elem - Element to present

HtmlRootView

public HtmlRootView(javax.swing.text.Element elem,
                    ViewPainter painter,
                    InetHtmlFontFactory fontFactory)
Creates a new RootView with a custom painter and a custom font factory

Parameters:
elem - the root element of the HTML document
painter - the custom paint manager, may be null
fontFactory - the font factory to override the default new Font behavior
Method Detail

forceLayout

public void forceLayout()
Forces a perform-layout and repaints the whole document. Waits 500ms before performing the layouting to gather multiple events. This method is supposed to be used, if any changes occurred within the date which affects the page layout(e.g. image loaded -> box size changed)

Overrides:
forceLayout in class BoxView

forceLayout

public void forceLayout(long timeout)
Forces a COMPLETE re-layout of the whole document!
NOTE: If timeout is 0, the layout is performed serial in this thread an no repaint is scheduled!

Overrides:
forceLayout in class BoxView
Parameters:
timeout - the timeout until the layout is performed(may be interesting to set it to 0 or for large images)

setParent

public void setParent(javax.swing.text.View parent)

Overrides:
setParent in class BlockView
Throws:
java.lang.IllegalArgumentException - Will be thrown if this is not the root of the html document

setSize

public void setSize(float newWidth,
                    float newHeight)
This method changes the OUTER box size, which is the box around the border of this box. The content size will be set to a size which fits into this box.

Overrides:
setSize in class BoxView
Parameters:
newWidth - the new width in px
newHeight - the new height in px

performPreLayout

public void performPreLayout()
Causes this view to update its preLayout data. The event will be passed down to all descendands by the layout. In case of print media this operation will wait for all images to be loaded. If this operation get's an interrupted Exception it will layout immediately.

Specified by:
performPreLayout in interface ILayouted
Overrides:
performPreLayout in class BlockView

performLayout

public java.awt.Rectangle performLayout(boolean hard)
Causes this view to update its layout. The event will be passed down to all descendants by the layout itself(has to be done while layouting).

Overrides:
performLayout in class BlockView
Parameters:
hard - if set to true, the current layout state will be ignored and the view will be re-layouted anyways
Returns:
the area spanned by this view an it's siblings

performLayoutWidth

public void performLayoutWidth()
Layout what is required to determin the width of this view. In most cases this method only requires the CSS width setting, the parent's width and the minumum and preferred span. ATTENTION: This method mus be called before layouting the children of a view. Otherwise the children don't get a corrent parent's size.

Overrides:
performLayoutWidth in class BlockView

getPreferredSpan

public float getPreferredSpan(int axis)

Overrides:
getPreferredSpan in class BlockView

getMinimumSpan

public float getMinimumSpan(int axis)

Overrides:
getMinimumSpan in class BlockView

paint

public void paint(java.awt.Graphics g,
                  java.awt.Shape allocation)

Overrides:
paint in class BlockView

changedUpdate

public void changedUpdate(javax.swing.event.DocumentEvent e,
                          java.awt.Shape a,
                          javax.swing.text.ViewFactory f)

Overrides:
changedUpdate in class BlockView

insertUpdate

public void insertUpdate(javax.swing.event.DocumentEvent e,
                         java.awt.Shape a,
                         javax.swing.text.ViewFactory f)

Overrides:
insertUpdate in class BlockView

removeUpdate

public void removeUpdate(javax.swing.event.DocumentEvent e,
                         java.awt.Shape a,
                         javax.swing.text.ViewFactory f)

Overrides:
removeUpdate in class BlockView

viewToModel

public int viewToModel(float x,
                       float y,
                       java.awt.Shape a,
                       javax.swing.text.Position.Bias[] biasReturn)

Overrides:
viewToModel in class BlockView

modelToView

public java.awt.Shape modelToView(int pos,
                                  java.awt.Shape a,
                                  javax.swing.text.Position.Bias b)
                           throws javax.swing.text.BadLocationException

Overrides:
modelToView in class BlockView
Throws:
javax.swing.text.BadLocationException

nativeModelToView

public final java.awt.Shape nativeModelToView(int pos,
                                              java.awt.Shape a,
                                              javax.swing.text.Position.Bias b)
                                       throws javax.swing.text.BadLocationException
The same like modelToView but it cannot be ovveridden.

Parameters:
pos - the position of the desired character (>=0)
a - the area of the view, which encompasses the requested character
b - the bias
Returns:
the bounding box, in view coordinate space, of the character at the specified position
Throws:
javax.swing.text.BadLocationException - if the specified position does not represent a valid location in the associated document

getNextVisualPositionFrom

public int getNextVisualPositionFrom(int pos,
                                     javax.swing.text.Position.Bias b,
                                     java.awt.Shape a,
                                     int direction,
                                     javax.swing.text.Position.Bias[] biasRet)
                              throws javax.swing.text.BadLocationException

Overrides:
getNextVisualPositionFrom in class javax.swing.text.View
Throws:
javax.swing.text.BadLocationException

getHTMLRoot

public HtmlRootView getHTMLRoot()
Returns the HTML root view or null, if this view was disposed

Overrides:
getHTMLRoot in class BoxView
Returns:
the HTML root view or null, if this view was disposed

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

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

getRenderContext

public RenderContext getRenderContext()
Returns the current render context, which defines render specific settings for this view tree

Overrides:
getRenderContext in class BoxView
Returns:
the current render context, never null

blockOnLayoutRunning

public void blockOnLayoutRunning()
Blocks the current thread until the current layout-run has finished.


isPositionRoot

public boolean isPositionRoot()
Returns whether this block is a root for positioned or floated elements

Overrides:
isPositionRoot in class BlockView
Returns:
true if this block is a root element, false otherwise