jdk/test/java/awt/geom/CubicCurve2D/IntersectsTest.java
author dlila
Thu, 27 Jan 2011 16:43:28 -0500
changeset 8129 54c848224b7b
permissions -rw-r--r--
4645692: solveCubic does not return all solutions. Summary: more robust solveCubic implementation. Reviewed-by: flar
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
8129
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
     1
/*
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
     2
 * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
     4
 *
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
     7
 * published by the Free Software Foundation.
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
     8
 *
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    13
 * accompanied this code).
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    14
 *
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    18
 *
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    21
 * questions.
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    22
 */
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    23
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    24
/**
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    25
 * @test
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    26
 * @bug 4493128
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    27
 * @summary Verifies that CubicCurve2D returns true for obvious intersection
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    28
 * @run main IntersectsTest
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    29
 */
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    30
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    31
import java.awt.geom.CubicCurve2D;
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    32
import java.awt.geom.Rectangle2D;
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    33
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    34
public class IntersectsTest {
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    35
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    36
    public static void main(String[] args) throws Exception {
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    37
        CubicCurve2D c = new CubicCurve2D.Double(50.0, 300.0,
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    38
                                                 150.0, 166.6666717529297,
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    39
                                                 238.0, 456.66668701171875,
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    40
                                                 350.0, 300.0);
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    41
        Rectangle2D r = new Rectangle2D.Double(260, 300, 10, 10);
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    42
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    43
        if (!c.intersects(r)) {
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    44
            throw new Exception("The rectangle is contained. " +
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    45
                                "intersects(Rectangle2D) should return true");
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    46
        }
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    47
    }
54c848224b7b 4645692: solveCubic does not return all solutions.
dlila
parents:
diff changeset
    48
}