|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjavax.swing.text.View
javax.swing.text.CompositeView
public abstract class CompositeView
An abstract base implementation of View that manages child
Views.
| 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 element)
Creates a new CompositeView for the given
Element. |
|
| Method Summary | |
|---|---|
protected abstract void |
childAllocation(int index,
Rectangle a)
Computes the allocation for a child View. |
protected boolean |
flipEastAndWestAtEnds(int pos,
Position.Bias bias)
Determines if the next view in horinzontal direction is located to the east or west of the view at position pos. |
protected short |
getBottomInset()
Returns the bottom inset of this CompositeView. |
Shape |
getChildAllocation(int index,
Shape a)
Returns the allocation for the specified child View. |
protected Rectangle |
getInsideAllocation(Shape a)
Returns the allocation that is given to this CompositeView
minus this CompositeView's insets. |
protected short |
getLeftInset()
Returns the left inset of this CompositeView. |
protected int |
getNextEastWestVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
Returns the next model location that is visible in east or west direction. |
protected int |
getNextNorthSouthVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
Returns the next model location that is visible in north or south direction. |
int |
getNextVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
Returns the next model location that is visible in eiter north / south direction or east / west direction. |
protected short |
getRightInset()
Returns the right inset of this CompositeView. |
protected short |
getTopInset()
Returns the top inset of this CompositeView. |
View |
getView(int n)
Returns the child view at index n. |
protected abstract View |
getViewAtPoint(int x,
int y,
Rectangle r)
Returns the child View at the specified location. |
protected View |
getViewAtPosition(int pos,
Rectangle a)
Returns the child View that contains the given model
position. |
int |
getViewCount()
Returns the number of child views. |
int |
getViewIndex(int pos,
Position.Bias b)
Returns the index of the child view that represents the specified model location. |
protected int |
getViewIndexAtPosition(int pos)
Returns the index of the child View for the given model
position. |
protected abstract boolean |
isAfter(int x,
int y,
Rectangle r)
Returns true if the specified point lies after the
given Rectangle, false otherwise. |
protected abstract boolean |
isBefore(int x,
int y,
Rectangle r)
Returns true if the specified point lies before the
given Rectangle, false otherwise. |
protected void |
loadChildren(ViewFactory f)
Loads the child views of this CompositeView. |
Shape |
modelToView(int p1,
Position.Bias b1,
int p2,
Position.Bias b2,
Shape a)
Maps a region in the document into the coordinate space of the View. |
Shape |
modelToView(int pos,
Shape a,
Position.Bias bias)
Maps a position in the document into the coordinate space of the View. |
void |
replace(int offset,
int length,
View[] views)
Replaces child views by some other child views. |
protected void |
setInsets(short t,
short l,
short b,
short r)
Sets the insets of this CompositeView. |
protected void |
setParagraphInsets(AttributeSet attributes)
Sets the insets defined by attributes in attributes. |
void |
setParent(View parent)
Sets the parent of this View. |
int |
viewToModel(float x,
float y,
Shape a,
Position.Bias[] b)
Maps coordinates from the View's space into a position
in the document model. |
| Methods inherited from class javax.swing.text.View |
|---|
append, breakView, changedUpdate, createFragment, dump, 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 element)
CompositeView for the given
Element.
element - the element that is rendered by this CompositeView| Method Detail |
|---|
protected void loadChildren(ViewFactory f)
CompositeView. This method
is called from setParent(javax.swing.text.View) to initialize the child views of
this composite view.
f - the view factory to use for creating new child viewssetParent(javax.swing.text.View)public void setParent(View parent)
View.
In addition to setting the parent, this calls loadChildren(javax.swing.text.ViewFactory), if
this View does not already have its children initialized.
setParent in class Viewparent - the parent to setpublic int getViewCount()
getViewCount in class Viewpublic View getView(int n)
n.
getView in class Viewn - the index of the requested child view
n
public void replace(int offset,
int length,
View[] views)
length == 0), the result is a simple insert, if
there are no children to add (view == null) the result
is a simple removal.
replace in class Viewoffset - the start offset from where to remove childrenlength - the number of children to removeviews - the views that replace the removed children
public Shape getChildAllocation(int index,
Shape a)
View.
getChildAllocation in class Viewindex - the index of the child viewa - the allocation for this view
View
public Shape modelToView(int pos,
Shape a,
Position.Bias bias)
throws BadLocationException
modelToView in class Viewpos - the position of the character in the modela - the area that is occupied by the viewbias - either Position.Bias.Forward or
Position.Bias.Backward depending on the preferred
direction bias. If null this defaults to
Position.Bias.Forward
BadLocationException - if pos is invalid
IllegalArgumentException - if b is not one of the above listed
valid values
public Shape modelToView(int p1,
Position.Bias b1,
int p2,
Position.Bias b2,
Shape a)
throws BadLocationException
modelToView in class Viewp1 - the beginning position inside the documentb1 - the direction bias for the beginning positionp2 - the end position inside the documentb2 - the direction bias for the end positiona - the area that is occupied by the view
BadLocationException - if p1 or p2 are
invalid
IllegalArgumentException - if b1 or b2 is not one of the above
listed valid values
public int viewToModel(float x,
float y,
Shape a,
Position.Bias[] b)
View's space into a position
in the document model.
viewToModel in class Viewx - the x coordinate in the view space, x >= 0y - the y coordinate in the view space, y >= 0a - the allocation of this Viewb - the bias to use
x, y >= 0
public int getNextVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
getNextNorthSouthVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[])
and getNextEastWestVisualPositionFrom(int, javax.swing.text.Position.Bias, java.awt.Shape, int, javax.swing.text.Position.Bias[]).
getNextVisualPositionFrom in class Viewpos - the model position to start search fromb - the bias for posa - the allocated region for this viewdirection - the direction from the current position, can be one of the
following:
biasRet - the bias of the return value gets stored here
BadLocationException - if pos is not a valid location inside the document
model
IllegalArgumentException - if direction is invalid
public int getViewIndex(int pos,
Position.Bias b)
getViewIndex in class Viewpos - the model location for which to determine the child view indexb - the bias to be applied to pos
protected abstract boolean isBefore(int x,
int y,
Rectangle r)
true if the specified point lies before the
given Rectangle, false otherwise.
"Before" is typically defined as being to the left or above.
x - the X coordinate of the pointy - the Y coordinate of the pointr - the rectangle to test the point against
true if the specified point lies before the
given Rectangle, false otherwise
protected abstract boolean isAfter(int x,
int y,
Rectangle r)
true if the specified point lies after the
given Rectangle, false otherwise.
"After" is typically defined as being to the right or below.
x - the X coordinate of the pointy - the Y coordinate of the pointr - the rectangle to test the point against
true if the specified point lies after the
given Rectangle, false otherwise
protected abstract View getViewAtPoint(int x,
int y,
Rectangle r)
View at the specified location.
x - the X coordinatey - the Y coordinater - the inner allocation of this BoxView on entry,
the allocation of the found child on exit
View at the specified location
protected abstract void childAllocation(int index,
Rectangle a)
View. The parameter
a stores the allocation of this CompositeView
and is then adjusted to hold the allocation of the child view.
index - the index of the child Viewa - the allocation of this CompositeView before the
call, the allocation of the child on exit
protected View getViewAtPosition(int pos,
Rectangle a)
View that contains the given model
position. The given Rectangle gives the parent's allocation
and is changed to the child's allocation on exit.
pos - the model position to query the child View fora - the parent allocation on entry and the child allocation on exit
protected int getViewIndexAtPosition(int pos)
View for the given model
position.
pos - the model position for whicht the child View is
queried
View for the given model
positionprotected Rectangle getInsideAllocation(Shape a)
CompositeView
minus this CompositeView's insets.
Also this translates from an immutable allocation to a mutable allocation
that is typically reused and further narrowed, like in
childAllocation(int, java.awt.Rectangle).
a - the allocation given to this CompositeView
CompositeView
minus this CompositeView's insets or
null if a was nullprotected void setParagraphInsets(AttributeSet attributes)
attributes. This
queries the attribute keys StyleConstants.SpaceAbove,
StyleConstants.SpaceBelow, StyleConstants.LeftIndent and
StyleConstants.RightIndent and calls setInsets(short, short, short, short) to
actually set the insets on this CompositeView.
attributes - the attributes from which to query the insets
protected void setInsets(short t,
short l,
short b,
short r)
CompositeView.
t - the top insetl - the left insetb - the bottom insetr - the right insetprotected short getLeftInset()
CompositeView.
CompositeViewprotected short getRightInset()
CompositeView.
CompositeViewprotected short getTopInset()
CompositeView.
CompositeViewprotected short getBottomInset()
CompositeView.
CompositeView
protected int getNextNorthSouthVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
pos - the model position to start search fromb - the bias for posa - the allocated region for this viewdirection - the direction from the current position, can be one of
the following:
biasRet - the bias of the return value gets stored here
BadLocationException - if pos is not a valid location
inside the document model
IllegalArgumentException - if direction is invalid
protected int getNextEastWestVisualPositionFrom(int pos,
Position.Bias b,
Shape a,
int direction,
Position.Bias[] biasRet)
throws BadLocationException
pos - the model position to start search fromb - the bias for posa - the allocated region for this viewdirection - the direction from the current position, can be one of
the following:
biasRet - the bias of the return value gets stored here
BadLocationException - if pos is not a valid location
inside the document model
IllegalArgumentException - if direction is invalid
protected boolean flipEastAndWestAtEnds(int pos,
Position.Bias bias)
pos. Usually
the Views are laid out from the east to the west, so
we unconditionally return false here. Subclasses that
support bidirectional text may wish to override this method.
pos - the position in the documentbias - the bias to be applied to pos
true if the next View is located
to the EAST, false otherwise
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||