- java.lang.Object
-
- javax.swing.text.View
-
- javax.swing.text.GlyphView
-
- javax.swing.text.LabelView
-
- javax.swing.text.html.InlineView
-
- All Implemented Interfaces:
- Cloneable, SwingConstants, TabableView
public class InlineView extends LabelView
Displays the inline element styles based upon css attributes.
-
-
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 InlineView(Element elem)
Constructs a new view wrapped on an element.
-
Method Summary
Methods Modifier and Type Method and Description View
breakView(int axis, int offset, float pos, float len)
Tries to break this view on the given axis.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.AttributeSet
getAttributes()
Fetches the attributes to use when rendering.int
getBreakWeight(int axis, float pos, float len)
Determines how attractive a break opportunity in this view is.protected StyleSheet
getStyleSheet()
void
insertUpdate(DocumentEvent e, Shape a, ViewFactory f)
Gives notification that something was inserted into the document in a location that this view is responsible for.void
removeUpdate(DocumentEvent e, Shape a, ViewFactory f)
Gives notification that something was removed from the document in a location that this view is responsible for.protected void
setPropertiesFromAttributes()
Set the cached properties from the attributes.-
Methods inherited from class javax.swing.text.LabelView
getBackground, getFont, getFontMetrics, getForeground, isStrikeThrough, isSubscript, isSuperscript, isUnderline, setBackground, setStrikeThrough, setSubscript, setSuperscript, setUnderline
-
Methods inherited from class javax.swing.text.GlyphView
checkPainter, clone, createFragment, getAlignment, getEndOffset, getGlyphPainter, getMinimumSpan, getNextVisualPositionFrom, getPartialSpan, getPreferredSpan, getStartOffset, getTabbedSpan, getTabExpander, getText, modelToView, paint, setGlyphPainter, viewToModel
-
Methods inherited from class javax.swing.text.View
append, forwardUpdate, forwardUpdateToView, 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
-
InlineView
public InlineView(Element elem)
Constructs a new view wrapped on an element.- Parameters:
elem
- the element
-
-
Method Detail
-
insertUpdate
public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f)
Gives notification that something was inserted into the document in a location that this view is responsible for. If either parameter isnull
, behavior of this method is implementation dependent.- Overrides:
insertUpdate
in 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- Since:
- 1.5
- See Also:
View.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
-
removeUpdate
public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f)
Gives notification that something was removed from the document in a location that this view is responsible for. If either parameter isnull
, behavior of this method is implementation dependent.- Overrides:
removeUpdate
in 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- Since:
- 1.5
- See Also:
View.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
-
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:
changedUpdate
in classLabelView
- 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)
-
getAttributes
public AttributeSet getAttributes()
Fetches the attributes to use when rendering. This is implemented to multiplex the attributes specified in the model with a StyleSheet.- Overrides:
getAttributes
in classView
-
getBreakWeight
public int getBreakWeight(int axis, float pos, float len)
Determines how attractive a break opportunity in this view is. This can be used for determining which view is the most attractive to callbreakView
on in the process of formatting. A view that represents text that has whitespace in it might be more attractive than a view that has no whitespace, for example. The higher the weight, the more attractive the break. A value equal to or lower thanBadBreakWeight
should not be considered for a break. A value greater than or equal toForcedBreakWeight
should be broken.This is implemented to provide the default behavior of returning
BadBreakWeight
unless the length is greater than the length of the view in which case the entire view represents the fragment. Unless a view has been written to support breaking behavior, it is not attractive to try and break the view. An example of a view that does support breaking isLabelView
. An example of a view that uses break weight isParagraphView
.- Overrides:
getBreakWeight
in classGlyphView
- Parameters:
axis
- may be either View.X_AXIS or View.Y_AXISpos
- the potential location of the start of the broken view >= 0. This may be useful for calculating tab positions.len
- specifies the relative length from pos where a potential break is desired >= 0.- Returns:
- the weight, which should be a value between ForcedBreakWeight and BadBreakWeight.
- See Also:
LabelView
,ParagraphView
,View.BadBreakWeight
,View.GoodBreakWeight
,View.ExcellentBreakWeight
,View.ForcedBreakWeight
-
breakView
public View breakView(int axis, int offset, float pos, float len)
Tries to break this view on the given axis. Refer toView.breakView(int, int, float, float)
for a complete description of this method.Behavior of this method is unspecified in case
axis
is neitherView.X_AXIS
norView.Y_AXIS
, and in caseoffset
,pos
, orlen
is null.- Overrides:
breakView
in classGlyphView
- Parameters:
axis
- may be eitherView.X_AXIS
orView.Y_AXIS
offset
- the location in the document model that a broken fragment would occupy >= 0. This would be the starting offset of the fragment returnedpos
- the position along the axis that the broken view would occupy >= 0. This may be useful for things like tab calculationslen
- specifies the distance along the axis where a potential break is desired >= 0- Returns:
- the fragment of the view that represents the given span.
- Since:
- 1.5
- See Also:
View.breakView(int, int, float, float)
-
setPropertiesFromAttributes
protected void setPropertiesFromAttributes()
Set the cached properties from the attributes.- Overrides:
setPropertiesFromAttributes
in classLabelView
-
getStyleSheet
protected StyleSheet getStyleSheet()
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/text/html/inlineview.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.