All Packages Class Hierarchy This Package Previous Next Index
Class java.awt.swing.text.View
java.lang.Object
|
+----java.awt.swing.text.View
- public abstract class View
- extends Object
A view of some portion of document model. Provides
a mapping to model coordinates from view coordinates
and a mapping to view coordinates from model coordinates.
A view also provides rendering and layout services.
PENALTY_BAD- These are the bounds for penalties used for determining breaks.
PENALTY_GOOD- These are the bounds for penalties used for determining breaks.
X_AXIS- Axis for format/break operations.
Y_AXIS- Axis for format/break operations.
View(Element)
- Creates a new JView object.
breakView(int, float, Shape)
- Breaks this view on the given axis at the given length.
changedUpdate(DocumentEvent, Shape, ViewFactory)
- Gives notification from the document that attributes were changed
in a location that this view is responsible for.
getAlignment(int)
- Determines the desired alignment for this view along an
axis.
getBreakPenalty(int, float)
- Determines the penalty for breaking the view.
getChildAllocation(int, Shape)
- Fetch the allocation for the given child view.
getContainer()
- Fetches the container hosting the view.
getDocument()
- Fetches the model associated with the view.
getElement()
- Fetches the structural portion of the subject that this
view is mapped to.
getEndOffset()
- Fetches the portion of the model that this view is
responsible for.
getParent()
- Returns the parent of the view.
getPreferredSpan(int)
- Determines the preferred span for this view along an
axis.
getResizeWeight(int)
- Determines the resizability of the view along the
given axis.
getStartOffset()
- Fetches the portion of the model that this view is
responsible for.
getView(int)
- Gets the nth child view.
getViewCount()
- Returns the number of views in this view.
getViewFactory()
- Fetches the ViewFactory implementation that is feeding
the view hierarchy.
insertUpdate(DocumentEvent, Shape, ViewFactory)
- Gives notification that something was inserted into the document
in a location that this view is responsible for.
modelToView(int, Shape)
- Provides a mapping from the document model coordinate space
to the coordinate space of the view mapped to it.
paint(Graphics, Shape)
- Renders using the given rendering surface and area on that
surface.
preferenceChanged(View, boolean, boolean)
- Child views can call this on the parent to indicate that
the preference has changed.
removeUpdate(DocumentEvent, Shape, ViewFactory)
- Gives notification from the document that attributes were removed
in a location that this view is responsible for.
setParent(View)
- Establishes the parent view for this view.
setSize(float, float)
- Sets the size of the view.
viewToModel(float, float, Shape)
- Provides a mapping from the view coordinate space to the logical
coordinate space of the model.
PENALTY_GOOD
public static final int PENALTY_GOOD
- These are the bounds for penalties used for determining breaks.
A good penalty value should always be less than a bad penalty
value. The penalty_good value is a value that is
considered a forced break (ie. a value <= this value will
be guaranteed to cause a break). The penalty_bad value
is a value that is considered to be unbreakable (ie. a
value >= this value will be guaranteed not to break).
PENALTY_BAD
public static final int PENALTY_BAD
- These are the bounds for penalties used for determining breaks.
A good penalty value should always be less than a bad penalty
value. The penalty_good value is a value that is
considered a forced break (ie. a value <= this value will
be guaranteed to cause a break). The penalty_bad value
is a value that is considered to be unbreakable (ie. a
value >= this value will be guaranteed not to break).
X_AXIS
public static final int X_AXIS
- Axis for format/break operations.
Y_AXIS
public static final int Y_AXIS
- Axis for format/break operations.
View
public View(Element elem)
- Creates a new JView object.
- Parameters:
- elem - the element to represent
getParent
protected final View getParent()
- Returns the parent of the view.
- Returns:
- the parent
getPreferredSpan
public abstract float getPreferredSpan(int axis)
- Determines the preferred span for this view along an
axis.
- Parameters:
- axis - may be either X_AXIS or Y_AXIS
- See Also:
- getPreferredSpan
preferenceChanged
public void preferenceChanged(View child,
boolean width,
boolean height)
- Child views can call this on the parent to indicate that
the preference has changed. By default this just propagates
upward to the next parent.
- Parameters:
- child - the child view
- width - true if the width preference has changed
- height - true if the height preference has changed
getAlignment
public float getAlignment(int axis)
- Determines the desired alignment for this view along an
axis. By default this is simply centered.
- Parameters:
- axis - may be either X_AXIS or Y_AXIS
paint
public abstract void paint(Graphics g,
Shape allocation)
- Renders using the given rendering surface and area on that
surface. The view may need to do layout and create child
views to enable itself to render into the given allocation.
- Parameters:
- g - the rendering surface to use
- allocation - the allocated region to render into
- See Also:
- paint
setParent
public void setParent(View parent)
- Establishes the parent view for this view. This is
guaranteed to be called before any other methods if the
parent view is functioning properly. This is also
the last method called, since it is called to indicate
the view has been removed from the hierarchy as
well. If this is reimplemented,
super.setParent()
should be called.
- Parameters:
- parent - the new parent, or null if the view is
being removed from a parent it was previously added
to
getViewCount
public int getViewCount()
- Returns the number of views in this view. Since
the default is to not be a composite view this
returns 0;
- Returns:
- the number of views
- See Also:
- getViewCount
getView
public View getView(int n)
- Gets the nth child view. Since there are no
children by default, this returns null.
- Parameters:
- n - the number of the view to get
- Returns:
- the view
getChildAllocation
public Shape getChildAllocation(int index,
Shape a)
- Fetch the allocation for the given child view.
This enables finding out where various views
are located, without assuming the views store
their location. This returns null since the
default is to not have any child views.
- Parameters:
- index - the index of the child
- a - the allocation to this view.
- Returns:
- the allocation to the child
modelToView
public abstract Shape modelToView(int pos,
Shape a) throws BadLocationException
- Provides a mapping from the document model coordinate space
to the coordinate space of the view mapped to it.
- Parameters:
- pos - the position to convert
- a - the allocated region to render into
- Returns:
- the bounding box of the given position is returned
- Throws:
BadLocationException
- if the given position does not represent a
valid location in the associated document
- See Also:
- modelToView
viewToModel
public abstract int viewToModel(float x,
float y,
Shape a)
- Provides a mapping from the view coordinate space to the logical
coordinate space of the model.
- Parameters:
- x - the X coordinate
- y - the Y coordinate
- a - the allocated region to render into
- Returns:
- the location within the model that best represents the
given point in the view
- See Also:
- viewToModel
insertUpdate
public void insertUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
- Gives notification that something was inserted into the document
in a location that this view is responsible for.
- Parameters:
- e - the change information from the associated document
- a - the current allocation of the view
- f - the factory to use to rebuild if the view has children
- See Also:
- insertUpdate
removeUpdate
public void removeUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
- Gives notification from the document that attributes were removed
in a location that this view is responsible for.
- Parameters:
- e - the change information from the associated document
- a - the current allocation of the view
- f - the factory to use to rebuild if the view has children
- See Also:
- removeUpdate
changedUpdate
public void changedUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
- Gives notification from the document that attributes were changed
in a location that this view is responsible for.
- Parameters:
- e - the change information from the associated document
- a - the current allocation of the view
- f - the factory to use to rebuild if the view has children
- See Also:
- changedUpdate
getDocument
public Document getDocument()
- Fetches the model associated with the view.
- Returns:
- the view model
- See Also:
- getDocument
getStartOffset
public int getStartOffset()
- Fetches the portion of the model that this view is
responsible for.
- Returns:
- the starting offset into the model
- See Also:
- getStartOffset
getEndOffset
public int getEndOffset()
- Fetches the portion of the model that this view is
responsible for.
- Returns:
- the ending offset into the model
- See Also:
- getEndOffset
getElement
public Element getElement()
- Fetches the structural portion of the subject that this
view is mapped to. The view may not be responsible for the
entire portion of the element.
- Returns:
- the subject
- See Also:
- getElement
breakView
public View breakView(int axis,
float len,
Shape a)
- Breaks this view on the given axis at the given length.
This is implemented to return this view, which is
not breakable.
- Parameters:
- axis - may be either X_AXIS or Y_AXIS
- len - specifies where a potential break is desired
along the given axis
- a - the current allocation of the view
- Returns:
- the fragment of the view that represents the
given span, if the view can be broken. If the view
doesn't support breaking behavior, the view itself is
returned.
- See Also:
- breakView
getBreakPenalty
public int getBreakPenalty(int axis,
float len)
- Determines the penalty for breaking the view.
- Parameters:
- axis - may be either X_AXIS or Y_AXIS
- len - specifies where a potential break is desired
- Returns:
- the penalty
- See Also:
- getBreakPenalty
getResizeWeight
public int getResizeWeight(int axis)
- Determines the resizability of the view along the
given axis. A value of 0 or less is not resizable.
- Parameters:
- axis - X_AXIS or Y_AXIS
- Returns:
- the weight
setSize
public void setSize(float width,
float height)
- Sets the size of the view. This should cause
layout of the view, if it has any layout duties.
The default is to do nothing.
- Parameters:
- width - the width
- height - the height
getContainer
public Container getContainer()
- Fetches the container hosting the view. This is useful for
things like scheduling a repaint, finding out the host
components font, etc. The default implementation
of this is to forward the query to the parent view.
- Returns:
- the container
getViewFactory
public ViewFactory getViewFactory()
- Fetches the 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.
- Returns:
- the factory
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature