jdk/test/javax/swing/SpringLayout/4726194/bug4726194.java
author dbuck
Tue, 18 Aug 2015 04:29:28 -0700
changeset 32417 6859107fc6c3
parent 23010 6dadb192ad81
permissions -rw-r--r--
8133666: OperatingSystemMXBean reports abnormally high machine CPU consumption on Linux Reviewed-by: sla, mgronlun
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15320
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
     1
/*
23010
6dadb192ad81 8029235: Update copyright year to match last edit in jdk8 jdk repository for 2013
lana
parents: 15320
diff changeset
     2
 * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
15320
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
     4
 *
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
     7
 * published by the Free Software Foundation.
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
     8
 *
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    13
 * accompanied this code).
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    14
 *
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    18
 *
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    21
 * questions.
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    22
 */
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    23
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    24
/*
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    25
 * @test
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    26
 * @bug 4726194 7124209
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    27
 * @summary Tests for 4726194
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    28
 * @author Phil Milne
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    29
 */
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    30
import java.awt.*;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    31
import java.lang.reflect.InvocationTargetException;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    32
import java.util.*;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    33
import java.util.List;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    34
import javax.swing.*;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    35
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    36
public class bug4726194 {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    37
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    38
    private static String[] hConstraints = {SpringLayout.WEST, "Width", SpringLayout.EAST, SpringLayout.HORIZONTAL_CENTER};
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    39
    private static String[] vConstraints = {SpringLayout.NORTH, "Height", SpringLayout.SOUTH, SpringLayout.VERTICAL_CENTER, SpringLayout.BASELINE};
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    40
    private static int[] FAIL = new int[3];
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    41
    private static boolean TEST_DUPLICATES = false;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    42
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    43
    public static void main(String[] args) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    44
        try {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    45
            SwingUtilities.invokeAndWait(new Runnable() {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    46
                @Override
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    47
                public void run() {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    48
                    int minLevel = 2;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    49
                    int maxLevel = 2;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    50
                    for (int i = minLevel; i <= maxLevel; i++) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    51
                        test(i, true);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    52
                        test(i, false);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    53
                    }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    54
                }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    55
            });
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    56
        } catch (InterruptedException | InvocationTargetException ex) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    57
            ex.printStackTrace();
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    58
            throw new RuntimeException("FAILED: SwingUtilities.invokeAndWait method failed!");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    59
        }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    60
    }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    61
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    62
    public static void test(int level, boolean horizontal) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    63
        List result = new ArrayList();
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    64
        String[] constraints = horizontal ? hConstraints : vConstraints;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    65
        test(level, constraints, result, Arrays.asList(new Object[level]));
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    66
        JTextField tf = new JTextField("");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    67
        tf.setFont(new Font("Dialog", Font.PLAIN, 6));
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    68
        System.out.print("\t\t");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    69
        for (int j = 0; j < constraints.length; j++) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    70
            String constraint = constraints[j];
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    71
            System.out.print(constraint + "                ".substring(constraint.length()));
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    72
        }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    73
        System.out.println("");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    74
        for (int i = 0; i < result.size(); i++) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    75
            SpringLayout.Constraints c = new SpringLayout.Constraints(tf);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    76
            List cc = (List) result.get(i);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    77
            for (int j = 0; j < cc.size(); j++) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    78
                String constraint = (String) cc.get(j);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    79
                c.setConstraint(constraint, Spring.constant((j + 1) * 10));
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    80
            }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    81
            System.out.print(" Input:\t\t");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    82
            for (int j = 0; j < constraints.length; j++) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    83
                String constraint = constraints[j];
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    84
                int jj = cc.indexOf(constraint);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    85
                String val = cc.contains(constraint) ? Integer.toString((jj + 1) * 10) : "?";
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    86
                System.out.print(val + "\t\t");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    87
            }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    88
            System.out.println("");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    89
            System.out.print("Output:\t\t");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    90
            for (int j = 0; j < constraints.length; j++) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    91
                String constraint = constraints[j];
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    92
                Spring spring = c.getConstraint(constraint);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    93
                String springVal = (spring == null) ? "?" : Integer.toString(spring.getValue());
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    94
                System.out.print(springVal);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    95
                System.out.print("\t\t");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    96
            }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    97
            for (int j = 0; j < cc.size(); j++) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    98
                String constraint = (String) cc.get(j);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
    99
                Spring con = c.getConstraint(constraint);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   100
                if (con == null || con.getValue() != (j + 1) * 10) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   101
                    throw new RuntimeException("Values are wrong!!! ");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   102
                }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   103
            }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   104
            if (horizontal) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   105
                int[] a1 = getValues(c, new String[]{SpringLayout.WEST, SpringLayout.WIDTH, SpringLayout.EAST});
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   106
                if (a1[0] + a1[1] != a1[2]) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   107
                    throw new RuntimeException("WEST + WIDTH != EAST!!! ");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   108
                }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   109
                int[] a2 = getValues(c, new String[]{SpringLayout.WEST, SpringLayout.WIDTH, SpringLayout.HORIZONTAL_CENTER});
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   110
                if (a2[0] + a2[1] / 2 != a2[2]) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   111
                    throw new RuntimeException("WEST + WIDTH/2 != HORIZONTAL_CENTER!!! ");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   112
                }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   113
            } else {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   114
                int[] a3 = getValues(c, new String[]{SpringLayout.NORTH, SpringLayout.HEIGHT, SpringLayout.SOUTH});
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   115
                if (a3[0] + a3[1] != a3[2]) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   116
                    throw new RuntimeException("NORTH + HEIGHT != SOUTH!!! ");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   117
                }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   118
                int[] a4 = getValues(c, new String[]{SpringLayout.NORTH, SpringLayout.HEIGHT, SpringLayout.VERTICAL_CENTER});
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   119
                int vcDiff = Math.abs(a4[0] + a4[1] / 2 - a4[2]);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   120
                if (vcDiff > 1) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   121
                    throw new RuntimeException("NORTH + HEIGHT/2 != VERTICAL_CENTER!!! ");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   122
                }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   123
                int[] a5 = getValues(c, new String[]{SpringLayout.NORTH, SpringLayout.BASELINE, SpringLayout.SOUTH});
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   124
                if (a5[0] > a5[1] != a5[1] > a5[2]) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   125
                    throw new RuntimeException("BASELINE is not in the range: [NORTH, SOUTH]!!!");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   126
                }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   127
            }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   128
            System.out.println("");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   129
        }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   130
        System.out.println("");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   131
    }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   132
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   133
    private static int[] getValues(SpringLayout.Constraints con, String[] cNames) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   134
        int[] result = new int[cNames.length];
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   135
        for (int i = 0; i < cNames.length; i++) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   136
            String name = cNames[i];
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   137
            Spring s = con.getConstraint(name);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   138
            if (s == null) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   139
                System.out.print("Warning: " + name + " is undefined. ");
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   140
                return FAIL;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   141
            }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   142
            result[i] = s.getValue();
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   143
        }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   144
        return result;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   145
    }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   146
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   147
    public static void test(int level, String[] constraints, List result, List soFar) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   148
        if (level == 0) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   149
            result.add(soFar);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   150
            return;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   151
        }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   152
        for (int i = 0; i < constraints.length; i++) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   153
            if (soFar.contains(constraints[i]) && !TEST_DUPLICATES) {
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   154
                continue;
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   155
            }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   156
            List child = new ArrayList(soFar);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   157
            child.set(level - 1, constraints[i]);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   158
            test(level - 1, constraints, result, child);
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   159
        }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   160
    }
fe8a477f2eef 7124209: [macosx] SpringLayout issue. BASELINE is not in the range: [NORTH, SOUTH]
kshefov
parents:
diff changeset
   161
}