Package org.lobobrowser.html.renderer
Class RImgControl
- java.lang.Object
-
- org.lobobrowser.html.renderer.RImgControl
-
- All Implemented Interfaces:
java.awt.image.ImageObserver,UINode,BoundableRenderable,RCollection,RElement,Renderable,RenderableContainer
public class RImgControl extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description protected java.awt.ColorbackgroundColorBackground color which may be different to that from RenderState in the case of a Document node.protected java.awt.ImagebackgroundImageprotected java.awt.ColorborderBottomColorprotected BorderInfoborderInfoprotected java.awt.InsetsborderInsetsprotected java.awt.ColorborderLeftColorprotected java.awt.ColorborderRightColorprotected java.awt.ColorborderTopColorprotected RenderableContainercontainerprotected java.awt.InsetsdefaultMarginInsetsprotected java.awt.InsetsdefaultPaddingInsetsprotected java.util.CollectiondelayedPairsA list of absolute positioned or float parent-child pairs.intheightprotected static java.lang.IntegerINVALID_SIZEprotected java.net.URLlastBackgroundImageUriprotected booleanlayoutDeepCanBeInvalidatedprotected booleanlayoutUpTreeCanBeInvalidatedStarts as true because ancestors could be invalidated.protected static java.util.logging.Loggerloggerprotected java.awt.InsetsmarginInsetsprotected ModelNodemodelNodeprotected RCollectionoriginalParentParent for invalidation.protected intoverflowXprotected intoverflowYprotected java.awt.InsetspaddingInsetsprotected RCollectionparentParent for graphics coordinates.protected static intSCROLL_BAR_THICKNESSprotected static java.awt.ColorSELECTION_COLORprotected static java.awt.ColorSELECTION_XORprotected UserAgentContextuserAgentContextorg.lobobrowser.html.renderer.UIControlwidgetintwidthintxintyprotected intzIndex-
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
Constructors Constructor Description RImgControl(ModelNode me, org.lobobrowser.html.renderer.UIControl widget, RenderableContainer container, FrameContext frameContext, UserAgentContext ucontext)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.awt.ComponentaddComponent(java.awt.Component component)voidaddDelayedPair(DelayedPair pair)protected voidapplyStyle(int availWidth, int availHeight)voidblur()voidclearDelayedPairs()protected voidclearGUIComponents()protected voidclearStyle(boolean isRootBlock)booleancontains(int x, int y)voiddoLayout(int availWidth, int availHeight, boolean sizeOnly)booleanextractSelectionText(java.lang.StringBuffer buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)voidfocus()floatgetAlignmentX()floatgetAlignmentY()java.awt.ColorgetBlockBackgroundColor()java.awt.RectanglegetBounds()java.awt.RectanglegetBoundsRelativeToBlock()intgetCollapsibleMarginBottom()intgetCollapsibleMarginTop()protected java.lang.IntegergetDeclaredHeight(RenderState renderState, int actualAvailHeight)protected intgetDeclaredHeightImpl(RenderState renderState, int availHeight)protected java.lang.IntegergetDeclaredWidth(RenderState renderState, int actualAvailWidth)java.util.CollectiongetDelayedPairs()java.awt.ColorgetForegroundColor()java.awt.PointgetGUIPoint(int clientX, int clientY)intgetHeight()java.awt.InsetsgetInsets(boolean hscroll, boolean vscroll)Gets insets of content area.RenderableSpotgetLowestRenderableSpot(int x, int y)intgetMarginBottom()intgetMarginLeft()intgetMarginRight()intgetMarginTop()ModelNodegetModelNode()intgetOrdinal()java.awt.PointgetOrigin()RCollectiongetOriginalOrCurrentParent()ReturnsBoundableRenderable.getOriginalParent()if not null.RCollectiongetOriginalParent()This is the parent based on the original element hierarchy.java.awt.PointgetOriginRelativeTo(RCollection ancestor)java.awt.ColorgetPaintedBackgroundColor()RCollectiongetParent()Gets the parent where the renderable is rendered.RenderableContainergetParentContainer()BoundableRenderablegetRenderable(int x, int y)java.awt.PointgetRenderablePoint(int guiX, int guiY)java.util.IteratorgetRenderables()Gets the collection ofRenderablechildren.java.awt.DimensiongetSize()intgetVAlign()Vertical alignment for elements rendered in a line.intgetWidth()intgetX()intgetY()intgetZIndex()booleanhasBackground()booleanhasDeclaredWidth()booleanimageUpdate(java.awt.Image img, int infoflags, int x, int y, int w, int h)voidinvalidateLayoutDeep()Invalidates this Renderable and all descendents.voidinvalidateLayoutLocal()voidinvalidateLayoutUpTree()Invalidates this Renderable and its parent (i.e.voidinvalidateRenderStyle()booleanisContainedByNode()Returns true if the renderable is fully contained by its modelNode, but said modelNode does not fully contain an ancestor renderable.protected booleanisMarginBoundary()protected booleanisValid()voidlayout(int availWidth, int availHeight, boolean sizeOnly)Lays out children, and deals with "valid" state.protected voidloadBackgroundImage(java.net.URL imageURL)voidmarkLayoutValid()booleanonDoubleClick(java.awt.event.MouseEvent event, int x, int y)booleanonMouseClick(java.awt.event.MouseEvent event, int x, int y)booleanonMouseDisarmed(java.awt.event.MouseEvent event)voidonMouseMoved(java.awt.event.MouseEvent event, int x, int y, boolean triggerEvent, ModelNode limit)voidonMouseOut(java.awt.event.MouseEvent event, int x, int y, ModelNode limit)booleanonMousePressed(java.awt.event.MouseEvent event, int x, int y)Returns false if the event is consumed.booleanonMouseReleased(java.awt.event.MouseEvent event, int x, int y)booleanonRightClick(java.awt.event.MouseEvent event, int x, int y)voidpaint(java.awt.Graphics g)All overriders should call super implementation.booleanpaintSelection(java.awt.Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)Asks the Renderable to paint the selection between two points.voidpaintTranslated(java.awt.Graphics g)Paints by either creating a new clipped graphics context corresponding to the bounds of the Renderable, or by translating the origin.voidpreferredSizeInvalidated()May be called by controls when they wish to modifiy their preferred size (e.g.protected voidprePaint(java.awt.Graphics g)voidrelayout()Invalidates the current Renderable (which invalidates its ancestors) and then requests the top level GUI container to do the layout and repaint.voidrelayoutIfValid()voidrepaint()voidrepaint(int x, int y, int width, int height)voidrepaint(ModelNode modelNode)Calledprotected voidsendDelayedPairsToParent()protected voidsendGUIComponentsToParent()voidsetBounds(int x, int y, int width, int height)voidsetDefaultMarginInsets(java.awt.Insets insets)voidsetDefaultPaddingInsets(java.awt.Insets insets)voidsetHeight(int height)voidsetOrdinal(int ordinal)voidsetOrigin(int x, int y)voidsetOriginalParent(RCollection origParent)voidsetParent(RCollection parent)voidsetWidth(int width)voidsetX(int x)voidsetY(int y)protected java.awt.PointtranslateDescendentPoint(BoundableRenderable descendent, int x, int y)voidupdateAllWidgetBounds()voidupdateWidgetBounds()Updates widget bounds below this node only.voidupdateWidgetBounds(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, finalize, getClass, hashCode, notify, notifyAll, toString, 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, getZIndex, invalidateLayoutUpTree, isContainedByNode, onMouseMoved, onMouseOut, onRightClick, paintTranslated, relayout, repaint, repaint, setBounds, setHeight, setOrdinal, setOrigin, setOriginalParent, setParent, setWidth, setX, setY
-
Methods inherited from interface org.lobobrowser.html.renderer.RCollection
blur, invalidateLayoutDeep
-
Methods inherited from interface org.lobobrowser.html.renderer.RElement
getCollapsibleMarginBottom, getCollapsibleMarginTop, getMarginBottom, getMarginLeft, getMarginRight, getMarginTop, layout
-
Methods inherited from interface org.lobobrowser.html.renderer.RenderableContainer
getGUIPoint, invalidateLayoutUpTree, relayout, repaint
-
Methods inherited from interface org.lobobrowser.html.domimpl.UINode
blur, getBounds, getBoundsRelativeToBlock
-
-
-
-
Field Detail
-
widget
public final org.lobobrowser.html.renderer.UIControl widget
-
modelNode
protected final ModelNode modelNode
-
INVALID_SIZE
protected static final java.lang.Integer INVALID_SIZE
-
delayedPairs
protected java.util.Collection delayedPairs
A list of absolute positioned or float parent-child pairs.
-
backgroundColor
protected java.awt.Color backgroundColor
Background color which may be different to that from RenderState in the case of a Document node.
-
backgroundImage
protected volatile java.awt.Image backgroundImage
-
zIndex
protected int zIndex
-
borderTopColor
protected java.awt.Color borderTopColor
-
borderLeftColor
protected java.awt.Color borderLeftColor
-
borderBottomColor
protected java.awt.Color borderBottomColor
-
borderRightColor
protected java.awt.Color borderRightColor
-
borderInsets
protected java.awt.Insets borderInsets
-
marginInsets
protected java.awt.Insets marginInsets
-
paddingInsets
protected java.awt.Insets paddingInsets
-
borderInfo
protected BorderInfo borderInfo
-
lastBackgroundImageUri
protected java.net.URL lastBackgroundImageUri
-
defaultMarginInsets
protected java.awt.Insets defaultMarginInsets
-
defaultPaddingInsets
protected java.awt.Insets defaultPaddingInsets
-
overflowX
protected int overflowX
-
overflowY
protected int overflowY
-
userAgentContext
protected final UserAgentContext userAgentContext
-
layoutDeepCanBeInvalidated
protected boolean layoutDeepCanBeInvalidated
-
SCROLL_BAR_THICKNESS
protected static final int SCROLL_BAR_THICKNESS
- See Also:
- Constant Field Values
-
logger
protected static final java.util.logging.Logger logger
-
SELECTION_COLOR
protected static final java.awt.Color SELECTION_COLOR
-
SELECTION_XOR
protected static final java.awt.Color SELECTION_XOR
-
container
protected final RenderableContainer container
-
x
public int x
-
y
public int y
-
width
public int width
-
height
public int height
-
layoutUpTreeCanBeInvalidated
protected boolean layoutUpTreeCanBeInvalidated
Starts as true because ancestors could be invalidated.
-
parent
protected RCollection parent
Parent for graphics coordinates.
-
originalParent
protected RCollection originalParent
Parent for invalidation.
-
-
Constructor Detail
-
RImgControl
public RImgControl(ModelNode me, org.lobobrowser.html.renderer.UIControl widget, RenderableContainer container, FrameContext frameContext, UserAgentContext ucontext)
-
-
Method Detail
-
applyStyle
protected void applyStyle(int availWidth, int availHeight)
-
focus
public void focus()
- Specified by:
focusin interfaceRCollection- Specified by:
focusin interfaceRenderableContainer- Specified by:
focusin interfaceUINode
-
invalidateLayoutLocal
public final void invalidateLayoutLocal()
-
getVAlign
public int getVAlign()
Description copied from interface:RElementVertical alignment for elements rendered in a line. Returns one of the constants defined in this class.
-
hasBackground
public boolean hasBackground()
-
paint
public final void paint(java.awt.Graphics g)
All overriders should call super implementation.- Specified by:
paintin interfaceRenderable
-
onMouseClick
public boolean onMouseClick(java.awt.event.MouseEvent event, int x, int y)- Specified by:
onMouseClickin interfaceBoundableRenderable
-
onDoubleClick
public boolean onDoubleClick(java.awt.event.MouseEvent event, int x, int y)- Specified by:
onDoubleClickin interfaceBoundableRenderable
-
onMousePressed
public boolean onMousePressed(java.awt.event.MouseEvent event, int x, int y)Description copied from interface:BoundableRenderableReturns false if the event is consumed. True to propagate further.- Specified by:
onMousePressedin interfaceBoundableRenderable
-
onMouseReleased
public boolean onMouseReleased(java.awt.event.MouseEvent event, int x, int y)- Specified by:
onMouseReleasedin interfaceBoundableRenderable
-
onMouseDisarmed
public boolean onMouseDisarmed(java.awt.event.MouseEvent event)
- Specified by:
onMouseDisarmedin interfaceBoundableRenderable
-
invalidateRenderStyle
public void invalidateRenderStyle()
-
updateWidgetBounds
public void updateWidgetBounds(int guiX, int guiY)Updates bounds of all descendent's GUI components, based on root bounds.- Specified by:
updateWidgetBoundsin interfaceRCollection
-
getBlockBackgroundColor
public java.awt.Color getBlockBackgroundColor()
-
paintSelection
public boolean paintSelection(java.awt.Graphics g, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)Description copied from interface:BoundableRenderableAsks the Renderable to paint the selection between two points. Nothing will be done if the points are outside the Renderable.- Specified by:
paintSelectionin interfaceBoundableRenderable- Returns:
- True iff it's in selection when finished painting.
-
extractSelectionText
public boolean extractSelectionText(java.lang.StringBuffer buffer, boolean inSelection, RenderableSpot startPoint, RenderableSpot endPoint)- Specified by:
extractSelectionTextin interfaceBoundableRenderable
-
getLowestRenderableSpot
public RenderableSpot getLowestRenderableSpot(int x, int y)
- Specified by:
getLowestRenderableSpotin interfaceBoundableRenderable
-
doLayout
public void doLayout(int availWidth, int availHeight, boolean sizeOnly)
-
preferredSizeInvalidated
public final void preferredSizeInvalidated()
May be called by controls when they wish to modifiy their preferred size (e.g. an image after it's loaded). This method must be called in the GUI thread.
-
getRenderables
public java.util.Iterator getRenderables()
Description copied from interface:RCollectionGets the collection ofRenderablechildren.- Specified by:
getRenderablesin interfaceRCollection
-
getPaintedBackgroundColor
public java.awt.Color getPaintedBackgroundColor()
- Specified by:
getPaintedBackgroundColorin interfaceRenderableContainer
-
getForegroundColor
public java.awt.Color getForegroundColor()
-
setDefaultPaddingInsets
public void setDefaultPaddingInsets(java.awt.Insets insets)
-
setDefaultMarginInsets
public void setDefaultMarginInsets(java.awt.Insets insets)
-
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:
invalidateLayoutDeepin interfaceRCollection
-
getDeclaredWidth
protected java.lang.Integer getDeclaredWidth(RenderState renderState, int actualAvailWidth)
-
hasDeclaredWidth
public final boolean hasDeclaredWidth()
-
getDeclaredHeight
protected java.lang.Integer getDeclaredHeight(RenderState renderState, int actualAvailHeight)
-
getDeclaredHeightImpl
protected int getDeclaredHeightImpl(RenderState renderState, int availHeight)
-
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
public java.awt.Component addComponent(java.awt.Component component)
- Specified by:
addComponentin interfaceRenderableContainer
-
updateAllWidgetBounds
public void updateAllWidgetBounds()
- Specified by:
updateAllWidgetBoundsin interfaceRenderableContainer
-
updateWidgetBounds
public void updateWidgetBounds()
Updates widget bounds below this node only. Should not be called during general rendering.
-
getBoundsRelativeToBlock
public java.awt.Rectangle getBoundsRelativeToBlock()
- Specified by:
getBoundsRelativeToBlockin interfaceUINode
-
clearStyle
protected void clearStyle(boolean isRootBlock)
-
loadBackgroundImage
protected void loadBackgroundImage(java.net.URL imageURL)
-
getZIndex
public int getZIndex()
- Specified by:
getZIndexin interfaceBoundableRenderable
-
prePaint
protected void prePaint(java.awt.Graphics g)
-
imageUpdate
public boolean imageUpdate(java.awt.Image img, int infoflags, int x, int y, int w, int h)- Specified by:
imageUpdatein interfacejava.awt.image.ImageObserver
-
getInsets
public java.awt.Insets getInsets(boolean hscroll, boolean vscroll)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:
clearDelayedPairsin interfaceRenderableContainer
-
getDelayedPairs
public final java.util.Collection getDelayedPairs()
- Specified by:
getDelayedPairsin interfaceRenderableContainer
-
addDelayedPair
public void addDelayedPair(DelayedPair pair)
- Specified by:
addDelayedPairin interfaceRenderableContainer
-
getParentContainer
public RenderableContainer getParentContainer()
- Specified by:
getParentContainerin interfaceRenderableContainer
-
isContainedByNode
public boolean isContainedByNode()
Description copied from interface:BoundableRenderableReturns true if the renderable is fully contained by its modelNode, but said modelNode does not fully contain an ancestor renderable.- Specified by:
isContainedByNodein interfaceBoundableRenderable
-
getCollapsibleMarginBottom
public int getCollapsibleMarginBottom()
- Specified by:
getCollapsibleMarginBottomin interfaceRElement
-
isMarginBoundary
protected boolean isMarginBoundary()
-
getCollapsibleMarginTop
public int getCollapsibleMarginTop()
- Specified by:
getCollapsibleMarginTopin interfaceRElement
-
getMarginBottom
public int getMarginBottom()
- Specified by:
getMarginBottomin interfaceRElement
-
getMarginLeft
public int getMarginLeft()
- Specified by:
getMarginLeftin interfaceRElement
-
getMarginRight
public int getMarginRight()
- Specified by:
getMarginRightin interfaceRElement
-
getMarginTop
public int getMarginTop()
- Specified by:
getMarginTopin interfaceRElement
-
blur
public void blur()
- Specified by:
blurin interfaceRCollection
-
onMouseMoved
public void onMouseMoved(java.awt.event.MouseEvent event, int x, int y, boolean triggerEvent, ModelNode limit)- Specified by:
onMouseMovedin interfaceBoundableRenderable
-
onMouseOut
public void onMouseOut(java.awt.event.MouseEvent event, int x, int y, ModelNode limit)- Specified by:
onMouseOutin interfaceBoundableRenderable
-
getRenderable
public BoundableRenderable getRenderable(int x, int y)
-
onRightClick
public boolean onRightClick(java.awt.event.MouseEvent event, int x, int y)- Specified by:
onRightClickin interfaceBoundableRenderable
-
markLayoutValid
public void markLayoutValid()
-
getGUIPoint
public java.awt.Point getGUIPoint(int clientX, int clientY)- Specified by:
getGUIPointin interfaceBoundableRenderable
-
getRenderablePoint
public java.awt.Point getRenderablePoint(int guiX, int guiY)- Specified by:
getRenderablePointin interfaceBoundableRenderable
-
getHeight
public int getHeight()
- Specified by:
getHeightin interfaceBoundableRenderable
-
getWidth
public int getWidth()
- Specified by:
getWidthin interfaceBoundableRenderable
-
setWidth
public void setWidth(int width)
- Specified by:
setWidthin interfaceBoundableRenderable
-
getX
public int getX()
- Specified by:
getXin interfaceBoundableRenderable
-
getY
public int getY()
- Specified by:
getYin interfaceBoundableRenderable
-
contains
public boolean contains(int x, int y)
-
getBounds
public java.awt.Rectangle getBounds()
- Specified by:
getBoundsin interfaceBoundableRenderable
-
getSize
public java.awt.Dimension getSize()
- Specified by:
getSizein interfaceBoundableRenderable
-
getModelNode
public ModelNode getModelNode()
- Specified by:
getModelNodein interfaceBoundableRenderable- Specified by:
getModelNodein interfaceRenderable
-
setBounds
public void setBounds(int x, int y, int width, int height)- Specified by:
setBoundsin interfaceBoundableRenderable
-
setX
public void setX(int x)
- Specified by:
setXin interfaceBoundableRenderable
-
setY
public void setY(int y)
- Specified by:
setYin interfaceBoundableRenderable
-
setHeight
public void setHeight(int height)
- Specified by:
setHeightin interfaceBoundableRenderable
-
setOrigin
public void setOrigin(int x, int y)- Specified by:
setOriginin interfaceBoundableRenderable
-
invalidateLayoutUpTree
public final void invalidateLayoutUpTree()
Invalidates this Renderable and its parent (i.e. all ancestors).- Specified by:
invalidateLayoutUpTreein 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:
relayoutin interfaceBoundableRenderable
-
relayoutIfValid
public void relayoutIfValid()
-
setParent
public void setParent(RCollection parent)
- Specified by:
setParentin interfaceBoundableRenderable
-
getParent
public RCollection getParent()
Description copied from interface:BoundableRenderableGets the parent where the renderable is rendered.- Specified by:
getParentin interfaceBoundableRenderable
-
setOriginalParent
public void setOriginalParent(RCollection origParent)
- Specified by:
setOriginalParentin interfaceBoundableRenderable
-
getOriginalParent
public RCollection getOriginalParent()
This is the parent based on the original element hierarchy.- Specified by:
getOriginalParentin interfaceBoundableRenderable
-
getOriginalOrCurrentParent
public RCollection getOriginalOrCurrentParent()
Description copied from interface:BoundableRenderableReturnsBoundableRenderable.getOriginalParent()if not null. Otherwise it returnsBoundableRenderable.getParent().- Specified by:
getOriginalOrCurrentParentin interfaceBoundableRenderable
-
repaint
public void repaint(int x, int y, int width, int height)- Specified by:
repaintin interfaceBoundableRenderable
-
repaint
public void repaint()
- Specified by:
repaintin interfaceBoundableRenderable
-
paintTranslated
public final void paintTranslated(java.awt.Graphics g)
Description copied from interface:BoundableRenderablePaints by either creating a new clipped graphics context corresponding to the bounds of the Renderable, or by translating the origin.- Specified by:
paintTranslatedin interfaceBoundableRenderable- Parameters:
g- Parent's Graphics context.
-
translateDescendentPoint
protected final java.awt.Point translateDescendentPoint(BoundableRenderable descendent, int x, int y)
-
getOrigin
public java.awt.Point getOrigin()
- Specified by:
getOriginin interfaceBoundableRenderable
-
getOriginRelativeTo
public java.awt.Point getOriginRelativeTo(RCollection ancestor)
- Specified by:
getOriginRelativeToin interfaceBoundableRenderable
-
getOrdinal
public int getOrdinal()
-
setOrdinal
public void setOrdinal(int ordinal)
-
-