Package org.lobobrowser.html.renderer
Class RBlock
java.lang.Object
org.lobobrowser.html.renderer.RBlock
- All Implemented Interfaces:
ImageObserver
,UINode
,BoundableRenderable
,RCollection
,RElement
,Renderable
,RenderableContainer
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
FieldsModifier and TypeFieldDescriptionprotected Color
Background color which may be different to that from RenderState in the case of a Document node.protected Image
protected final RBlockViewport
protected Color
protected BorderInfo
protected Insets
protected Color
protected Color
protected Color
protected final Map
protected final RenderableContainer
protected Insets
protected int
protected int
protected Insets
protected Collection
A list of absolute positioned or float parent-child pairs.protected RenderableSpot
protected final FrameContext
protected boolean
protected boolean
int
protected JScrollBar
protected static final Integer
protected URL
protected boolean
protected boolean
Starts as true because ancestors could be invalidated.protected final int
protected static final Logger
protected Insets
protected final ModelNode
protected RCollection
Parent for invalidation.protected int
protected int
protected Insets
protected RCollection
Parent for graphics coordinates.protected final HtmlRendererContext
protected static final int
protected static final Color
protected static final Color
protected RenderableSpot
protected final UserAgentContext
protected JScrollBar
int
int
int
protected int
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Fields inherited from interface org.lobobrowser.html.renderer.RElement
VALIGN_ABSBOTTOM, VALIGN_ABSMIDDLE, VALIGN_BASELINE, VALIGN_BOTTOM, VALIGN_MIDDLE, VALIGN_TOP
Fields inherited from interface org.lobobrowser.html.renderer.Renderable
EMPTY_ARRAY
-
Constructor Summary
ConstructorsConstructorDescriptionRBlock
(NodeImpl modelNode, int listNesting, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, RenderableContainer parentContainer) -
Method Summary
Modifier and TypeMethodDescriptionaddComponent
(Component component) void
addDelayedPair
(DelayedPair pair) protected void
applyStyle
(int availWidth, int availHeight) void
blur()
final void
protected final void
protected void
clearStyle
(boolean isRootBlock) boolean
contains
(int x, int y) final void
doLayout
(int availWidth, int availHeight, boolean sizeOnly) void
doLayout
(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource, int defaultOverflowX, int defaultOverflowY, boolean sizeOnly) 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) boolean
extractSelectionText
(StringBuffer buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) void
finalize()
void
focus()
float
float
int
int
protected Integer
getDeclaredHeight
(RenderState renderState, int actualAvailHeight) protected int
getDeclaredHeightImpl
(RenderState renderState, int availHeight) protected Integer
getDeclaredWidth
(RenderState renderState, int actualAvailWidth) int
int
final Collection
int
int
getGUIPoint
(int clientX, int clientY) int
getInsets
(boolean hscroll, boolean vscroll) Gets insets of content area.getLowestRenderableSpot
(int x, int y) int
int
int
int
int
ReturnsBoundableRenderable.getOriginalParent()
if not null.This is the parent based on the original element hierarchy.getOriginRelativeTo
(RCollection ancestor) Gets the parent where the renderable is rendered.getRenderable
(int x, int y) getRenderablePoint
(int guiX, int guiY) Gets the collection ofRenderable
children.getSize()
int
Vertical alignment for elements rendered in a line.int
getViewportListNesting
(int blockNesting) int
Gets the width the vertical scrollbar has when shown.int
getWidth()
int
getX()
int
getY()
int
final boolean
boolean
imageUpdate
(Image img, int infoflags, int x, int y, int w, int h) final void
Invalidates this Renderable and all descendents.void
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.final void
Invalidates this Renderable and its parent (i.e.boolean
Returns true if the renderable is fully contained by its modelNode, but said modelNode does not fully contain an ancestor renderable.protected boolean
final boolean
final boolean
protected boolean
isValid()
final void
layout
(int availWidth, int availHeight, boolean sizeOnly) Lays out children, and deals with "valid" state.final void
layout
(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, int defaultOverflowX, int defaultOverflowY, boolean sizeOnly) final void
layout
(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource, boolean sizeOnly) final void
layout
(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource, int defaultOverflowX, int defaultOverflowY, boolean sizeOnly) protected void
loadBackgroundImage
(URL imageURL) void
boolean
onDoubleClick
(MouseEvent event, int x, int y) boolean
onMouseClick
(MouseEvent event, int x, int y) boolean
onMouseDisarmed
(MouseEvent event) void
onMouseMoved
(MouseEvent event, int x, int y, boolean triggerEvent, ModelNode limit) void
onMouseOut
(MouseEvent event, int x, int y, ModelNode limit) boolean
onMousePressed
(MouseEvent event, int x, int y) Returns false if the event is consumed.boolean
onMouseReleased
(MouseEvent event, int x, int y) boolean
onRightClick
(MouseEvent event, int x, int y) void
All overriders should call super implementation.boolean
paintSelection
(Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) Asks the Renderable to paint the selection between two points.final void
Paints by either creating a new clipped graphics context corresponding to the bounds of the Renderable, or by translating the origin.protected void
void
relayout()
Invalidates the current Renderable (which invalidates its ancestors) and then requests the top level GUI container to do the layout and repaint.void
void
repaint()
void
repaint
(int x, int y, int width, int height) void
Calledvoid
scrollBy
(int orientation, int offset) void
scrollByUnits
(int orientation, int units) void
scrollHorizontalTo
(int newX) void
Scrolls the viewport's origin to the given location, or as close to it as possible.void
scrollVerticalTo
(int newY) protected final void
protected final void
void
setBounds
(int x, int y, int width, int height) void
setDefaultMarginInsets
(Insets insets) void
setDefaultOverflowX
(int defaultOverflowX) void
setDefaultOverflowY
(int defaultOverflowY) void
setDefaultPaddingInsets
(Insets insets) void
setHeight
(int height) void
setOrdinal
(int ordinal) void
setOrigin
(int x, int y) void
setOriginalParent
(RCollection origParent) void
setParent
(RCollection parent) void
setSelectionEnd
(RenderableSpot rpoint) void
setSelectionStart
(RenderableSpot rpoint) void
setWidth
(int width) void
setX
(int x) void
setY
(int y) toString()
protected final Point
translateDescendentPoint
(BoundableRenderable descendent, int x, int y) void
void
Updates widget bounds below this node only.void
updateWidgetBounds
(int guiX, int guiY) Updates bounds of all descendent's GUI components, based on root bounds.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.lobobrowser.html.renderer.BoundableRenderable
getBounds, getGUIPoint, getHeight, getModelNode, getOrdinal, getOrigin, getOriginalOrCurrentParent, getOriginalParent, getOriginRelativeTo, getParent, getRenderablePoint, getSize, getWidth, getX, getY, invalidateLayoutUpTree, onMouseMoved, onMouseOut, onRightClick, paintTranslated, relayout, repaint, repaint, setBounds, setHeight, setOrdinal, setOrigin, setOriginalParent, setParent, setWidth, setX, setY
Methods inherited from interface java.awt.image.ImageObserver
imageUpdate
Methods inherited from interface org.lobobrowser.html.renderer.RCollection
blur, focus
Methods inherited from interface org.lobobrowser.html.renderer.RenderableContainer
addComponent, addDelayedPair, clearDelayedPairs, focus, getDelayedPairs, getGUIPoint, getParentContainer, invalidateLayoutUpTree, relayout, repaint, updateAllWidgetBounds
-
Field Details
-
logger
-
frameContext
-
listNesting
protected final int listNesting -
rendererContext
-
bodyLayout
-
cachedLayout
-
startSelection
-
endSelection
-
vScrollBar
-
hScrollBar
-
hasHScrollBar
protected boolean hasHScrollBar -
hasVScrollBar
protected boolean hasVScrollBar -
defaultOverflowX
protected int defaultOverflowX -
defaultOverflowY
protected int defaultOverflowY -
INVALID_SIZE
-
delayedPairs
A list of absolute positioned or float parent-child pairs. -
backgroundColor
Background color which may be different to that from RenderState in the case of a Document node. -
backgroundImage
-
zIndex
protected int zIndex -
borderTopColor
-
borderLeftColor
-
borderBottomColor
-
borderRightColor
-
borderInsets
-
marginInsets
-
paddingInsets
-
borderInfo
-
lastBackgroundImageUri
-
defaultMarginInsets
-
defaultPaddingInsets
-
overflowX
protected int overflowX -
overflowY
protected int overflowY -
userAgentContext
-
layoutDeepCanBeInvalidated
protected boolean layoutDeepCanBeInvalidated -
SCROLL_BAR_THICKNESS
protected static final int SCROLL_BAR_THICKNESS- See Also:
-
SELECTION_COLOR
-
SELECTION_XOR
-
container
-
modelNode
-
x
public int x -
y
public int y -
width
public int width -
height
public int height -
layoutUpTreeCanBeInvalidated
protected boolean layoutUpTreeCanBeInvalidatedStarts as true because ancestors could be invalidated. -
parent
Parent for graphics coordinates. -
originalParent
Parent for invalidation.
-
-
Constructor Details
-
RBlock
public RBlock(NodeImpl modelNode, int listNesting, UserAgentContext pcontext, HtmlRendererContext rcontext, FrameContext frameContext, RenderableContainer parentContainer)
-
-
Method Details
-
getVScrollBarWidth
public int getVScrollBarWidth()Gets the width the vertical scrollbar has when shown. -
finalize
-
getVAlign
public int getVAlign()Description copied from interface:RElement
Vertical alignment for elements rendered in a line. Returns one of the constants defined in this class. -
ensureVisible
-
isOverflowVisibleX
public final boolean isOverflowVisibleX() -
isOverflowVisibleY
public final boolean isOverflowVisibleY() -
getFirstLineHeight
public int getFirstLineHeight() -
getFirstBaselineOffset
public int getFirstBaselineOffset() -
setSelectionEnd
-
setSelectionStart
-
getViewportListNesting
public int getViewportListNesting(int blockNesting) -
paint
All overriders should call super implementation.- Specified by:
paint
in interfaceRenderable
-
layout
public final void layout(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, int defaultOverflowX, int defaultOverflowY, boolean sizeOnly) -
layout
public final void layout(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource, boolean sizeOnly) -
layout
public final void layout(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource, int defaultOverflowX, int defaultOverflowY, boolean sizeOnly) -
doLayout
public final void doLayout(int availWidth, int availHeight, boolean sizeOnly) -
doLayout
public void doLayout(int availWidth, int availHeight, boolean expandWidth, boolean expandHeight, org.lobobrowser.html.renderer.FloatingBoundsSource floatBoundsSource, int defaultOverflowX, int defaultOverflowY, boolean sizeOnly) 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
-
-
paintSelection
public boolean paintSelection(Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) Description copied from interface:BoundableRenderable
Asks the Renderable to paint the selection between two points. Nothing will be done if the points are outside the Renderable.- Specified by:
paintSelection
in interfaceBoundableRenderable
- Returns:
- True iff it's in selection when finished painting.
-
getLowestRenderableSpot
- Specified by:
getLowestRenderableSpot
in interfaceBoundableRenderable
-
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. -
clearStyle
protected void clearStyle(boolean isRootBlock) -
onMouseClick
- Specified by:
onMouseClick
in interfaceBoundableRenderable
-
onDoubleClick
- Specified by:
onDoubleClick
in interfaceBoundableRenderable
-
onMouseDisarmed
- Specified by:
onMouseDisarmed
in interfaceBoundableRenderable
-
onMousePressed
Description copied from interface:BoundableRenderable
Returns false if the event is consumed. True to propagate further.- Specified by:
onMousePressed
in interfaceBoundableRenderable
-
onMouseReleased
- Specified by:
onMouseReleased
in interfaceBoundableRenderable
-
getPaintedBackgroundColor
- Specified by:
getPaintedBackgroundColor
in interfaceRenderableContainer
-
getRenderables
Description copied from interface:RCollection
Gets the collection ofRenderable
children.- Specified by:
getRenderables
in interfaceRCollection
-
repaint
Description copied from interface:UINode
Called -
updateWidgetBounds
public void updateWidgetBounds(int guiX, int guiY) Updates bounds of all descendent's GUI components, based on root bounds.- Specified by:
updateWidgetBounds
in interfaceRCollection
-
scrollHorizontalTo
public void scrollHorizontalTo(int newX) -
scrollVerticalTo
public void scrollVerticalTo(int newY) -
scrollByUnits
public void scrollByUnits(int orientation, int units) -
scrollBy
public void scrollBy(int orientation, int offset) -
scrollTo
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 istrue
the x coordinate is changed only if the horizontal bounds are not currently visible.yIfNeeded
- If this parameter istrue
the y coordinate is changed only if the vertical bounds are not currently visible.
-
getRBlockViewport
-
extractSelectionText
public boolean extractSelectionText(StringBuffer buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint) - Specified by:
extractSelectionText
in interfaceBoundableRenderable
-
toString
-
getExportableFloatingInfo
-
getDefaultOverflowX
public int getDefaultOverflowX() -
getDefaultOverflowY
public int getDefaultOverflowY() -
setDefaultOverflowX
public void setDefaultOverflowX(int defaultOverflowX) -
setDefaultOverflowY
public void setDefaultOverflowY(int defaultOverflowY) -
setDefaultPaddingInsets
-
setDefaultMarginInsets
-
getAlignmentX
public float getAlignmentX() -
getAlignmentY
public float getAlignmentY() -
invalidateLayoutDeep
public final void invalidateLayoutDeep()Invalidates this Renderable and all descendents. This is only used in special cases, such as when a new style sheet is added.- Specified by:
invalidateLayoutDeep
in interfaceRCollection
-
getDeclaredWidth
-
hasDeclaredWidth
public final boolean hasDeclaredWidth() -
getDeclaredHeight
-
getDeclaredHeightImpl
-
layout
public final void layout(int availWidth, int availHeight, boolean sizeOnly) Lays out children, and deals with "valid" state. Override doLayout method instead of this one. -
sendGUIComponentsToParent
protected final void sendGUIComponentsToParent() -
clearGUIComponents
protected final void clearGUIComponents() -
addComponent
- Specified by:
addComponent
in interfaceRenderableContainer
-
updateAllWidgetBounds
public void updateAllWidgetBounds()- Specified by:
updateAllWidgetBounds
in interfaceRenderableContainer
-
updateWidgetBounds
public void updateWidgetBounds()Updates widget bounds below this node only. Should not be called during general rendering. -
getBoundsRelativeToBlock
- Specified by:
getBoundsRelativeToBlock
in interfaceUINode
-
applyStyle
protected void applyStyle(int availWidth, int availHeight) -
loadBackgroundImage
-
getZIndex
public int getZIndex()- Specified by:
getZIndex
in interfaceBoundableRenderable
-
prePaint
-
imageUpdate
- Specified by:
imageUpdate
in interfaceImageObserver
-
getInsets
Gets insets of content area. It includes margin, borders and scrollbars, but not padding. -
sendDelayedPairsToParent
protected final void sendDelayedPairsToParent() -
clearDelayedPairs
public final void clearDelayedPairs()- Specified by:
clearDelayedPairs
in interfaceRenderableContainer
-
getDelayedPairs
- Specified by:
getDelayedPairs
in interfaceRenderableContainer
-
addDelayedPair
- Specified by:
addDelayedPair
in interfaceRenderableContainer
-
getParentContainer
- Specified by:
getParentContainer
in interfaceRenderableContainer
-
isContainedByNode
public boolean isContainedByNode()Description copied from interface:BoundableRenderable
Returns true if the renderable is fully contained by its modelNode, but said modelNode does not fully contain an ancestor renderable.- Specified by:
isContainedByNode
in interfaceBoundableRenderable
-
getCollapsibleMarginBottom
public int getCollapsibleMarginBottom()- Specified by:
getCollapsibleMarginBottom
in interfaceRElement
-
isMarginBoundary
protected boolean isMarginBoundary() -
getCollapsibleMarginTop
public int getCollapsibleMarginTop()- Specified by:
getCollapsibleMarginTop
in interfaceRElement
-
getMarginBottom
public int getMarginBottom()- Specified by:
getMarginBottom
in interfaceRElement
-
getMarginLeft
public int getMarginLeft()- Specified by:
getMarginLeft
in interfaceRElement
-
getMarginRight
public int getMarginRight()- Specified by:
getMarginRight
in interfaceRElement
-
getMarginTop
public int getMarginTop()- Specified by:
getMarginTop
in interfaceRElement
-
focus
public void focus()- Specified by:
focus
in interfaceRCollection
-
blur
public void blur()- Specified by:
blur
in interfaceRCollection
-
onMouseMoved
- Specified by:
onMouseMoved
in interfaceBoundableRenderable
-
onMouseOut
- Specified by:
onMouseOut
in interfaceBoundableRenderable
-
getRenderable
-
onRightClick
- Specified by:
onRightClick
in interfaceBoundableRenderable
-
markLayoutValid
public void markLayoutValid() -
getGUIPoint
- Specified by:
getGUIPoint
in interfaceBoundableRenderable
-
getRenderablePoint
- Specified by:
getRenderablePoint
in interfaceBoundableRenderable
-
getHeight
public int getHeight()- Specified by:
getHeight
in interfaceBoundableRenderable
-
getWidth
public int getWidth()- Specified by:
getWidth
in interfaceBoundableRenderable
-
setWidth
public void setWidth(int width) - Specified by:
setWidth
in interfaceBoundableRenderable
-
getX
public int getX()- Specified by:
getX
in interfaceBoundableRenderable
-
getY
public int getY()- Specified by:
getY
in interfaceBoundableRenderable
-
contains
public boolean contains(int x, int y) -
getBounds
- Specified by:
getBounds
in interfaceBoundableRenderable
-
getSize
- Specified by:
getSize
in interfaceBoundableRenderable
-
getModelNode
- Specified by:
getModelNode
in interfaceBoundableRenderable
- Specified by:
getModelNode
in interfaceRenderable
-
setBounds
public void setBounds(int x, int y, int width, int height) - Specified by:
setBounds
in interfaceBoundableRenderable
-
setX
public void setX(int x) - Specified by:
setX
in interfaceBoundableRenderable
-
setY
public void setY(int y) - Specified by:
setY
in interfaceBoundableRenderable
-
setHeight
public void setHeight(int height) - Specified by:
setHeight
in interfaceBoundableRenderable
-
setOrigin
public void setOrigin(int x, int y) - Specified by:
setOrigin
in interfaceBoundableRenderable
-
invalidateLayoutUpTree
public final void invalidateLayoutUpTree()Invalidates this Renderable and its parent (i.e. all ancestors).- Specified by:
invalidateLayoutUpTree
in interfaceBoundableRenderable
-
isValid
protected boolean isValid() -
relayout
public void relayout()Invalidates the current Renderable (which invalidates its ancestors) and then requests the top level GUI container to do the layout and repaint. It's safe to call this method outside the GUI thread.- Specified by:
relayout
in interfaceBoundableRenderable
-
relayoutIfValid
public void relayoutIfValid() -
setParent
- Specified by:
setParent
in interfaceBoundableRenderable
-
getParent
Description copied from interface:BoundableRenderable
Gets the parent where the renderable is rendered.- Specified by:
getParent
in interfaceBoundableRenderable
-
setOriginalParent
- Specified by:
setOriginalParent
in interfaceBoundableRenderable
-
getOriginalParent
This is the parent based on the original element hierarchy.- Specified by:
getOriginalParent
in interfaceBoundableRenderable
-
getOriginalOrCurrentParent
Description copied from interface:BoundableRenderable
ReturnsBoundableRenderable.getOriginalParent()
if not null. Otherwise it returnsBoundableRenderable.getParent()
.- Specified by:
getOriginalOrCurrentParent
in interfaceBoundableRenderable
-
repaint
public void repaint(int x, int y, int width, int height) - Specified by:
repaint
in interfaceBoundableRenderable
-
repaint
public void repaint()- Specified by:
repaint
in interfaceBoundableRenderable
-
getBlockBackgroundColor
-
paintTranslated
Description copied from interface:BoundableRenderable
Paints by either creating a new clipped graphics context corresponding to the bounds of the Renderable, or by translating the origin.- Specified by:
paintTranslated
in interfaceBoundableRenderable
- Parameters:
g
- Parent's Graphics context.
-
translateDescendentPoint
-
getOrigin
- Specified by:
getOrigin
in interfaceBoundableRenderable
-
getOriginRelativeTo
- Specified by:
getOriginRelativeTo
in interfaceBoundableRenderable
-
getOrdinal
public int getOrdinal() -
setOrdinal
public void setOrdinal(int ordinal)
-