|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.swing.text.View
Safe:
Field Summary | |
static int |
BadBreakWeight
Enabled: The weight to indicate a view is a bad break opportunity for the purpose of formatting. |
private Element |
elem
|
static int |
ExcellentBreakWeight
Enabled: The weight to indicate a view supports breaking, and this represents a very attractive place to break. |
static int |
ForcedBreakWeight
Enabled: The weight to indicate a view supports breaking, and must be broken to be represented properly when placed in a view that formats its children by breaking them. |
static int |
GoodBreakWeight
Enabled: The weight to indicate a view supports breaking, but better opportunities probably exist. |
private View |
parent
|
(package private) static javax.swing.text.Position.Bias[] |
sharedBiasReturn
|
static int |
X_AXIS
Enabled: Axis for format/break operations. |
static int |
Y_AXIS
Enabled: Axis for format/break operations. |
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)
Enabled: Creates a new View object. |
Method Summary | |
void |
append(View v)
Enabled: Appends a single child view. |
View |
breakView(int axis,
int offset,
float pos,
float len)
Enabled: Tries to break this view on the given axis. |
void |
changedUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
Enabled: Gives notification from the document that attributes were changed in a location that this view is responsible for. |
View |
createFragment(int p0,
int p1)
Enabled: Creates a view that represents a portion of the element. |
protected void |
forwardUpdate(javax.swing.event.DocumentEvent.ElementChange ec,
DocumentEvent e,
Shape a,
ViewFactory f)
Forwards the given DocumentEvent to the child views
that need to be notified of the change to the model. |
protected void |
forwardUpdateToView(View v,
DocumentEvent e,
Shape a,
ViewFactory f)
Forwards the DocumentEvent to the give child view. |
float |
getAlignment(int axis)
Enabled: Determines the desired alignment for this view along an axis. |
AttributeSet |
getAttributes()
Enabled: Fetches the attributes to use when rendering. |
int |
getBreakWeight(int axis,
float pos,
float len)
Enabled: Determines how attractive a break opportunity in this view is. |
Shape |
getChildAllocation(int index,
Shape a)
Enabled: Fetches the allocation for the given child view. |
Container |
getContainer()
Suppressed: Fetches the container hosting the view. |
Document |
getDocument()
Enabled: Fetches the model associated with the view. |
Element |
getElement()
Enabled: Fetches the structural portion of the subject that this view is mapped to. |
int |
getEndOffset()
Enabled: Fetches the portion of the model for which this view is responsible. |
Graphics |
getGraphics()
Enabled: Fetch a Graphics for rendering. |
float |
getMaximumSpan(int axis)
Enabled: Determines the maximum span for this view along an axis. |
float |
getMinimumSpan(int axis)
Enabled: Determines the minimum span for this view along an axis. |
int |
getNextVisualPositionFrom(int pos,
javax.swing.text.Position.Bias b,
Shape a,
int direction,
javax.swing.text.Position.Bias[] biasRet)
Suppressed: Provides a way to determine the next visually represented model location at which one might place a caret. |
View |
getParent()
Suppressed: Returns the parent of the view. |
abstract float |
getPreferredSpan(int axis)
Enabled: Determines the preferred span for this view along an axis. |
int |
getResizeWeight(int axis)
Enabled: Determines the resizability of the view along the given axis. |
int |
getStartOffset()
Enabled: Fetches the portion of the model for which this view is responsible. |
String |
getToolTipText(float x,
float y,
Shape allocation)
Enabled: Returns the tooltip text at the specified location. |
View |
getView(int n)
Enabled: Gets the nth child view. |
int |
getViewCount()
Enabled: Returns the number of views in this view. |
ViewFactory |
getViewFactory()
Enabled: Fetches the ViewFactory implementation that is feeding
the view hierarchy. |
int |
getViewIndex(float x,
float y,
Shape allocation)
Enabled: Returns the child view index representing the given position in the view. |
int |
getViewIndex(int pos,
javax.swing.text.Position.Bias b)
Suppressed: Returns the child view index representing the given position in the model. |
void |
insert(int offs,
View v)
Enabled: Inserts a single child view. |
void |
insertUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
Enabled: Gives notification that something was inserted into the document in a location that this view is responsible for. |
boolean |
isVisible()
Enabled: Returns a boolean that indicates whether the view is visible or not. |
Shape |
modelToView(int p0,
javax.swing.text.Position.Bias b0,
int p1,
javax.swing.text.Position.Bias b1,
Shape a)
Suppressed: Provides a mapping, for a given region, from the document model coordinate space to the view coordinate space. |
Shape |
modelToView(int pos,
Shape a)
Deprecated. |
abstract Shape |
modelToView(int pos,
Shape a,
javax.swing.text.Position.Bias b)
Suppressed: Provides a mapping, for a given character, from the document model coordinate space to the view coordinate space. |
abstract void |
paint(Graphics g,
Shape allocation)
Suppressed: Renders using the given rendering surface and area on that surface. |
void |
preferenceChanged(View child,
boolean width,
boolean height)
Enabled: Child views can call this on the parent to indicate that the preference has changed and should be reconsidered for layout. |
void |
remove(int i)
Enabled: Removes one of the children at the given position. |
void |
removeAll()
Enabled: Removes all of the children. |
void |
removeUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
Enabled: Gives notification that something was removed from the document in a location that this view is responsible for. |
void |
replace(int offset,
int length,
View[] views)
Enabled: Replaces child views. |
void |
setParent(View parent)
Suppressed: Establishes the parent view for this view. |
void |
setSize(float width,
float height)
Enabled: Sets the size of the view. |
protected boolean |
updateChildren(javax.swing.event.DocumentEvent.ElementChange ec,
DocumentEvent e,
ViewFactory f)
Updates the child views in response to receiving notification that the model changed, and there is change record for the element this view is responsible for. |
protected void |
updateLayout(javax.swing.event.DocumentEvent.ElementChange ec,
DocumentEvent e,
Shape a)
Updates the layout in response to receiving notification of change from the model. |
int |
viewToModel(float x,
float y,
Shape a)
Deprecated. |
abstract int |
viewToModel(float x,
float y,
Shape a,
javax.swing.text.Position.Bias[] biasReturn)
Suppressed: Provides a mapping from the view coordinate space to the logical coordinate space of the model. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final int BadBreakWeight
getBreakWeight(int, float, float)
,
GoodBreakWeight
,
ExcellentBreakWeight
,
ForcedBreakWeight
public static final int GoodBreakWeight
getBreakWeight(int, float, float)
,
BadBreakWeight
,
ExcellentBreakWeight
,
ForcedBreakWeight
public static final int ExcellentBreakWeight
getBreakWeight(int, float, float)
,
BadBreakWeight
,
GoodBreakWeight
,
ForcedBreakWeight
public static final int ForcedBreakWeight
getBreakWeight(int, float, float)
,
BadBreakWeight
,
GoodBreakWeight
,
ExcellentBreakWeight
public static final int X_AXIS
public static final int Y_AXIS
static final javax.swing.text.Position.Bias[] sharedBiasReturn
private View parent
private Element elem
Constructor Detail |
public View(Element elem)
View
object.
elem
- the Element
to representMethod Detail |
public View getParent()
null
if none existspublic boolean isVisible()
public abstract float getPreferredSpan(int axis)
axis
- may be either View.X_AXIS
or
View.Y_AXIS
getPreferredSpan(int)
public float getMinimumSpan(int axis)
axis
- may be either View.X_AXIS
or
View.Y_AXIS
getPreferredSpan(int)
public float getMaximumSpan(int axis)
axis
- may be either View.X_AXIS
or
View.Y_AXIS
getPreferredSpan(int)
public void preferenceChanged(View child, boolean width, boolean height)
revalidate
on the associated text component.
child
- the child viewwidth
- true if the width preference has changedheight
- true if the height preference has changedjavax.swing.JComponent#revalidate
public float getAlignment(int axis)
axis
- may be either View.X_AXIS
or
View.Y_AXIS
public abstract void paint(Graphics g, Shape allocation)
g
- the rendering surface to useallocation
- the allocated region to render intopaint(java.awt.Graphics, java.awt.Shape)
public void setParent(View parent)
super.setParent()
should
be called.
parent
- the new parent, or null
if the view is
being removed from a parentpublic int getViewCount()
getViewCount()
public View getView(int n)
null
.
n
- the number of the view to get, >= 0 && < getViewCount()
public void removeAll()
replace
.
public void remove(int i)
replace
.
public void insert(int offs, View v)
replace
.
offs
- the offset of the view to insert before >= 0v
- the viewreplace(int, int, javax.swing.text.View[])
public void append(View v)
replace
.
v
- the viewreplace(int, int, javax.swing.text.View[])
public void replace(int offset, int length, View[] views)
null
, and the internal reference
to them removed so that they can be garbage collected.
This is implemented to do nothing, because by default
a view has no children.
length
- the number of existing child views to remove
This should be a value >= 0 and <= (getViewCount() - offset).views
- the child views to add. This value can be
null
to indicate no children are being added
(useful to remove).public int getViewIndex(int pos, javax.swing.text.Position.Bias b)
pos
- the position >= 0
public Shape getChildAllocation(int index, Shape a)
null
since the
default is to not have any child views.
index
- the index of the child, >= 0 && <
getViewCount()
a
- the allocation to this view
public int getNextVisualPositionFrom(int pos, javax.swing.text.Position.Bias b, Shape a, int direction, javax.swing.text.Position.Bias[] biasRet) throws BadLocationException
pos
- the position to convert >= 0a
- the allocated region in which to renderdirection
- the direction from the current position that can
be thought of as the arrow keys typically found on a keyboard.
This will be one of the following values:
BadLocationException
public abstract Shape modelToView(int pos, Shape a, javax.swing.text.Position.Bias b) throws BadLocationException
pos
- the position of the desired character (>=0)a
- the area of the view, which encompasses the requested characterb
- the bias toward the previous character or the
next character represented by the offset, in case the
position is a boundary of two views; b
will have one
of these values:
Position.Bias.Forward
Position.Bias.Backward
BadLocationException
viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
public Shape modelToView(int p0, javax.swing.text.Position.Bias b0, int p1, javax.swing.text.Position.Bias b1, Shape a) throws BadLocationException
p0
- the position of the first character (>=0)b0
- the bias of the first character position,
toward the previous character or the
next character represented by the offset, in case the
position is a boundary of two views; b0
will have one
of these values:
Position.Bias.Forward
Position.Bias.Backward
p1
- the position of the last character (>=0)b1
- the bias for the second character position, defined
one of the legal values shown abovea
- the area of the view, which encompasses the requested region
BadLocationException
viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
public abstract int viewToModel(float x, float y, Shape a, javax.swing.text.Position.Bias[] biasReturn)
biasReturn
argument will be filled in to indicate that the point given is
closer to the next character in the model or the previous
character in the model.
x
- the X coordinate >= 0y
- the Y coordinate >= 0a
- the allocated region in which to render
biasReturn
argument will be
filled in to indicate that the point given is closer to the next
character in the model or the previous character in the model.public void insertUpdate(DocumentEvent e, Shape a, ViewFactory f)
e
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childreninsertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public void removeUpdate(DocumentEvent e, Shape a, ViewFactory f)
e
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childrenremoveUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public void changedUpdate(DocumentEvent e, Shape a, ViewFactory f)
e
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childrenchangedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public Document getDocument()
null
if nonegetDocument()
public int getStartOffset()
getStartOffset()
public int getEndOffset()
getEndOffset()
public Element getElement()
getElement()
public Graphics getGraphics()
Graphics
for rendering.
This can be used to determine
font characteristics, and will be different for a print view
than a component view.
Graphics
object for renderingpublic AttributeSet getAttributes()
AttributeSet
returned
by this method.
public View breakView(int axis, int offset, float pos, float len)
This is implemented to return the view itself, which represents the default behavior on not being breakable. If the view does support breaking, the starting offset of the view returned should be the given offset, and the end offset should be less than or equal to the end offset of the view being broken.
axis
- may be either View.X_AXIS
or
View.Y_AXIS
offset
- the location in the document model
that a broken fragment would occupy >= 0. This
would be the starting offset of the fragment
returnedpos
- the position along the axis that the
broken view would occupy >= 0. This may be useful for
things like tab calculationslen
- specifies the distance along the axis
where a potential break is desired >= 0
ParagraphView
public View createFragment(int p0, int p1)
p0
- the starting offset >= 0. This should be a value
greater or equal to the element starting offset and
less than the element ending offset.p1
- the ending offset > p0. This should be a value
less than or equal to the elements end offset and
greater than the elements starting offset.
LabelView
public int getBreakWeight(int axis, float pos, float len)
breakView
on in the process of formatting. A view that represents
text that has whitespace in it might be more attractive
than a view that has no whitespace, for example. The
higher the weight, the more attractive the break. A
value equal to or lower than BadBreakWeight
should not be considered for a break. A value greater
than or equal to ForcedBreakWeight
should
be broken.
This is implemented to provide the default behavior
of returning BadBreakWeight
unless the length
is greater than the length of the view in which case the
entire view represents the fragment. Unless a view has
been written to support breaking behavior, it is not
attractive to try and break the view. An example of
a view that does support breaking is LabelView
.
An example of a view that uses break weight is
ParagraphView
.
axis
- may be either View.X_AXIS
or
View.Y_AXIS
pos
- the potential location of the start of the
broken view >= 0. This may be useful for calculating tab
positionslen
- specifies the relative length from pos
where a potential break is desired >= 0
LabelView
,
ParagraphView
,
BadBreakWeight
,
GoodBreakWeight
,
ExcellentBreakWeight
,
ForcedBreakWeight
public int getResizeWeight(int axis)
axis
- may be either View.X_AXIS
or
View.Y_AXIS
public void setSize(float width, float height)
width
- the width >= 0height
- the height >= 0public Container getContainer()
null
if nonepublic ViewFactory getViewFactory()
ViewFactory
implementation that is feeding
the view hierarchy. Normally the views are given this
as an argument to updates from the model when they
are most likely to need the factory, but this
method serves to provide it at other times.
null
if nonepublic String getToolTipText(float x, float y, Shape allocation)
JTextComponent.getToolTipText(java.awt.event.MouseEvent)
public int getViewIndex(float x, float y, Shape allocation)
x
, y
.
x
- the x coordinatey
- the y coordinateallocation
- current allocation of the View.
protected boolean updateChildren(javax.swing.event.DocumentEvent.ElementChange ec, DocumentEvent e, ViewFactory f)
ViewFactory
is used to create child views for each element
specified as added in the ElementChange
, starting at the
index specified in the given ElementChange
. The number of
child views representing the removed elements specified are
removed.
ec
- the change information for the element this view
is responsible for. This should not be null
if
this method gets callede
- the change information from the associated documentf
- the factory to use to build child views
insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
,
removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
,
changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
protected void forwardUpdate(javax.swing.event.DocumentEvent.ElementChange ec, DocumentEvent e, Shape a, ViewFactory f)
DocumentEvent
to the child views
that need to be notified of the change to the model.
If there were changes to the element this view is
responsible for, that should be considered when
forwarding (i.e. new child views should not get
notified).
ec
- changes to the element this view is responsible
for (may be null
if there were no changes).e
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childreninsertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
,
removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
,
changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
protected void forwardUpdateToView(View v, DocumentEvent e, Shape a, ViewFactory f)
DocumentEvent
to the give child view. This
simply messages the view with a call to insertUpdate
,
removeUpdate
, or changedUpdate
depending
upon the type of the event. This is called by
forwardUpdate to forward
the event to children that need it.
v
- the child view to forward the event toe
- the change information from the associated documenta
- the current allocation of the viewf
- the factory to use to rebuild if the view has childrenforwardUpdate(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
protected void updateLayout(javax.swing.event.DocumentEvent.ElementChange ec, DocumentEvent e, Shape a)
preferenceChanged
to reschedule a new layout
if the ElementChange
record is not null
.
ec
- changes to the element this view is responsible
for (may be null
if there were no changes)e
- the change information from the associated documenta
- the current allocation of the viewinsertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
,
removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
,
changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public Shape modelToView(int pos, Shape a) throws BadLocationException
Position.Bias.Forward
which was previously implied.
pos
- the position to convert >= 0a
- the allocated region in which to render
BadLocationException
modelToView(int, java.awt.Shape, javax.swing.text.Position.Bias)
public int viewToModel(float x, float y, Shape a)
x
- the X coordinate >= 0y
- the Y coordinate >= 0a
- the allocated region in which to render
viewToModel(float, float, java.awt.Shape, javax.swing.text.Position.Bias[])
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |