com.threerings.opengl.gui.text
Class HTMLView

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.text.HTMLView
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>

public class HTMLView
extends Component

Displays HTML using Java's HTML rendering support to layout and render the HTML. This is not a part of the text factory system as we're not going to write our own HTML renderer to avoid dependence on Sun's JDK. If you don't want to depend on that, don't use this class.

Note: width and height hints do not work. The Java HTML code doesn't seem to handle being sized to a particular width or height and then determining its preferred span along the other axis. So we always get the "natural" preferred size of the HTML without any forced wrapping. Of course if the component is forcibly made smaller, the HTML will be wrapped, but it may not fit in the vertical or horizontal space made available. Caveat user.


Nested Class Summary
protected  class HTMLView.BridgeView
           
 
Field Summary
protected  boolean _antialias
           
protected  HTMLEditorKit _kit
           
protected  Image _rendered
           
protected  Rectangle _rsize
           
protected  StyleSheet _style
           
protected  HTMLView.BridgeView _view
           
 
Fields inherited from class com.threerings.opengl.gui.Component
_alpha, _backgrounds, _borders, _colors, _ctx, _cursor, _enabled, _height, _hover, _hoverable, _insets, _listeners, _parent, _preferredSize, _properties, _rect, _styleConfigs, _tipmouse, _tiptext, _tooltipStyle, _transferHandler, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Constructor Summary
HTMLView(GlContext ctx)
          Creates a blank HTML view.
HTMLView(GlContext ctx, String stylesheet, String contents)
          Creates an HTML view with the specified contents.
 
Method Summary
protected  Dimension computePreferredSize(int whint, int hhint)
          Computes and returns a preferred size for this component.
protected  void forceRelayout()
           
 HTMLEditorKit getEditorKit()
          Returns the HTML editor kit used by this view.
 StyleSheet getStyleSheet()
          Returns the stylesheet in effect for this view.
protected  void layout()
          Instructs this component to lay itself out.
protected  void renderComponent(Renderer renderer)
          Renders any custom bits for this component.
 void setAntialiased(boolean antialias)
          Configures whether or not our text is antialiased.
 void setContents(HTMLDocument document)
          Configures the contents of this HTML view.
 void setContents(String contents)
          Configures the contents of this HTML view.
 void setStyleSheet(String stylesheet)
          Configures the stylesheet used to render HTML in this view.
 void setStyleSheet(StyleSheet stylesheet)
          Configures the stylesheet used to render HTML in this view.
 
Methods inherited from class com.threerings.opengl.gui.Component
acceptsFocus, addListener, boundsToString, changeCursor, configUpdated, contains, createDefaultTooltipComponent, createDefaultTooltipComponent, createTooltipComponent, dispatchEvent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getContext, getCursor, getDefaultStyleConfig, getFallbackState, getFirstDescendantFocus, getFocusTarget, getHeight, getHitComponent, getInsets, getLastDescendantFocus, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleConfigs, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, getTransferHandler, getWidth, getWindow, getX, getY, hasFocus, intersectScissor, invalidate, isAdded, isEnabled, isHoverable, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, scrollRectToVisible, scrollRectToVisible, setAlpha, setBackground, setBounds, setCursor, setEnabled, setHoverable, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleConfig, setStyleConfig, setStyleConfig, setStyleConfigs, setTooltipRelativeToMouse, setTooltipText, setTransferHandler, setVisible, stateDidChange, updateCursor, updateFromStyleConfig, updateFromStyleConfig, validate, wasAdded, wasRemoved
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_style

protected StyleSheet _style

_rsize

protected Rectangle _rsize

_view

protected HTMLView.BridgeView _view

_rendered

protected Image _rendered

_antialias

protected boolean _antialias

_kit

protected HTMLEditorKit _kit
Constructor Detail

HTMLView

public HTMLView(GlContext ctx)
Creates a blank HTML view. The HTML contents can be set later with a call to setContents(java.lang.String).


HTMLView

public HTMLView(GlContext ctx,
                String stylesheet,
                String contents)
Creates an HTML view with the specified contents.

Method Detail

setAntialiased

public void setAntialiased(boolean antialias)
Configures whether or not our text is antialiased. Antialiasing is on by default.


setStyleSheet

public void setStyleSheet(String stylesheet)
Configures the stylesheet used to render HTML in this view.


setStyleSheet

public void setStyleSheet(StyleSheet stylesheet)
Configures the stylesheet used to render HTML in this view.


getStyleSheet

public StyleSheet getStyleSheet()
Returns the stylesheet in effect for this view.


getEditorKit

public HTMLEditorKit getEditorKit()
Returns the HTML editor kit used by this view.


setContents

public void setContents(String contents)
Configures the contents of this HTML view. This should be well-formed HTML which will be laid out according to the previously configured style sheet (which must be set before the contents).


setContents

public void setContents(HTMLDocument document)
Configures the contents of this HTML view.


layout

protected void layout()
Description copied from class: Component
Instructs this component to lay itself out. This is called as a result of the component changing size.

Overrides:
layout in class Component

renderComponent

protected void renderComponent(Renderer renderer)
Description copied from class: Component
Renders any custom bits for this component. This is called with the graphics context translated to (0, 0) relative to this component.

Overrides:
renderComponent in class Component

computePreferredSize

protected Dimension computePreferredSize(int whint,
                                         int hhint)
Description copied from class: Component
Computes and returns a preferred size for this component. This method is called if no overriding preferred size has been supplied.

Overrides:
computePreferredSize in class Component
Returns:
the computed preferred size of this component in a newly created Dimension instance which will be adopted (and modified) by the caller.

forceRelayout

protected void forceRelayout()