001: /*
002: * Copyright 1998 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025:
026: package sun.awt.geom;
027:
028: final class CurveLink {
029: Curve curve;
030: double ytop;
031: double ybot;
032: int etag;
033:
034: CurveLink next;
035:
036: public CurveLink(Curve curve, double ystart, double yend, int etag) {
037: this .curve = curve;
038: this .ytop = ystart;
039: this .ybot = yend;
040: this .etag = etag;
041: if (ytop < curve.getYTop() || ybot > curve.getYBot()) {
042: throw new InternalError("bad curvelink [" + ytop + "=>"
043: + ybot + "] for " + curve);
044: }
045: }
046:
047: public boolean absorb(CurveLink link) {
048: return absorb(link.curve, link.ytop, link.ybot, link.etag);
049: }
050:
051: public boolean absorb(Curve curve, double ystart, double yend,
052: int etag) {
053: if (this .curve != curve || this .etag != etag || ybot < ystart
054: || ytop > yend) {
055: return false;
056: }
057: if (ystart < curve.getYTop() || yend > curve.getYBot()) {
058: throw new InternalError("bad curvelink [" + ystart + "=>"
059: + yend + "] for " + curve);
060: }
061: this .ytop = Math.min(ytop, ystart);
062: this .ybot = Math.max(ybot, yend);
063: return true;
064: }
065:
066: public boolean isEmpty() {
067: return (ytop == ybot);
068: }
069:
070: public Curve getCurve() {
071: return curve;
072: }
073:
074: public Curve getSubCurve() {
075: if (ytop == curve.getYTop() && ybot == curve.getYBot()) {
076: return curve.getWithDirection(etag);
077: }
078: return curve.getSubCurve(ytop, ybot, etag);
079: }
080:
081: public Curve getMoveto() {
082: return new Order0(getXTop(), getYTop());
083: }
084:
085: public double getXTop() {
086: return curve.XforY(ytop);
087: }
088:
089: public double getYTop() {
090: return ytop;
091: }
092:
093: public double getXBot() {
094: return curve.XforY(ybot);
095: }
096:
097: public double getYBot() {
098: return ybot;
099: }
100:
101: public double getX() {
102: return curve.XforY(ytop);
103: }
104:
105: public int getEdgeTag() {
106: return etag;
107: }
108:
109: public void setNext(CurveLink link) {
110: this .next = link;
111: }
112:
113: public CurveLink getNext() {
114: return next;
115: }
116: }
|