public final class PatchedHtmlRenderer
extends java.lang.Object
org.openide.awt.HtmlRenderer
to allow disabling
of the color change in case when the particular item is selected.Modifier and Type | Field and Description |
---|---|
static int |
STYLE_CLIP
Constant used by
renderString , renderPlainString ,
renderHTML , and Renderer#setRenderStyle
if painting should simply be cut off at the boundary of the cooordinates passed. |
static int |
STYLE_TRUNCATE
Constant used by
renderString , renderPlainString ,
renderHTML , and Renderer#setRenderStyle if
painting should produce an ellipsis (...)
if the text would overlap the boundary of the coordinates passed. |
Modifier and Type | Method and Description |
---|---|
static double |
renderHTML(java.lang.String s,
java.awt.Graphics g,
int x,
int y,
int w,
int h,
java.awt.Font f,
java.awt.Color defaultColor,
int style,
boolean paint,
boolean disableColorChange)
Render a string as HTML using a fast, lightweight renderer supporting a limited
subset of HTML.
|
static double |
renderPlainString(java.lang.String s,
java.awt.Graphics g,
int x,
int y,
int w,
int h,
java.awt.Font f,
java.awt.Color defaultColor,
int style,
boolean paint)
Render a string to a graphics instance, using the same API as
renderHTML . |
static double |
renderString(java.lang.String s,
java.awt.Graphics g,
int x,
int y,
int w,
int h,
java.awt.Font f,
java.awt.Color defaultColor,
int style,
boolean paint)
Render a string to a graphics context, using HTML markup if the string
begins with
<html> . |
public static final int STYLE_CLIP
renderString
, renderPlainString
,
renderHTML
, and Renderer#setRenderStyle
if painting should simply be cut off at the boundary of the cooordinates passed.public static final int STYLE_TRUNCATE
renderString
, renderPlainString
,
renderHTML
, and Renderer#setRenderStyle
if
painting should produce an ellipsis (...)
if the text would overlap the boundary of the coordinates passed.public static double renderPlainString(java.lang.String s, java.awt.Graphics g, int x, int y, int w, int h, java.awt.Font f, java.awt.Color defaultColor, int style, boolean paint)
renderHTML
.
Can render a string using JLabel-style ellipsis (...) in the case that
it will not fit in the passed rectangle, if the style parameter is
STYLE_CLIP
. Returns the width in pixels successfully painted.
This method is not thread-safe and should not be called off
the AWT thread.public static double renderString(java.lang.String s, java.awt.Graphics g, int x, int y, int w, int h, java.awt.Font f, java.awt.Color defaultColor, int style, boolean paint)
<html>
. Delegates to renderPlainString
or renderHTML
as appropriate. See the class documentation for
for details of the subset of HTML that is
supported.s
- The string to renderg
- A graphics object into which the string should be drawn, or which should be
used for calculating the appropriate sizex
- The x coordinate to paint at.y
- The y position at which to paint. Note that this method does not calculate font
height/descent - this value should be the baseline for the line of text, not
the upper corner of the rectangle to paint in.w
- The maximum width within which to paint.h
- The maximum height within which to paint.f
- The base font to be used for painting or calculating string width/height.defaultColor
- The base color to use if no font color is specified as html tagsstyle
- The wrapping style to use, either STYLE_CLIP
,
or STYLE_TRUNCATE
paint
- True if actual painting should occur. If false, this method will not actually
paint anything, only return a value representing the width/height needed to
paint the passed string.w
if it is
smaller than the required width.public static double renderHTML(java.lang.String s, java.awt.Graphics g, int x, int y, int w, int h, java.awt.Font f, java.awt.Color defaultColor, int style, boolean paint, boolean disableColorChange)
This method can also be used in non-painting mode to establish the space
necessary to paint a string. This is accomplished by passing the value of the
paint
argument as false. The return value will be the required
width in pixels
to display the text. Note that in order to retrieve an
accurate value, the argument for available width should be passed
as Integer.MAX_VALUE
or an appropriate maximum size - otherwise
the return value will either be the passed maximum width or the required
width, whichever is smaller. Also, the clip shape for the passed graphics
object should be null or a value larger than the maximum possible render size.
This method will log a warning if it encounters HTML markup it cannot
render. To aid diagnostics, if NetBeans is run with the argument
-J-Dnetbeans.lwhtml.strict=true
an exception will be thrown
when an attempt is made to render unsupported HTML.
s
- The string to renderg
- A graphics object into which the string should be drawn, or which should be
used for calculating the appropriate sizex
- The x coordinate to paint at.y
- The y position at which to paint. Note that this method does not calculate font
height/descent - this value should be the baseline for the line of text, not
the upper corner of the rectangle to paint in.w
- The maximum width within which to paint.h
- The maximum height within which to paint.f
- The base font to be used for painting or calculating string width/height.defaultColor
- The base color to use if no font color is specified as html tagsstyle
- The wrapping style to use, either STYLE_CLIP
,
or STYLE_TRUNCATE
paint
- True if actual painting should occur. If false, this method will not actually
paint anything, only return a value representing the width/height needed to
paint the passed string.w
if it is
smaller than the required width.