org.lobobrowser.html.renderer

Class RBlock

Implemented Interfaces:
ImageObserver, BoundableRenderable, ImageObserver, RCollection, Renderable, RenderableContainer, RElement, UINode

public class RBlock
extends org.lobobrowser.html.renderer.BaseElementRenderable
implements RenderableContainer, ImageObserver

Represents a HTML block in a rendered document, typically a DIV. The root renderer node is of this type as well.

Immediately below an RBlock you will find a node of type RBlockViewport.

Field Summary

protected RBlockViewport
bodyLayout
protected int
defaultOverflow
protected RenderableSpot
endSelection
protected FrameContext
frameContext
protected JScrollBar
hScrollBar
protected boolean
hasHScrollBar
protected boolean
hasVScrollBar
protected int
listNesting
protected HtmlRendererContext
rendererContext
protected RenderableSpot
startSelection
protected JScrollBar
vScrollBar

Fields inherited from class org.lobobrowser.html.renderer.BaseElementRenderable

INVALID_SIZE, OVERFLOW_AUTO, OVERFLOW_HIDDEN, OVERFLOW_NONE, OVERFLOW_SCROLL, OVERFLOW_VERTICAL, OVERFLOW_VISIBLE, SCROLL_BAR_THICKNESS, backgroundColor, backgroundImage, borderBottomColor, borderInsets, borderLeftColor, borderRightColor, borderStyles, borderTopColor, defaultMarginInsets, delayedPairs, lastBackgroundImageUri, layoutDeepCanBeInvalidated, userAgentContext, zIndex

Fields inherited from class org.lobobrowser.html.renderer.BaseBoundableRenderable

SELECTION_COLOR, SELECTION_XOR, container, height, layoutUpTreeCanBeInvalidated, logger, modelNode, originalParent, parent, width, x, y

Fields inherited from interface org.lobobrowser.html.renderer.Renderable

EMPTY_ARRAY

Fields inherited from interface org.lobobrowser.html.renderer.RElement

VALIGN_ABSBOTTOM, VALIGN_ABSMIDDLE, VALIGN_BASELINE, VALIGN_BOTTOM, VALIGN_MIDDLE, VALIGN_TOP

Constructor Summary

RBlock(NodeImpl modelNode, int listNesting, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, RenderableContainer parentContainer)
RBlock(NodeImpl modelNode, int listNesting, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, RenderableContainer parentContainer, int defaultOverflow)

Method Summary

void
adjust()
This adjustment step needs to be performed after layout.
void
adjust(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource)
Adjustment step which must be done after layout.
boolean
couldBeScrollable()
void
doLayout(int availWidth, int availHeight)
void
doLayout(int availWidth, int availHeight, int tentativeY)
void
doLayout(int availWidth, int availHeight, org.lobobrowser.html.renderer.FloatingBounds floatBounds, int tentativeY, int defaultOverflow)
Lays out and sets dimensions only if RBlock is invalid (or never before layed out), if the parameters passed differ from the last layout, or if the current font differs from the font for the last layout.
void
ensureVisible(Point point)
void
finalize()
org.lobobrowser.html.renderer.FloatingBounds
getExportableFloatingBounds()
int
getFirstBaselineOffset()
int
getFirstLineHeight()
RenderableSpot
getLowestRenderableSpot(int x, int y)
protected Insets
getPaddingInsets(RenderState rs)
Color
getPaintedBackgroundColor()
RBlockViewport
getRBlockViewport()
Iterator
getRenderables()
int
getVAlign()
Vertical alignment for elements rendered in a line.
int
getVScrollBarWidth()
Gets the width the vertical scrollbar has when shown.
int
getViewportListNesting(int blockNesting)
void
invalidateLayoutLocal()
RBlocks should only be invalidated if one of their properties change, or if a descendent changes, or if a style property of an ancestor is such that it could produce layout changes in this RBlock.
boolean
isOverflowVisible()
void
layout(int availWidth, int availHeight, int defaultOverflow)
void
layout(int availWidth, int availHeight, org.lobobrowser.html.renderer.FloatingBounds floatBounds, int tentativeY)
void
layout(int availWidth, int availHeight, org.lobobrowser.html.renderer.FloatingBounds floatBounds, int tentativeY, int defaultOverflow)
boolean
onDoubleClick(MouseEvent event, int x, int y)
boolean
onMouseClick(MouseEvent event, int x, int y)
boolean
onMouseDisarmed(MouseEvent event)
boolean
onMousePressed(MouseEvent event, int x, int y)
boolean
onMouseReleased(MouseEvent event, int x, int y)
void
paint(Graphics g)
boolean
paintSelection(Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)
void
repaint(ModelNode modelNode)
Called
void
scrollBy(int orientation, int offset)
void
scrollByUnits(int orientation, int units)
void
scrollHorizontalTo(int newX)
void
scrollTo(Rectangle bounds, boolean xIfNeeded, boolean yIfNeeded)
Scrolls the viewport's origin to the given location, or as close to it as possible.
void
scrollVerticalTo(int newY)
void
setDefaultMarginInsets(Insets insets)
void
setDefaultPaddingInsets(Insets insets)
void
setSelectionEnd(RenderableSpot rpoint)
void
setSelectionStart(RenderableSpot rpoint)
String
toString()
void
updateWidgetBounds(int guiX, int guiY)
Updates bounds of all descendent's GUI components, based on root bounds.

Methods inherited from class org.lobobrowser.html.renderer.BaseElementRenderable

addComponent, addDelayedPair, applyStyle, clearDelayedPairs, clearGUIComponents, doLayout, getAlignmentX, getAlignmentY, getDeclaredHeight, getDeclaredHeightImpl, getDeclaredWidth, getDelayedPairs, getInsets, getMarginInsets, getOverflow, getParentContainer, getZIndex, imageUpdate, invalidateLayoutDeep, invalidateLayoutLocal, isContainedByNode, layout, loadBackgroundImage, paint, prePaint, sendDelayedPairsToParent, sendGUIComponentsToParent, updateAllWidgetBounds, updateWidgetBounds

Methods inherited from class org.lobobrowser.html.renderer.BaseRCollection

blur, extractSelectionText, focus, getRenderable, invalidateLayoutDeep, onMouseMoved, onMouseOut, onRightClick, paintSelection, updateWidgetBounds

Methods inherited from class org.lobobrowser.html.renderer.BaseBoundableRenderable

contains, getBlockBackgroundColor, getBounds, getGUIPoint, getHeight, getModelNode, getOrigin, getOriginRelativeTo, getOriginalOrCurrentParent, getOriginalParent, getParent, getRenderablePoint, getSize, getWidth, getX, getY, invalidateLayoutLocal, invalidateLayoutUpTree, isValid, markLayoutValid, onMouseMoved, onMouseOut, paintTranslated, relayout, relayoutImpl, repaint, repaint, setBounds, setHeight, setOrigin, setOriginalParent, setParent, setWidth, setX, setY, translateDescendentPoint

Methods inherited from class org.lobobrowser.html.renderer.BaseRenderable

getOrdinal, getZIndex, setOrdinal

Field Details

bodyLayout

protected final RBlockViewport bodyLayout

defaultOverflow

protected final int defaultOverflow

endSelection

protected RenderableSpot endSelection

frameContext

protected final FrameContext frameContext

hScrollBar

protected JScrollBar hScrollBar

hasHScrollBar

protected boolean hasHScrollBar

hasVScrollBar

protected boolean hasVScrollBar

listNesting

protected final int listNesting

rendererContext

protected final HtmlRendererContext rendererContext

startSelection

protected RenderableSpot startSelection

vScrollBar

protected JScrollBar vScrollBar

Constructor Details

RBlock

public RBlock(NodeImpl modelNode,
              int listNesting,
              UserAgentContext pcontext,
              HtmlRendererContext rcontext,
              FrameContext frameContext,
              RenderableContainer parentContainer)

RBlock

public RBlock(NodeImpl modelNode,
              int listNesting,
              UserAgentContext pcontext,
              HtmlRendererContext rcontext,
              FrameContext frameContext,
              RenderableContainer parentContainer,
              int defaultOverflow)

Method Details

adjust

public void adjust()
This adjustment step needs to be performed after layout. In this case, the dimensions previously obtained in the layout are assumed to be the desired dimensions of the block.

adjust

public void adjust(int availWidth,
                   int availHeight,
                   boolean expandWidth,
                   boolean expandHeight,
                   org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource)
Adjustment step which must be done after layout. This will expand blocks that need to be expanded and relayout blocks with relative sizes accordingly.
Parameters:
availWidth -
availHeight -
expandWidth -
expandHeight -

couldBeScrollable

public final boolean couldBeScrollable()

doLayout

public final void doLayout(int availWidth,
                           int availHeight)
Overrides:
doLayout in interface org.lobobrowser.html.renderer.BaseElementRenderable

doLayout

public final void doLayout(int availWidth,
                           int availHeight,
                           int tentativeY)

doLayout

public void doLayout(int availWidth,
                     int availHeight,
                     org.lobobrowser.html.renderer.FloatingBounds floatBounds,
                     int tentativeY,
                     int defaultOverflow)
Lays out and sets dimensions only if RBlock is invalid (or never before layed out), if the parameters passed differ from the last layout, or if the current font differs from the font for the last layout.
Parameters:
availWidth -
availHeight -

ensureVisible

public void ensureVisible(Point point)

finalize

public void finalize()
            throws Throwable

getExportableFloatingBounds

public org.lobobrowser.html.renderer.FloatingBounds getExportableFloatingBounds()

getFirstBaselineOffset

public int getFirstBaselineOffset()

getFirstLineHeight

public int getFirstLineHeight()

getLowestRenderableSpot

public RenderableSpot getLowestRenderableSpot(int x,
                                              int y)
Specified by:
getLowestRenderableSpot in interface BoundableRenderable

getPaddingInsets

protected final Insets getPaddingInsets(RenderState rs)

getPaintedBackgroundColor

public Color getPaintedBackgroundColor()
Specified by:
getPaintedBackgroundColor in interface RenderableContainer

getRBlockViewport

public RBlockViewport getRBlockViewport()

getRenderables

public Iterator getRenderables()
Specified by:
getRenderables in interface RCollection

getVAlign

public int getVAlign()
Vertical alignment for elements rendered in a line. Returns one of the constants defined in this class.
Specified by:
getVAlign in interface RElement

getVScrollBarWidth

public int getVScrollBarWidth()
Gets the width the vertical scrollbar has when shown.

getViewportListNesting

public int getViewportListNesting(int blockNesting)

invalidateLayoutLocal

public void invalidateLayoutLocal()
RBlocks should only be invalidated if one of their properties change, or if a descendent changes, or if a style property of an ancestor is such that it could produce layout changes in this RBlock.
Overrides:
invalidateLayoutLocal in interface org.lobobrowser.html.renderer.BaseElementRenderable

isOverflowVisible

public final boolean isOverflowVisible()

layout

public final void layout(int availWidth,
                         int availHeight,
                         int defaultOverflow)

layout

public final void layout(int availWidth,
                         int availHeight,
                         org.lobobrowser.html.renderer.FloatingBounds floatBounds,
                         int tentativeY)

layout

public final void layout(int availWidth,
                         int availHeight,
                         org.lobobrowser.html.renderer.FloatingBounds floatBounds,
                         int tentativeY,
                         int defaultOverflow)

onDoubleClick

public boolean onDoubleClick(MouseEvent event,
                             int x,
                             int y)
Specified by:
onDoubleClick in interface BoundableRenderable

onMouseClick

public boolean onMouseClick(MouseEvent event,
                            int x,
                            int y)
Specified by:
onMouseClick in interface BoundableRenderable

onMouseDisarmed

public boolean onMouseDisarmed(MouseEvent event)
Specified by:
onMouseDisarmed in interface BoundableRenderable

onMousePressed

public boolean onMousePressed(MouseEvent event,
                              int x,
                              int y)
Specified by:
onMousePressed in interface BoundableRenderable

onMouseReleased

public boolean onMouseReleased(MouseEvent event,
                               int x,
                               int y)
Specified by:
onMouseReleased in interface BoundableRenderable

paint

public void paint(Graphics g)
Specified by:
paint in interface Renderable
Overrides:
paint in interface org.lobobrowser.html.renderer.BaseElementRenderable

paintSelection

public boolean paintSelection(Graphics g,
                              boolean inSelection,
                              RenderableSpot startPoint,
                              RenderableSpot endPoint)
Specified by:
paintSelection in interface BoundableRenderable
Overrides:
paintSelection in interface org.lobobrowser.html.renderer.BaseRCollection

repaint

public void repaint(ModelNode modelNode)
Called
Specified by:
repaint in interface UINode
Parameters:
modelNode -

scrollBy

public void scrollBy(int orientation,
                     int offset)

scrollByUnits

public void scrollByUnits(int orientation,
                          int units)

scrollHorizontalTo

public void scrollHorizontalTo(int newX)

scrollTo

public void scrollTo(Rectangle bounds,
                     boolean xIfNeeded,
                     boolean yIfNeeded)
Scrolls the viewport's origin to the given location, or as close to it as possible.

This method should be invoked in the GUI thread.

Parameters:
bounds - The bounds of the scrollable area that should become visible.
xIfNeeded - If this parameter is true the x coordinate is changed only if the horizontal bounds are not currently visible.
yIfNeeded - If this parameter is true the y coordinate is changed only if the vertical bounds are not currently visible.

scrollVerticalTo

public void scrollVerticalTo(int newY)

setDefaultMarginInsets

public void setDefaultMarginInsets(Insets insets)

setDefaultPaddingInsets

public void setDefaultPaddingInsets(Insets insets)

setSelectionEnd

public void setSelectionEnd(RenderableSpot rpoint)

setSelectionStart

public void setSelectionStart(RenderableSpot rpoint)

toString

public String toString()

updateWidgetBounds

public void updateWidgetBounds(int guiX,
                               int guiY)
Updates bounds of all descendent's GUI components, based on root bounds.
Specified by:
updateWidgetBounds in interface RCollection
Overrides:
updateWidgetBounds in interface org.lobobrowser.html.renderer.BaseRCollection