public class ZoneView extends BoxView
ZoneView extends BoxView to provide a box that implements zones for its children. The zones are special View implementations (the children of an instance of this class) that represent only a portion of the model that an instance of ZoneView is responsible for. The zones don't create child views until an attempt is made to display them. A box shaped view is well suited to this because:
The default behavior is controlled by two properties, maxZoneSize and maxZonesLoaded. Setting maxZoneSize to Integer.MAX_VALUE would have the effect of causing only one zone to be created. This would effectively turn the view into an implementation of the decorator pattern. Setting maxZonesLoaded to a value of Integer.MAX_VALUE would cause zones to never be unloaded. For simplicity, zones are created on boundaries represented by the child elements of the element the view is responsible for. The zones can be any View implementation, but the default implementation is based upon AsyncBoxView which supports fairly large zones efficiently.
View
BadBreakWeight, ExcellentBreakWeight, ForcedBreakWeight, GoodBreakWeight, X_AXIS, Y_AXISBOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST| Constructor and Description |
|---|
ZoneView(Element
Constructs a ZoneView.
|
| Modifier and Type | Method and Description |
|---|---|
protected View |
createZone(int p0, int p1)
Create a view to represent a zone for the given range within the model (which should be within the range of this objects responsibility).
|
int |
getMaximumZoneSize()
Get the current maximum zone size.
|
int |
getMaxZonesLoaded()
Get the current setting of the number of zones allowed to be loaded at the same time.
|
protected int |
getViewIndexAtPosition(int pos)
Returns the child view index representing the given position in the model.
|
void |
insertUpdate(DocumentEvent
Gives notification that something was inserted into the document in a location that this view is responsible for.
|
protected boolean |
isZoneLoaded(View
Determine if a zone is in the loaded state.
|
protected void |
loadChildren(ViewFactory
Loads all of the children to initialize the view.
|
void |
removeUpdate(DocumentEvent
Gives notification that something was removed from the document in a location that this view is responsible for.
|
void |
setMaximumZoneSize(int size)
Set the desired maximum zone size.
|
void |
setMaxZonesLoaded(int mzl)
Sets the current setting of the number of zones allowed to be loaded at the same time.
|
protected void |
unloadZone(View
Unload a zone (Convert the zone to its memory saving state).
|
protected boolean |
updateChildren(DocumentEvent
The superclass behavior will try to update the child views which is not desired in this case, since the children are zones and not directly effected by the changes to the associated element.
|
protected void |
zoneWasLoaded(View
Called by a zone when it gets loaded.
|
baselineLayout, baselineRequirements, calculateMajorAxisRequirements, calculateMinorAxisRequirements, childAllocation, flipEastAndWestAtEnds, forwardUpdate, getAlignment, getAxis, getChildAllocation, getHeight, getMaximumSpan, getMinimumSpan, getOffset, getPreferredSpan, getResizeWeight, getSpan, getViewAtPoint, getWidth, isAfter, isAllocationValid, isBefore, isLayoutValid, layout, layoutChanged, layoutMajorAxis, layoutMinorAxis, modelToView, paint, paintChild, preferenceChanged, replace, setAxis, setSize, viewToModelgetBottomInset, getInsideAllocation, getLeftInset, getNextEastWestVisualPositionFrom, getNextNorthSouthVisualPositionFrom, getNextVisualPositionFrom, getRightInset, getTopInset, getView, getViewAtPosition, getViewCount, getViewIndex, modelToView, setInsets, setParagraphInsets, setParentappend, breakView, changedUpdate, createFragment, forwardUpdateToView, getAttributes, getBreakWeight, getContainer, getDocument, getElement, getEndOffset, getGraphics, getParent, getStartOffset, getToolTipText, getViewFactory, getViewIndex, insert, isVisible, modelToView, remove, removeAll, updateLayout, viewToModelpublic ZoneView(Elementelem, int axis)
elem - the element this view is responsible for
axis - either View.X_AXIS or View.Y_AXIS
public int getMaximumZoneSize()
public void setMaximumZoneSize(int size)
size - the number of characters the zone may represent before attempting to break the zone into a smaller size.
public int getMaxZonesLoaded()
public void setMaxZonesLoaded(int mzl)
IllegalArgumentException if
mzl is less than 1.
mzl - the desired maximum number of zones to be actively loaded, must be greater than 0
IllegalArgumentException - if
mzl is < 1
protected void zoneWasLoaded(Viewzone)
zone - the child view that was just loaded.
protected void unloadZone(Viewzone)
zone - the child view desired to be set to an unloaded state.
protected boolean isZoneLoaded(Viewzone)
protected ViewcreateZone(int p0, int p1)
p0 - the start of the desired zone. This should be >= getStartOffset() and < getEndOffset(). This value should also be < p1.
p1 - the end of the desired zone. This should be > getStartOffset() and <= getEndOffset(). This value should also be > p0.
protected void loadChildren(ViewFactoryf)
setParent method. This is reimplemented to not load any children directly (as they are created by the zones). This method creates the initial set of zones. Zones don't actually get populated however until an attempt is made to display them or to do model/view coordinate translation.
loadChildren in class
CompositeView
f - the view factory
CompositeView.setParent(javax.swing.text.View)
protected int getViewIndexAtPosition(int pos)
getViewIndexAtPosition in class
CompositeView
pos - the position >= 0
protected boolean updateChildren(DocumentEvent.ElementChange ec, DocumentEvent e, ViewFactory f)
updateChildren in class
View
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
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)
public void insertUpdate(DocumentEventchanges, Shape a, ViewFactory f)
insertUpdate in class
View
changes - 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
View.insertUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)
public void removeUpdate(DocumentEventchanges, Shape a, ViewFactory f)
removeUpdate in class
View
changes - 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
View.removeUpdate(javax.swing.event.DocumentEvent, java.awt.Shape, javax.swing.text.ViewFactory)