- java.lang.Object
-
- javax.swing.text.View
-
- javax.swing.text.GlyphView
-
- javax.swing.text.LabelView
-
- All Implemented Interfaces:
- Cloneable, SwingConstants, TabableView
- Direct Known Subclasses:
- InlineView
public class LabelView extends GlyphView implements TabableView
ALabelViewis a styled chunk of text that represents a view mapped over an element in the text model. It caches the character level attributes used for rendering.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.text.GlyphView
GlyphView.GlyphPainter
-
-
Field Summary
-
Fields inherited from class javax.swing.text.View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXIS
-
Fields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST
-
-
Constructor Summary
Constructors Constructor and Description LabelView(Element elem)Constructs a new view wrapped on an element.
-
Method Summary
Methods Modifier and Type Method and Description voidchangedUpdate(DocumentEvent e, Shape a, ViewFactory f)Gives notification from the document that attributes were changed in a location that this view is responsible for.ColorgetBackground()Fetches the background color to use to render the glyphs.FontgetFont()Fetches the font that the glyphs should be based upon.protected FontMetricsgetFontMetrics()Deprecated.FontMetrics are not used for glyph rendering when running in the JDK.ColorgetForeground()Fetches the foreground color to use to render the glyphs.booleanisStrikeThrough()Determines if the glyphs should have a strikethrough line.booleanisSubscript()Determines if the glyphs should be rendered as superscript.booleanisSuperscript()Determines if the glyphs should be rendered as subscript.booleanisUnderline()Determines if the glyphs should be underlined.protected voidsetBackground(Color bg)Sets the background color for the view.protected voidsetPropertiesFromAttributes()Sets the cached properties from the attributes.protected voidsetStrikeThrough(boolean s)Sets whether or not the view has a strike/line through it.protected voidsetSubscript(boolean s)Sets whether or not the view represents a subscript.protected voidsetSuperscript(boolean s)Sets whether or not the view represents a superscript.protected voidsetUnderline(boolean u)Sets whether or not the view is underlined.-
Methods inherited from class javax.swing.text.GlyphView
breakView, checkPainter, clone, createFragment, getAlignment, getBreakWeight, getEndOffset, getGlyphPainter, getMinimumSpan, getNextVisualPositionFrom, getPartialSpan, getPreferredSpan, getStartOffset, getTabbedSpan, getTabExpander, getText, insertUpdate, modelToView, paint, removeUpdate, setGlyphPainter, viewToModel
-
Methods inherited from class javax.swing.text.View
append, forwardUpdate, forwardUpdateToView, getAttributes, getChildAllocation, getContainer, getDocument, getElement, getGraphics, getMaximumSpan, getParent, getResizeWeight, getToolTipText, getView, getViewCount, getViewFactory, getViewIndex, getViewIndex, insert, isVisible, modelToView, modelToView, preferenceChanged, remove, removeAll, replace, setParent, setSize, updateChildren, updateLayout, viewToModel
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface javax.swing.text.TabableView
getPartialSpan, getTabbedSpan
-
-
-
-
Constructor Detail
-
LabelView
public LabelView(Element elem)
Constructs a new view wrapped on an element.- Parameters:
elem- the element
-
-
Method Detail
-
setUnderline
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.- Parameters:
u- true if the view is underlined, otherwise false- See Also:
isUnderline()
-
setStrikeThrough
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.- Parameters:
s- true if the view has a strike/line through it, otherwise false- See Also:
isStrikeThrough()
-
setSuperscript
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.- Parameters:
s- true if the view represents a superscript, otherwise false- See Also:
isSuperscript()
-
setSubscript
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.- Parameters:
s- true if the view represents a subscript, otherwise false- See Also:
isSubscript()
-
setBackground
protected void setBackground(Color bg)
Sets the background color for the view. This method is typically invoked as part of configuring thisView. If you need to customize the background color you should overridesetPropertiesFromAttributesand invoke this method. A value of null indicates no background should be rendered, so that the background of the parentViewwill show through.- Parameters:
bg- background color, or null- Since:
- 1.5
- See Also:
setPropertiesFromAttributes()
-
setPropertiesFromAttributes
protected void setPropertiesFromAttributes()
Sets the cached properties from the attributes.
-
getFontMetrics
@Deprecated protected FontMetrics getFontMetrics()
Deprecated. FontMetrics are not used for glyph rendering when running in the JDK.Fetches theFontMetricsused for this view.
-
getBackground
public Color getBackground()
Fetches the background color to use to render the glyphs. This is implemented to return a cached background color, which defaults tonull.- Overrides:
getBackgroundin classGlyphView- Returns:
- the cached background color
- Since:
- 1.3
-
getForeground
public Color getForeground()
Fetches the foreground color to use to render the glyphs. This is implemented to return a cached foreground color, which defaults tonull.- Overrides:
getForegroundin classGlyphView- Returns:
- the cached foreground color
- Since:
- 1.3
-
getFont
public Font getFont()
Fetches the font that the glyphs should be based upon. This is implemented to return a cached font.
-
isUnderline
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,
LabelViewre-syncs its state with the properties of theElement'sAttributeSet. IfElement'sAttributeSetdoes not have this property set, it will revert to false.- Overrides:
isUnderlinein classGlyphView- Returns:
- the value of the cached
underlineproperty - Since:
- 1.3
-
isStrikeThrough
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 cachedstrikeThroughproperty.When you request this property,
LabelViewre-syncs its state with the properties of theElement'sAttributeSet. IfElement'sAttributeSetdoes not have this property set, it will revert to false.- Overrides:
isStrikeThroughin classGlyphView- Returns:
- the value of the cached
strikeThroughproperty - Since:
- 1.3
-
isSubscript
public boolean isSubscript()
Determines if the glyphs should be rendered as superscript.- Overrides:
isSubscriptin classGlyphView- Returns:
- the value of the cached subscript property
When you request this property,
LabelViewre-syncs its state with the properties of theElement'sAttributeSet. IfElement'sAttributeSetdoes not have this property set, it will revert to false. - Since:
- 1.3
-
isSuperscript
public boolean isSuperscript()
Determines if the glyphs should be rendered as subscript.When you request this property,
LabelViewre-syncs its state with the properties of theElement'sAttributeSet. IfElement'sAttributeSetdoes not have this property set, it will revert to false.- Overrides:
isSuperscriptin classGlyphView- Returns:
- the value of the cached
superscriptproperty - Since:
- 1.3
-
changedUpdate
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
Gives notification from the document that attributes were changed in a location that this view is responsible for.- Overrides:
changedUpdatein classGlyphView- Parameters:
e- the change information from the associated documenta- the current allocation of the viewf- the factory to use to rebuild if the view has children- See Also:
View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
-
-
Deutsche Übersetzung
Sie haben gebeten, diese Seite auf Deutsch zu besuchen. Momentan ist nur die Oberfläche übersetzt, aber noch nicht der gesamte Inhalt.Wenn Sie mir bei Übersetzungen helfen wollen, ist Ihr Beitrag willkommen. Alles, was Sie tun müssen, ist, sich auf der Website zu registrieren und mir eine Nachricht zu schicken, in der Sie gebeten werden, Sie der Gruppe der Übersetzer hinzuzufügen, die Ihnen die Möglichkeit gibt, die gewünschten Seiten zu übersetzen. Ein Link am Ende jeder übersetzten Seite zeigt an, dass Sie der Übersetzer sind und einen Link zu Ihrem Profil haben.
Vielen Dank im Voraus.
Dokument erstellt 11/06/2005, zuletzt geändert 04/03/2020
Quelle des gedruckten Dokuments:https://www.gaudry.be/de/java-api-rf-javax/swing/text/labelview.html
Die Infobro ist eine persönliche Seite, deren Inhalt in meiner alleinigen Verantwortung liegt. Der Text ist unter der CreativeCommons-Lizenz (BY-NC-SA) verfügbar. Weitere Informationen auf die Nutzungsbedingungen und dem Autor.
Referenzen
Diese Verweise und Links verweisen auf Dokumente, die während des Schreibens dieser Seite konsultiert wurden, oder die zusätzliche Informationen liefern können, aber die Autoren dieser Quellen können nicht für den Inhalt dieser Seite verantwortlich gemacht werden.
Der Autor dieser Website ist allein dafür verantwortlich, wie die verschiedenen Konzepte und Freiheiten, die mit den Nachschlagewerken gemacht werden, hier dargestellt werden. Denken Sie daran, dass Sie mehrere Quellinformationen austauschen müssen, um das Risiko von Fehlern zu reduzieren.