CompositeView (Java SE 15 & JDK 15) (original) (raw)

All Implemented Interfaces:

[SwingConstants](../SwingConstants.html "interface in javax.swing")

Direct Known Subclasses:

[BoxView](BoxView.html "class in javax.swing.text")


public abstract class CompositeView extends View

CompositeView is an abstract View implementation which manages one or more child views. (Note that CompositeView is intended for managing relatively small numbers of child views.)CompositeView is intended to be used as a starting point for View implementations, such as BoxView, that will contain childViews. Subclasses that wish to manage the collection of child Views should use thereplace(int, int, javax.swing.text.View[]) method. As View invokesreplace during DocumentListener notification, you normally won't need to directly invoke replace.

While CompositeView does not impose a layout policy on its child Views, it does allow for inseting the child Views it will contain. The insets can be set by eithersetInsets(short, short, short, short) or setParagraphInsets(javax.swing.text.AttributeSet).

In addition to the abstract methods ofView, subclasses of CompositeView will need to override:

Fields declared in interface javax.swing.SwingConstants

[BOTTOM](../SwingConstants.html#BOTTOM), [CENTER](../SwingConstants.html#CENTER), [EAST](../SwingConstants.html#EAST), [HORIZONTAL](../SwingConstants.html#HORIZONTAL), [LEADING](../SwingConstants.html#LEADING), [LEFT](../SwingConstants.html#LEFT), [NEXT](../SwingConstants.html#NEXT), [NORTH](../SwingConstants.html#NORTH), [NORTH_EAST](../SwingConstants.html#NORTH%5FEAST), [NORTH_WEST](../SwingConstants.html#NORTH%5FWEST), [PREVIOUS](../SwingConstants.html#PREVIOUS), [RIGHT](../SwingConstants.html#RIGHT), [SOUTH](../SwingConstants.html#SOUTH), [SOUTH_EAST](../SwingConstants.html#SOUTH%5FEAST), [SOUTH_WEST](../SwingConstants.html#SOUTH%5FWEST), [TOP](../SwingConstants.html#TOP), [TRAILING](../SwingConstants.html#TRAILING), [VERTICAL](../SwingConstants.html#VERTICAL), [WEST](../SwingConstants.html#WEST)

Constructors

Constructor Description
CompositeView​(Element elem) Constructs a CompositeView for the given element.
Modifier and Type Method Description
protected abstract void childAllocation​(int index,Rectangle a) Returns the allocation for a given child.
protected boolean flipEastAndWestAtEnds​(int position,Position.Bias bias) Determines in which direction the next view lays.
protected short getBottomInset() Gets the bottom inset.
Shape getChildAllocation​(int index,Shape a) Fetches the allocation for the given child view to render into.
protected Rectangle getInsideAllocation​(Shape a) Translates the immutable allocation given to the view to a mutable allocation that represents the interior allocation (i.e. the bounds of the given allocation with the top, left, bottom, and right insets removed.
protected short getLeftInset() Gets the left inset.
protected int getNextEastWestVisualPositionFrom​(int pos,Position.Bias b,Shape a, int direction,Position.Bias[] biasRet) Returns the next visual position for the cursor, in either the east or west direction.
protected int getNextNorthSouthVisualPositionFrom​(int pos,Position.Bias b,Shape a, int direction,Position.Bias[] biasRet) Returns the next visual position for the cursor, in either the north or south direction.
int getNextVisualPositionFrom​(int pos,Position.Bias b,Shape a, int direction,Position.Bias[] biasRet) Provides a way to determine the next visually represented model location that one might place a caret.
protected short getRightInset() Gets the right inset.
protected short getTopInset() Gets the top inset.
View getView​(int n) Returns the n-th view in this container.
protected abstract View getViewAtPoint​(int x, int y,Rectangle alloc) Fetches the child view at the given coordinates.
protected View getViewAtPosition​(int pos,Rectangle a) Fetches the child view that represents the given position in the model.
int getViewCount() Returns the number of child views of this view.
int getViewIndex​(int pos,Position.Bias b) Returns the child view index representing the given position in the model.
protected int getViewIndexAtPosition​(int pos) Fetches the child view index representing the given position in the model.
protected abstract boolean isAfter​(int x, int y,Rectangle alloc) Tests whether a point lies after the rectangle range.
protected abstract boolean isBefore​(int x, int y,Rectangle alloc) Tests whether a point lies before the rectangle range.
protected void loadChildren​(ViewFactory f) Loads all of the children to initialize the view.
Shape modelToView​(int pos,Shape a,Position.Bias b) Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
Shape modelToView​(int p0,Position.Bias b0, int p1,Position.Bias b1,Shape a) Provides a mapping from the document model coordinate space to the coordinate space of the view mapped to it.
void replace​(int offset, int length,View[] views) Replaces child views.
protected void setInsets​(short top, short left, short bottom, short right) Sets the insets for the view.
protected void setParagraphInsets​(AttributeSet attr) Sets the insets from the paragraph attributes specified in the given attributes.
void setParent​(View parent) Sets the parent of the view.
int viewToModel​(float x, float y,Shape a,Position.Bias[] bias) Provides a mapping from the view coordinate space to the logical coordinate space of the model.

Methods declared in class javax.swing.text.View

[append](View.html#append%28javax.swing.text.View%29), [breakView](View.html#breakView%28int,int,float,float%29), [changedUpdate](View.html#changedUpdate%28javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [createFragment](View.html#createFragment%28int,int%29), [forwardUpdate](View.html#forwardUpdate%28javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [forwardUpdateToView](View.html#forwardUpdateToView%28javax.swing.text.View,javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [getAlignment](View.html#getAlignment%28int%29), [getAttributes](View.html#getAttributes%28%29), [getBreakWeight](View.html#getBreakWeight%28int,float,float%29), [getContainer](View.html#getContainer%28%29), [getDocument](View.html#getDocument%28%29), [getElement](View.html#getElement%28%29), [getEndOffset](View.html#getEndOffset%28%29), [getGraphics](View.html#getGraphics%28%29), [getMaximumSpan](View.html#getMaximumSpan%28int%29), [getMinimumSpan](View.html#getMinimumSpan%28int%29), [getParent](View.html#getParent%28%29), [getPreferredSpan](View.html#getPreferredSpan%28int%29), [getResizeWeight](View.html#getResizeWeight%28int%29), [getStartOffset](View.html#getStartOffset%28%29), [getToolTipText](View.html#getToolTipText%28float,float,java.awt.Shape%29), [getViewFactory](View.html#getViewFactory%28%29), [getViewIndex](View.html#getViewIndex%28float,float,java.awt.Shape%29), [insert](View.html#insert%28int,javax.swing.text.View%29), [insertUpdate](View.html#insertUpdate%28javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [isVisible](View.html#isVisible%28%29), [modelToView](View.html#modelToView%28int,java.awt.Shape%29), [paint](View.html#paint%28java.awt.Graphics,java.awt.Shape%29), [preferenceChanged](View.html#preferenceChanged%28javax.swing.text.View,boolean,boolean%29), [remove](View.html#remove%28int%29), [removeAll](View.html#removeAll%28%29), [removeUpdate](View.html#removeUpdate%28javax.swing.event.DocumentEvent,java.awt.Shape,javax.swing.text.ViewFactory%29), [setSize](View.html#setSize%28float,float%29), [updateChildren](View.html#updateChildren%28javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,javax.swing.text.ViewFactory%29), [updateLayout](View.html#updateLayout%28javax.swing.event.DocumentEvent.ElementChange,javax.swing.event.DocumentEvent,java.awt.Shape%29), [viewToModel](View.html#viewToModel%28float,float,java.awt.Shape%29)

Methods declared in class java.lang.Object

[clone](../../../../java.base/java/lang/Object.html#clone%28%29), [equals](../../../../java.base/java/lang/Object.html#equals%28java.lang.Object%29), [finalize](../../../../java.base/java/lang/Object.html#finalize%28%29), [getClass](../../../../java.base/java/lang/Object.html#getClass%28%29), [hashCode](../../../../java.base/java/lang/Object.html#hashCode%28%29), [notify](../../../../java.base/java/lang/Object.html#notify%28%29), [notifyAll](../../../../java.base/java/lang/Object.html#notifyAll%28%29), [toString](../../../../java.base/java/lang/Object.html#toString%28%29), [wait](../../../../java.base/java/lang/Object.html#wait%28%29), [wait](../../../../java.base/java/lang/Object.html#wait%28long%29), [wait](../../../../java.base/java/lang/Object.html#wait%28long,int%29)