Package org.xhtmlrenderer.swt
Class BasicRenderer
java.lang.Object
org.eclipse.swt.widgets.Widget
org.eclipse.swt.widgets.Control
org.eclipse.swt.widgets.Scrollable
org.eclipse.swt.widgets.Composite
org.eclipse.swt.widgets.Canvas
org.xhtmlrenderer.swt.BasicRenderer
- All Implemented Interfaces:
EventListener,org.eclipse.swt.events.PaintListener,org.eclipse.swt.graphics.Drawable,org.eclipse.swt.internal.SWTEventListener,FSCanvas,UserInterface
public class BasicRenderer
extends org.eclipse.swt.widgets.Canvas
implements org.eclipse.swt.events.PaintListener, UserInterface, FSCanvas
Renders XML+CSS using SWT in a widget (a Composite). Scrollbars are handled
automatically.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate classprivate classprivate classprivate classInformation about a special way of redrawing. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Elementprivate @Nullable Documentprivate final Set<DocumentListener> private org.eclipse.swt.graphics.Pointprivate Elementprivate floatprivate booleanprivate Elementprivate LayoutContextprivate @Nullable org.eclipse.swt.graphics.GCprivate @Nullable org.eclipse.swt.graphics.Imageprivate floatprivate floatprivate booleanprivate booleanprivate @Nullable org.eclipse.swt.graphics.Imageprivate org.eclipse.swt.graphics.Pointprivate @Nullable BlockBoxprivate final SharedContextprivate BasicRenderer.SpecialRedrawprivate static final org.slf4j.Loggerprivate static final intFields inherited from class org.eclipse.swt.widgets.Control
handle -
Constructor Summary
ConstructorsConstructorDescriptionBasicRenderer(org.eclipse.swt.widgets.Composite parent, int style) BasicRenderer(org.eclipse.swt.widgets.Composite parent, int style, UserAgentCallback uac) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDocumentListener(DocumentListener listener) private org.eclipse.swt.graphics.PointcheckOrigin(org.eclipse.swt.graphics.Point pt) Check (and correct) the point to be within origin bounds.private static intcheckStyle(int style) org.eclipse.swt.graphics.PointcomputeSize(int wHint, int hHint, boolean changed) private static RectangleconvertRectangle(org.eclipse.swt.graphics.Rectangle rect) Convert an SWT rectangle into an AWT rectangle.voidDecrements all rendered fonts on the current document by the current scaling factor for the panel.protected voiddoLayout()protected voidfind(int x, int y) protected voidprotected voidprotected voidprivate StringgetAnchorId(String url) protected RectanglefloatReturns the maximum font scaling that may be applied, e.g.floatReturns the minimum font scaling that may be applied, e.g.org.eclipse.swt.graphics.Point@Nullable Box@Nullable Layerorg.eclipse.swt.graphics.PointintgetX()intgetY()voidIncrements all rendered fonts on the current document by the current scaling factor for the panel.voidInvalidate the whole view.voidinvalidate(org.eclipse.swt.graphics.Rectangle rect) Redraw only rect.booleanGets the active attribute of the UserInterface objectprivate booleanbooleanGets the focus attribute of the UserInterface objectbooleanGets the hover attribute of the UserInterface objectbooleanisPrint()protected DocumentloadDocument(String uri) protected LayoutContextprotected RenderingContextnewRenderingContext(org.eclipse.swt.graphics.GC gc) voidpaintControl(org.eclipse.swt.events.PaintEvent e) private voidpaintPagedView(RenderingContext c, Layer root) private voidvoidrelayout()Do a full relayout and redrawvoidreload()Reload the current document.voidremoveDocumentListener(DocumentListener listener) voidResets all rendered fonts on the current document to the font size specified in the document's styling instructions.private voidscaleFont(float scaleBy) Applies a change in scale for fonts using the rendering context's text renderer.protected voidscrollTo(org.eclipse.swt.graphics.Point pt) voidsetActive_element(Element active_element) voidsetDocument(InputStream stream, String url) voidsetDocument(InputStream stream, String url, NamespaceHandler nsh) voidsetDocument(String url) voidsetDocument(String url, NamespaceHandler nsh) voidsetDocument(Document doc, String url) voidsetDocument(Document doc, String url, NamespaceHandler nsh) voidsetDocumentFromString(String content, String url, NamespaceHandler nsh) protected voidsetDocumentRelative(String filename) Sets the new current document, where the new document is located relative, e.g.voidsetFocus_element(Element focus_element) voidsetFontScalingFactor(float scaling) Sets the scaling factor used byincrementFontSize()anddecrementFontSize()--both scale the font up or down by this scaling factor.voidsetHovered_element(Element hovered_element) voidsetLayout(org.eclipse.swt.widgets.Layout layout) A Renderer has no layout!voidsetMaxFontScale(float f) Sets the maximum font scaling that may be applied, e.g.voidsetMinFontScale(float f) Sets the minimum font scaling that may be applied, e.g.voidsetOrigin(org.eclipse.swt.graphics.Point pt) Set the origin of the view.voidsetPrint(boolean print) protected booleanUpdate the scrollbarsMethods inherited from class org.eclipse.swt.widgets.Canvas
drawBackground, getCaret, getIME, scroll, setCaret, setFont, setIMEMethods inherited from class org.eclipse.swt.widgets.Composite
changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayoutDeferred, setTabListMethods inherited from class org.eclipse.swt.widgets.Scrollable
computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBarMethods inherited from class org.eclipse.swt.widgets.Control
addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackground, getBackgroundImage, getBorderWidth, getBounds, getCursor, getDragDetect, getEnabled, getFont, getForeground, getLayoutData, getLocation, getMenu, getMonitor, getOrientation, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, redraw, redraw, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackground, setBackgroundImage, setBounds, setBounds, setCapture, setCursor, setDragDetect, setEnabled, setForeground, setLayoutData, setLocation, setLocation, setMenu, setOrientation, setParent, setRedraw, setRegion, setSize, setSize, setTextDirection, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, updateMethods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.eclipse.swt.graphics.Drawable
isAutoScalable
-
Field Details
-
log
private static final org.slf4j.Logger log -
PAGE_PAINTING_CLEARANCE
private static final int PAGE_PAINTING_CLEARANCE- See Also:
-
_layout_context
-
_layout_image
private @Nullable org.eclipse.swt.graphics.Image _layout_image -
_layout_gc
private @Nullable org.eclipse.swt.graphics.GC _layout_gc -
_fontScalingFactor
private float _fontScalingFactor -
_minFontScale
private float _minFontScale -
_maxFontScale
private float _maxFontScale -
_doc
-
_rootBox
-
_documentListeners
-
_needRelayout
private boolean _needRelayout -
_hasFixedContent
private boolean _hasFixedContent -
_noResize
private boolean _noResize -
_origin
private org.eclipse.swt.graphics.Point _origin -
_drawnSize
private org.eclipse.swt.graphics.Point _drawnSize -
_offscreen
private @Nullable org.eclipse.swt.graphics.Image _offscreen -
_specialRedraw
-
_hovered_element
-
_active_element
-
_focus_element
-
-
Constructor Details
-
BasicRenderer
public BasicRenderer(org.eclipse.swt.widgets.Composite parent, int style) -
BasicRenderer
-
-
Method Details
-
checkStyle
private static int checkStyle(int style) -
addDocumentListener
-
removeDocumentListener
-
fireDocumentLoaded
protected void fireDocumentLoaded() -
fireOnLayoutException
-
fireOnRenderException
-
setLayout
public void setLayout(org.eclipse.swt.widgets.Layout layout) A Renderer has no layout!- Overrides:
setLayoutin classorg.eclipse.swt.widgets.Composite
-
relayout
public void relayout()Do a full relayout and redraw -
invalidate
public void invalidate()Invalidate the whole view. Redraw everything. -
redrawSpecial
-
invalidate
public void invalidate(org.eclipse.swt.graphics.Rectangle rect) Redraw only rect.- Parameters:
rect- the rectangle
-
newLayoutcontext
- Returns:
- a new
LayoutContext
-
newRenderingContext
- Returns:
- a new
RenderingContext
-
getInitialExtents
-
getScreenSize
public org.eclipse.swt.graphics.Point getScreenSize()- Returns:
- the size of the drawable screen
-
computeSize
public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint, boolean changed) - Overrides:
computeSizein classorg.eclipse.swt.widgets.Control
-
getFixedRectangle
- Specified by:
getFixedRectanglein interfaceFSCanvas
-
getX
public int getX() -
getY
public int getY() -
checkOrigin
private org.eclipse.swt.graphics.Point checkOrigin(org.eclipse.swt.graphics.Point pt) Check (and correct) the point to be within origin bounds. -
getOrigin
public org.eclipse.swt.graphics.Point getOrigin()- Returns:
- the origin of the view
-
setOrigin
public void setOrigin(org.eclipse.swt.graphics.Point pt) Set the origin of the view. NOTE: this won't be done immediately. -
scrollTo
protected void scrollTo(org.eclipse.swt.graphics.Point pt) -
updateScrollBars
protected boolean updateScrollBars()Update the scrollbars- Returns:
- true if we need to relayout the whole thing
-
convertRectangle
Convert an SWT rectangle into an AWT rectangle. -
paintControl
public void paintControl(org.eclipse.swt.events.PaintEvent e) - Specified by:
paintControlin interfaceorg.eclipse.swt.events.PaintListener
-
doLayout
protected void doLayout() -
doRender
-
paintPagedView
-
getDocument
-
reload
public void reload()Reload the current document. -
setDocument
-
setDocument
-
setDocumentFromString
-
setDocument
-
setDocument
-
setDocument
-
setDocument
-
isAnchorInCurrentDocument
-
getAnchorId
-
setDocumentRelative
Sets the new current document, where the new document is located relative, e.g. using a relative URL.- Parameters:
filename- The new document to load
-
loadDocument
-
getDocumentTitle
-
getRootBox
-
getRootLayer
-
getLayoutContext
-
find
-
isHover
Description copied from interface:UserInterfaceGets the hover attribute of the UserInterface object- Specified by:
isHoverin interfaceUserInterface- Parameters:
e- PARAM- Returns:
- The hover value
-
getHovered_element
-
setHovered_element
-
isActive
Description copied from interface:UserInterfaceGets the active attribute of the UserInterface object- Specified by:
isActivein interfaceUserInterface- Parameters:
e- PARAM- Returns:
- The active value
-
getActive_element
-
setActive_element
-
isFocus
Description copied from interface:UserInterfaceGets the focus attribute of the UserInterface object- Specified by:
isFocusin interfaceUserInterface- Parameters:
e- PARAM- Returns:
- The focus value
-
getFocus_element
-
setFocus_element
-
isPrint
public boolean isPrint() -
setPrint
public void setPrint(boolean print) -
setFontScalingFactor
public void setFontScalingFactor(float scaling) Sets the scaling factor used byincrementFontSize()anddecrementFontSize()--both scale the font up or down by this scaling factor. The scaling roughly modifies the font size as a multiplier or divisor. A scaling factor of 1.2 applied against a font size of 10pt results in a scaled font of 12pt. The default scaling factor is 1.2F. -
incrementFontSize
public void incrementFontSize()Increments all rendered fonts on the current document by the current scaling factor for the panel. Scaling applies cumulatively, which means that multiple calls to this method scale fonts larger and larger by applying the current scaling factor against itself. You can modify the scaling factor bysetFontScalingFactor(float), and reset to the document's specified font size withresetFontSize(). -
resetFontSize
public void resetFontSize()Resets all rendered fonts on the current document to the font size specified in the document's styling instructions. -
decrementFontSize
public void decrementFontSize()Decrements all rendered fonts on the current document by the current scaling factor for the panel. Scaling applies cumulatively, which means that multiple calls to this method scale fonts smaller and smaller by applying the current scaling factor against itself. You can modify the scaling factor bysetFontScalingFactor(float), and reset to the document's specified font size withresetFontSize(). -
scaleFont
private void scaleFont(float scaleBy) Applies a change in scale for fonts using the rendering context's text renderer. -
getMaxFontScale
public float getMaxFontScale()Returns the maximum font scaling that may be applied, e.g. 3 times assigned font size. -
getMinFontScale
public float getMinFontScale()Returns the minimum font scaling that may be applied, e.g. 0.5 times assigned font size. -
setMaxFontScale
public void setMaxFontScale(float f) Sets the maximum font scaling that may be applied, e.g. 3 times assigned font size. Calling incrementFontSize() after this scale has been reached doesn't have an effect. -
setMinFontScale
public void setMinFontScale(float f) Sets the minimum font scaling that may be applied, e.g. 3 times assigned font size. Calling decrementFontSize() after this scale has been reached doesn't have an effect.
-