Methods Summary |
---|
public void | changedUpdate(javax.swing.event.DocumentEvent e, java.awt.Shape a, javax.swing.text.ViewFactory f)Gives notification from the document that attributes were changed
in a location that this view is responsible for.
font = null;
super.changedUpdate(e, a, f);
|
public java.awt.Color | getBackground()Fetches the background color to use to render the glyphs.
This is implemented to return a cached background color,
which defaults to null .
sync();
return bg;
|
public java.awt.Font | getFont()Fetches the font that the glyphs should be based upon.
This is implemented to return a cached font.
sync();
return font;
|
protected java.awt.FontMetrics | getFontMetrics()Fetches the FontMetrics used for this view.
sync();
Container c = getContainer();
return (c != null) ? c.getFontMetrics(font) :
Toolkit.getDefaultToolkit().getFontMetrics(font);
|
public java.awt.Color | getForeground()Fetches the foreground color to use to render the glyphs.
This is implemented to return a cached foreground color,
which defaults to null .
sync();
return fg;
|
public boolean | isStrikeThrough()Determines if the glyphs should have a strikethrough
line. If true, a line should be drawn through the center
of the glyphs. This is implemented to return the
cached strikeThrough property.
When you request this property, LabelView
re-syncs its state with the properties of the
Element 's AttributeSet .
If Element 's AttributeSet
does not have this property set, it will revert to false.
sync();
return strike;
|
public boolean | isSubscript()Determines if the glyphs should be rendered as superscript.
sync();
return subscript;
|
public boolean | isSuperscript()Determines if the glyphs should be rendered as subscript.
When you request this property, LabelView
re-syncs its state with the properties of the
Element 's AttributeSet .
If Element 's AttributeSet
does not have this property set, it will revert to false.
sync();
return superscript;
|
public boolean | isUnderline()Determines if the glyphs should be underlined. If true,
an underline should be drawn through the baseline. This
is implemented to return the cached underline property.
When you request this property, LabelView
re-syncs its state with the properties of the
Element 's AttributeSet .
If Element 's AttributeSet
does not have this property set, it will revert to false.
sync();
return underline;
|
protected void | setBackground(java.awt.Color bg)Sets the background color for the view. This method is typically
invoked as part of configuring this View . If you need
to customize the background color you should override
setPropertiesFromAttributes and invoke this method. A
value of null indicates no background should be rendered, so that the
background of the parent View will show through.
this.bg = bg;
|
protected void | setPropertiesFromAttributes()Sets the cached properties from the attributes.
AttributeSet attr = getAttributes();
if (attr != null) {
Document d = getDocument();
if (d instanceof StyledDocument) {
StyledDocument doc = (StyledDocument) d;
font = doc.getFont(attr);
fg = doc.getForeground(attr);
if (attr.isDefined(StyleConstants.Background)) {
bg = doc.getBackground(attr);
} else {
bg = null;
}
setUnderline(StyleConstants.isUnderline(attr));
setStrikeThrough(StyleConstants.isStrikeThrough(attr));
setSuperscript(StyleConstants.isSuperscript(attr));
setSubscript(StyleConstants.isSubscript(attr));
} else {
throw new StateInvariantError("LabelView needs StyledDocument");
}
}
|
protected void | setStrikeThrough(boolean s)Sets whether or not the view has a strike/line
through it.
Note that this setter is protected and is really
only meant if you need to update some additional
state when set.
strike = s;
|
protected void | setSubscript(boolean s)Sets whether or not the view represents a
subscript.
Note that this setter is protected and is really
only meant if you need to update some additional
state when set.
subscript = s;
|
protected void | setSuperscript(boolean s)Sets whether or not the view represents a
superscript.
Note that this setter is protected and is really
only meant if you need to update some additional
state when set.
superscript = s;
|
protected void | setUnderline(boolean u)Sets whether or not the view is underlined.
Note that this setter is protected and is really
only meant if you need to update some additional
state when set.
underline = u;
|
final void | sync()Synchronize the view's cached values with the model.
This causes the font, metrics, color, etc to be
re-cached if the cache has been invalidated.
if (font == null) {
setPropertiesFromAttributes();
}
|