javax.swing.text
Class FlowView.LogicalView

java.lang.Object
  extended byjavax.swing.text.View
      extended byjavax.swing.text.CompositeView
          extended byjavax.swing.text.FlowView.LogicalView
All Implemented Interfaces:
SwingConstants
Enclosing class:
FlowView

static class FlowView.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, sharedBiasReturn, 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) FlowView.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.
 AttributeSet getAttributes()
          Fetches the attributes to use when rendering.
 float getMinimumSpan(int axis)
          Determines the minimum span for this view along an axis.
 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 point.
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.
 
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, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getMaximumSpan, getParent, getResizeWeight, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, insertUpdate, isVisible, modelToView, preferenceChanged, remove, removeAll, removeUpdate, setSize, updateChildren, updateLayout, viewToModel
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FlowView.LogicalView

FlowView.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

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)

getAttributes

public AttributeSet getAttributes()
Fetches the attributes to use when rendering. This view isn't directly responsible for an element so it returns the outer classes attributes.

Overrides:
getAttributes in class View

getPreferredSpan

public float getPreferredSpan(int axis)
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)

getMinimumSpan

public float getMinimumSpan(int axis)
Determines the minimum span for this view along an axis. The is implemented to find the minimum unbreakable span.

Overrides:
getMinimumSpan 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)
Renders using the given rendering surface and area on that surface. This is implemented to do nothing, the logical view is never visible.

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)
Tests whether a point lies before the rectangle range. Implemented to return false, as hit detection is not performed on the logical view.

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)
Tests whether a point lies after the rectangle range. Implemented to return false, as hit detection is not performed on the logical view.

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)
Fetches the child view at the given point. Implemented to return null, as hit detection is not performed on the logical view.

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)
Returns the allocation for a given child. Implemented to do nothing, as the logical view doesn't perform layout on the children.

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.