javax.swing.text

Class ZoneView

  • All Implemented Interfaces:
    SwingConstants

    public class ZoneView
    extends BoxView
    ZoneView is a View implementation that creates zones for which the child views are not created or stored until they are needed for display or model/view translations. This enables a substantial reduction in memory consumption for situations where the model being represented is very large, by building view objects only for the region being actively viewed/edited. The size of the children can be estimated in some way, or calculated asynchronously with only the result being saved.

    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:

    • Boxes are a heavily used view, and having a box that provides this behavior gives substantial opportunity to plug the behavior into a view hierarchy from the view factory.
    • Boxes are tiled in one direction, so it is easy to divide them into zones in a reliable way.
    • Boxes typically have a simple relationship to the model (i.e. they create child views that directly represent the child elements).
    • Boxes are easier to estimate the size of than some other shapes.

    The default behavior is controled 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.

    Since:
    1.3
    See Also:
    View
    • Constructor Detail

      • ZoneView

        public ZoneView(Element elem,
                int axis)
        Constructs a ZoneView.
        Parameters:
        elem - the element this view is responsible for
        axis - either View.X_AXIS or View.Y_AXIS
    • Method Detail

      • getMaximumZoneSize

        public int getMaximumZoneSize()
        Get the current maximum zone size.
      • setMaximumZoneSize

        public void setMaximumZoneSize(int size)
        Set the desired maximum zone size. A zone may get larger than this size if a single child view is larger than this size since zones are formed on child view boundaries.
        Parameters:
        size - the number of characters the zone may represent before attempting to break the zone into a smaller size.
      • getMaxZonesLoaded

        public int getMaxZonesLoaded()
        Get the current setting of the number of zones allowed to be loaded at the same time.
      • setMaxZonesLoaded

        public void setMaxZonesLoaded(int mzl)
        Sets the current setting of the number of zones allowed to be loaded at the same time. This will throw an IllegalArgumentException if mzl is less than 1.
        Parameters:
        mzl - the desired maximum number of zones to be actively loaded, must be greater than 0
        Throws:
        IllegalArgumentException - if mzl is < 1
      • zoneWasLoaded

        protected void zoneWasLoaded(View zone)
        Called by a zone when it gets loaded. This happens when an attempt is made to display or perform a model/view translation on a zone that was in an unloaded state. This is imlemented to check if the maximum number of zones was reached and to unload the oldest zone if so.
        Parameters:
        zone - the child view that was just loaded.
      • unloadZone

        protected void unloadZone(View zone)
        Unload a zone (Convert the zone to its memory saving state). The zones are expected to represent a subset of the child elements of the element this view is responsible for. Therefore, the default implementation is to simple remove all the children.
        Parameters:
        zone - the child view desired to be set to an unloaded state.
      • isZoneLoaded

        protected boolean isZoneLoaded(View zone)
        Determine if a zone is in the loaded state. The zones are expected to represent a subset of the child elements of the element this view is responsible for. Therefore, the default implementation is to return true if the view has children.
      • createZone

        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). This is called by the zone management logic to create new zones. Subclasses can provide a different implementation for a zone by changing this method.
        Parameters:
        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.
      • loadChildren

        protected void loadChildren(ViewFactory f)
        Loads all of the children to initialize the view. This is called by the 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.
        Overrides:
        loadChildren in class CompositeView
        Parameters:
        f - the view factory
        See Also:
        CompositeView.setParent(javax.swing.text.View)
      • getViewIndexAtPosition

        protected int getViewIndexAtPosition(int pos)
        Returns the child view index representing the given position in the model.
        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

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/swing/text/ZoneView.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:fr Manuel PHP : https://docs.oracle.com

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut