KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lobobrowser > html > renderer > FloatingViewportBounds


1 /*
2     GNU LESSER GENERAL PUBLIC LICENSE
3     Copyright (C) 2006 The XAMJ Project
4
5     This library is free software; you can redistribute it and/or
6     modify it under the terms of the GNU Lesser General Public
7     License as published by the Free Software Foundation; either
8     version 2.1 of the License, or (at your option) any later version.
9
10     This library is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13     Lesser General Public License for more details.
14
15     You should have received a copy of the GNU Lesser General Public
16     License along with this library; if not, write to the Free Software
17     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18
19     Contact info: xamjadmin@users.sourceforge.net
20 */

21 package org.lobobrowser.html.renderer;
22
23 class FloatingViewportBounds implements FloatingBounds {
24     private final FloatingBounds prevBounds;
25     private final int alignment;
26     private final int y;
27     private final int width;
28     private final int height;
29     
30     public FloatingViewportBounds(FloatingBounds prevBounds, int alignment, int y, int width, int height) {
31         this.prevBounds = prevBounds;
32         this.alignment = alignment;
33         this.y = y;
34         this.width = width;
35         this.height = height;
36     }
37     
38     public int getLeft(int y) {
39         int left = 0;
40         FloatingBounds prev = this.prevBounds;
41         if(prev != null) {
42             left = prev.getLeft(y);
43         }
44         if(this.alignment < 0 && y >= this.y && y < this.y + height) {
45             left += this.width;
46         }
47         return left;
48     }
49     
50     /**
51      * The offset from the right edge, not counting padding.
52      */

53     public int getRight(int y) {
54         int right = 0;
55         FloatingBounds prev = this.prevBounds;
56         if(prev != null) {
57             right = prev.getRight(y);
58         }
59         if(this.alignment > 0 && y >= this.y && y < this.y + this.height) {
60             right += this.width;
61         }
62         return right;
63     }
64     
65     public int getClearY(int y) {
66         int cleary = Math.max(y, this.y + this.height);
67         FloatingBounds prev = this.prevBounds;
68         if(prev != null) {
69             int pcy = prev.getClearY(y);
70             if(pcy > cleary) {
71                 cleary = pcy;
72             }
73         }
74         return cleary;
75     }
76     
77     public boolean equals(Object JavaDoc other) {
78         if(!(other instanceof FloatingViewportBounds)) {
79             return false;
80         }
81         FloatingViewportBounds olm = (FloatingViewportBounds) other;
82         return olm.alignment == this.alignment &&
83                 olm.y == this.y &&
84                 olm.height == this.height &&
85                 olm.width == this.width &&
86                 org.lobobrowser.util.Objects.equals(olm.prevBounds, this.prevBounds);
87     }
88 }
89
Popular Tags