< prev index next >

src/java.desktop/share/classes/javax/swing/text/html/FrameSetView.java

Print this page


   1 /*
   2  * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 167      *  each of the child views; this is a return value and is
 168      *  filled in by the implementation of this method
 169      * @param spans the span of each child view; this is a return
 170      *  value and is filled in by the implementation of this method
 171      * @return the offset and span for each child view in the
 172      *  offsets and spans parameters
 173      */
 174     protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets,
 175                                    int[] spans) {
 176         if (children == null) {
 177             init();
 178         }
 179         SizeRequirements.calculateTiledPositions(targetSpan, null,
 180                                                  getChildRequests(targetSpan,
 181                                                                   axis),
 182                                                  offsets, spans);
 183     }
 184 
 185     protected SizeRequirements[] getChildRequests(int targetSpan, int axis) {
 186 
 187         int span[] = new int[children.length];
 188 
 189         spread(targetSpan, span);
 190         int n = getViewCount();
 191         SizeRequirements[] reqs = new SizeRequirements[n];
 192         for (int i = 0, sIndex = 0; i < n; i++) {
 193             View v = getView(i);
 194             if ((v instanceof FrameView) || (v instanceof FrameSetView)) {
 195                 reqs[i] = new SizeRequirements((int) v.getMinimumSpan(axis),
 196                                                span[sIndex],
 197                                                (int) v.getMaximumSpan(axis),
 198                                                0.5f);
 199                 sIndex++;
 200             } else {
 201                 int min = (int) v.getMinimumSpan(axis);
 202                 int pref = (int) v.getPreferredSpan(axis);
 203                 int max = (int) v.getMaximumSpan(axis);
 204                 float a = v.getAlignment(axis);
 205                 reqs[i] = new SizeRequirements(min, pref, max, a);
 206             }
 207         }
 208         return reqs;
 209     }
 210 
 211 
 212     /**
 213      * This method is responsible for returning in span[] the
 214      * span for each child view along the major axis.  it
 215      * computes this based on the information that extracted
 216      * from the value of the ROW/COL attribute.
 217      */
 218     private void spread(int targetSpan, int span[]) {
 219 
 220         if (targetSpan == 0) {
 221             return;
 222         }
 223 
 224         int tempSpace = 0;
 225         int remainingSpace = targetSpan;
 226 
 227         // allocate the absolute's first, they have
 228         // precedence
 229         //
 230         for (int i = 0; i < span.length; i++) {
 231             if (absoluteChildren[i] > 0) {
 232                 span[i] = absoluteChildren[i];
 233                 remainingSpace -= span[i];
 234             }
 235         }
 236 
 237         // then deal with percents.
 238         //


   1 /*
   2  * Copyright (c) 1998, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


 167      *  each of the child views; this is a return value and is
 168      *  filled in by the implementation of this method
 169      * @param spans the span of each child view; this is a return
 170      *  value and is filled in by the implementation of this method
 171      * @return the offset and span for each child view in the
 172      *  offsets and spans parameters
 173      */
 174     protected void layoutMajorAxis(int targetSpan, int axis, int[] offsets,
 175                                    int[] spans) {
 176         if (children == null) {
 177             init();
 178         }
 179         SizeRequirements.calculateTiledPositions(targetSpan, null,
 180                                                  getChildRequests(targetSpan,
 181                                                                   axis),
 182                                                  offsets, spans);
 183     }
 184 
 185     protected SizeRequirements[] getChildRequests(int targetSpan, int axis) {
 186 
 187         int[] span = new int[children.length];
 188 
 189         spread(targetSpan, span);
 190         int n = getViewCount();
 191         SizeRequirements[] reqs = new SizeRequirements[n];
 192         for (int i = 0, sIndex = 0; i < n; i++) {
 193             View v = getView(i);
 194             if ((v instanceof FrameView) || (v instanceof FrameSetView)) {
 195                 reqs[i] = new SizeRequirements((int) v.getMinimumSpan(axis),
 196                                                span[sIndex],
 197                                                (int) v.getMaximumSpan(axis),
 198                                                0.5f);
 199                 sIndex++;
 200             } else {
 201                 int min = (int) v.getMinimumSpan(axis);
 202                 int pref = (int) v.getPreferredSpan(axis);
 203                 int max = (int) v.getMaximumSpan(axis);
 204                 float a = v.getAlignment(axis);
 205                 reqs[i] = new SizeRequirements(min, pref, max, a);
 206             }
 207         }
 208         return reqs;
 209     }
 210 
 211 
 212     /**
 213      * This method is responsible for returning in span[] the
 214      * span for each child view along the major axis.  it
 215      * computes this based on the information that extracted
 216      * from the value of the ROW/COL attribute.
 217      */
 218     private void spread(int targetSpan, int[] span) {
 219 
 220         if (targetSpan == 0) {
 221             return;
 222         }
 223 
 224         int tempSpace = 0;
 225         int remainingSpace = targetSpan;
 226 
 227         // allocate the absolute's first, they have
 228         // precedence
 229         //
 230         for (int i = 0; i < span.length; i++) {
 231             if (absoluteChildren[i] > 0) {
 232                 span[i] = absoluteChildren[i];
 233                 remainingSpace -= span[i];
 234             }
 235         }
 236 
 237         // then deal with percents.
 238         //


< prev index next >