jdk/src/java.desktop/share/classes/java/awt/GridBagLayoutInfo.java
author avstepan
Thu, 26 Mar 2015 14:18:42 +0400
changeset 29882 d36e2fcc5f55
parent 25859 3317bb8137f4
permissions -rw-r--r--
8075956: Fix some tidy warnings for java.awt Summary: minor HTML markup fix Reviewed-by: azvegint
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     2
 * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
package java.awt;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
/**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
 * The {@code GridBagLayoutInfo} is an utility class for
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
 * {@code GridBagLayout} layout manager.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
 * It stores align, size and baseline parameters for every component within a container.
23717
6457189cd574 8039259: Tidy warnings cleanup for java.awt
yan
parents: 5506
diff changeset
    32
 *
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
 * @see       java.awt.GridBagLayout
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
 * @see       java.awt.GridBagConstraints
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 * @since 1.6
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
public class GridBagLayoutInfo implements java.io.Serializable {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
     * serialVersionUID
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    private static final long serialVersionUID = -4899416460737170217L;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    int width, height;          /* number of  cells: horizontal and vertical */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    int startx, starty;         /* starting point for layout */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    int minWidth[];             /* largest minWidth in each column */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
    int minHeight[];            /* largest minHeight in each row */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    double weightX[];           /* largest weight in each column */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    double weightY[];           /* largest weight in each row */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
    boolean hasBaseline;        /* Whether or not baseline layout has been
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
                                 * requested and one of the components
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
                                 * has a valid baseline. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    // These are only valid if hasBaseline is true and are indexed by
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    // row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
    short baselineType[];       /* The type of baseline for a particular
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
                                 * row.  A mix of the BaselineResizeBehavior
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
                                 * constants (1 << ordinal()) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    int maxAscent[];            /* Max ascent (baseline). */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    int maxDescent[];           /* Max descent (height - baseline) */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
     * Creates an instance of GridBagLayoutInfo representing {@code GridBagLayout}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
     * grid cells with it's own parameters.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
     * @param width the columns
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
     * @param height the rows
24865
09b1d992ca72 8044740: Convert all JDK versions used in @since tag to 1.n[.n] in jdk repo
henryjen
parents: 23717
diff changeset
    65
     * @since 1.6
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    GridBagLayoutInfo(int width, int height) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
        this.width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
        this.height = height;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
     * Returns true if the specified row has any component aligned on the
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * baseline with a baseline resize behavior of CONSTANT_DESCENT.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
    boolean hasConstantDescent(int row) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
        return ((baselineType[row] & (1 << Component.BaselineResizeBehavior.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                                      CONSTANT_DESCENT.ordinal())) != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
     * Returns true if there is a baseline for the specified row.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    boolean hasBaseline(int row) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        return (hasBaseline && baselineType[row] != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
}