All Packages Class Hierarchy This Package Previous Next Index
Interface com.sun.java.swing.text.View
- public interface View
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.
Many methods pass an allocated Shape and a ViewFactory
as arguments. This enables the views to be dynamically
computed if desired.
-
PENALTY_BAD
-
-
PENALTY_GOOD
- These are the bounds for penalties used for determining breaks.
-
X_AXIS
- axis for format/break operations.
-
Y_AXIS
-
-
breakView(int, float, Shape)
- Break this view on the given axis at the given length.
-
changedUpdate(DocumentEvent, Shape, ViewFactory)
- Notification from the document that attributes were changed
in a location that this view is responsible for.
-
getBreakPenalty(int, float)
- Determines the penalty for breaking the view.
-
getDocument()
- Fetch the model associated with the view.
-
getElement()
- Fetch the structural portion of the subject that this
view is mapped to.
-
getPreferredShape(Shape, ViewFactory)
- Determine the preferred region for this view.
-
getRange()
- Fetch the portion of the model that this view is
responsible for.
-
getResizePenalty(int, float)
- Determines the penalty for changing
the size of the view if it supports multiple sizes.
-
insertUpdate(DocumentEvent, Shape, ViewFactory)
- Notification that something was inserted into the document
in a location that this view is responsible for.
-
modelToView(Position, Shape, ViewFactory)
- Provides a mapping from the document model coordinate space
to the coordinate space of the view mapped to it.
-
paint(Graphics, Shape, ViewFactory)
- Render using the given rendering surface and area on that
surface.
-
removeUpdate(DocumentEvent, Shape, ViewFactory)
- Notification that something was removed from the document
in a location that this view is responsible for.
-
viewToModel(Point, Shape, ViewFactory)
- 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
X_AXIS
public static final int X_AXIS
- axis for format/break operations.
Y_AXIS
public static final int Y_AXIS
getPreferredShape
public abstract Shape getPreferredShape(Shape candidate,
ViewFactory f)
- Determine the preferred region for this view. The candidate
shape may be mutated and used as the return value. The
factory is given because a view may recreate children if
it does layout to satisfy the request.
- Parameters:
- candidate - A region that the parent is considering
allocating to the view. Typically this will be whatever
is left for the parent to allocate.
- f - A factory that can be used to create child
views if a new layout is needed to determine
the desired shape.
- Returns:
- s The shape the view would like to be rendered into.
Typically the view is told to render into the shape
that is returned, although there is no guarantee.
The parent may choose to resize or break the view.
paint
public abstract void paint(Graphics g,
Shape allocation,
ViewFactory f)
- Render 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
- a - The allocated region to render into.
- f - The factory to use if children need to be created.
getDocument
public abstract Document getDocument()
- Fetch the model associated with the view.
getRange
public abstract Range getRange()
- Fetch the portion of the model that this view is
responsible for.
getElement
public abstract Element getElement()
- Fetch 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.
- See Also:
- getRange
modelToView
public abstract Shape modelToView(Position pos,
Shape a,
ViewFactory f) throws BadLocation
- 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.
- f - The factory to use if children need to be created.
- Returns:
- s The bounding box of the given position is returned.
Since a position has no width, the shape returned has only height.
- Throws: BadLocation
- The given position is not a valid location
within the model.
viewToModel
public abstract Position viewToModel(Point pt,
Shape a,
ViewFactory f)
- Provides a mapping from the view coordinate space to the logical
coordinate space of the model.
- Parameters:
- pt - The view location to convert.
- a - The allocated region to render into.
- f - The factory to use if children need to be created.
- Returns:
- s The locaion within the model that best represents the
given point in the view.
insertUpdate
public abstract void insertUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
- 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
- f - The factory to use to rebuild if the view has children.
- a - The current allocation of the view.
removeUpdate
public abstract void removeUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
- Notification that something was removed from the document
in a location that this view is responsible for.
- Parameters:
- e - The change information from the associated document
- f - The factory to use to rebuild if the view has children.
- a - The current allocation of the view.
changedUpdate
public abstract void changedUpdate(DocumentEvent e,
Shape a,
ViewFactory f)
- 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
- f - The factory to use to rebuild if the view has children.
- a - The current allocation of the view.
breakView
public abstract View breakView(int axis,
float len,
Shape a)
- Break this view on the given axis at the given length.
This causes a view to be created that represents the
portion of the view that can fit within the given
span. A factory is not needed for this operation since
the view fragment created will be of the same type as
the view being broken.
- Parameters:
- axis - May be either X_AXIS or Y_AXIS
- len - Specifies where a potential break is desired
within the span along the given axis of the allocated
area for the view.
- a - The current allocation of the view.
- Returns:
- s The fragment of the view that represents the
given span, if the view can be broken. If the view
doesn't support breaking behavior, null is returned.
getBreakPenalty
public abstract int getBreakPenalty(int axis,
float len)
- Determines the penalty for breaking the view. The view
might not support breaking (returns PENALTY_BAD), or the
view might insist on being broken (returns PENALTY_GOOD),
it might return some value between the two bounds.
- Parameters:
- axis - May be either X_AXIS or Y_AXIS
- len - Specifies where a potential break is desired
within the span along the given axis of the allocated
area for the view.
getResizePenalty
public abstract int getResizePenalty(int axis,
float len)
- Determines the penalty for changing
the size of the view if it supports multiple sizes. Some
views may look at this information and use it to
determine whether to break or resize based upon it. Other
views may ignore this value and enforce their own
policy of break versus resize.
All Packages Class Hierarchy This Package Previous Next Index