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

Last change on this file since 1102 was 1102, checked in by davidb, 6 years ago

Reworking of the code-base to separate logic from graphics. This version of Expeditee now supports a JFX graphics as an alternative to SWING

  • Property svn:executable set to *
File size: 2.5 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
21
22import org.expeditee.core.Point;
23import org.expeditee.core.bounds.AxisAlignedBoxBounds;
24import org.expeditee.items.Item;
25
26public abstract class XItem
27{
28 protected AxisAlignedBoxBounds bounding_rect;
29
30 protected XItem()
31 {
32 bounding_rect = null;
33 }
34
35 protected XItem(AxisAlignedBoxBounds imprint_bounding_rect)
36 {
37 this.bounding_rect = imprint_bounding_rect;
38 }
39
40 public int getX()
41 {
42 return bounding_rect.getMinX();
43 }
44
45 public int getBoundingXLeft()
46 {
47 // name alias for getX()
48 return bounding_rect.getMinX();
49 }
50
51 public int getY()
52 {
53 return bounding_rect.getMinY();
54 }
55
56 public int getBoundingYTop()
57 {
58 // name alias for getY()
59 return bounding_rect.getMinY();
60 }
61
62 public int getBoundingYBot()
63 {
64 return bounding_rect.getMaxY();
65 }
66
67 public int getBoundingXRight()
68 {
69 return bounding_rect.getMaxX();
70 }
71
72 public int getBoundingWidth()
73 {
74 return bounding_rect.getWidth();
75 }
76
77 public int getBoundingHeight()
78 {
79 return bounding_rect.getHeight();
80 }
81
82 public AxisAlignedBoxBounds getBoundingRect()
83 {
84 return bounding_rect;
85 }
86
87 public AxisAlignedBoxBounds setBoundingRect(AxisAlignedBoxBounds 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.