public class ChangeableHighlightPainter
extends javax.swing.text.LayeredHighlighter.LayerPainter
implements java.io.Serializable
LayerPainter
that allows the user to
change several of its properties:
GradientPaint
, for
example).构造器和说明 |
---|
ChangeableHighlightPainter()
Creates a new
ChangableHighlightPainter that paints
highlights with the text area's selection color (i.e., behaves exactly
like
javax.swing.text.DefaultHighlighter.DefaultHighlightPainter
). |
ChangeableHighlightPainter(java.awt.Paint paint)
Creates a new highlight painter using the specified
Paint
without rounded edges. |
ChangeableHighlightPainter(java.awt.Paint paint,
boolean rounded)
Creates a new highlight painter.
|
ChangeableHighlightPainter(java.awt.Paint paint,
boolean rounded,
float alpha)
Creates a new highlight painter.
|
限定符和类型 | 方法和说明 |
---|---|
float |
getAlpha()
Returns the alpha value used in computing the translucency of these
highlights.
|
java.awt.Paint |
getPaint()
Returns the
Paint (usually a java.awt.Color )
being used to paint highlights. |
boolean |
getRoundedEdges()
Returns whether rounded edges are used when painting selections with
this highlight painter.
|
void |
paint(java.awt.Graphics g,
int offs0,
int offs1,
java.awt.Shape bounds,
javax.swing.text.JTextComponent c)
Paints a highlight.
|
java.awt.Shape |
paintLayer(java.awt.Graphics g,
int offs0,
int offs1,
java.awt.Shape bounds,
javax.swing.text.JTextComponent c,
javax.swing.text.View view)
Paints a portion of a highlight.
|
void |
setAlpha(float alpha)
Sets the alpha value used in rendering highlights.
|
void |
setPaint(java.awt.Paint paint)
Sets the
Paint (usually a java.awt.Color )
used to paint this highlight. |
void |
setRoundedEdges(boolean rounded)
Sets whether rounded edges are used when painting this highlight.
|
public ChangeableHighlightPainter()
ChangableHighlightPainter
that paints
highlights with the text area's selection color (i.e., behaves exactly
like
javax.swing.text.DefaultHighlighter.DefaultHighlightPainter
).public ChangeableHighlightPainter(java.awt.Paint paint)
Paint
without rounded edges.paint
- The Paint
(usually a
java.awt.Color
) with which to paint the
highlights.public ChangeableHighlightPainter(java.awt.Paint paint, boolean rounded)
paint
- The Paint
(usually a
java.awt.Color
) with which to paint the
highlights.rounded
- Whether to use rounded edges on the highlights.public ChangeableHighlightPainter(java.awt.Paint paint, boolean rounded, float alpha)
paint
- The Paint
(usually a
java.awt.Color
) with which to paint the
highlights.rounded
- Whether to use rounded edges on the highlights.alpha
- The alpha value to use when painting highlights. This
value should be in the range 0.0f
(completely
transparent) through 1.0f
(opaque).public float getAlpha()
1.0f
(the default) means that no
translucency is used; there is no performance hit for this value. For
all other values ([0.0f..1.0f)
), there will be a
performance hit.setAlpha(float)
public java.awt.Paint getPaint()
Paint
(usually a java.awt.Color
)
being used to paint highlights.Paint
.setPaint(java.awt.Paint)
public boolean getRoundedEdges()
setRoundedEdges(boolean)
public void paint(java.awt.Graphics g, int offs0, int offs1, java.awt.Shape bounds, javax.swing.text.JTextComponent c)
paint
在接口中 javax.swing.text.Highlighter.HighlightPainter
g
- the graphics contextoffs0
- the starting model offset >= 0offs1
- the ending model offset >= offs1bounds
- the bounding box for the highlightc
- the editorpublic java.awt.Shape paintLayer(java.awt.Graphics g, int offs0, int offs1, java.awt.Shape bounds, javax.swing.text.JTextComponent c, javax.swing.text.View view)
paintLayer
在类中 javax.swing.text.LayeredHighlighter.LayerPainter
g
- the graphics contextoffs0
- the starting model offset >= 0offs1
- the ending model offset >= offs1bounds
- the bounding box of the view, which is not
necessarily the region to paint.c
- the editorview
- View painting forpublic void setAlpha(float alpha)
1.0f
(the default), the highlights are rendered completely
opaque. This behavior matches that of
DefaultHighlightPainter
and imposes no performance hit. If
this value is below 1.0f
, it represents how opaque the
highlight will be. There will be a small performance hit for values
less than 1.0f
.alpha
- The new alpha value to use for transparency.getAlpha()
public void setPaint(java.awt.Paint paint)
Paint
(usually a java.awt.Color
)
used to paint this highlight.paint
- The new Paint
.getPaint()
public void setRoundedEdges(boolean rounded)
rounded
- Whether rounded edges should be used.getRoundedEdges()