Statistics
| Revision:

root / branches / v2_0_0_prep / libraries / org.gvsig.openjdk.v1_6 / src / main / java / org / gvsig / openjdk / v1_6 / sun / awt / geom / CurveLink.java @ 31668

History | View | Annotate | Download (3.2 KB)

1
/*
2
 * Copyright 1998 Sun Microsystems, Inc.  All Rights Reserved.
3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
 *
5
 * This code is free software; you can redistribute it and/or modify it
6
 * under the terms of the GNU General Public License version 2 only, as
7
 * published by the Free Software Foundation.  Sun designates this
8
 * particular file as subject to the "Classpath" exception as provided
9
 * by Sun in the LICENSE file that accompanied this code.
10
 *
11
 * This code is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14
 * version 2 for more details (a copy is included in the LICENSE file that
15
 * accompanied this code).
16
 *
17
 * You should have received a copy of the GNU General Public License version
18
 * 2 along with this work; if not, write to the Free Software Foundation,
19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20
 *
21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
22
 * CA 95054 USA or visit www.sun.com if you need additional information or
23
 * have any questions.
24
 */
25

    
26
package org.gvsig.openjdk.v1_6.sun.awt.geom;
27

    
28
final class CurveLink {
29
    Curve curve;
30
    double ytop;
31
    double ybot;
32
    int etag;
33

    
34
    CurveLink next;
35

    
36
    CurveLink(Curve curve, double ystart, double yend, int etag) {
37
        this.curve = curve;
38
        this.ytop = ystart;
39
        this.ybot = yend;
40
        this.etag = etag;
41
        if (ytop < curve.getYTop() || ybot > curve.getYBot()) {
42
            throw new InternalError("bad curvelink ["+ytop+"=>"+ybot+"] for "+curve);
43
        }
44
    }
45

    
46
    public boolean absorb(CurveLink link) {
47
        return absorb(link.curve, link.ytop, link.ybot, link.etag);
48
    }
49

    
50
    public boolean absorb(Curve curve, double ystart, double yend, int etag) {
51
        if (this.curve != curve || this.etag != etag ||
52
            ybot < ystart || ytop > yend)
53
        {
54
            return false;
55
        }
56
        if (ystart < curve.getYTop() || yend > curve.getYBot()) {
57
            throw new InternalError("bad curvelink ["+ystart+"=>"+yend+"] for "+curve);
58
        }
59
        this.ytop = Math.min(ytop, ystart);
60
        this.ybot = Math.max(ybot, yend);
61
        return true;
62
    }
63

    
64
    public boolean isEmpty() {
65
        return (ytop == ybot);
66
    }
67

    
68
    public Curve getCurve() {
69
        return curve;
70
    }
71

    
72
    public Curve getSubCurve() {
73
        if (ytop == curve.getYTop() && ybot == curve.getYBot()) {
74
            return curve.getWithDirection(etag);
75
        }
76
        return curve.getSubCurve(ytop, ybot, etag);
77
    }
78

    
79
    public Curve getMoveto() {
80
        return new Order0(getXTop(), getYTop());
81
    }
82

    
83
    public double getXTop() {
84
        return curve.XforY(ytop);
85
    }
86

    
87
    public double getYTop() {
88
        return ytop;
89
    }
90

    
91
    public double getXBot() {
92
        return curve.XforY(ybot);
93
    }
94

    
95
    public double getYBot() {
96
        return ybot;
97
    }
98

    
99
    public double getX() {
100
        return curve.XforY(ytop);
101
    }
102

    
103
    public int getEdgeTag() {
104
        return etag;
105
    }
106

    
107
    public void setNext(CurveLink link) {
108
        this.next = link;
109
    }
110

    
111
    public CurveLink getNext() {
112
        return next;
113
    }
114
}