< prev index next >

src/java.desktop/share/classes/javax/swing/text/ZoneView.java

Print this page




 111      * may represent before attempting to break
 112      * the zone into a smaller size.
 113      */
 114     public void setMaximumZoneSize(int size) {
 115         maxZoneSize = size;
 116     }
 117 
 118     /**
 119      * Get the current setting of the number of zones
 120      * allowed to be loaded at the same time.
 121      * @return current setting of the number of zones
 122      * allowed to be loaded at the same time
 123      */
 124     public int getMaxZonesLoaded() {
 125         return maxZonesLoaded;
 126     }
 127 
 128     /**
 129      * Sets the current setting of the number of zones
 130      * allowed to be loaded at the same time. This will throw an
 131      * <code>IllegalArgumentException</code> if <code>mzl</code> is less
 132      * than 1.
 133      *
 134      * @param mzl the desired maximum number of zones
 135      *  to be actively loaded, must be greater than 0
 136      * @exception IllegalArgumentException if <code>mzl</code> is &lt; 1
 137      */
 138     public void setMaxZonesLoaded(int mzl) {
 139         if (mzl < 1) {
 140             throw new IllegalArgumentException("ZoneView.setMaxZonesLoaded must be greater than 0.");
 141         }
 142         maxZonesLoaded = mzl;
 143         unloadOldZones();
 144     }
 145 
 146     /**
 147      * Called by a zone when it gets loaded.  This happens when
 148      * an attempt is made to display or perform a model/view
 149      * translation on a zone that was in an unloaded state.
 150      * This is implemented to check if the maximum number of
 151      * zones was reached and to unload the oldest zone if so.
 152      *
 153      * @param zone the child view that was just loaded.
 154      */
 155     protected void zoneWasLoaded(View zone) {
 156         //System.out.println("loading: " + zone.getStartOffset() + "," + zone.getEndOffset());


 211      *  value should also be &gt; p0.
 212      * @return a view to represent a zone for the given range within
 213      * the model
 214      */
 215     protected View createZone(int p0, int p1) {
 216         Document doc = getDocument();
 217         View zone;
 218         try {
 219             zone = new Zone(getElement(),
 220                             doc.createPosition(p0),
 221                             doc.createPosition(p1));
 222         } catch (BadLocationException ble) {
 223             // this should puke in some way.
 224             throw new StateInvariantError(ble.getMessage());
 225         }
 226         return zone;
 227     }
 228 
 229     /**
 230      * Loads all of the children to initialize the view.
 231      * This is called by the <code>setParent</code> method.
 232      * This is reimplemented to not load any children directly
 233      * (as they are created by the zones).  This method creates
 234      * the initial set of zones.  Zones don't actually get
 235      * populated however until an attempt is made to display
 236      * them or to do model/view coordinate translation.
 237      *
 238      * @param f the view factory
 239      */
 240     protected void loadChildren(ViewFactory f) {
 241         // build the first zone.
 242         Document doc = getDocument();
 243         int offs0 = getStartOffset();
 244         int offs1 = getEndOffset();
 245         append(createZone(offs0, offs1));
 246         handleInsert(offs0, offs1 - offs0);
 247     }
 248 
 249     /**
 250      * Returns the child view index representing the given position in
 251      * the model.




 111      * may represent before attempting to break
 112      * the zone into a smaller size.
 113      */
 114     public void setMaximumZoneSize(int size) {
 115         maxZoneSize = size;
 116     }
 117 
 118     /**
 119      * Get the current setting of the number of zones
 120      * allowed to be loaded at the same time.
 121      * @return current setting of the number of zones
 122      * allowed to be loaded at the same time
 123      */
 124     public int getMaxZonesLoaded() {
 125         return maxZonesLoaded;
 126     }
 127 
 128     /**
 129      * Sets the current setting of the number of zones
 130      * allowed to be loaded at the same time. This will throw an
 131      * {@code IllegalArgumentException} if {@code mzl} is less
 132      * than 1.
 133      *
 134      * @param mzl the desired maximum number of zones
 135      *  to be actively loaded, must be greater than 0
 136      * @exception IllegalArgumentException if {@code mzl} is &lt; 1
 137      */
 138     public void setMaxZonesLoaded(int mzl) {
 139         if (mzl < 1) {
 140             throw new IllegalArgumentException("ZoneView.setMaxZonesLoaded must be greater than 0.");
 141         }
 142         maxZonesLoaded = mzl;
 143         unloadOldZones();
 144     }
 145 
 146     /**
 147      * Called by a zone when it gets loaded.  This happens when
 148      * an attempt is made to display or perform a model/view
 149      * translation on a zone that was in an unloaded state.
 150      * This is implemented to check if the maximum number of
 151      * zones was reached and to unload the oldest zone if so.
 152      *
 153      * @param zone the child view that was just loaded.
 154      */
 155     protected void zoneWasLoaded(View zone) {
 156         //System.out.println("loading: " + zone.getStartOffset() + "," + zone.getEndOffset());


 211      *  value should also be &gt; p0.
 212      * @return a view to represent a zone for the given range within
 213      * the model
 214      */
 215     protected View createZone(int p0, int p1) {
 216         Document doc = getDocument();
 217         View zone;
 218         try {
 219             zone = new Zone(getElement(),
 220                             doc.createPosition(p0),
 221                             doc.createPosition(p1));
 222         } catch (BadLocationException ble) {
 223             // this should puke in some way.
 224             throw new StateInvariantError(ble.getMessage());
 225         }
 226         return zone;
 227     }
 228 
 229     /**
 230      * Loads all of the children to initialize the view.
 231      * This is called by the {@code setParent} method.
 232      * This is reimplemented to not load any children directly
 233      * (as they are created by the zones).  This method creates
 234      * the initial set of zones.  Zones don't actually get
 235      * populated however until an attempt is made to display
 236      * them or to do model/view coordinate translation.
 237      *
 238      * @param f the view factory
 239      */
 240     protected void loadChildren(ViewFactory f) {
 241         // build the first zone.
 242         Document doc = getDocument();
 243         int offs0 = getStartOffset();
 244         int offs1 = getEndOffset();
 245         append(createZone(offs0, offs1));
 246         handleInsert(offs0, offs1 - offs0);
 247     }
 248 
 249     /**
 250      * Returns the child view index representing the given position in
 251      * the model.


< prev index next >