com.jmex.bui.text
Class HTMLView

java.lang.Object
  extended by com.jmex.bui.BComponent
      extended by com.jmex.bui.text.HTMLView

public class HTMLView
extends BComponent

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  javax.swing.text.html.HTMLEditorKit _kit
           
protected  BImage _rendered
           
protected  java.awt.Rectangle _rsize
           
protected  javax.swing.text.html.StyleSheet _style
           
protected  HTMLView.BridgeView _view
           
 
Fields inherited from class com.jmex.bui.BComponent
_alpha, _backgrounds, _bbuf, _borders, _colors, _cursor, _enabled, _height, _hover, _insets, _listeners, _parent, _preferredSize, _properties, _styleClass, _tipmouse, _tipStyle, _tiptext, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Constructor Summary
HTMLView()
          Creates a blank HTML view.
HTMLView(java.lang.String stylesheet, java.lang.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()
           
 javax.swing.text.html.HTMLEditorKit getEditorKit()
          Returns the HTML editor kit used by this view.
 javax.swing.text.html.StyleSheet getStyleSheet()
          Returns the stylesheet in effect for this view.
protected  void layout()
          Instructs this component to lay itself out.
protected  void release()
           
protected  void renderComponent(com.jme.renderer.Renderer renderer)
          Renders any custom bits for this component.
 void setAntialiased(boolean antialias)
          Configures whether or not our text is antialiased.
 void setContents(javax.swing.text.html.HTMLDocument document)
          Configures the contents of this HTML view.
 void setContents(java.lang.String contents)
          Configures the contents of this HTML view.
 void setStyleSheet(java.lang.String stylesheet)
          Configures the stylesheet used to render HTML in this view.
 void setStyleSheet(javax.swing.text.html.StyleSheet stylesheet)
          Configures the stylesheet used to render HTML in this view.
protected  void wasRemoved()
          This method is called when we are removed from a hierarchy that is connected to a top-level window.
 
Methods inherited from class com.jmex.bui.BComponent
acceptsFocus, addListener, addListeners, applyDefaultStates, boundsToString, changeCursor, configureStyle, createTooltipComponent, dispatchEvent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getCursor, getDefaultStyleClass, getFocusTarget, getHeight, getHitComponent, getInsets, getLocation, getName, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleClass, getTooltipText, getWidth, getWindow, getX, getY, hasFocus, intersectScissorBox, invalidate, isAdded, isConsumeMouseEvents, isEnabled, isHoverEnabled, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, restoreScissorState, setAlpha, setBackground, setBounds, setConsumeMouseEvents, setCursor, setEnabled, setHoverEnabled, setLocation, setName, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleClass, setTooltipRelativeToMouse, setTooltipText, setVisible, stateDidChange, updateCursor, validate, wasAdded
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_style

protected javax.swing.text.html.StyleSheet _style

_rsize

protected java.awt.Rectangle _rsize

_view

protected HTMLView.BridgeView _view

_rendered

protected BImage _rendered

_antialias

protected boolean _antialias

_kit

protected javax.swing.text.html.HTMLEditorKit _kit
Constructor Detail

HTMLView

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


HTMLView

public HTMLView(java.lang.String stylesheet,
                java.lang.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(java.lang.String stylesheet)
Configures the stylesheet used to render HTML in this view.


setStyleSheet

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


getStyleSheet

public javax.swing.text.html.StyleSheet getStyleSheet()
Returns the stylesheet in effect for this view.


getEditorKit

public javax.swing.text.html.HTMLEditorKit getEditorKit()
Returns the HTML editor kit used by this view.


setContents

public void setContents(java.lang.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(javax.swing.text.html.HTMLDocument document)
Configures the contents of this HTML view.


wasRemoved

protected void wasRemoved()
Description copied from class: BComponent
This method is called when we are removed from a hierarchy that is connected to a top-level window. If we wish to clean up after things done in BComponent.wasAdded(), this is a fine place to do so.

Overrides:
wasRemoved in class BComponent

layout

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

Overrides:
layout in class BComponent

renderComponent

protected void renderComponent(com.jme.renderer.Renderer renderer)
Description copied from class: BComponent
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 BComponent

computePreferredSize

protected Dimension computePreferredSize(int whint,
                                         int hhint)
Description copied from class: BComponent
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 BComponent
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()

release

protected void release()


Copyright © 2011 Michael Bayne. All Rights Reserved.