javax.swing.text

Class ZoneView

public class ZoneView extends BoxView

A View implementation that delays loading of sub views until they are needed for display or internal transformations. This can be used for editors that need to handle large documents more effectivly than the standard {@link BoxView}.

Since: 1.3

Constructor Summary
ZoneView(Element element, int axis)
Creates a new ZoneView for the specified element and axis.
Method Summary
protected ViewcreateZone(int p0, int p1)
Creates a zone for the specified range.
intgetMaximumZoneSize()
Returns the maximum zone size.
intgetMaxZonesLoaded()
Returns the number of zones that are allowed to be loaded.
protected intgetViewIndexAtPosition(int pos)
Returns the index of the child view at the document position pos.
voidinsertUpdate(DocumentEvent e, Shape a, ViewFactory vf)
protected booleanisZoneLoaded(View zone)
Returns true when the specified zone is loaded, false otherwise.
protected voidloadChildren(ViewFactory vf)
Overridden to not load all the child views.
voidremoveUpdate(DocumentEvent e, Shape a, ViewFactory vf)
voidsetMaximumZoneSize(int size)
Sets the maximum zone size.
voidsetMaxZonesLoaded(int num)
Sets the maximum number of zones that are allowed to be loaded at the same time.
protected voidunloadZone(View zone)
This unloads the specified zone.
protected booleanupdateChildren(DocumentEvent.ElementChange ec, DocumentEvent e, ViewFactory vf)
protected voidzoneWasLoaded(View zone)
Gets called after a zone has been loaded.

Constructor Detail

ZoneView

public ZoneView(Element element, int axis)
Creates a new ZoneView for the specified element and axis.

Parameters: element the element for which to create a ZoneView axis the major layout axis for the box

Method Detail

createZone

protected View createZone(int p0, int p1)
Creates a zone for the specified range. Subclasses can override this to provide a custom implementation for the zones.

Parameters: p0 the start of the range p1 the end of the range

Returns: the zone

getMaximumZoneSize

public int getMaximumZoneSize()
Returns the maximum zone size. Note that zones might still become larger then the size specified when a singe child view is larger for itself, because zones are formed on child view boundaries.

Returns: the maximum zone size

See Also: ZoneView

getMaxZonesLoaded

public int getMaxZonesLoaded()
Returns the number of zones that are allowed to be loaded.

Returns: the number of zones that are allowed to be loaded

See Also: ZoneView

getViewIndexAtPosition

protected int getViewIndexAtPosition(int pos)
Returns the index of the child view at the document position pos. This overrides the CompositeView implementation because the ZoneView does not provide a one to one mapping from Elements to Views.

Parameters: pos the document position

Returns: the index of the child view at the document position pos

insertUpdate

public void insertUpdate(DocumentEvent e, Shape a, ViewFactory vf)

isZoneLoaded

protected boolean isZoneLoaded(View zone)
Returns true when the specified zone is loaded, false otherwise. The default implementation checks if the zone view has child elements.

Parameters: zone the zone view to check

Returns: true when the specified zone is loaded, false otherwise

loadChildren

protected void loadChildren(ViewFactory vf)
Overridden to not load all the child views. This methods creates initial zones without actually loading them.

Parameters: vf not used

removeUpdate

public void removeUpdate(DocumentEvent e, Shape a, ViewFactory vf)

setMaximumZoneSize

public void setMaximumZoneSize(int size)
Sets the maximum zone size. Note that zones might still become larger then the size specified when a singe child view is larger for itself, because zones are formed on child view boundaries.

Parameters: size the maximum zone size to set

See Also: getMaximumZoneSize

setMaxZonesLoaded

public void setMaxZonesLoaded(int num)
Sets the maximum number of zones that are allowed to be loaded at the same time. If the new number of allowed zones is smaller then the previous settings, this unloads all zones the aren't allowed to be loaded anymore.

Parameters: num the number of zones allowed to be loaded at the same time

Throws: IllegalArgumentException if num <= 0

See Also: getMaxZonesLoaded

unloadZone

protected void unloadZone(View zone)
This unloads the specified zone. This is implemented to simply remove all child views from that zone.

Parameters: zone the zone to be unloaded

updateChildren

protected boolean updateChildren(DocumentEvent.ElementChange ec, DocumentEvent e, ViewFactory vf)

zoneWasLoaded

protected void zoneWasLoaded(View zone)
Gets called after a zone has been loaded. This unloads the oldest zone(s) when the maximum number of zones is reached.

Parameters: zone the zone that has been loaded