edu.umd.cs.piccolo.nodes
Class PHtmlView

java.lang.Object
  extended by edu.umd.cs.piccolo.PNode
      extended by edu.umd.cs.piccolo.nodes.PHtmlView
All Implemented Interfaces:
Printable, Serializable, Cloneable

public class PHtmlView
extends PNode

PHtmlView is a Piccolo node for rendering HTML text. It uses a JLabel under the hood so you have the same restrictions regarding HTML as you have when using standard Swing components (HTML 3.2 + subset of CSS 1.0).

Since:
1.3
Author:
Chris Malley (cmal...@pixelzoom.com), Sam Reid, Allain Lalonde
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class edu.umd.cs.piccolo.PNode
PNode.PSceneGraphDelegate
 
Field Summary
static Font DEFAULT_FONT
          Default font if not otherwise specified in the HTML text, 12 point "SansSerif".
static Color DEFAULT_TEXT_COLOR
          Default text color if not otherwise specified in the HTML text, Color.BLACK.
static int PROPERTY_CODE_FONT
          The property code that identifies a change of this node's font (see getFont).
static int PROPERTY_CODE_TEXT
          The property code that identifies a change of this node's HTML text (see getText).
static int PROPERTY_CODE_TEXT_COLOR
          The property code that identifies a change of this node's HTML text color (see getTextColor).
static String PROPERTY_FONT
          The property name that identifies a change of this node's font (see getFont).
static String PROPERTY_TEXT
          The property name that identifies a change of this node's HTML text (see getText).
static String PROPERTY_TEXT_COLOR
          The property name that identifies a change of this node's HTML text color (see getTextColor).
 
Fields inherited from class edu.umd.cs.piccolo.PNode
FILL_STRATEGY_ASPECT_COVER, FILL_STRATEGY_ASPECT_FIT, FILL_STRATEGY_EXACT_FIT, PROPERTY_BOUNDS, PROPERTY_CHILDREN, PROPERTY_CHILDREN_PICKABLE, PROPERTY_CLIENT_PROPERTIES, PROPERTY_CODE_BOUNDS, PROPERTY_CODE_CHILDREN, PROPERTY_CODE_CHILDREN_PICKABLE, PROPERTY_CODE_CLIENT_PROPERTIES, PROPERTY_CODE_FULL_BOUNDS, PROPERTY_CODE_PAINT, PROPERTY_CODE_PARENT, PROPERTY_CODE_PICKABLE, PROPERTY_CODE_TRANSFORM, PROPERTY_CODE_TRANSPARENCY, PROPERTY_CODE_VISIBLE, PROPERTY_FULL_BOUNDS, PROPERTY_PAINT, PROPERTY_PARENT, PROPERTY_PICKABLE, PROPERTY_TRANSFORM, PROPERTY_TRANSPARENCY, PROPERTY_VISIBLE, SCENE_GRAPH_DELEGATE
 
Fields inherited from interface java.awt.print.Printable
NO_SUCH_PAGE, PAGE_EXISTS
 
Constructor Summary
PHtmlView()
          Create an empty HTML text node with the default font and text color.
PHtmlView(String text)
          Create a HTML text node with the specified HTML text and the default font and text color.
PHtmlView(String text, Font font, Color textColor)
          Create a HTML text node with the specified HTML text, font, and text color.
 
Method Summary
 Font getFont()
          Return the font for this HTML text node.
 String getLinkAddressAt(double x, double y)
          Return the address specified in the HTML link at the specified x and y coordinates in this node's local coordinate system, if any.
 String getLinkAddressAt(Point2D point)
          Return the address specified in the HTML link at the specified point in this node's local coordinate system, if any.
 String getText()
          Return the HTML text for this HTML text node.
 Color getTextColor()
          Return the text color for this HTML text node.
protected  void paint(PPaintContext paintContext)
          Paint this node behind any of its children nodes.
 boolean setBounds(double x, double y, double width, double height)
          Set the bounds of this node to the given position and size.
 boolean setBounds(Rectangle2D newBounds)
          Set the bounds of this node to the given value.
 void setFont(Font font)
          Set the font for this HTML text node to font.
 void setText(String text)
          Set the HTML text for this HTML text node to text.
 void setTextColor(Color textColor)
          Set the text color for this HTML text node to textColor.
 
Methods inherited from class edu.umd.cs.piccolo.PNode
addActivity, addAttribute, addChild, addChild, addChildren, addClientProperty, addInputEventListener, addPropertyChangeListener, addPropertyChangeListener, animateToBounds, animateToColor, animateToPositionScaleRotation, animateToRelativePosition, animateToTransform, animateToTransparency, animateTransformToBounds, centerBoundsOnPoint, centerFullBoundsOnPoint, clone, computeFullBounds, endResizeBounds, findIntersectingNodes, fireChildPropertyChange, firePropertyChange, fullIntersects, fullPaint, fullPick, getAllNodes, getAllNodes, getAttribute, getAttribute, getBooleanAttribute, getBounds, getBoundsChanged, getBoundsReference, getBoundsVolatile, getChild, getChildBoundsInvalid, getChildBoundsVolatile, getChildPaintInvalid, getChildrenCount, getChildrenIterator, getChildrenPickable, getChildrenReference, getClientProperties, getClientProperty, getClientPropertyKeysEnumeration, getClientPropertyKeysIterator, getDoubleAttribute, getFullBounds, getFullBoundsInvalid, getFullBoundsReference, getGlobalBounds, getGlobalFullBounds, getGlobalRotation, getGlobalScale, getGlobalToLocalTransform, getGlobalTranslation, getHeight, getInputEventListeners, getIntegerAttribute, getInverseTransform, getListenerList, getLocalToGlobalTransform, getName, getOccluded, getOffset, getPaint, getPaintInvalid, getParent, getPickable, getPropertyChangeParentMask, getRoot, getRotation, getScale, getTransform, getTransformReference, getTransparency, getUnionOfChildrenBounds, getVisible, getWidth, getX, getXOffset, getY, getYOffset, globalToLocal, globalToLocal, globalToLocal, indexOfChild, internalUpdateBounds, intersects, invalidateFullBounds, invalidateLayout, invalidatePaint, isAncestorOf, isDescendentOf, isDescendentOfRoot, isOpaque, layoutChildren, lerp, localToGlobal, localToGlobal, localToGlobal, localToParent, localToParent, localToParent, moveInBackOf, moveInFrontOf, moveToBack, moveToFront, offset, paintAfterChildren, paramString, parentBoundsChanged, parentToLocal, parentToLocal, parentToLocal, pick, pickAfterChildren, position, print, print, removeAllChildren, removeChild, removeChild, removeChildren, removeFromParent, removeInputEventListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaintFrom, reparent, replaceWith, resetBounds, rotate, rotateAboutPoint, rotateAboutPoint, rotateInPlace, scale, scaleAboutPoint, scaleAboutPoint, setBoundsChanged, setChildBoundsInvalid, setChildBoundsVolatile, setChildPaintInvalid, setChildrenPickable, setFullBoundsInvalid, setGlobalRotation, setGlobalScale, setGlobalTranslation, setHeight, setName, setOccluded, setOffset, setOffset, setPaint, setPaintInvalid, setParent, setPickable, setPropertyChangeParentMask, setRotation, setScale, setTransform, setTransparency, setVisible, setWidth, setX, setY, signalBoundsChanged, startResizeBounds, toImage, toImage, toImage, toImage, transformBy, translate, validateFullBounds, validateFullPaint
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_FONT

public static final Font DEFAULT_FONT
Default font if not otherwise specified in the HTML text, 12 point "SansSerif".


DEFAULT_TEXT_COLOR

public static final Color DEFAULT_TEXT_COLOR
Default text color if not otherwise specified in the HTML text, Color.BLACK.


PROPERTY_FONT

public static final String PROPERTY_FONT
The property name that identifies a change of this node's font (see getFont). Both old and new value will be set in any property change event.

See Also:
Constant Field Values

PROPERTY_CODE_FONT

public static final int PROPERTY_CODE_FONT
The property code that identifies a change of this node's font (see getFont). Both old and new value will be set in any property change event.

See Also:
Constant Field Values

PROPERTY_TEXT

public static final String PROPERTY_TEXT
The property name that identifies a change of this node's HTML text (see getText). Both old and new value will be set in any property change event.

See Also:
Constant Field Values

PROPERTY_CODE_TEXT

public static final int PROPERTY_CODE_TEXT
The property code that identifies a change of this node's HTML text (see getText). Both old and new value will be set in any property change event.

See Also:
Constant Field Values

PROPERTY_TEXT_COLOR

public static final String PROPERTY_TEXT_COLOR
The property name that identifies a change of this node's HTML text color (see getTextColor). Both old and new value will be set in any property change event.

See Also:
Constant Field Values

PROPERTY_CODE_TEXT_COLOR

public static final int PROPERTY_CODE_TEXT_COLOR
The property code that identifies a change of this node's HTML text color (see getTextColor). Both old and new value will be set in any property change event.

See Also:
Constant Field Values
Constructor Detail

PHtmlView

public PHtmlView()
Create an empty HTML text node with the default font and text color.


PHtmlView

public PHtmlView(String text)
Create a HTML text node with the specified HTML text and the default font and text color.

Parameters:
text - HTML text for this HTML text node

PHtmlView

public PHtmlView(String text,
                 Font font,
                 Color textColor)
Create a HTML text node with the specified HTML text, font, and text color. The font and text color are used to render the HTML text if not otherwise specified via CSS.

Parameters:
text - HTML text for this HTML text node
font - font for this HTML text node
textColor - text color for this HTML text node
Method Detail

getText

public String getText()
Return the HTML text for this HTML text node.

Returns:
the HTML text for this HTML text node

setText

public void setText(String text)
Set the HTML text for this HTML text node to text.

This is a bound property.

Parameters:
text - HTML text for this HTML text node

getFont

public Font getFont()
Return the font for this HTML text node. This font is used to render the HTML text if not otherwise specified via CSS. Defaults to DEFAULT_FONT.

Returns:
the font for this HTML text node

setFont

public void setFont(Font font)
Set the font for this HTML text node to font. This font is used to render the HTML text if not otherwise specified via CSS.

This is a bound property.

Parameters:
font - font for this HTML text node

getTextColor

public Color getTextColor()
Return the text color for this HTML text node. This text color is used to render the HTML text if not otherwise specified via CSS. Defaults to DEFAULT_TEXT_COLOR.

Returns:
the text color for this HTML text node

setTextColor

public void setTextColor(Color textColor)
Set the text color for this HTML text node to textColor. This text color is used to render the HTML text if not otherwise specified via CSS. This is a bound property.

Parameters:
textColor - text color for this HTML text node

setBounds

public boolean setBounds(double x,
                         double y,
                         double width,
                         double height)
Set the bounds of this node to the given position and size. These bounds are stored in the local coordinate system of this node. If the width or height is less then or equal to zero then the bound's empty bit will be set to true. Subclasses must call the super.setBounds() method.

Overrides:
setBounds in class PNode
Parameters:
x - x position of bounds
y - y position of bounds
width - width to apply to the bounds
height - height to apply to the bounds
Returns:
true if the bounds changed.

setBounds

public boolean setBounds(Rectangle2D newBounds)
Set the bounds of this node to the given value. These bounds are stored in the local coordinate system of this node.

Overrides:
setBounds in class PNode
Parameters:
newBounds - bounds to apply to this node
Returns:
true if the bounds changed.

paint

protected void paint(PPaintContext paintContext)
Paint this node behind any of its children nodes. Subclasses that define a different appearance should override this method and paint themselves there.

The HTML text is painted last, so it will appear on top of any child nodes.

Overrides:
paint in class PNode
Parameters:
paintContext - the paint context to use for painting the node

getLinkAddressAt

public String getLinkAddressAt(Point2D point)
Return the address specified in the HTML link at the specified point in this node's local coordinate system, if any.

Parameters:
point - point in this node's local coordinate system
Returns:
the address specified in the HTML link at the specified point in this node's local coordinate system, or null if no such HTML link exists

getLinkAddressAt

public String getLinkAddressAt(double x,
                               double y)
Return the address specified in the HTML link at the specified x and y coordinates in this node's local coordinate system, if any.

Parameters:
x - x coordinate in this node's local coordinate system
y - y coordinate in this node's local coordinate system
Returns:
the address specified in the HTML link at the specified x and y coordinates in this node's local coordinate system, or null if no such HTML link exists


Copyright © 1995-2011 Piccolo2D. All Rights Reserved.