is new.
java.lang.Objectjavax.swing.text.View
javax.swing.text.CompositeView
public abstract class CompositeView
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 child Views. Subclasses that wish to manage the collection of child Views should use the replace(int, int, javax.swing.text.View[]) method. As View invokes replace 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 either setInsets(short, short, short, short) or setParagraphInsets(javax.swing.text.AttributeSet) .
In addition to the abstract methods of View , subclasses of CompositeView will need to override:
| 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 | |
|---|---|
|
CompositeView
(
Element
elem) Constructs a CompositeView for the given element. |
|
| Method Summary | |
|---|---|
| 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. |
| 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 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. |
| 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. |
| 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 inherited from class javax.swing.text. View |
|---|
| append , breakView , changedUpdate , createFragment , forwardUpdate , forwardUpdateToView , getAlignment , getAttributes , getBreakWeight , getContainer , getDocument , getElement , getEndOffset , getGraphics , getMaximumSpan , getMinimumSpan , getParent , getPreferredSpan , getResizeWeight , getStartOffset , getToolTipText , getViewFactory , getViewIndex , insert , insertUpdate , isVisible , modelToView , paint , preferenceChanged , remove , removeAll , removeUpdate , setSize , updateChildren , updateLayout , viewToModel |
| Methods inherited from class java.lang. Object |
|---|
| clone , equals , finalize , getClass , hashCode , notify , notifyAll , toString , wait , wait , wait |
| Constructor Detail |
|---|
public CompositeView(Element elem)
| Method Detail |
|---|
protected void loadChildren(ViewFactory f)
public void setParent(View parent)
public int getViewCount()
public View getView(int n)
public void replace(int offset,
int length,
View[] views)
public Shape getChildAllocation(int index,
Shape a)
public Shape modelToView(int pos,
Shape a,
Position.Bias b)
throws BadLocationException
public Shape modelToView(int p0,
Position.Bias b0,
int p1,
Position.Bias b1,
Shape a)
throws BadLocationException
public int viewToModel(float x,
float y,
Shape a,
Position.Bias[] bias)
public int getNextVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
public int getViewIndex(int pos,
Position.Bias b)
Since:
1.3
protected abstract boolean isBefore(int x,
int y,
Rectangle alloc)
protected abstract boolean isAfter(int x,
int y,
Rectangle alloc)
protected abstract View getViewAtPoint(int x,
int y,
Rectangle alloc)
protected abstract void childAllocation(int index,
Rectangle a)
protected View getViewAtPosition(int pos,
Rectangle a)
protected int getViewIndexAtPosition(int pos)
protected Rectangle getInsideAllocation(Shape a)
protected void setParagraphInsets(AttributeSet attr)
protected void setInsets(short top,
short left,
short bottom,
short right)
protected short getLeftInset()
protected short getRightInset()
protected short getTopInset()
protected short getBottomInset()
protected int getNextNorthSouthVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
protected int getNextEastWestVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
protected boolean flipEastAndWestAtEnds(int position,
Position.Bias bias)
This unconditionally returns false, subclasses should override this method if there is the possibility for laying Views in descending order.