- java.lang.Object
-
- javax.swing.text.View
-
- javax.swing.text.CompositeView
-
- javax.swing.text.BoxView
-
- javax.swing.text.FlowView
-
- javax.swing.text.ParagraphView
-
- javax.swing.text.html.ParagraphView
-
- All Implemented Interfaces:
- SwingConstants, TabExpander
public class ParagraphView extends ParagraphView
Displays the a paragraph, and uses css attributes for its configuration.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class javax.swing.text.FlowView
FlowView.FlowStrategy
-
-
Field Summary
-
Fields inherited from class javax.swing.text.ParagraphView
firstLineIndent
-
Fields inherited from class javax.swing.text.FlowView
layoutPool, layoutSpan, strategy
-
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 ParagraphView(Element elem)
Constructs a ParagraphView for the given element.
-
Method Summary
Methods Modifier and Type Method and Description protected SizeRequirements
calculateMinorAxisRequirements(int axis, SizeRequirements r)
Calculate the needs for the paragraph along the minor axis.AttributeSet
getAttributes()
Fetches the attributes to use when rendering.float
getMaximumSpan(int axis)
Determines the maximum span for this view along an axis.float
getMinimumSpan(int axis)
Determines the minimum span for this view along an axis.float
getPreferredSpan(int axis)
Determines the preferred span for this view.protected StyleSheet
getStyleSheet()
boolean
isVisible()
Indicates whether or not this view should be displayed.void
paint(Graphics g, Shape a)
Renders using the given rendering surface and area on that surface.void
setParent(View parent)
Establishes the parent view for this view.protected void
setPropertiesFromAttributes()
Sets up the paragraph from css attributes instead of the values found in StyleConstants (i.e.-
Methods inherited from class javax.swing.text.ParagraphView
breakView, changedUpdate, createRow, findOffsetToCharactersInString, flipEastAndWestAtEnds, getAlignment, getBreakWeight, getClosestPositionTo, getFlowSpan, getFlowStart, getLayoutView, getLayoutViewCount, getNextNorthSouthVisualPositionFrom, getPartialSize, getTabBase, getTabSet, nextTabStop, setFirstLineIndent, setJustification, setLineSpacing
-
Methods inherited from class javax.swing.text.FlowView
getFlowAxis, getViewIndexAtPosition, insertUpdate, layout, loadChildren, removeUpdate
-
Methods inherited from class javax.swing.text.BoxView
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, childAllocation, forwardUpdate, getAxis, getChildAllocation, getHeight, getOffset, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paintChild, preferenceChanged, replace, setAxis, setSize, viewToModel
-
Methods inherited from class javax.swing.text.CompositeView
getBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, modelToView, setInsets, setParagraphInsets
-
Methods inherited from class javax.swing.text.View
append, breakView, createFragment, forwardUpdateToView, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, modelToView, remove, removeAll, updateChildren, updateLayout, viewToModel
-
-
-
-
Constructor Detail
-
ParagraphView
public ParagraphView(Element elem)
Constructs a ParagraphView for the given element.- Parameters:
elem
- the element that this view is responsible for
-
-
Method Detail
-
setParent
public void setParent(View parent)
Establishes the parent view for this view. This is guaranteed to be called before any other methods if the parent view is functioning properly.This is implemented to forward to the superclass as well as call the
setPropertiesFromAttributes
method to set the paragraph properties from the css attributes. The call is made at this time to ensure the ability to resolve upward through the parents view attributes.
-
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
-
setPropertiesFromAttributes
protected void setPropertiesFromAttributes()
Sets up the paragraph from css attributes instead of the values found in StyleConstants (i.e. which are used by the superclass). Since- Overrides:
setPropertiesFromAttributes
in classParagraphView
-
getStyleSheet
protected StyleSheet getStyleSheet()
-
calculateMinorAxisRequirements
protected SizeRequirements calculateMinorAxisRequirements(int axis, SizeRequirements r)
Calculate the needs for the paragraph along the minor axis.If size requirements are explicitly specified for the paragraph, use that requirements. Otherwise, use the requirements of the superclass
ParagraphView
.If the
axis
parameter is neitherView.X_AXIS
norView.Y_AXIS
,IllegalArgumentException
is thrown. If ther
parameter isnull,
a newSizeRequirements
object is created, otherwise the suppliedSizeRequirements
object is returned.- Overrides:
calculateMinorAxisRequirements
in classParagraphView
- Parameters:
axis
- the minor axisr
- the inputSizeRequirements
object- Returns:
- the new or adjusted
SizeRequirements
object - Throws:
IllegalArgumentException
- if theaxis
parameter is invalid- See Also:
SizeRequirements
-
isVisible
public boolean isVisible()
Indicates whether or not this view should be displayed. If none of the children wish to be displayed and the only visible child is the break that ends the paragraph, the paragraph will not be considered visible. Otherwise, it will be considered visible and return true.
-
paint
public void paint(Graphics g, Shape a)
Renders using the given rendering surface and area on that surface. This is implemented to delgate to the superclass after stashing the base coordinate for tab calculations.- Overrides:
paint
in classParagraphView
- Parameters:
g
- the rendering surface to usea
- the allocated region to render into- See Also:
View.paint(java.awt.Graphics, java.awt.Shape)
-
getPreferredSpan
public float getPreferredSpan(int axis)
Determines the preferred span for this view. Returns 0 if the view is not visible, otherwise it calls the superclass method to get the preferred span. axis.- Overrides:
getPreferredSpan
in classBoxView
- Parameters:
axis
- may be either View.X_AXIS or View.Y_AXIS- Returns:
- the span the view would like to be rendered into; typically the view is told to render into the span that is returned, although there is no guarantee; the parent may choose to resize or break the view
- See Also:
BoxView.getPreferredSpan(int)
-
getMinimumSpan
public float getMinimumSpan(int axis)
Determines the minimum span for this view along an axis. Returns 0 if the view is not visible, otherwise it calls the superclass method to get the minimum span.- Overrides:
getMinimumSpan
in classBoxView
- Parameters:
axis
- may be eitherView.X_AXIS
orView.Y_AXIS
- Returns:
- the minimum span the view can be rendered into
- See Also:
BoxView.getMinimumSpan(int)
-
getMaximumSpan
public float getMaximumSpan(int axis)
Determines the maximum span for this view along an axis. Returns 0 if the view is not visible, otherwise it calls the superclass method ot get the maximum span.- Overrides:
getMaximumSpan
in classBoxView
- Parameters:
axis
- may be eitherView.X_AXIS
orView.Y_AXIS
- Returns:
- the maximum span the view can be rendered into
- See Also:
BoxView.getMaximumSpan(int)
-
-
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/paragraphview.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.