0N/A/*
2362N/A * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/Apackage sun.awt.geom;
0N/A
0N/Afinal class ChainEnd {
0N/A CurveLink head;
0N/A CurveLink tail;
0N/A ChainEnd partner;
0N/A int etag;
0N/A
0N/A public ChainEnd(CurveLink first, ChainEnd partner) {
0N/A this.head = first;
0N/A this.tail = first;
0N/A this.partner = partner;
0N/A this.etag = first.getEdgeTag();
0N/A }
0N/A
0N/A public CurveLink getChain() {
0N/A return head;
0N/A }
0N/A
0N/A public void setOtherEnd(ChainEnd partner) {
0N/A this.partner = partner;
0N/A }
0N/A
0N/A public ChainEnd getPartner() {
0N/A return partner;
0N/A }
0N/A
0N/A /*
0N/A * Returns head of a complete chain to be added to subcurves
0N/A * or null if the links did not complete such a chain.
0N/A */
0N/A public CurveLink linkTo(ChainEnd that) {
0N/A if (etag == AreaOp.ETAG_IGNORE ||
0N/A that.etag == AreaOp.ETAG_IGNORE)
0N/A {
0N/A throw new InternalError("ChainEnd linked more than once!");
0N/A }
0N/A if (etag == that.etag) {
0N/A throw new InternalError("Linking chains of the same type!");
0N/A }
0N/A ChainEnd enter, exit;
0N/A // assert(partner.etag != that.partner.etag);
0N/A if (etag == AreaOp.ETAG_ENTER) {
0N/A enter = this;
0N/A exit = that;
0N/A } else {
0N/A enter = that;
0N/A exit = this;
0N/A }
0N/A // Now make sure these ChainEnds are not linked to any others...
0N/A etag = AreaOp.ETAG_IGNORE;
0N/A that.etag = AreaOp.ETAG_IGNORE;
0N/A // Now link everything up...
0N/A enter.tail.setNext(exit.head);
0N/A enter.tail = exit.tail;
0N/A if (partner == that) {
0N/A // Curve has closed on itself...
0N/A return enter.head;
0N/A }
0N/A // Link this chain into one end of the chain formed by the partners
0N/A ChainEnd otherenter = exit.partner;
0N/A ChainEnd otherexit = enter.partner;
0N/A otherenter.partner = otherexit;
0N/A otherexit.partner = otherenter;
0N/A if (enter.head.getYTop() < otherenter.head.getYTop()) {
0N/A enter.tail.setNext(otherenter.head);
0N/A otherenter.head = enter.head;
0N/A } else {
0N/A otherexit.tail.setNext(enter.head);
0N/A otherexit.tail = enter.tail;
0N/A }
0N/A return null;
0N/A }
0N/A
0N/A public void addLink(CurveLink newlink) {
0N/A if (etag == AreaOp.ETAG_ENTER) {
0N/A tail.setNext(newlink);
0N/A tail = newlink;
0N/A } else {
0N/A newlink.setNext(head);
0N/A head = newlink;
0N/A }
0N/A }
0N/A
0N/A public double getX() {
0N/A if (etag == AreaOp.ETAG_ENTER) {
0N/A return tail.getXBot();
0N/A } else {
0N/A return head.getXBot();
0N/A }
0N/A }
0N/A}