source: trunk/src/org/expeditee/io/flowlayout/XItem.java@ 919

Last change on this file since 919 was 919, checked in by jts21, 10 years ago

Added license headers to all files, added full GPL3 license file, moved license header generator script to dev/bin/scripts

  • Property svn:executable set to *
File size: 2.4 KB
Line 
1/**
2 * XItem.java
3 * Copyright (C) 2010 New Zealand Digital Library, http://expeditee.org
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program 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
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package org.expeditee.io.flowlayout;
20
21import java.awt.Point;
22import java.awt.Rectangle;
23
24import org.expeditee.items.Item;
25
26public abstract class XItem
27{
28 protected Rectangle bounding_rect;
29
30 protected XItem()
31 {
32 bounding_rect = null;
33 }
34
35 protected XItem(Rectangle imprint_bounding_rect)
36 {
37 this.bounding_rect = imprint_bounding_rect;
38 }
39
40 public int getX()
41 {
42 return bounding_rect.x;
43 }
44
45 public int getBoundingXLeft()
46 {
47 // name alias for getX()
48 return bounding_rect.x;
49 }
50
51 public int getY()
52 {
53 return bounding_rect.y;
54 }
55
56 public int getBoundingYTop()
57 {
58 // name alias for getY()
59 return bounding_rect.y;
60 }
61
62 public int getBoundingYBot()
63 {
64 return bounding_rect.y + bounding_rect.height -1;
65 }
66
67 public int getBoundingXRight()
68 {
69 return bounding_rect.x + bounding_rect.width -1;
70 }
71
72 public int getBoundingWidth()
73 {
74 return bounding_rect.width;
75 }
76
77 public int getBoundingHeight()
78 {
79 return bounding_rect.height;
80 }
81
82 public Rectangle getBoundingRect()
83 {
84 return bounding_rect;
85 }
86
87 public Rectangle setBoundingRect(Rectangle rect)
88 {
89 return bounding_rect = rect;
90 }
91
92 public boolean containsItem(Item item)
93 {
94 int x = item.getX();
95 int y = item.getY();
96
97 Point pt = new Point(x,y);
98
99 return bounding_rect.contains(pt);
100 }
101
102 public boolean containedInXExtent(int x)
103 {
104 int xl = getBoundingXLeft();
105 int xr = getBoundingXRight();
106
107 return (x>= xl) && (x<=xr);
108 }
109
110
111 public boolean containedInYExtent(int y)
112 {
113 int yt = getBoundingYTop();
114 int yb = getBoundingYBot();
115
116 return (y>= yt) && (y<=yb);
117 }
118
119
120}
Note: See TracBrowser for help on using the repository browser.