01: /*
02: * @(#)YXBand.java 1.10 06/10/10
03: *
04: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
05: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
06: *
07: * This program is free software; you can redistribute it and/or
08: * modify it under the terms of the GNU General Public License version
09: * 2 only, as published by the Free Software Foundation.
10: *
11: * This program is distributed in the hope that it will be useful, but
12: * WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * General Public License version 2 for more details (a copy is
15: * included at /legal/license.txt).
16: *
17: * You should have received a copy of the GNU General Public License
18: * version 2 along with this work; if not, write to the Free Software
19: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20: * 02110-1301 USA
21: *
22: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
23: * Clara, CA 95054 or visit www.sun.com if you need additional
24: * information or have any questions.
25: *
26: */
27:
28: package sun.porting.utils;
29:
30: /**
31: * A class which stores a single Y/X band.
32: *
33: * @version 1.5, 08/19/02
34: */
35: class YXBand {
36: int y, h;
37: YXBand next, prev;
38: XSpan children;
39:
40: public YXBand(int x, int y, int w, int h, YXBand prev, YXBand next) {
41: // // Coverage.cover(108, "YXBand(x,y,w,h,prev,next)");
42: this .y = y;
43: this .h = h;
44: this .children = new XSpan(0, -1);
45: this .children.next = new XSpan(x, w, this .children,
46: this .children);
47: this .children.prev = this .children.next;
48: this .prev = prev;
49: this .next = next;
50: }
51:
52: public YXBand(int y, int h, XSpan children) {
53: this (y, h, children, null, null);
54: // // Coverage.cover(109, "YXBand(y,h,children)");
55: }
56:
57: public YXBand(int y, int h, XSpan children, YXBand prev, YXBand next) {
58: // // Coverage.cover(110, "YXBand(y,h,children,prev,next)");
59: this .y = y;
60: this .h = h;
61: this .children = children;
62: this .prev = prev;
63: this .next = next;
64: }
65:
66: static YXBand findBand(int y, int y2, YXBand head) {
67: // // Coverage.cover(111, "findBand(y,y2,head)");
68: YXBand yb;
69: for (yb = head.next; yb != head; yb = yb.next) {
70: if (yb.y >= y2) {
71: // // Coverage.cover(112, "ran off list");
72: return null;
73: } else if ((yb.y + yb.h) > y) {
74: // // Coverage.cover(113, "found band");
75: break;
76: }
77: }
78: return (yb == head) ? null : yb;
79: }
80:
81: // no test coverage for makeString
82: public static String makeString(YXBand head) {
83: String ret = "[";
84: for (YXBand yb = head.next; yb != head; yb = yb.next) {
85: if (yb != head.next) {
86: ret += " ";
87: }
88: String s = "[(" + yb.y + "," + yb.h + "): "
89: + XSpan.makeString(yb.children) + "]";
90: ret += s;
91: }
92: return ret + "]";
93: }
94:
95: // no test coverage for toString
96: public String toString() {
97: return "(y = " + y + ", h = " + h + ")";
98: }
99: }
|