|
|||||||||
| Home >> All >> javax >> swing >> [ text overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
javax.swing.text
Class View

java.lang.Objectjavax.swing.text.View
- All Implemented Interfaces:
- javax.swing.SwingConstants
- Direct Known Subclasses:
- AsyncBoxView, ComponentView, CompositeView, GlyphView, IconView, PlainView, WrappedPlainView.WrappedLine
- public abstract class View
- extends java.lang.Object
- implements javax.swing.SwingConstants
- extends java.lang.Object
| Field Summary | |
static int |
BadBreakWeight
|
private Element |
elt
|
static int |
ExcellentBreakWeight
|
static int |
ForcedBreakWeight
|
static int |
GoodBreakWeight
|
private float |
height
|
private View |
parent
|
private float |
width
|
static int |
X_AXIS
|
static int |
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 | |
View(Element elem)
Creates a new View instance. |
|
| Method Summary | |
void |
append(View view)
|
View |
breakView(int axis,
int offset,
float pos,
float len)
|
void |
changedUpdate(javax.swing.event.DocumentEvent ev,
java.awt.Shape shape,
ViewFactory vf)
Receive notification about a change update to the text model. |
View |
createFragment(int p0,
int p1)
|
protected void |
dump()
Dumps the complete View hierarchy. |
(package private) void |
dump(int indent)
Dumps the view hierarchy below this View with the specified indentation level. |
protected void |
forwardUpdate(javax.swing.event.DocumentEvent.ElementChange ec,
javax.swing.event.DocumentEvent ev,
java.awt.Shape shape,
ViewFactory vf)
Forwards the DocumentEvent to child views that need to get notified of the change to the model. |
protected void |
forwardUpdateToView(View view,
javax.swing.event.DocumentEvent ev,
java.awt.Shape shape,
ViewFactory vf)
Forwards an update event to the given child view. |
float |
getAlignment(int axis)
Returns the alignment of this view along the baseline of the parent view. |
AttributeSet |
getAttributes()
|
int |
getBreakWeight(int axis,
float pos,
float len)
|
java.awt.Shape |
getChildAllocation(int index,
java.awt.Shape a)
|
java.awt.Container |
getContainer()
|
Document |
getDocument()
|
Element |
getElement()
|
int |
getEndOffset()
|
java.awt.Graphics |
getGraphics()
|
float |
getMaximumSpan(int axis)
Returns the maximum span along the specified axis. |
float |
getMinimumSpan(int axis)
Returns the minimum span along the specified axis. |
int |
getNextVisualPositionFrom(int pos,
Position.Bias b,
java.awt.Shape a,
int d,
Position.Bias[] biasRet)
Returns the document position that is (visually) nearest to the given document position pos in the given direction d. |
View |
getParent()
|
abstract float |
getPreferredSpan(int axis)
Returns the preferred span along the specified axis. |
int |
getResizeWeight(int axis)
Returns the resize weight of this view. |
int |
getStartOffset()
|
java.lang.String |
getToolTipText(float x,
float y,
java.awt.Shape allocation)
|
View |
getView(int index)
|
int |
getViewCount()
|
ViewFactory |
getViewFactory()
|
int |
getViewIndex(float x,
float y,
java.awt.Shape allocation)
|
int |
getViewIndex(int pos,
Position.Bias b)
|
void |
insert(int offset,
View view)
|
void |
insertUpdate(javax.swing.event.DocumentEvent ev,
java.awt.Shape shape,
ViewFactory vf)
Receive notification about an insert update to the text model. |
boolean |
isVisible()
|
java.awt.Shape |
modelToView(int p1,
Position.Bias b1,
int p2,
Position.Bias b2,
java.awt.Shape a)
Maps a region in the document into the coordinate space of the View. |
java.awt.Shape |
modelToView(int pos,
java.awt.Shape a)
Deprecated. Use modelToView(int, Shape, Position.Bias) 55 instead. |
abstract java.awt.Shape |
modelToView(int pos,
java.awt.Shape a,
Position.Bias b)
Maps a position in the document into the coordinate space of the View. |
abstract void |
paint(java.awt.Graphics g,
java.awt.Shape s)
|
void |
preferenceChanged(View child,
boolean width,
boolean height)
|
void |
remove(int index)
|
void |
removeAll()
|
void |
removeUpdate(javax.swing.event.DocumentEvent ev,
java.awt.Shape shape,
ViewFactory vf)
Receive notification about a remove update to the text model. |
void |
replace(int offset,
int length,
View[] views)
Replaces a couple of child views with new child views. |
void |
setParent(View parent)
Sets the parent for this view. |
void |
setSize(float width,
float height)
|
protected boolean |
updateChildren(javax.swing.event.DocumentEvent.ElementChange ec,
javax.swing.event.DocumentEvent ev,
ViewFactory vf)
Updates the list of children that is returned by getView(int) 55
and getViewCount() 55 . |
protected void |
updateLayout(javax.swing.event.DocumentEvent.ElementChange ec,
javax.swing.event.DocumentEvent ev,
java.awt.Shape shape)
Updates the layout. |
int |
viewToModel(float x,
float y,
java.awt.Shape a)
Deprecated. Use viewToModel(float, float, Shape, Position.Bias[]) 55
instead. |
abstract int |
viewToModel(float x,
float y,
java.awt.Shape a,
Position.Bias[] b)
Maps coordinates from the View's space into a position
in the document model. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
BadBreakWeight
public static final int BadBreakWeight
- See Also:
- Constant Field Values
ExcellentBreakWeight
public static final int ExcellentBreakWeight
- See Also:
- Constant Field Values
ForcedBreakWeight
public static final int ForcedBreakWeight
- See Also:
- Constant Field Values
GoodBreakWeight
public static final int GoodBreakWeight
- See Also:
- Constant Field Values
X_AXIS
public static final int X_AXIS
- See Also:
- Constant Field Values
Y_AXIS
public static final int Y_AXIS
- See Also:
- Constant Field Values
width
private float width
height
private float height
elt
private Element elt
parent
private View parent
| Constructor Detail |
View
public View(Element elem)
- Creates a new
Viewinstance.
| Method Detail |
paint
public abstract void paint(java.awt.Graphics g, java.awt.Shape s)
setParent
public void setParent(View parent)
- Sets the parent for this view. This is the first method that is beeing
called on a view to setup the view hierarchy. This is also the last method
beeing called when the view is disconnected from the view hierarchy, in
this case
parentis null. Ifparentisnull, a call to this method also callssetParenton the children, thus disconnecting them from the view hierarchy. That means that super must be called when this method is overridden.
getParent
public View getParent()
getContainer
public java.awt.Container getContainer()
getDocument
public Document getDocument()
getElement
public Element getElement()
getPreferredSpan
public abstract float getPreferredSpan(int axis)
- Returns the preferred span along the specified axis. Normally the view is
rendered with the span returned here if that is possible.
getResizeWeight
public int getResizeWeight(int axis)
- Returns the resize weight of this view. A value of
0or less means this view is not resizeable. Positive values make the view resizeable. The default implementation returns0unconditionally.
getMaximumSpan
public float getMaximumSpan(int axis)
- Returns the maximum span along the specified axis. The default
implementation will forward to
getPreferredSpan(int)55 unlessgetResizeWeight(int)55 returns a value > 0, in which case this returns Integer.MIN_VALUE>Integer.MIN_VALUE55 .
getMinimumSpan
public float getMinimumSpan(int axis)
- Returns the minimum span along the specified axis. The default
implementation will forward to
getPreferredSpan(int)55 unlessgetResizeWeight(int)55 returns a value > 0, in which case this returns0.
setSize
public void setSize(float width,
float height)
getAlignment
public float getAlignment(int axis)
- Returns the alignment of this view along the baseline of the parent view.
An alignment of
0.0will align this view with the left edge along the baseline, an alignment of0.5will align it centered to the baseline, an alignment of1.0will align the right edge along the baseline. The default implementation returns 0.5 unconditionally.
getAttributes
public AttributeSet getAttributes()
isVisible
public boolean isVisible()
getViewCount
public int getViewCount()
getView
public View getView(int index)
getViewFactory
public ViewFactory getViewFactory()
replace
public void replace(int offset,
int length,
View[] views)
- Replaces a couple of child views with new child views. If
length == 0then this is a simple insertion, ifviews == nullthis only removes some child views.
insert
public void insert(int offset,
View view)
append
public void append(View view)
removeAll
public void removeAll()
remove
public void remove(int index)
createFragment
public View createFragment(int p0, int p1)
getStartOffset
public int getStartOffset()
getEndOffset
public int getEndOffset()
getChildAllocation
public java.awt.Shape getChildAllocation(int index, java.awt.Shape a)
getViewIndex
public int getViewIndex(float x,
float y,
java.awt.Shape allocation)
- Since:
- 1.4
getToolTipText
public java.lang.String getToolTipText(float x, float y, java.awt.Shape allocation)
- Since:
- 1.4
getGraphics
public java.awt.Graphics getGraphics()
- Since:
- 1.3
preferenceChanged
public void preferenceChanged(View child, boolean width, boolean height)
getBreakWeight
public int getBreakWeight(int axis,
float pos,
float len)
breakView
public View breakView(int axis, int offset, float pos, float len)
getViewIndex
public int getViewIndex(int pos,
Position.Bias b)
- Since:
- 1.3
insertUpdate
public void insertUpdate(javax.swing.event.DocumentEvent ev, java.awt.Shape shape, ViewFactory vf)
- Receive notification about an insert update to the text model.
The default implementation of this method does the following:
- Call
updateChildren(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, javax.swing.text.ViewFactory)55 if the element that this view is responsible for has changed. This makes sure that the children can correctly represent the model. - Call
forwardUpdate(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)55 . This forwards the DocumentEvent to the child views. - Call
updateLayout(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape)55 . Gives the view a chance to either repair its layout, reschedule layout or do nothing at all.
- Call
removeUpdate
public void removeUpdate(javax.swing.event.DocumentEvent ev, java.awt.Shape shape, ViewFactory vf)
- Receive notification about a remove update to the text model.
The default implementation of this method does the following:
- Call
updateChildren(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, javax.swing.text.ViewFactory)55 if the element that this view is responsible for has changed. This makes sure that the children can correctly represent the model. - Call
forwardUpdate(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)55 . This forwards the DocumentEvent to the child views. - Call
updateLayout(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape)55 . Gives the view a chance to either repair its layout, reschedule layout or do nothing at all.
- Call
changedUpdate
public void changedUpdate(javax.swing.event.DocumentEvent ev, java.awt.Shape shape, ViewFactory vf)
- Receive notification about a change update to the text model.
The default implementation of this method does the following:
- Call
updateChildren(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, javax.swing.text.ViewFactory)55 if the element that this view is responsible for has changed. This makes sure that the children can correctly represent the model. - Call
forwardUpdate(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)55 . This forwards the DocumentEvent to the child views. - Call
updateLayout(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape)55 . Gives the view a chance to either repair its layout, reschedule layout or do nothing at all.
- Call
updateChildren
protected boolean updateChildren(javax.swing.event.DocumentEvent.ElementChange ec,
javax.swing.event.DocumentEvent ev,
ViewFactory vf)
- Updates the list of children that is returned by
getView(int)55 andgetViewCount()55 . Element that are specified as beeing added in the ElementChange record are assigned a view for using the ViewFactory. Views of Elements that are specified as beeing removed are removed from the list.- Since:
- 1.3
forwardUpdate
protected void forwardUpdate(javax.swing.event.DocumentEvent.ElementChange ec,
javax.swing.event.DocumentEvent ev,
java.awt.Shape shape,
ViewFactory vf)
- Forwards the DocumentEvent to child views that need to get notified
of the change to the model. This calles
forwardUpdateToView(javax.swing.text.View, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)55 for each View that must be forwarded to. Ifecis notnull(this means there have been structural changes to the element that this view is responsible for) this method should recognize this and don't notify newly added child views.- Since:
- 1.3
forwardUpdateToView
protected void forwardUpdateToView(View view, javax.swing.event.DocumentEvent ev, java.awt.Shape shape, ViewFactory vf)
- Forwards an update event to the given child view. This calls
insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)55 ,removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)55 orchangedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)55 , depending on the type of document event.- Since:
- 1.3
updateLayout
protected void updateLayout(javax.swing.event.DocumentEvent.ElementChange ec,
javax.swing.event.DocumentEvent ev,
java.awt.Shape shape)
- Updates the layout.
- Since:
- 1.3
modelToView
public abstract java.awt.Shape modelToView(int pos, java.awt.Shape a, Position.Bias b) throws BadLocationException
- Maps a position in the document into the coordinate space of the View.
The output rectangle usually reflects the font height but has a width
of zero.
modelToView
public java.awt.Shape modelToView(int p1, Position.Bias b1, int p2, Position.Bias b2, java.awt.Shape a) throws BadLocationException
- Maps a region in the document into the coordinate space of the View.
modelToView
public java.awt.Shape modelToView(int pos, java.awt.Shape a) throws BadLocationException
- Deprecated. Use
modelToView(int, Shape, Position.Bias)55 instead.- Maps a position in the document into the coordinate space of the View. The output rectangle usually reflects the font height but has a width of zero. This method is deprecated and calls
modelToView(int, Position.Bias, int, Position.Bias, Shape)55 with a bias ofPosition.Bias.Forward55 . - Maps a position in the document into the coordinate space of the View. The output rectangle usually reflects the font height but has a width of zero. This method is deprecated and calls
viewToModel
public abstract int viewToModel(float x,
float y,
java.awt.Shape a,
Position.Bias[] b)
- Maps coordinates from the
View's space into a position in the document model.
viewToModel
public int viewToModel(float x,
float y,
java.awt.Shape a)
- Deprecated. Use
viewToModel(float, float, Shape, Position.Bias[])55 instead.- Maps coordinates from the
View's space into a position in the document model. This method is deprecated and only there for compatibility. - Maps coordinates from the
dump
protected void dump()
- Dumps the complete View hierarchy. This method can be used for debugging
purposes.
dump
void dump(int indent)
- Dumps the view hierarchy below this View with the specified indentation
level.
getNextVisualPositionFrom
public int getNextVisualPositionFrom(int pos,
Position.Bias b,
java.awt.Shape a,
int d,
Position.Bias[] biasRet)
throws BadLocationException
- Returns the document position that is (visually) nearest to the given
document position
posin the given directiond.
|
|||||||||
| Home >> All >> javax >> swing >> [ text overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
JAVADOC
javax.swing.text.View