javax.swing.plaf.basic
Class BasicTextAreaUI.PlainParagraph.LogicalView

java.lang.Object
  extended byjavax.swing.text.View
      extended byjavax.swing.text.CompositeView
          extended byjavax.swing.plaf.basic.BasicTextAreaUI.PlainParagraph.LogicalView
All Implemented Interfaces:
SwingConstants
Enclosing class:
BasicTextAreaUI.PlainParagraph

static class BasicTextAreaUI.PlainParagraph.LogicalView
extends CompositeView

This class can be used to represent a logical view for a flow. It keeps the children updated to reflect the state of the model, gives the logical child views access to the view hierarchy, and calculates a preferred span. It doesn't do any rendering, layout, or model/view translation.


Field Summary
 
Fields inherited from class javax.swing.text.CompositeView
 
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
(package private) BasicTextAreaUI.PlainParagraph.LogicalView(Element elem)
           
 
Method Summary
protected  void childAllocation(int index, Rectangle a)
          Returns the allocation for a given child.
protected  void forwardUpdateToView(View v, DocumentEvent e, Shape a, ViewFactory f)
          Forward the DocumentEvent to the given child view.
 float getPreferredSpan(int axis)
          Determines the preferred span for this view along an axis.
protected  View getViewAtPoint(int x, int y, Rectangle alloc)
          Fetches the child view at the given coordinates.
protected  int getViewIndexAtPosition(int pos)
          Fetches the child view index representing the given position in the model.
protected  boolean isAfter(int x, int y, Rectangle alloc)
          Tests whether a point lies after the rectangle range.
protected  boolean isBefore(int x, int y, Rectangle alloc)
          Tests whether a point lies before the rectangle range.
protected  void loadChildren(ViewFactory f)
          Loads all of the children to initialize the view.
 void paint(Graphics g, Shape allocation)
          Renders using the given rendering surface and area on that surface.
protected  boolean updateChildren(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.
 
Methods inherited from class javax.swing.text.CompositeView
flipEastAndWestAtEnds, getBottomInset, getChildAllocation, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, modelToView, modelToView, replace, setInsets, setParagraphInsets, setParent, viewToModel
 
Methods inherited from class javax.swing.text.View
append, breakView, changedUpdate, createFragment, forwardUpdate, getAlignment, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getMinimumSpan, getParent, getResizeWeight, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, preferenceChanged, remove, removeAll, removeUpdate, setSize, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicTextAreaUI.PlainParagraph.LogicalView

BasicTextAreaUI.PlainParagraph.LogicalView(Element elem)
Method Detail

getViewIndexAtPosition

protected int getViewIndexAtPosition(int pos)
Description copied from class: CompositeView
Fetches the child view index representing the given position in the model. This is implemented to fetch the view in the case where there is a child view for each child element.

Overrides:
getViewIndexAtPosition in class CompositeView
Parameters:
pos - the position >= 0
Returns:
index of the view representing the given position, or -1 if no view represents that position

updateChildren

protected boolean updateChildren(DocumentEvent.ElementChange ec,
                                 DocumentEvent e,
                                 ViewFactory f)
Description copied from class: View
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. This is implemented to assume the child views are directly responsible for the child elements of the element this view represents. The 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.

Overrides:
updateChildren in class View
Parameters:
ec - the change information for the element this view is responsible for. This should not be null if this method gets called
e - the change information from the associated document
f - the factory to use to build child views
Returns:
whether or not the child views represent the child elements of the element this view is responsible for. Some views create children that represent a portion of the element they are responsible for, and should return false. This information is used to determine if views in the range of the added elements should be forwarded to or not
See Also:
View.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory), View.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory), View.changedUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)

loadChildren

protected void loadChildren(ViewFactory f)
Description copied from class: CompositeView
Loads all of the children to initialize the view. This is called by the CompositeView.setParent(javax.swing.text.View) method. Subclasses can reimplement this to initialize their child views in a different manner. The default implementation creates a child view for each child element.

Overrides:
loadChildren in class CompositeView
Parameters:
f - the view factory
See Also:
CompositeView.setParent(javax.swing.text.View)

getPreferredSpan

public float getPreferredSpan(int axis)
Description copied from class: View
Determines the preferred span for this view along an axis.

Specified by:
getPreferredSpan in class View
Parameters:
axis - may be either View.X_AXIS or View.Y_AXIS
Returns:
the span the view would like to be rendered into. Typically the view is told to render into the span that is returned, although there is no guarantee. The parent may choose to resize or break the view
See Also:
View.getPreferredSpan(int)

forwardUpdateToView

protected void forwardUpdateToView(View v,
                                   DocumentEvent e,
                                   Shape a,
                                   ViewFactory f)
Forward the DocumentEvent to the given child view. This is implemented to reparent the child to the logical view (the children may have been parented by a row in the flow if they fit without breaking) and then execute the superclass behavior.

Overrides:
forwardUpdateToView in class View
Parameters:
v - the child view to forward the event to.
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
Since:
1.3
See Also:
View.forwardUpdate(javax.swing.event.DocumentEvent.ElementChange, javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)

paint

public void paint(Graphics g,
                  Shape allocation)
Description copied from class: View
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.

Specified by:
paint in class View
Parameters:
g - the rendering surface to use
allocation - the allocated region to render into
See Also:
View.paint(java.awt.Graphics, java.awt.Shape)

isBefore

protected boolean isBefore(int x,
                           int y,
                           Rectangle alloc)
Description copied from class: CompositeView
Tests whether a point lies before the rectangle range.

Specified by:
isBefore in class CompositeView
Parameters:
x - the X coordinate >= 0
y - the Y coordinate >= 0
alloc - the rectangle
Returns:
true if the point is before the specified range

isAfter

protected boolean isAfter(int x,
                          int y,
                          Rectangle alloc)
Description copied from class: CompositeView
Tests whether a point lies after the rectangle range.

Specified by:
isAfter in class CompositeView
Parameters:
x - the X coordinate >= 0
y - the Y coordinate >= 0
alloc - the rectangle
Returns:
true if the point is after the specified range

getViewAtPoint

protected View getViewAtPoint(int x,
                              int y,
                              Rectangle alloc)
Description copied from class: CompositeView
Fetches the child view at the given coordinates.

Specified by:
getViewAtPoint in class CompositeView
Parameters:
x - the X coordinate >= 0
y - the Y coordinate >= 0
alloc - the parent's allocation on entry, which should be changed to the child's allocation on exit
Returns:
the child view

childAllocation

protected void childAllocation(int index,
                               Rectangle a)
Description copied from class: CompositeView
Returns the allocation for a given child.

Specified by:
childAllocation in class CompositeView
Parameters:
index - the index of the child, >= 0 && < getViewCount()
a - the allocation to the interior of the box on entry, and the allocation of the child view at the index on exit.